babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281
  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. * @returns true if the loader can load the specified file
  1053. */
  1054. canLoad(extension: string): boolean;
  1055. /**
  1056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1057. * @param data contains the texture data
  1058. * @param texture defines the BabylonJS internal texture
  1059. * @param createPolynomials will be true if polynomials have been requested
  1060. * @param onLoad defines the callback to trigger once the texture is ready
  1061. * @param onError defines the callback to trigger in case of error
  1062. */
  1063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1064. /**
  1065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1066. * @param data contains the texture data
  1067. * @param texture defines the BabylonJS internal texture
  1068. * @param callback defines the method to call once ready to upload
  1069. */
  1070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1071. }
  1072. }
  1073. declare module "babylonjs/Engines/IPipelineContext" {
  1074. /**
  1075. * Class used to store and describe the pipeline context associated with an effect
  1076. */
  1077. export interface IPipelineContext {
  1078. /**
  1079. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1080. */
  1081. isAsync: boolean;
  1082. /**
  1083. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1084. */
  1085. isReady: boolean;
  1086. /** @hidden */
  1087. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1088. }
  1089. }
  1090. declare module "babylonjs/Meshes/dataBuffer" {
  1091. /**
  1092. * Class used to store gfx data (like WebGLBuffer)
  1093. */
  1094. export class DataBuffer {
  1095. /**
  1096. * Gets or sets the number of objects referencing this buffer
  1097. */
  1098. references: number;
  1099. /** Gets or sets the size of the underlying buffer */
  1100. capacity: number;
  1101. /**
  1102. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1103. */
  1104. is32Bits: boolean;
  1105. /**
  1106. * Gets the underlying buffer
  1107. */
  1108. get underlyingResource(): any;
  1109. }
  1110. }
  1111. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1112. /** @hidden */
  1113. export interface IShaderProcessor {
  1114. attributeProcessor?: (attribute: string) => string;
  1115. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1116. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1117. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1118. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1119. lineProcessor?: (line: string, isFragment: boolean) => string;
  1120. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1121. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1122. }
  1123. }
  1124. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1126. /** @hidden */
  1127. export interface ProcessingOptions {
  1128. defines: string[];
  1129. indexParameters: any;
  1130. isFragment: boolean;
  1131. shouldUseHighPrecisionShader: boolean;
  1132. supportsUniformBuffers: boolean;
  1133. shadersRepository: string;
  1134. includesShadersStore: {
  1135. [key: string]: string;
  1136. };
  1137. processor?: IShaderProcessor;
  1138. version: string;
  1139. platformName: string;
  1140. lookForClosingBracketForUniformBuffer?: boolean;
  1141. }
  1142. }
  1143. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1144. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1145. /** @hidden */
  1146. export class ShaderCodeNode {
  1147. line: string;
  1148. children: ShaderCodeNode[];
  1149. additionalDefineKey?: string;
  1150. additionalDefineValue?: string;
  1151. isValid(preprocessors: {
  1152. [key: string]: string;
  1153. }): boolean;
  1154. process(preprocessors: {
  1155. [key: string]: string;
  1156. }, options: ProcessingOptions): string;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1160. /** @hidden */
  1161. export class ShaderCodeCursor {
  1162. private _lines;
  1163. lineIndex: number;
  1164. get currentLine(): string;
  1165. get canRead(): boolean;
  1166. set lines(value: string[]);
  1167. }
  1168. }
  1169. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1170. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1171. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1190. /** @hidden */
  1191. export class ShaderCodeTestNode extends ShaderCodeNode {
  1192. testExpression: ShaderDefineExpression;
  1193. isValid(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1199. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1200. /** @hidden */
  1201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1202. define: string;
  1203. not: boolean;
  1204. constructor(define: string, not?: boolean);
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1211. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1212. /** @hidden */
  1213. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module "babylonjs/Offline/IOfflineProvider" {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module "babylonjs/Misc/filesInputStore" {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module "babylonjs/Misc/retryStrategy" {
  1297. import { WebRequest } from "babylonjs/Misc/webRequest";
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/baseError" {
  1312. /**
  1313. * @ignore
  1314. * Application error to support additional information when loading a file
  1315. */
  1316. export abstract class BaseError extends Error {
  1317. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1318. }
  1319. }
  1320. declare module "babylonjs/Misc/fileTools" {
  1321. import { WebRequest } from "babylonjs/Misc/webRequest";
  1322. import { Nullable } from "babylonjs/types";
  1323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1324. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1325. import { BaseError } from "babylonjs/Misc/baseError";
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. 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>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1444. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1445. import { WebRequest } from "babylonjs/Misc/webRequest";
  1446. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. /**
  1463. * Loads a file from a url
  1464. * @param url url to load
  1465. * @param onSuccess callback called when the file successfully loads
  1466. * @param onProgress callback called while file is loading (if the server supports this mode)
  1467. * @param offlineProvider defines the offline provider for caching
  1468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1469. * @param onError callback called when the file fails to load
  1470. * @returns a file request object
  1471. * @hidden
  1472. */
  1473. 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;
  1474. }
  1475. }
  1476. declare module "babylonjs/Maths/math.like" {
  1477. import { float, int, DeepImmutable } from "babylonjs/types";
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module "babylonjs/Materials/iEffectFallbacks" {
  1545. import { Effect } from "babylonjs/Materials/effect";
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module "babylonjs/Misc/tags" {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Maths/math.scalar" {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module "babylonjs/Maths/math.constants" {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. export { Epsilon };
  1850. }
  1851. declare module "babylonjs/Maths/math.viewport" {
  1852. /**
  1853. * Class used to represent a viewport on screen
  1854. */
  1855. export class Viewport {
  1856. /** viewport left coordinate */
  1857. x: number;
  1858. /** viewport top coordinate */
  1859. y: number;
  1860. /**viewport width */
  1861. width: number;
  1862. /** viewport height */
  1863. height: number;
  1864. /**
  1865. * Creates a Viewport object located at (x, y) and sized (width, height)
  1866. * @param x defines viewport left coordinate
  1867. * @param y defines viewport top coordinate
  1868. * @param width defines the viewport width
  1869. * @param height defines the viewport height
  1870. */
  1871. constructor(
  1872. /** viewport left coordinate */
  1873. x: number,
  1874. /** viewport top coordinate */
  1875. y: number,
  1876. /**viewport width */
  1877. width: number,
  1878. /** viewport height */
  1879. height: number);
  1880. /**
  1881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1882. * @param renderWidth defines the rendering width
  1883. * @param renderHeight defines the rendering height
  1884. * @returns a new Viewport
  1885. */
  1886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1887. /**
  1888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @param ref defines the target viewport
  1892. * @returns the current viewport
  1893. */
  1894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1895. /**
  1896. * Returns a new Viewport copied from the current one
  1897. * @returns a new Viewport
  1898. */
  1899. clone(): Viewport;
  1900. }
  1901. }
  1902. declare module "babylonjs/Misc/arrayTools" {
  1903. /**
  1904. * Class containing a set of static utilities functions for arrays.
  1905. */
  1906. export class ArrayTools {
  1907. /**
  1908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1909. * @param size the number of element to construct and put in the array
  1910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1911. * @returns a new array filled with new objects
  1912. */
  1913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1914. }
  1915. }
  1916. declare module "babylonjs/Maths/math.vector" {
  1917. import { Viewport } from "babylonjs/Maths/math.viewport";
  1918. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1919. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1920. /**
  1921. * Class representing a vector containing 2 coordinates
  1922. */
  1923. export class Vector2 {
  1924. /** defines the first coordinate */
  1925. x: number;
  1926. /** defines the second coordinate */
  1927. y: number;
  1928. /**
  1929. * Creates a new Vector2 from the given x and y coordinates
  1930. * @param x defines the first coordinate
  1931. * @param y defines the second coordinate
  1932. */
  1933. constructor(
  1934. /** defines the first coordinate */
  1935. x?: number,
  1936. /** defines the second coordinate */
  1937. y?: number);
  1938. /**
  1939. * Gets a string with the Vector2 coordinates
  1940. * @returns a string with the Vector2 coordinates
  1941. */
  1942. toString(): string;
  1943. /**
  1944. * Gets class name
  1945. * @returns the string "Vector2"
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * Gets current vector hash code
  1950. * @returns the Vector2 hash code as a number
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1955. * @param array defines the source array
  1956. * @param index defines the offset in source array
  1957. * @returns the current Vector2
  1958. */
  1959. toArray(array: FloatArray, index?: number): Vector2;
  1960. /**
  1961. * Copy the current vector to an array
  1962. * @returns a new array with 2 elements: the Vector2 coordinates.
  1963. */
  1964. asArray(): number[];
  1965. /**
  1966. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1967. * @param source defines the source Vector2
  1968. * @returns the current updated Vector2
  1969. */
  1970. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Sets the Vector2 coordinates with the given floats
  1973. * @param x defines the first coordinate
  1974. * @param y defines the second coordinate
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFromFloats(x: number, y: number): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. set(x: number, y: number): Vector2;
  1985. /**
  1986. * Add another vector with the current one
  1987. * @param otherVector defines the other vector
  1988. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1989. */
  1990. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1993. * @param otherVector defines the other vector
  1994. * @param result defines the target vector
  1995. * @returns the unmodified current Vector2
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1998. /**
  1999. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. addVector3(otherVector: Vector3): Vector2;
  2010. /**
  2011. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2012. * @param otherVector defines the other vector
  2013. * @returns a new Vector2
  2014. */
  2015. subtract(otherVector: Vector2): Vector2;
  2016. /**
  2017. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2018. * @param otherVector defines the other vector
  2019. * @param result defines the target vector
  2020. * @returns the unmodified current Vector2
  2021. */
  2022. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2023. /**
  2024. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @returns the current updated Vector2
  2027. */
  2028. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2029. /**
  2030. * Multiplies in place the current Vector2 coordinates by the given ones
  2031. * @param otherVector defines the other vector
  2032. * @returns the current updated Vector2
  2033. */
  2034. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2035. /**
  2036. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns a new Vector2
  2039. */
  2040. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @param result defines the target vector
  2045. * @returns the unmodified current Vector2
  2046. */
  2047. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2048. /**
  2049. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. * @returns a new Vector2
  2053. */
  2054. multiplyByFloats(x: number, y: number): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. divide(otherVector: Vector2): Vector2;
  2061. /**
  2062. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Divides the current Vector2 coordinates by the given ones
  2070. * @param otherVector defines the other vector
  2071. * @returns the current updated Vector2
  2072. */
  2073. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Gets a new Vector2 with current Vector2 negated coordinates
  2076. * @returns a new Vector2
  2077. */
  2078. negate(): Vector2;
  2079. /**
  2080. * Negate this vector in place
  2081. * @returns this
  2082. */
  2083. negateInPlace(): Vector2;
  2084. /**
  2085. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2086. * @param result defines the Vector3 object where to store the result
  2087. * @returns the current Vector2
  2088. */
  2089. negateToRef(result: Vector2): Vector2;
  2090. /**
  2091. * Multiply the Vector2 coordinates by scale
  2092. * @param scale defines the scaling factor
  2093. * @returns the current updated Vector2
  2094. */
  2095. scaleInPlace(scale: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2098. * @param scale defines the scaling factor
  2099. * @returns a new Vector2
  2100. */
  2101. scale(scale: number): Vector2;
  2102. /**
  2103. * Scale the current Vector2 values by a factor to a given Vector2
  2104. * @param scale defines the scale factor
  2105. * @param result defines the Vector2 object where to store the result
  2106. * @returns the unmodified current Vector2
  2107. */
  2108. scaleToRef(scale: number, result: Vector2): Vector2;
  2109. /**
  2110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2111. * @param scale defines the scale factor
  2112. * @param result defines the Vector2 object where to store the result
  2113. * @returns the unmodified current Vector2
  2114. */
  2115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2116. /**
  2117. * Gets a boolean if two vectors are equals
  2118. * @param otherVector defines the other vector
  2119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2120. */
  2121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2122. /**
  2123. * Gets a boolean if two vectors are equals (using an epsilon value)
  2124. * @param otherVector defines the other vector
  2125. * @param epsilon defines the minimal distance to consider equality
  2126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2127. */
  2128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2129. /**
  2130. * Gets a new Vector2 from current Vector2 floored values
  2131. * @returns a new Vector2
  2132. */
  2133. floor(): Vector2;
  2134. /**
  2135. * Gets a new Vector2 from current Vector2 floored values
  2136. * @returns a new Vector2
  2137. */
  2138. fract(): Vector2;
  2139. /**
  2140. * Gets the length of the vector
  2141. * @returns the vector length (float)
  2142. */
  2143. length(): number;
  2144. /**
  2145. * Gets the vector squared length
  2146. * @returns the vector squared length (float)
  2147. */
  2148. lengthSquared(): number;
  2149. /**
  2150. * Normalize the vector
  2151. * @returns the current updated Vector2
  2152. */
  2153. normalize(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 copied from the Vector2
  2156. * @returns a new Vector2
  2157. */
  2158. clone(): Vector2;
  2159. /**
  2160. * Gets a new Vector2(0, 0)
  2161. * @returns a new Vector2
  2162. */
  2163. static Zero(): Vector2;
  2164. /**
  2165. * Gets a new Vector2(1, 1)
  2166. * @returns a new Vector2
  2167. */
  2168. static One(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 set from the given index element of the given array
  2171. * @param array defines the data source
  2172. * @param offset defines the offset in the data source
  2173. * @returns a new Vector2
  2174. */
  2175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2176. /**
  2177. * Sets "result" from the given index element of the given array
  2178. * @param array defines the data source
  2179. * @param offset defines the offset in the data source
  2180. * @param result defines the target vector
  2181. */
  2182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2183. /**
  2184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2185. * @param value1 defines 1st point of control
  2186. * @param value2 defines 2nd point of control
  2187. * @param value3 defines 3rd point of control
  2188. * @param value4 defines 4th point of control
  2189. * @param amount defines the interpolation factor
  2190. * @returns a new Vector2
  2191. */
  2192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2193. /**
  2194. * 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".
  2195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2197. * @param value defines the value to clamp
  2198. * @param min defines the lower limit
  2199. * @param max defines the upper limit
  2200. * @returns a new Vector2
  2201. */
  2202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2205. * @param value1 defines the 1st control point
  2206. * @param tangent1 defines the outgoing tangent
  2207. * @param value2 defines the 2nd control point
  2208. * @param tangent2 defines the incoming tangent
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2215. * @param start defines the start vector
  2216. * @param end defines the end vector
  2217. * @param amount defines the interpolation factor
  2218. * @returns a new Vector2
  2219. */
  2220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2221. /**
  2222. * Gets the dot product of the vector "left" and the vector "right"
  2223. * @param left defines first vector
  2224. * @param right defines second vector
  2225. * @returns the dot product (float)
  2226. */
  2227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2228. /**
  2229. * Returns a new Vector2 equal to the normalized given vector
  2230. * @param vector defines the vector to normalize
  2231. * @returns a new Vector2
  2232. */
  2233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2236. * @param left defines 1st vector
  2237. * @param right defines 2nd vector
  2238. * @returns a new Vector2
  2239. */
  2240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2241. /**
  2242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2243. * @param left defines 1st vector
  2244. * @param right defines 2nd vector
  2245. * @returns a new Vector2
  2246. */
  2247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2250. * @param vector defines the vector to transform
  2251. * @param transformation defines the matrix to apply
  2252. * @returns a new Vector2
  2253. */
  2254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2255. /**
  2256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2257. * @param vector defines the vector to transform
  2258. * @param transformation defines the matrix to apply
  2259. * @param result defines the target vector
  2260. */
  2261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2262. /**
  2263. * Determines if a given vector is included in a triangle
  2264. * @param p defines the vector to test
  2265. * @param p0 defines 1st triangle point
  2266. * @param p1 defines 2nd triangle point
  2267. * @param p2 defines 3rd triangle point
  2268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2269. */
  2270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2271. /**
  2272. * Gets the distance between the vectors "value1" and "value2"
  2273. * @param value1 defines first vector
  2274. * @param value2 defines second vector
  2275. * @returns the distance between vectors
  2276. */
  2277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2278. /**
  2279. * Returns the squared distance between the vectors "value1" and "value2"
  2280. * @param value1 defines first vector
  2281. * @param value2 defines second vector
  2282. * @returns the squared distance between vectors
  2283. */
  2284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2285. /**
  2286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2287. * @param value1 defines first vector
  2288. * @param value2 defines second vector
  2289. * @returns a new Vector2
  2290. */
  2291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2292. /**
  2293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2294. * @param p defines the middle point
  2295. * @param segA defines one point of the segment
  2296. * @param segB defines the other point of the segment
  2297. * @returns the shortest distance
  2298. */
  2299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2300. }
  2301. /**
  2302. * Class used to store (x,y,z) vector representation
  2303. * A Vector3 is the main object used in 3D geometry
  2304. * It can represent etiher the coordinates of a point the space, either a direction
  2305. * Reminder: js uses a left handed forward facing system
  2306. */
  2307. export class Vector3 {
  2308. /**
  2309. * Defines the first coordinates (on X axis)
  2310. */
  2311. x: number;
  2312. /**
  2313. * Defines the second coordinates (on Y axis)
  2314. */
  2315. y: number;
  2316. /**
  2317. * Defines the third coordinates (on Z axis)
  2318. */
  2319. z: number;
  2320. private static _UpReadOnly;
  2321. private static _ZeroReadOnly;
  2322. /**
  2323. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2324. * @param x defines the first coordinates (on X axis)
  2325. * @param y defines the second coordinates (on Y axis)
  2326. * @param z defines the third coordinates (on Z axis)
  2327. */
  2328. constructor(
  2329. /**
  2330. * Defines the first coordinates (on X axis)
  2331. */
  2332. x?: number,
  2333. /**
  2334. * Defines the second coordinates (on Y axis)
  2335. */
  2336. y?: number,
  2337. /**
  2338. * Defines the third coordinates (on Z axis)
  2339. */
  2340. z?: number);
  2341. /**
  2342. * Creates a string representation of the Vector3
  2343. * @returns a string with the Vector3 coordinates.
  2344. */
  2345. toString(): string;
  2346. /**
  2347. * Gets the class name
  2348. * @returns the string "Vector3"
  2349. */
  2350. getClassName(): string;
  2351. /**
  2352. * Creates the Vector3 hash code
  2353. * @returns a number which tends to be unique between Vector3 instances
  2354. */
  2355. getHashCode(): number;
  2356. /**
  2357. * Creates an array containing three elements : the coordinates of the Vector3
  2358. * @returns a new array of numbers
  2359. */
  2360. asArray(): number[];
  2361. /**
  2362. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2363. * @param array defines the destination array
  2364. * @param index defines the offset in the destination array
  2365. * @returns the current Vector3
  2366. */
  2367. toArray(array: FloatArray, index?: number): Vector3;
  2368. /**
  2369. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2370. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2371. */
  2372. toQuaternion(): Quaternion;
  2373. /**
  2374. * Adds the given vector to the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Adds the given coordinates to the current Vector3
  2381. * @param x defines the x coordinate of the operand
  2382. * @param y defines the y coordinate of the operand
  2383. * @param z defines the z coordinate of the operand
  2384. * @returns the current updated Vector3
  2385. */
  2386. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2387. /**
  2388. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2389. * @param otherVector defines the second operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2395. * @param otherVector defines the second operand
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2400. /**
  2401. * Subtract the given vector from the current Vector3
  2402. * @param otherVector defines the second operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2406. /**
  2407. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2421. * @param x defines the x coordinate of the operand
  2422. * @param y defines the y coordinate of the operand
  2423. * @param z defines the z coordinate of the operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2427. /**
  2428. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2429. * @param x defines the x coordinate of the operand
  2430. * @param y defines the y coordinate of the operand
  2431. * @param z defines the z coordinate of the operand
  2432. * @param result defines the Vector3 object where to store the result
  2433. * @returns the current Vector3
  2434. */
  2435. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2436. /**
  2437. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2438. * @returns a new Vector3
  2439. */
  2440. negate(): Vector3;
  2441. /**
  2442. * Negate this vector in place
  2443. * @returns this
  2444. */
  2445. negateInPlace(): Vector3;
  2446. /**
  2447. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the current Vector3
  2450. */
  2451. negateToRef(result: Vector3): Vector3;
  2452. /**
  2453. * Multiplies the Vector3 coordinates by the float "scale"
  2454. * @param scale defines the multiplier factor
  2455. * @returns the current updated Vector3
  2456. */
  2457. scaleInPlace(scale: number): Vector3;
  2458. /**
  2459. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2460. * @param scale defines the multiplier factor
  2461. * @returns a new Vector3
  2462. */
  2463. scale(scale: number): Vector3;
  2464. /**
  2465. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2466. * @param scale defines the multiplier factor
  2467. * @param result defines the Vector3 object where to store the result
  2468. * @returns the current Vector3
  2469. */
  2470. scaleToRef(scale: number, result: Vector3): Vector3;
  2471. /**
  2472. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2473. * @param scale defines the scale factor
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the unmodified current Vector3
  2476. */
  2477. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2478. /**
  2479. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2480. * @param otherVector defines the second operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2484. /**
  2485. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2486. * @param otherVector defines the second operand
  2487. * @param epsilon defines the minimal distance to define values as equals
  2488. * @returns true if both vectors are distant less than epsilon
  2489. */
  2490. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2491. /**
  2492. * Returns true if the current Vector3 coordinates equals the given floats
  2493. * @param x defines the x coordinate of the operand
  2494. * @param y defines the y coordinate of the operand
  2495. * @param z defines the z coordinate of the operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equalsToFloats(x: number, y: number, z: number): boolean;
  2499. /**
  2500. * Multiplies the current Vector3 coordinates by the given ones
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2505. /**
  2506. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2528. * @param otherVector defines the second operand
  2529. * @returns the new Vector3
  2530. */
  2531. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Divides the current Vector3 coordinates by the given ones.
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. divideInPlace(otherVector: Vector3): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2547. * @param other defines the second operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2553. * @param other defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2575. * Check if is non uniform within a certain amount of decimal places to account for this
  2576. * @param epsilon the amount the values can differ
  2577. * @returns if the the vector is non uniform to a certain number of decimal places
  2578. */
  2579. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2580. /**
  2581. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2582. */
  2583. get isNonUniform(): boolean;
  2584. /**
  2585. * Gets a new Vector3 from current Vector3 floored values
  2586. * @returns a new Vector3
  2587. */
  2588. floor(): Vector3;
  2589. /**
  2590. * Gets a new Vector3 from current Vector3 floored values
  2591. * @returns a new Vector3
  2592. */
  2593. fract(): Vector3;
  2594. /**
  2595. * Gets the length of the Vector3
  2596. * @returns the length of the Vector3
  2597. */
  2598. length(): number;
  2599. /**
  2600. * Gets the squared length of the Vector3
  2601. * @returns squared length of the Vector3
  2602. */
  2603. lengthSquared(): number;
  2604. /**
  2605. * Normalize the current Vector3.
  2606. * Please note that this is an in place operation.
  2607. * @returns the current updated Vector3
  2608. */
  2609. normalize(): Vector3;
  2610. /**
  2611. * Reorders the x y z properties of the vector in place
  2612. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2613. * @returns the current updated vector
  2614. */
  2615. reorderInPlace(order: string): this;
  2616. /**
  2617. * Rotates the vector around 0,0,0 by a quaternion
  2618. * @param quaternion the rotation quaternion
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2623. /**
  2624. * Rotates a vector around a given point
  2625. * @param quaternion the rotation quaternion
  2626. * @param point the point to rotate around
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2631. /**
  2632. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2633. * The cross product is then orthogonal to both current and "other"
  2634. * @param other defines the right operand
  2635. * @returns the cross product
  2636. */
  2637. cross(other: Vector3): Vector3;
  2638. /**
  2639. * Normalize the current Vector3 with the given input length.
  2640. * Please note that this is an in place operation.
  2641. * @param len the length of the vector
  2642. * @returns the current updated Vector3
  2643. */
  2644. normalizeFromLength(len: number): Vector3;
  2645. /**
  2646. * Normalize the current Vector3 to a new vector
  2647. * @returns the new Vector3
  2648. */
  2649. normalizeToNew(): Vector3;
  2650. /**
  2651. * Normalize the current Vector3 to the reference
  2652. * @param reference define the Vector3 to update
  2653. * @returns the updated Vector3
  2654. */
  2655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Creates a new Vector3 copied from the current Vector3
  2658. * @returns the new Vector3
  2659. */
  2660. clone(): Vector3;
  2661. /**
  2662. * Copies the given vector coordinates to the current Vector3 ones
  2663. * @param source defines the source Vector3
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. set(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given float to the current Vector3 coordinates
  2685. * @param v defines the x, y and z coordinates of the operand
  2686. * @returns the current updated Vector3
  2687. */
  2688. setAll(v: number): Vector3;
  2689. /**
  2690. * Get the clip factor between two vectors
  2691. * @param vector0 defines the first operand
  2692. * @param vector1 defines the second operand
  2693. * @param axis defines the axis to use
  2694. * @param size defines the size along the axis
  2695. * @returns the clip factor
  2696. */
  2697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2698. /**
  2699. * Get angle between two vectors
  2700. * @param vector0 angle between vector0 and vector1
  2701. * @param vector1 angle between vector0 and vector1
  2702. * @param normal direction of the normal
  2703. * @return the angle between vector0 and vector1
  2704. */
  2705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2706. /**
  2707. * Returns a new Vector3 set from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @returns the new Vector3
  2711. */
  2712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @returns the new Vector3
  2718. * @deprecated Please use FromArray instead.
  2719. */
  2720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2721. /**
  2722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @param result defines the Vector3 where to store the result
  2726. */
  2727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @param result defines the Vector3 where to store the result
  2733. * @deprecated Please use FromArrayToRef instead.
  2734. */
  2735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the given floats.
  2738. * @param x defines the x coordinate of the source
  2739. * @param y defines the y coordinate of the source
  2740. * @param z defines the z coordinate of the source
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2746. * @returns a new empty Vector3
  2747. */
  2748. static Zero(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2751. * @returns a new unit Vector3
  2752. */
  2753. static One(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2756. * @returns a new up Vector3
  2757. */
  2758. static Up(): Vector3;
  2759. /**
  2760. * Gets a up Vector3 that must not be updated
  2761. */
  2762. static get UpReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Gets a zero Vector3 that must not be updated
  2765. */
  2766. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2769. * @returns a new down Vector3
  2770. */
  2771. static Down(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2774. * @returns a new forward Vector3
  2775. */
  2776. static Forward(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2779. * @returns a new forward Vector3
  2780. */
  2781. static Backward(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2784. * @returns a new right Vector3
  2785. */
  2786. static Right(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2789. * @returns a new left Vector3
  2790. */
  2791. static Left(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the transformed Vector3
  2798. */
  2799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2810. * This method computes tranformed coordinates only, not transformed direction vectors
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @returns the new Vector3
  2824. */
  2825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param x define the x coordinate of the source vector
  2838. * @param y define the y coordinate of the source vector
  2839. * @param z define the z coordinate of the source vector
  2840. * @param transformation defines the transformation matrix
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2846. * @param value1 defines the first control point
  2847. * @param value2 defines the second control point
  2848. * @param value3 defines the third control point
  2849. * @param value4 defines the fourth control point
  2850. * @param amount defines the amount on the spline to use
  2851. * @returns the new Vector3
  2852. */
  2853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * 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"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @returns the new Vector3
  2862. */
  2863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2864. /**
  2865. * 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"
  2866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2868. * @param value defines the current value
  2869. * @param min defines the lower range value
  2870. * @param max defines the upper range value
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2874. /**
  2875. * Checks if a given vector is inside a specific range
  2876. * @param v defines the vector to test
  2877. * @param min defines the minimum range
  2878. * @param max defines the maximum range
  2879. */
  2880. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2883. * @param value1 defines the first control point
  2884. * @param tangent1 defines the first tangent vector
  2885. * @param value2 defines the second control point
  2886. * @param tangent2 defines the second tangent vector
  2887. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2907. /**
  2908. * Returns the dot product (float) between the vectors "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the dot product
  2912. */
  2913. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2914. /**
  2915. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the cross product
  2920. */
  2921. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2922. /**
  2923. * Sets the given vector "result" with the cross product of "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 as the normalization of the given vector
  2932. * @param vector defines the Vector3 to normalize
  2933. * @returns the new Vector3
  2934. */
  2935. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the normalization of the given first vector
  2938. * @param vector defines the Vector3 to normalize
  2939. * @param result defines the Vector3 where to store the result
  2940. */
  2941. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2942. /**
  2943. * Project a Vector3 onto screen space
  2944. * @param vector defines the Vector3 to project
  2945. * @param world defines the world matrix to use
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @param viewport defines the screen viewport to use
  2948. * @returns the new Vector3
  2949. */
  2950. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2951. /** @hidden */
  2952. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param sourceX defines the screen space x coordinate to use
  2988. * @param sourceY defines the screen space y coordinate to use
  2989. * @param sourceZ defines the screen space z coordinate to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Gets the minimal coordinate values between two Vector3
  3000. * @param left defines the first operand
  3001. * @param right defines the second operand
  3002. * @returns the new Vector3
  3003. */
  3004. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3005. /**
  3006. * Gets the maximal coordinate values between two Vector3
  3007. * @param left defines the first operand
  3008. * @param right defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Returns the distance between the vectors "value1" and "value2"
  3014. * @param value1 defines the first operand
  3015. * @param value2 defines the second operand
  3016. * @returns the distance
  3017. */
  3018. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3019. /**
  3020. * Returns the squared distance between the vectors "value1" and "value2"
  3021. * @param value1 defines the first operand
  3022. * @param value2 defines the second operand
  3023. * @returns the squared distance
  3024. */
  3025. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 located at the center between "value1" and "value2"
  3028. * @param value1 defines the first operand
  3029. * @param value2 defines the second operand
  3030. * @returns the new Vector3
  3031. */
  3032. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3036. * to something in order to rotate it from its local system to the given target system
  3037. * Note: axis1, axis2 and axis3 are normalized during this operation
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @returns a new Vector3
  3042. */
  3043. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @param ref defines the Vector3 where to store the result
  3050. */
  3051. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3052. }
  3053. /**
  3054. * Vector4 class created for EulerAngle class conversion to Quaternion
  3055. */
  3056. export class Vector4 {
  3057. /** x value of the vector */
  3058. x: number;
  3059. /** y value of the vector */
  3060. y: number;
  3061. /** z value of the vector */
  3062. z: number;
  3063. /** w value of the vector */
  3064. w: number;
  3065. /**
  3066. * Creates a Vector4 object from the given floats.
  3067. * @param x x value of the vector
  3068. * @param y y value of the vector
  3069. * @param z z value of the vector
  3070. * @param w w value of the vector
  3071. */
  3072. constructor(
  3073. /** x value of the vector */
  3074. x: number,
  3075. /** y value of the vector */
  3076. y: number,
  3077. /** z value of the vector */
  3078. z: number,
  3079. /** w value of the vector */
  3080. w: number);
  3081. /**
  3082. * Returns the string with the Vector4 coordinates.
  3083. * @returns a string containing all the vector values
  3084. */
  3085. toString(): string;
  3086. /**
  3087. * Returns the string "Vector4".
  3088. * @returns "Vector4"
  3089. */
  3090. getClassName(): string;
  3091. /**
  3092. * Returns the Vector4 hash code.
  3093. * @returns a unique hash code
  3094. */
  3095. getHashCode(): number;
  3096. /**
  3097. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3098. * @returns the resulting array
  3099. */
  3100. asArray(): number[];
  3101. /**
  3102. * Populates the given array from the given index with the Vector4 coordinates.
  3103. * @param array array to populate
  3104. * @param index index of the array to start at (default: 0)
  3105. * @returns the Vector4.
  3106. */
  3107. toArray(array: FloatArray, index?: number): Vector4;
  3108. /**
  3109. * Adds the given vector to the current Vector4.
  3110. * @param otherVector the vector to add
  3111. * @returns the updated Vector4.
  3112. */
  3113. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3114. /**
  3115. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3116. * @param otherVector the vector to add
  3117. * @returns the resulting vector
  3118. */
  3119. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3122. * @param otherVector the vector to add
  3123. * @param result the vector to store the result
  3124. * @returns the current Vector4.
  3125. */
  3126. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3127. /**
  3128. * Subtract in place the given vector from the current Vector4.
  3129. * @param otherVector the vector to subtract
  3130. * @returns the updated Vector4.
  3131. */
  3132. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3135. * @param otherVector the vector to add
  3136. * @returns the new vector with the result
  3137. */
  3138. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3139. /**
  3140. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3141. * @param otherVector the vector to subtract
  3142. * @param result the vector to store the result
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3148. */
  3149. /**
  3150. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3151. * @param x value to subtract
  3152. * @param y value to subtract
  3153. * @param z value to subtract
  3154. * @param w value to subtract
  3155. * @returns new vector containing the result
  3156. */
  3157. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3158. /**
  3159. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3160. * @param x value to subtract
  3161. * @param y value to subtract
  3162. * @param z value to subtract
  3163. * @param w value to subtract
  3164. * @param result the vector to store the result in
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3170. * @returns a new vector with the negated values
  3171. */
  3172. negate(): Vector4;
  3173. /**
  3174. * Negate this vector in place
  3175. * @returns this
  3176. */
  3177. negateInPlace(): Vector4;
  3178. /**
  3179. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3180. * @param result defines the Vector3 object where to store the result
  3181. * @returns the current Vector4
  3182. */
  3183. negateToRef(result: Vector4): Vector4;
  3184. /**
  3185. * Multiplies the current Vector4 coordinates by scale (float).
  3186. * @param scale the number to scale with
  3187. * @returns the updated Vector4.
  3188. */
  3189. scaleInPlace(scale: number): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3192. * @param scale the number to scale with
  3193. * @returns a new vector with the result
  3194. */
  3195. scale(scale: number): Vector4;
  3196. /**
  3197. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3198. * @param scale the number to scale with
  3199. * @param result a vector to store the result in
  3200. * @returns the current Vector4.
  3201. */
  3202. scaleToRef(scale: number, result: Vector4): Vector4;
  3203. /**
  3204. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3205. * @param scale defines the scale factor
  3206. * @param result defines the Vector4 object where to store the result
  3207. * @returns the unmodified current Vector4
  3208. */
  3209. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3210. /**
  3211. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3212. * @param otherVector the vector to compare against
  3213. * @returns true if they are equal
  3214. */
  3215. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3216. /**
  3217. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3218. * @param otherVector vector to compare against
  3219. * @param epsilon (Default: very small number)
  3220. * @returns true if they are equal
  3221. */
  3222. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3223. /**
  3224. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3225. * @param x x value to compare against
  3226. * @param y y value to compare against
  3227. * @param z z value to compare against
  3228. * @param w w value to compare against
  3229. * @returns true if equal
  3230. */
  3231. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3232. /**
  3233. * Multiplies in place the current Vector4 by the given one.
  3234. * @param otherVector vector to multiple with
  3235. * @returns the updated Vector4.
  3236. */
  3237. multiplyInPlace(otherVector: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3240. * @param otherVector vector to multiple with
  3241. * @returns resulting new vector
  3242. */
  3243. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3246. * @param otherVector vector to multiple with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3253. * @param x x value multiply with
  3254. * @param y y value multiply with
  3255. * @param z z value multiply with
  3256. * @param w w value multiply with
  3257. * @returns resulting new vector
  3258. */
  3259. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3262. * @param otherVector vector to devide with
  3263. * @returns resulting new vector
  3264. */
  3265. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3268. * @param otherVector vector to devide with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Divides the current Vector3 coordinates by the given ones.
  3275. * @param otherVector vector to devide with
  3276. * @returns the updated Vector3.
  3277. */
  3278. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3281. * @param other defines the second operand
  3282. * @returns the current updated Vector4
  3283. */
  3284. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3287. * @param other defines the second operand
  3288. * @returns the current updated Vector4
  3289. */
  3290. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Gets a new Vector4 from current Vector4 floored values
  3293. * @returns a new Vector4
  3294. */
  3295. floor(): Vector4;
  3296. /**
  3297. * Gets a new Vector4 from current Vector3 floored values
  3298. * @returns a new Vector4
  3299. */
  3300. fract(): Vector4;
  3301. /**
  3302. * Returns the Vector4 length (float).
  3303. * @returns the length
  3304. */
  3305. length(): number;
  3306. /**
  3307. * Returns the Vector4 squared length (float).
  3308. * @returns the length squared
  3309. */
  3310. lengthSquared(): number;
  3311. /**
  3312. * Normalizes in place the Vector4.
  3313. * @returns the updated Vector4.
  3314. */
  3315. normalize(): Vector4;
  3316. /**
  3317. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3318. * @returns this converted to a new vector3
  3319. */
  3320. toVector3(): Vector3;
  3321. /**
  3322. * Returns a new Vector4 copied from the current one.
  3323. * @returns the new cloned vector
  3324. */
  3325. clone(): Vector4;
  3326. /**
  3327. * Updates the current Vector4 with the given one coordinates.
  3328. * @param source the source vector to copy from
  3329. * @returns the updated Vector4.
  3330. */
  3331. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Updates the current Vector4 coordinates with the given floats.
  3334. * @param x float to copy from
  3335. * @param y float to copy from
  3336. * @param z float to copy from
  3337. * @param w float to copy from
  3338. * @returns the updated Vector4.
  3339. */
  3340. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3341. /**
  3342. * Updates the current Vector4 coordinates with the given floats.
  3343. * @param x float to set from
  3344. * @param y float to set from
  3345. * @param z float to set from
  3346. * @param w float to set from
  3347. * @returns the updated Vector4.
  3348. */
  3349. set(x: number, y: number, z: number, w: number): Vector4;
  3350. /**
  3351. * Copies the given float to the current Vector3 coordinates
  3352. * @param v defines the x, y, z and w coordinates of the operand
  3353. * @returns the current updated Vector3
  3354. */
  3355. setAll(v: number): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set from the starting index of the given array.
  3358. * @param array the array to pull values from
  3359. * @param offset the offset into the array to start at
  3360. * @returns the new vector
  3361. */
  3362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3363. /**
  3364. * Updates the given vector "result" from the starting index of the given array.
  3365. * @param array the array to pull values from
  3366. * @param offset the offset into the array to start at
  3367. * @param result the vector to store the result in
  3368. */
  3369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3370. /**
  3371. * Updates the given vector "result" from the starting index of the given Float32Array.
  3372. * @param array the array to pull values from
  3373. * @param offset the offset into the array to start at
  3374. * @param result the vector to store the result in
  3375. */
  3376. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3377. /**
  3378. * Updates the given vector "result" coordinates from the given floats.
  3379. * @param x float to set from
  3380. * @param y float to set from
  3381. * @param z float to set from
  3382. * @param w float to set from
  3383. * @param result the vector to the floats in
  3384. */
  3385. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3386. /**
  3387. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3388. * @returns the new vector
  3389. */
  3390. static Zero(): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3393. * @returns the new vector
  3394. */
  3395. static One(): Vector4;
  3396. /**
  3397. * Returns a new normalized Vector4 from the given one.
  3398. * @param vector the vector to normalize
  3399. * @returns the vector
  3400. */
  3401. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Updates the given vector "result" from the normalization of the given one.
  3404. * @param vector the vector to normalize
  3405. * @param result the vector to store the result in
  3406. */
  3407. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3408. /**
  3409. * Returns a vector with the minimum values from the left and right vectors
  3410. * @param left left vector to minimize
  3411. * @param right right vector to minimize
  3412. * @returns a new vector with the minimum of the left and right vector values
  3413. */
  3414. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Returns a vector with the maximum values from the left and right vectors
  3417. * @param left left vector to maximize
  3418. * @param right right vector to maximize
  3419. * @returns a new vector with the maximum of the left and right vector values
  3420. */
  3421. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns the distance (float) between the vectors "value1" and "value2".
  3424. * @param value1 value to calulate the distance between
  3425. * @param value2 value to calulate the distance between
  3426. * @return the distance between the two vectors
  3427. */
  3428. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3429. /**
  3430. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3431. * @param value1 value to calulate the distance between
  3432. * @param value2 value to calulate the distance between
  3433. * @return the distance between the two vectors squared
  3434. */
  3435. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3436. /**
  3437. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3438. * @param value1 value to calulate the center between
  3439. * @param value2 value to calulate the center between
  3440. * @return the center between the two vectors
  3441. */
  3442. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3445. * This methods computes transformed normalized direction vectors only.
  3446. * @param vector the vector to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @returns the new vector
  3449. */
  3450. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3451. /**
  3452. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3453. * This methods computes transformed normalized direction vectors only.
  3454. * @param vector the vector to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the result in
  3457. */
  3458. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3461. * This methods computes transformed normalized direction vectors only.
  3462. * @param x value to transform
  3463. * @param y value to transform
  3464. * @param z value to transform
  3465. * @param w value to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the results in
  3468. */
  3469. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Creates a new Vector4 from a Vector3
  3472. * @param source defines the source data
  3473. * @param w defines the 4th component (default is 0)
  3474. * @returns a new Vector4
  3475. */
  3476. static FromVector3(source: Vector3, w?: number): Vector4;
  3477. }
  3478. /**
  3479. * Class used to store quaternion data
  3480. * @see https://en.wikipedia.org/wiki/Quaternion
  3481. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3482. */
  3483. export class Quaternion {
  3484. /** defines the first component (0 by default) */
  3485. x: number;
  3486. /** defines the second component (0 by default) */
  3487. y: number;
  3488. /** defines the third component (0 by default) */
  3489. z: number;
  3490. /** defines the fourth component (1.0 by default) */
  3491. w: number;
  3492. /**
  3493. * Creates a new Quaternion from the given floats
  3494. * @param x defines the first component (0 by default)
  3495. * @param y defines the second component (0 by default)
  3496. * @param z defines the third component (0 by default)
  3497. * @param w defines the fourth component (1.0 by default)
  3498. */
  3499. constructor(
  3500. /** defines the first component (0 by default) */
  3501. x?: number,
  3502. /** defines the second component (0 by default) */
  3503. y?: number,
  3504. /** defines the third component (0 by default) */
  3505. z?: number,
  3506. /** defines the fourth component (1.0 by default) */
  3507. w?: number);
  3508. /**
  3509. * Gets a string representation for the current quaternion
  3510. * @returns a string with the Quaternion coordinates
  3511. */
  3512. toString(): string;
  3513. /**
  3514. * Gets the class name of the quaternion
  3515. * @returns the string "Quaternion"
  3516. */
  3517. getClassName(): string;
  3518. /**
  3519. * Gets a hash code for this quaternion
  3520. * @returns the quaternion hash code
  3521. */
  3522. getHashCode(): number;
  3523. /**
  3524. * Copy the quaternion to an array
  3525. * @returns a new array populated with 4 elements from the quaternion coordinates
  3526. */
  3527. asArray(): number[];
  3528. /**
  3529. * Check if two quaternions are equals
  3530. * @param otherQuaternion defines the second operand
  3531. * @return true if the current quaternion and the given one coordinates are strictly equals
  3532. */
  3533. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3534. /**
  3535. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3536. * @param otherQuaternion defines the other quaternion
  3537. * @param epsilon defines the minimal distance to consider equality
  3538. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3539. */
  3540. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3541. /**
  3542. * Clone the current quaternion
  3543. * @returns a new quaternion copied from the current one
  3544. */
  3545. clone(): Quaternion;
  3546. /**
  3547. * Copy a quaternion to the current one
  3548. * @param other defines the other quaternion
  3549. * @returns the updated current quaternion
  3550. */
  3551. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Updates the current quaternion with the given float coordinates
  3554. * @param x defines the x coordinate
  3555. * @param y defines the y coordinate
  3556. * @param z defines the z coordinate
  3557. * @param w defines the w coordinate
  3558. * @returns the updated current quaternion
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3561. /**
  3562. * Updates the current quaternion from the given float coordinates
  3563. * @param x defines the x coordinate
  3564. * @param y defines the y coordinate
  3565. * @param z defines the z coordinate
  3566. * @param w defines the w coordinate
  3567. * @returns the updated current quaternion
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Quaternion;
  3570. /**
  3571. * Adds two quaternions
  3572. * @param other defines the second operand
  3573. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3574. */
  3575. add(other: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Add a quaternion to the current one
  3578. * @param other defines the quaternion to add
  3579. * @returns the current quaternion
  3580. */
  3581. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Subtract two quaternions
  3584. * @param other defines the second operand
  3585. * @returns a new quaternion as the subtraction result of the given one from the current one
  3586. */
  3587. subtract(other: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3592. */
  3593. scale(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies in place the current quaternion by a scale factor
  3603. * @param value defines the scale factor
  3604. * @returns the current modified quaternion
  3605. */
  3606. scaleInPlace(value: number): Quaternion;
  3607. /**
  3608. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3609. * @param scale defines the scale factor
  3610. * @param result defines the Quaternion object where to store the result
  3611. * @returns the unmodified current quaternion
  3612. */
  3613. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3614. /**
  3615. * Multiplies two quaternions
  3616. * @param q1 defines the second operand
  3617. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3618. */
  3619. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3622. * @param q1 defines the second operand
  3623. * @param result defines the target quaternion
  3624. * @returns the current quaternion
  3625. */
  3626. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3627. /**
  3628. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3629. * @param q1 defines the second operand
  3630. * @returns the currentupdated quaternion
  3631. */
  3632. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3633. /**
  3634. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3635. * @param ref defines the target quaternion
  3636. * @returns the current quaternion
  3637. */
  3638. conjugateToRef(ref: Quaternion): Quaternion;
  3639. /**
  3640. * Conjugates in place (1-q) the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. conjugateInPlace(): Quaternion;
  3644. /**
  3645. * Conjugates in place (1-q) the current quaternion
  3646. * @returns a new quaternion
  3647. */
  3648. conjugate(): Quaternion;
  3649. /**
  3650. * Gets length of current quaternion
  3651. * @returns the quaternion length (float)
  3652. */
  3653. length(): number;
  3654. /**
  3655. * Normalize in place the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. normalize(): Quaternion;
  3659. /**
  3660. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3661. * @param order is a reserved parameter and is ignore for now
  3662. * @returns a new Vector3 containing the Euler angles
  3663. */
  3664. toEulerAngles(order?: string): Vector3;
  3665. /**
  3666. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3667. * @param result defines the vector which will be filled with the Euler angles
  3668. * @param order is a reserved parameter and is ignore for now
  3669. * @returns the current unchanged quaternion
  3670. */
  3671. toEulerAnglesToRef(result: Vector3): Quaternion;
  3672. /**
  3673. * Updates the given rotation matrix with the current quaternion values
  3674. * @param result defines the target matrix
  3675. * @returns the current unchanged quaternion
  3676. */
  3677. toRotationMatrix(result: Matrix): Quaternion;
  3678. /**
  3679. * Updates the current quaternion from the given rotation matrix values
  3680. * @param matrix defines the source matrix
  3681. * @returns the current updated quaternion
  3682. */
  3683. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3684. /**
  3685. * Creates a new quaternion from a rotation matrix
  3686. * @param matrix defines the source matrix
  3687. * @returns a new quaternion created from the given rotation matrix values
  3688. */
  3689. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3690. /**
  3691. * Updates the given quaternion with the given rotation matrix values
  3692. * @param matrix defines the source matrix
  3693. * @param result defines the target quaternion
  3694. */
  3695. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3696. /**
  3697. * Returns the dot product (float) between the quaternions "left" and "right"
  3698. * @param left defines the left operand
  3699. * @param right defines the right operand
  3700. * @returns the dot product
  3701. */
  3702. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3703. /**
  3704. * Checks if the two quaternions are close to each other
  3705. * @param quat0 defines the first quaternion to check
  3706. * @param quat1 defines the second quaternion to check
  3707. * @returns true if the two quaternions are close to each other
  3708. */
  3709. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates an empty quaternion
  3712. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3713. */
  3714. static Zero(): Quaternion;
  3715. /**
  3716. * Inverse a given quaternion
  3717. * @param q defines the source quaternion
  3718. * @returns a new quaternion as the inverted current quaternion
  3719. */
  3720. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3721. /**
  3722. * Inverse a given quaternion
  3723. * @param q defines the source quaternion
  3724. * @param result the quaternion the result will be stored in
  3725. * @returns the result quaternion
  3726. */
  3727. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates an identity quaternion
  3730. * @returns the identity quaternion
  3731. */
  3732. static Identity(): Quaternion;
  3733. /**
  3734. * Gets a boolean indicating if the given quaternion is identity
  3735. * @param quaternion defines the quaternion to check
  3736. * @returns true if the quaternion is identity
  3737. */
  3738. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3739. /**
  3740. * Creates a quaternion from a rotation around an axis
  3741. * @param axis defines the axis to use
  3742. * @param angle defines the angle to use
  3743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3744. */
  3745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3746. /**
  3747. * Creates a rotation around an axis and stores it into the given quaternion
  3748. * @param axis defines the axis to use
  3749. * @param angle defines the angle to use
  3750. * @param result defines the target quaternion
  3751. * @returns the target quaternion
  3752. */
  3753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3754. /**
  3755. * Creates a new quaternion from data stored into an array
  3756. * @param array defines the data source
  3757. * @param offset defines the offset in the source array where the data starts
  3758. * @returns a new quaternion
  3759. */
  3760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3761. /**
  3762. * Create a quaternion from Euler rotation angles
  3763. * @param x Pitch
  3764. * @param y Yaw
  3765. * @param z Roll
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation angles
  3771. * @param x Pitch
  3772. * @param y Yaw
  3773. * @param z Roll
  3774. * @param result the quaternion to store the result
  3775. * @returns the updated quaternion
  3776. */
  3777. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3778. /**
  3779. * Create a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @returns the new Quaternion
  3782. */
  3783. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3784. /**
  3785. * Updates a quaternion from Euler rotation vector
  3786. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3787. * @param result the quaternion to store the result
  3788. * @returns the updated quaternion
  3789. */
  3790. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3791. /**
  3792. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3793. * @param yaw defines the rotation around Y axis
  3794. * @param pitch defines the rotation around X axis
  3795. * @param roll defines the rotation around Z axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3799. /**
  3800. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3801. * @param yaw defines the rotation around Y axis
  3802. * @param pitch defines the rotation around X axis
  3803. * @param roll defines the rotation around Z axis
  3804. * @param result defines the target quaternion
  3805. */
  3806. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3807. /**
  3808. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3809. * @param alpha defines the rotation around first axis
  3810. * @param beta defines the rotation around second axis
  3811. * @param gamma defines the rotation around third axis
  3812. * @returns the new quaternion
  3813. */
  3814. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3815. /**
  3816. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3817. * @param alpha defines the rotation around first axis
  3818. * @param beta defines the rotation around second axis
  3819. * @param gamma defines the rotation around third axis
  3820. * @param result defines the target quaternion
  3821. */
  3822. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3823. /**
  3824. * 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)
  3825. * @param axis1 defines the first axis
  3826. * @param axis2 defines the second axis
  3827. * @param axis3 defines the third axis
  3828. * @returns the new quaternion
  3829. */
  3830. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3831. /**
  3832. * 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
  3833. * @param axis1 defines the first axis
  3834. * @param axis2 defines the second axis
  3835. * @param axis3 defines the third axis
  3836. * @param ref defines the target quaternion
  3837. */
  3838. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3839. /**
  3840. * Interpolates between two quaternions
  3841. * @param left defines first quaternion
  3842. * @param right defines second quaternion
  3843. * @param amount defines the gradient to use
  3844. * @returns the new interpolated quaternion
  3845. */
  3846. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3847. /**
  3848. * Interpolates between two quaternions and stores it into a target quaternion
  3849. * @param left defines first quaternion
  3850. * @param right defines second quaternion
  3851. * @param amount defines the gradient to use
  3852. * @param result defines the target quaternion
  3853. */
  3854. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3855. /**
  3856. * Interpolate between two quaternions using Hermite interpolation
  3857. * @param value1 defines first quaternion
  3858. * @param tangent1 defines the incoming tangent
  3859. * @param value2 defines second quaternion
  3860. * @param tangent2 defines the outgoing tangent
  3861. * @param amount defines the target quaternion
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. }
  3866. /**
  3867. * Class used to store matrix data (4x4)
  3868. */
  3869. export class Matrix {
  3870. private static _updateFlagSeed;
  3871. private static _identityReadOnly;
  3872. private _isIdentity;
  3873. private _isIdentityDirty;
  3874. private _isIdentity3x2;
  3875. private _isIdentity3x2Dirty;
  3876. /**
  3877. * Gets the update flag of the matrix which is an unique number for the matrix.
  3878. * It will be incremented every time the matrix data change.
  3879. * You can use it to speed the comparison between two versions of the same matrix.
  3880. */
  3881. updateFlag: number;
  3882. private readonly _m;
  3883. /**
  3884. * Gets the internal data of the matrix
  3885. */
  3886. get m(): DeepImmutable<Float32Array>;
  3887. /** @hidden */
  3888. _markAsUpdated(): void;
  3889. /** @hidden */
  3890. private _updateIdentityStatus;
  3891. /**
  3892. * Creates an empty matrix (filled with zeros)
  3893. */
  3894. constructor();
  3895. /**
  3896. * Check if the current matrix is identity
  3897. * @returns true is the matrix is the identity matrix
  3898. */
  3899. isIdentity(): boolean;
  3900. /**
  3901. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3902. * @returns true is the matrix is the identity matrix
  3903. */
  3904. isIdentityAs3x2(): boolean;
  3905. /**
  3906. * Gets the determinant of the matrix
  3907. * @returns the matrix determinant
  3908. */
  3909. determinant(): number;
  3910. /**
  3911. * Returns the matrix as a Float32Array
  3912. * @returns the matrix underlying array
  3913. */
  3914. toArray(): DeepImmutable<Float32Array>;
  3915. /**
  3916. * Returns the matrix as a Float32Array
  3917. * @returns the matrix underlying array.
  3918. */
  3919. asArray(): DeepImmutable<Float32Array>;
  3920. /**
  3921. * Inverts the current matrix in place
  3922. * @returns the current inverted matrix
  3923. */
  3924. invert(): Matrix;
  3925. /**
  3926. * Sets all the matrix elements to zero
  3927. * @returns the current matrix
  3928. */
  3929. reset(): Matrix;
  3930. /**
  3931. * Adds the current matrix with a second one
  3932. * @param other defines the matrix to add
  3933. * @returns a new matrix as the addition of the current matrix and the given one
  3934. */
  3935. add(other: DeepImmutable<Matrix>): Matrix;
  3936. /**
  3937. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3938. * @param other defines the matrix to add
  3939. * @param result defines the target matrix
  3940. * @returns the current matrix
  3941. */
  3942. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3943. /**
  3944. * Adds in place the given matrix to the current matrix
  3945. * @param other defines the second operand
  3946. * @returns the current updated matrix
  3947. */
  3948. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3949. /**
  3950. * Sets the given matrix to the current inverted Matrix
  3951. * @param other defines the target matrix
  3952. * @returns the unmodified current matrix
  3953. */
  3954. invertToRef(other: Matrix): Matrix;
  3955. /**
  3956. * add a value at the specified position in the current Matrix
  3957. * @param index the index of the value within the matrix. between 0 and 15.
  3958. * @param value the value to be added
  3959. * @returns the current updated matrix
  3960. */
  3961. addAtIndex(index: number, value: number): Matrix;
  3962. /**
  3963. * mutiply the specified position in the current Matrix by a value
  3964. * @param index the index of the value within the matrix. between 0 and 15.
  3965. * @param value the value to be added
  3966. * @returns the current updated matrix
  3967. */
  3968. multiplyAtIndex(index: number, value: number): Matrix;
  3969. /**
  3970. * Inserts the translation vector (using 3 floats) in the current matrix
  3971. * @param x defines the 1st component of the translation
  3972. * @param y defines the 2nd component of the translation
  3973. * @param z defines the 3rd component of the translation
  3974. * @returns the current updated matrix
  3975. */
  3976. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3977. /**
  3978. * Adds the translation vector (using 3 floats) in the current matrix
  3979. * @param x defines the 1st component of the translation
  3980. * @param y defines the 2nd component of the translation
  3981. * @param z defines the 3rd component of the translation
  3982. * @returns the current updated matrix
  3983. */
  3984. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3985. /**
  3986. * Inserts the translation vector in the current matrix
  3987. * @param vector3 defines the translation to insert
  3988. * @returns the current updated matrix
  3989. */
  3990. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3991. /**
  3992. * Gets the translation value of the current matrix
  3993. * @returns a new Vector3 as the extracted translation from the matrix
  3994. */
  3995. getTranslation(): Vector3;
  3996. /**
  3997. * Fill a Vector3 with the extracted translation from the matrix
  3998. * @param result defines the Vector3 where to store the translation
  3999. * @returns the current matrix
  4000. */
  4001. getTranslationToRef(result: Vector3): Matrix;
  4002. /**
  4003. * Remove rotation and scaling part from the matrix
  4004. * @returns the updated matrix
  4005. */
  4006. removeRotationAndScaling(): Matrix;
  4007. /**
  4008. * Multiply two matrices
  4009. * @param other defines the second operand
  4010. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4011. */
  4012. multiply(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Copy the current matrix from the given one
  4015. * @param other defines the source matrix
  4016. * @returns the current updated matrix
  4017. */
  4018. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4019. /**
  4020. * Populates the given array from the starting index with the current matrix values
  4021. * @param array defines the target array
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. copyToArray(array: Float32Array, offset?: number): Matrix;
  4026. /**
  4027. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4028. * @param other defines the second operand
  4029. * @param result defines the matrix where to store the multiplication
  4030. * @returns the current matrix
  4031. */
  4032. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4033. /**
  4034. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4035. * @param other defines the second operand
  4036. * @param result defines the array where to store the multiplication
  4037. * @param offset defines the offset in the target array where to start storing values
  4038. * @returns the current matrix
  4039. */
  4040. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4041. /**
  4042. * Check equality between this matrix and a second one
  4043. * @param value defines the second matrix to compare
  4044. * @returns true is the current matrix and the given one values are strictly equal
  4045. */
  4046. equals(value: DeepImmutable<Matrix>): boolean;
  4047. /**
  4048. * Clone the current matrix
  4049. * @returns a new matrix from the current matrix
  4050. */
  4051. clone(): Matrix;
  4052. /**
  4053. * Returns the name of the current matrix class
  4054. * @returns the string "Matrix"
  4055. */
  4056. getClassName(): string;
  4057. /**
  4058. * Gets the hash code of the current matrix
  4059. * @returns the hash code
  4060. */
  4061. getHashCode(): number;
  4062. /**
  4063. * Decomposes the current Matrix into a translation, rotation and scaling components
  4064. * @param scale defines the scale vector3 given as a reference to update
  4065. * @param rotation defines the rotation quaternion given as a reference to update
  4066. * @param translation defines the translation vector3 given as a reference to update
  4067. * @returns true if operation was successful
  4068. */
  4069. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4070. /**
  4071. * Gets specific row of the matrix
  4072. * @param index defines the number of the row to get
  4073. * @returns the index-th row of the current matrix as a new Vector4
  4074. */
  4075. getRow(index: number): Nullable<Vector4>;
  4076. /**
  4077. * Sets the index-th row of the current matrix to the vector4 values
  4078. * @param index defines the number of the row to set
  4079. * @param row defines the target vector4
  4080. * @returns the updated current matrix
  4081. */
  4082. setRow(index: number, row: Vector4): Matrix;
  4083. /**
  4084. * Compute the transpose of the matrix
  4085. * @returns the new transposed matrix
  4086. */
  4087. transpose(): Matrix;
  4088. /**
  4089. * Compute the transpose of the matrix and store it in a given matrix
  4090. * @param result defines the target matrix
  4091. * @returns the current matrix
  4092. */
  4093. transposeToRef(result: Matrix): Matrix;
  4094. /**
  4095. * Sets the index-th row of the current matrix with the given 4 x float values
  4096. * @param index defines the row index
  4097. * @param x defines the x component to set
  4098. * @param y defines the y component to set
  4099. * @param z defines the z component to set
  4100. * @param w defines the w component to set
  4101. * @returns the updated current matrix
  4102. */
  4103. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4104. /**
  4105. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4106. * @param scale defines the scale factor
  4107. * @returns a new matrix
  4108. */
  4109. scale(scale: number): Matrix;
  4110. /**
  4111. * Scale the current matrix values by a factor to a given result matrix
  4112. * @param scale defines the scale factor
  4113. * @param result defines the matrix to store the result
  4114. * @returns the current matrix
  4115. */
  4116. scaleToRef(scale: number, result: Matrix): Matrix;
  4117. /**
  4118. * Scale the current matrix values by a factor and add the result to a given matrix
  4119. * @param scale defines the scale factor
  4120. * @param result defines the Matrix to store the result
  4121. * @returns the current matrix
  4122. */
  4123. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4124. /**
  4125. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4126. * @param ref matrix to store the result
  4127. */
  4128. toNormalMatrix(ref: Matrix): void;
  4129. /**
  4130. * Gets only rotation part of the current matrix
  4131. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4132. */
  4133. getRotationMatrix(): Matrix;
  4134. /**
  4135. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4136. * @param result defines the target matrix to store data to
  4137. * @returns the current matrix
  4138. */
  4139. getRotationMatrixToRef(result: Matrix): Matrix;
  4140. /**
  4141. * Toggles model matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleModelMatrixHandInPlace(): void;
  4144. /**
  4145. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleProjectionMatrixHandInPlace(): void;
  4148. /**
  4149. * Creates a matrix from an array
  4150. * @param array defines the source array
  4151. * @param offset defines an offset in the source array
  4152. * @returns a new Matrix set from the starting index of the given array
  4153. */
  4154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4155. /**
  4156. * Copy the content of an array into a given matrix
  4157. * @param array defines the source array
  4158. * @param offset defines an offset in the source array
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4162. /**
  4163. * Stores an array into a matrix after having multiplied each component by a given factor
  4164. * @param array defines the source array
  4165. * @param offset defines the offset in the source array
  4166. * @param scale defines the scaling factor
  4167. * @param result defines the target matrix
  4168. */
  4169. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4170. /**
  4171. * Gets an identity matrix that must not be updated
  4172. */
  4173. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4174. /**
  4175. * Stores a list of values (16) inside a given matrix
  4176. * @param initialM11 defines 1st value of 1st row
  4177. * @param initialM12 defines 2nd value of 1st row
  4178. * @param initialM13 defines 3rd value of 1st row
  4179. * @param initialM14 defines 4th value of 1st row
  4180. * @param initialM21 defines 1st value of 2nd row
  4181. * @param initialM22 defines 2nd value of 2nd row
  4182. * @param initialM23 defines 3rd value of 2nd row
  4183. * @param initialM24 defines 4th value of 2nd row
  4184. * @param initialM31 defines 1st value of 3rd row
  4185. * @param initialM32 defines 2nd value of 3rd row
  4186. * @param initialM33 defines 3rd value of 3rd row
  4187. * @param initialM34 defines 4th value of 3rd row
  4188. * @param initialM41 defines 1st value of 4th row
  4189. * @param initialM42 defines 2nd value of 4th row
  4190. * @param initialM43 defines 3rd value of 4th row
  4191. * @param initialM44 defines 4th value of 4th row
  4192. * @param result defines the target matrix
  4193. */
  4194. 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;
  4195. /**
  4196. * Creates new matrix from a list of values (16)
  4197. * @param initialM11 defines 1st value of 1st row
  4198. * @param initialM12 defines 2nd value of 1st row
  4199. * @param initialM13 defines 3rd value of 1st row
  4200. * @param initialM14 defines 4th value of 1st row
  4201. * @param initialM21 defines 1st value of 2nd row
  4202. * @param initialM22 defines 2nd value of 2nd row
  4203. * @param initialM23 defines 3rd value of 2nd row
  4204. * @param initialM24 defines 4th value of 2nd row
  4205. * @param initialM31 defines 1st value of 3rd row
  4206. * @param initialM32 defines 2nd value of 3rd row
  4207. * @param initialM33 defines 3rd value of 3rd row
  4208. * @param initialM34 defines 4th value of 3rd row
  4209. * @param initialM41 defines 1st value of 4th row
  4210. * @param initialM42 defines 2nd value of 4th row
  4211. * @param initialM43 defines 3rd value of 4th row
  4212. * @param initialM44 defines 4th value of 4th row
  4213. * @returns the new matrix
  4214. */
  4215. 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;
  4216. /**
  4217. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4218. * @param scale defines the scale vector3
  4219. * @param rotation defines the rotation quaternion
  4220. * @param translation defines the translation vector3
  4221. * @returns a new matrix
  4222. */
  4223. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4224. /**
  4225. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4226. * @param scale defines the scale vector3
  4227. * @param rotation defines the rotation quaternion
  4228. * @param translation defines the translation vector3
  4229. * @param result defines the target matrix
  4230. */
  4231. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4232. /**
  4233. * Creates a new identity matrix
  4234. * @returns a new identity matrix
  4235. */
  4236. static Identity(): Matrix;
  4237. /**
  4238. * Creates a new identity matrix and stores the result in a given matrix
  4239. * @param result defines the target matrix
  4240. */
  4241. static IdentityToRef(result: Matrix): void;
  4242. /**
  4243. * Creates a new zero matrix
  4244. * @returns a new zero matrix
  4245. */
  4246. static Zero(): Matrix;
  4247. /**
  4248. * Creates a new rotation matrix for "angle" radians around the X axis
  4249. * @param angle defines the angle (in radians) to use
  4250. * @return the new matrix
  4251. */
  4252. static RotationX(angle: number): Matrix;
  4253. /**
  4254. * Creates a new matrix as the invert of a given matrix
  4255. * @param source defines the source matrix
  4256. * @returns the new matrix
  4257. */
  4258. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationXToRef(angle: number, result: Matrix): void;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationY(angle: number): Matrix;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationYToRef(angle: number, result: Matrix): void;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationZ(angle: number): Matrix;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4285. * @param angle defines the angle (in radians) to use
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationZToRef(angle: number, result: Matrix): void;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the given axis
  4291. * @param axis defines the axis to use
  4292. * @param angle defines the angle (in radians) to use
  4293. * @return the new matrix
  4294. */
  4295. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4296. /**
  4297. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4298. * @param axis defines the axis to use
  4299. * @param angle defines the angle (in radians) to use
  4300. * @param result defines the target matrix
  4301. */
  4302. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4303. /**
  4304. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4305. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4306. * @param from defines the vector to align
  4307. * @param to defines the vector to align to
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4311. /**
  4312. * Creates a rotation matrix
  4313. * @param yaw defines the yaw angle in radians (Y axis)
  4314. * @param pitch defines the pitch angle in radians (X axis)
  4315. * @param roll defines the roll angle in radians (X axis)
  4316. * @returns the new rotation matrix
  4317. */
  4318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4319. /**
  4320. * Creates a rotation matrix and stores it in a given matrix
  4321. * @param yaw defines the yaw angle in radians (Y axis)
  4322. * @param pitch defines the pitch angle in radians (X axis)
  4323. * @param roll defines the roll angle in radians (X axis)
  4324. * @param result defines the target matrix
  4325. */
  4326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4327. /**
  4328. * Creates a scaling matrix
  4329. * @param x defines the scale factor on X axis
  4330. * @param y defines the scale factor on Y axis
  4331. * @param z defines the scale factor on Z axis
  4332. * @returns the new matrix
  4333. */
  4334. static Scaling(x: number, y: number, z: number): Matrix;
  4335. /**
  4336. * Creates a scaling matrix and stores it in a given matrix
  4337. * @param x defines the scale factor on X axis
  4338. * @param y defines the scale factor on Y axis
  4339. * @param z defines the scale factor on Z axis
  4340. * @param result defines the target matrix
  4341. */
  4342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4343. /**
  4344. * Creates a translation matrix
  4345. * @param x defines the translation on X axis
  4346. * @param y defines the translation on Y axis
  4347. * @param z defines the translationon Z axis
  4348. * @returns the new matrix
  4349. */
  4350. static Translation(x: number, y: number, z: number): Matrix;
  4351. /**
  4352. * Creates a translation matrix and stores it in a given matrix
  4353. * @param x defines the translation on X axis
  4354. * @param y defines the translation on Y axis
  4355. * @param z defines the translationon Z axis
  4356. * @param result defines the target matrix
  4357. */
  4358. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4359. /**
  4360. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4361. * @param startValue defines the start value
  4362. * @param endValue defines the end value
  4363. * @param gradient defines the gradient factor
  4364. * @returns the new matrix
  4365. */
  4366. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4367. /**
  4368. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4369. * @param startValue defines the start value
  4370. * @param endValue defines the end value
  4371. * @param gradient defines the gradient factor
  4372. * @param result defines the Matrix object where to store data
  4373. */
  4374. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4375. /**
  4376. * Builds a new matrix whose values are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @returns the new matrix
  4384. */
  4385. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4386. /**
  4387. * Update a matrix to values which are computed by:
  4388. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4389. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4390. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4391. * @param startValue defines the first matrix
  4392. * @param endValue defines the second matrix
  4393. * @param gradient defines the gradient between the two matrices
  4394. * @param result defines the target matrix
  4395. */
  4396. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * 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"
  4399. * This function works in left handed mode
  4400. * @param eye defines the final position of the entity
  4401. * @param target defines where the entity should look at
  4402. * @param up defines the up vector for the entity
  4403. * @returns the new matrix
  4404. */
  4405. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * 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".
  4408. * This function works in left handed mode
  4409. * @param eye defines the final position of the entity
  4410. * @param target defines where the entity should look at
  4411. * @param up defines the up vector for the entity
  4412. * @param result defines the target matrix
  4413. */
  4414. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, 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 right 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 LookAtRH(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 right 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 LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Create a left-handed orthographic projection matrix
  4435. * @param width defines the viewport width
  4436. * @param height defines the viewport height
  4437. * @param znear defines the near clip plane
  4438. * @param zfar defines the far clip plane
  4439. * @returns a new matrix as a left-handed orthographic projection matrix
  4440. */
  4441. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4442. /**
  4443. * Store a left-handed orthographic projection to a given matrix
  4444. * @param width defines the viewport width
  4445. * @param height defines the viewport height
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @returns a new matrix as a left-handed orthographic projection matrix
  4460. */
  4461. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4462. /**
  4463. * Stores a left-handed orthographic projection into a given matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Creates a right-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a left-handed perspective projection matrix
  4497. * @param width defines the viewport width
  4498. * @param height defines the viewport height
  4499. * @param znear defines the near clip plane
  4500. * @param zfar defines the far clip plane
  4501. * @returns a new matrix as a left-handed perspective projection matrix
  4502. */
  4503. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4504. /**
  4505. * Creates a left-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a left-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Creates a right-handed perspective projection matrix
  4535. * @param fov defines the horizontal field of view
  4536. * @param aspect defines the aspect ratio
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @returns a new matrix as a right-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a right-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar defines the far clip plane
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a right-handed perspective projection into a given matrix
  4554. * @param fov defines the horizontal field of view
  4555. * @param aspect defines the aspect ratio
  4556. * @param znear defines the near clip plane
  4557. * @param zfar not used as infinity is used as far clip
  4558. * @param result defines the target matrix
  4559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4560. */
  4561. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Stores a perspective projection for WebVR info a given matrix
  4564. * @param fov defines the field of view
  4565. * @param znear defines the near clip plane
  4566. * @param zfar defines the far clip plane
  4567. * @param result defines the target matrix
  4568. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4569. */
  4570. static PerspectiveFovWebVRToRef(fov: {
  4571. upDegrees: number;
  4572. downDegrees: number;
  4573. leftDegrees: number;
  4574. rightDegrees: number;
  4575. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4576. /**
  4577. * Computes a complete transformation matrix
  4578. * @param viewport defines the viewport to use
  4579. * @param world defines the world matrix
  4580. * @param view defines the view matrix
  4581. * @param projection defines the projection matrix
  4582. * @param zmin defines the near clip plane
  4583. * @param zmax defines the far clip plane
  4584. * @returns the transformation matrix
  4585. */
  4586. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4587. /**
  4588. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4595. * @param matrix defines the matrix to use
  4596. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4597. */
  4598. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4599. /**
  4600. * Compute the transpose of a given matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @returns the new matrix
  4603. */
  4604. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4605. /**
  4606. * Compute the transpose of a matrix and store it in a target matrix
  4607. * @param matrix defines the matrix to transpose
  4608. * @param result defines the target matrix
  4609. */
  4610. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @returns a new matrix
  4615. */
  4616. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4617. /**
  4618. * Computes a reflection matrix from a plane
  4619. * @param plane defines the reflection plane
  4620. * @param result defines the target matrix
  4621. */
  4622. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4623. /**
  4624. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4625. * @param xaxis defines the value of the 1st axis
  4626. * @param yaxis defines the value of the 2nd axis
  4627. * @param zaxis defines the value of the 3rd axis
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4631. /**
  4632. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4633. * @param quat defines the quaternion to use
  4634. * @param result defines the target matrix
  4635. */
  4636. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4637. }
  4638. /**
  4639. * @hidden
  4640. */
  4641. export class TmpVectors {
  4642. static Vector2: Vector2[];
  4643. static Vector3: Vector3[];
  4644. static Vector4: Vector4[];
  4645. static Quaternion: Quaternion[];
  4646. static Matrix: Matrix[];
  4647. }
  4648. }
  4649. declare module "babylonjs/Maths/math.path" {
  4650. import { DeepImmutable, Nullable } from "babylonjs/types";
  4651. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4652. /**
  4653. * Defines potential orientation for back face culling
  4654. */
  4655. export enum Orientation {
  4656. /**
  4657. * Clockwise
  4658. */
  4659. CW = 0,
  4660. /** Counter clockwise */
  4661. CCW = 1
  4662. }
  4663. /** Class used to represent a Bezier curve */
  4664. export class BezierCurve {
  4665. /**
  4666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4667. * @param t defines the time
  4668. * @param x1 defines the left coordinate on X axis
  4669. * @param y1 defines the left coordinate on Y axis
  4670. * @param x2 defines the right coordinate on X axis
  4671. * @param y2 defines the right coordinate on Y axis
  4672. * @returns the interpolated value
  4673. */
  4674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4675. }
  4676. /**
  4677. * Defines angle representation
  4678. */
  4679. export class Angle {
  4680. private _radians;
  4681. /**
  4682. * Creates an Angle object of "radians" radians (float).
  4683. * @param radians the angle in radians
  4684. */
  4685. constructor(radians: number);
  4686. /**
  4687. * Get value in degrees
  4688. * @returns the Angle value in degrees (float)
  4689. */
  4690. degrees(): number;
  4691. /**
  4692. * Get value in radians
  4693. * @returns the Angle value in radians (float)
  4694. */
  4695. radians(): number;
  4696. /**
  4697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4698. * @param a defines first vector
  4699. * @param b defines second vector
  4700. * @returns a new Angle
  4701. */
  4702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in radians
  4705. * @param radians defines the angle value in radians
  4706. * @returns a new Angle
  4707. */
  4708. static FromRadians(radians: number): Angle;
  4709. /**
  4710. * Gets a new Angle object from the given float in degrees
  4711. * @param degrees defines the angle value in degrees
  4712. * @returns a new Angle
  4713. */
  4714. static FromDegrees(degrees: number): Angle;
  4715. }
  4716. /**
  4717. * This represents an arc in a 2d space.
  4718. */
  4719. export class Arc2 {
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2;
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2;
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2;
  4726. /**
  4727. * Defines the center point of the arc.
  4728. */
  4729. centerPoint: Vector2;
  4730. /**
  4731. * Defines the radius of the arc.
  4732. */
  4733. radius: number;
  4734. /**
  4735. * Defines the angle of the arc (from mid point to end point).
  4736. */
  4737. angle: Angle;
  4738. /**
  4739. * Defines the start angle of the arc (from start point to middle point).
  4740. */
  4741. startAngle: Angle;
  4742. /**
  4743. * Defines the orientation of the arc (clock wise/counter clock wise).
  4744. */
  4745. orientation: Orientation;
  4746. /**
  4747. * Creates an Arc object from the three given points : start, middle and end.
  4748. * @param startPoint Defines the start point of the arc
  4749. * @param midPoint Defines the midlle point of the arc
  4750. * @param endPoint Defines the end point of the arc
  4751. */
  4752. constructor(
  4753. /** Defines the start point of the arc */
  4754. startPoint: Vector2,
  4755. /** Defines the mid point of the arc */
  4756. midPoint: Vector2,
  4757. /** Defines the end point of the arc */
  4758. endPoint: Vector2);
  4759. }
  4760. /**
  4761. * Represents a 2D path made up of multiple 2D points
  4762. */
  4763. export class Path2 {
  4764. private _points;
  4765. private _length;
  4766. /**
  4767. * If the path start and end point are the same
  4768. */
  4769. closed: boolean;
  4770. /**
  4771. * Creates a Path2 object from the starting 2D coordinates x and y.
  4772. * @param x the starting points x value
  4773. * @param y the starting points y value
  4774. */
  4775. constructor(x: number, y: number);
  4776. /**
  4777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4778. * @param x the added points x value
  4779. * @param y the added points y value
  4780. * @returns the updated Path2.
  4781. */
  4782. addLineTo(x: number, y: number): Path2;
  4783. /**
  4784. * 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.
  4785. * @param midX middle point x value
  4786. * @param midY middle point y value
  4787. * @param endX end point x value
  4788. * @param endY end point y value
  4789. * @param numberOfSegments (default: 36)
  4790. * @returns the updated Path2.
  4791. */
  4792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4793. /**
  4794. * Closes the Path2.
  4795. * @returns the Path2.
  4796. */
  4797. close(): Path2;
  4798. /**
  4799. * Gets the sum of the distance between each sequential point in the path
  4800. * @returns the Path2 total length (float).
  4801. */
  4802. length(): number;
  4803. /**
  4804. * Gets the points which construct the path
  4805. * @returns the Path2 internal array of points.
  4806. */
  4807. getPoints(): Vector2[];
  4808. /**
  4809. * Retreives the point at the distance aways from the starting point
  4810. * @param normalizedLengthPosition the length along the path to retreive the point from
  4811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4812. */
  4813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4814. /**
  4815. * Creates a new path starting from an x and y position
  4816. * @param x starting x value
  4817. * @param y starting y value
  4818. * @returns a new Path2 starting at the coordinates (x, y).
  4819. */
  4820. static StartingAt(x: number, y: number): Path2;
  4821. }
  4822. /**
  4823. * Represents a 3D path made up of multiple 3D points
  4824. */
  4825. export class Path3D {
  4826. /**
  4827. * an array of Vector3, the curve axis of the Path3D
  4828. */
  4829. path: Vector3[];
  4830. private _curve;
  4831. private _distances;
  4832. private _tangents;
  4833. private _normals;
  4834. private _binormals;
  4835. private _raw;
  4836. private _alignTangentsWithPath;
  4837. private readonly _pointAtData;
  4838. /**
  4839. * new Path3D(path, normal, raw)
  4840. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4841. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4842. * @param path an array of Vector3, the curve axis of the Path3D
  4843. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4844. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4846. */
  4847. constructor(
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4852. /**
  4853. * Returns the Path3D array of successive Vector3 designing its curve.
  4854. * @returns the Path3D array of successive Vector3 designing its curve.
  4855. */
  4856. getCurve(): Vector3[];
  4857. /**
  4858. * Returns the Path3D array of successive Vector3 designing its curve.
  4859. * @returns the Path3D array of successive Vector3 designing its curve.
  4860. */
  4861. getPoints(): Vector3[];
  4862. /**
  4863. * @returns the computed length (float) of the path.
  4864. */
  4865. length(): number;
  4866. /**
  4867. * Returns an array populated with tangent vectors on each Path3D curve point.
  4868. * @returns an array populated with tangent vectors on each Path3D curve point.
  4869. */
  4870. getTangents(): Vector3[];
  4871. /**
  4872. * Returns an array populated with normal vectors on each Path3D curve point.
  4873. * @returns an array populated with normal vectors on each Path3D curve point.
  4874. */
  4875. getNormals(): Vector3[];
  4876. /**
  4877. * Returns an array populated with binormal vectors on each Path3D curve point.
  4878. * @returns an array populated with binormal vectors on each Path3D curve point.
  4879. */
  4880. getBinormals(): Vector3[];
  4881. /**
  4882. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4883. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4884. */
  4885. getDistances(): number[];
  4886. /**
  4887. * Returns an interpolated point along this path
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @returns a new Vector3 as the point
  4890. */
  4891. getPointAt(position: number): Vector3;
  4892. /**
  4893. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4894. * @param position the position of the point along this path, from 0.0 to 1.0
  4895. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4896. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4897. */
  4898. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4899. /**
  4900. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4901. * @param position the position of the point along this path, from 0.0 to 1.0
  4902. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4903. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4904. */
  4905. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4906. /**
  4907. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4908. * @param position the position of the point along this path, from 0.0 to 1.0
  4909. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4910. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4911. */
  4912. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4913. /**
  4914. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4917. */
  4918. getDistanceAt(position: number): number;
  4919. /**
  4920. * Returns the array index of the previous point of an interpolated point along this path
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the array index
  4923. */
  4924. getPreviousPointIndexAt(position: number): number;
  4925. /**
  4926. * 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)
  4927. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4928. * @returns the sub position
  4929. */
  4930. getSubPositionAt(position: number): number;
  4931. /**
  4932. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4933. * @param target the vector of which to get the closest position to
  4934. * @returns the position of the closest virtual point on this path to the target vector
  4935. */
  4936. getClosestPositionTo(target: Vector3): number;
  4937. /**
  4938. * Returns a sub path (slice) of this path
  4939. * @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
  4940. * @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
  4941. * @returns a sub path (slice) of this path
  4942. */
  4943. slice(start?: number, end?: number): Path3D;
  4944. /**
  4945. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4946. * @param path path which all values are copied into the curves points
  4947. * @param firstNormal which should be projected onto the curve
  4948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4949. * @returns the same object updated.
  4950. */
  4951. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4952. private _compute;
  4953. private _getFirstNonNullVector;
  4954. private _getLastNonNullVector;
  4955. private _normalVector;
  4956. /**
  4957. * Updates the point at data for an interpolated point along this curve
  4958. * @param position the position of the point along this curve, from 0.0 to 1.0
  4959. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4960. * @returns the (updated) point at data
  4961. */
  4962. private _updatePointAtData;
  4963. /**
  4964. * Updates the point at data from the specified parameters
  4965. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4966. * @param point the interpolated point
  4967. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4968. */
  4969. private _setPointAtData;
  4970. /**
  4971. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4972. */
  4973. private _updateInterpolationMatrix;
  4974. }
  4975. /**
  4976. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4977. * A Curve3 is designed from a series of successive Vector3.
  4978. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4979. */
  4980. export class Curve3 {
  4981. private _points;
  4982. private _length;
  4983. /**
  4984. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4985. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4986. * @param v1 (Vector3) the control point
  4987. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4994. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4995. * @param v1 (Vector3) the first control point
  4996. * @param v2 (Vector3) the second control point
  4997. * @param v3 (Vector3) the end point of the Cubic Bezier
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5004. * @param p1 (Vector3) the origin point of the Hermite Spline
  5005. * @param t1 (Vector3) the tangent vector at the origin point
  5006. * @param p2 (Vector3) the end point of the Hermite Spline
  5007. * @param t2 (Vector3) the tangent vector at the end point
  5008. * @param nbPoints (integer) the wanted number of points in the curve
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5012. /**
  5013. * Returns a Curve3 object along a CatmullRom Spline curve :
  5014. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5015. * @param nbPoints (integer) the wanted number of points between each curve control points
  5016. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5020. /**
  5021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5022. * A Curve3 is designed from a series of successive Vector3.
  5023. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5024. * @param points points which make up the curve
  5025. */
  5026. constructor(points: Vector3[]);
  5027. /**
  5028. * @returns the Curve3 stored array of successive Vector3
  5029. */
  5030. getPoints(): Vector3[];
  5031. /**
  5032. * @returns the computed length (float) of the curve.
  5033. */
  5034. length(): number;
  5035. /**
  5036. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5037. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5038. * curveA and curveB keep unchanged.
  5039. * @param curve the curve to continue from this curve
  5040. * @returns the newly constructed curve
  5041. */
  5042. continue(curve: DeepImmutable<Curve3>): Curve3;
  5043. private _computeLength;
  5044. }
  5045. }
  5046. declare module "babylonjs/Animations/easing" {
  5047. /**
  5048. * This represents the main contract an easing function should follow.
  5049. * Easing functions are used throughout the animation system.
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export interface IEasingFunction {
  5053. /**
  5054. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5055. * of the easing function.
  5056. * The link below provides some of the most common examples of easing functions.
  5057. * @see https://easings.net/
  5058. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5059. * @returns the corresponding value on the curve defined by the easing function
  5060. */
  5061. ease(gradient: number): number;
  5062. }
  5063. /**
  5064. * Base class used for every default easing function.
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class EasingFunction implements IEasingFunction {
  5068. /**
  5069. * Interpolation follows the mathematical formula associated with the easing function.
  5070. */
  5071. static readonly EASINGMODE_EASEIN: number;
  5072. /**
  5073. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEOUT: number;
  5076. /**
  5077. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5078. */
  5079. static readonly EASINGMODE_EASEINOUT: number;
  5080. private _easingMode;
  5081. /**
  5082. * Sets the easing mode of the current function.
  5083. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5084. */
  5085. setEasingMode(easingMode: number): void;
  5086. /**
  5087. * Gets the current easing mode.
  5088. * @returns the easing mode
  5089. */
  5090. getEasingMode(): number;
  5091. /**
  5092. * @hidden
  5093. */
  5094. easeInCore(gradient: number): number;
  5095. /**
  5096. * Given an input gradient between 0 and 1, this returns the corresponding value
  5097. * of the easing function.
  5098. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5099. * @returns the corresponding value on the curve defined by the easing function
  5100. */
  5101. ease(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a circle shape (see link below).
  5105. * @see https://easings.net/#easeInCirc
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class CircleEase extends EasingFunction implements IEasingFunction {
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. /**
  5113. * Easing function with a ease back shape (see link below).
  5114. * @see https://easings.net/#easeInBack
  5115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5116. */
  5117. export class BackEase extends EasingFunction implements IEasingFunction {
  5118. /** Defines the amplitude of the function */
  5119. amplitude: number;
  5120. /**
  5121. * Instantiates a back ease easing
  5122. * @see https://easings.net/#easeInBack
  5123. * @param amplitude Defines the amplitude of the function
  5124. */
  5125. constructor(
  5126. /** Defines the amplitude of the function */
  5127. amplitude?: number);
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with a bouncing shape (see link below).
  5133. * @see https://easings.net/#easeInBounce
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class BounceEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of bounces */
  5138. bounces: number;
  5139. /** Defines the amplitude of the bounce */
  5140. bounciness: number;
  5141. /**
  5142. * Instantiates a bounce easing
  5143. * @see https://easings.net/#easeInBounce
  5144. * @param bounces Defines the number of bounces
  5145. * @param bounciness Defines the amplitude of the bounce
  5146. */
  5147. constructor(
  5148. /** Defines the number of bounces */
  5149. bounces?: number,
  5150. /** Defines the amplitude of the bounce */
  5151. bounciness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with a power of 3 shape (see link below).
  5157. * @see https://easings.net/#easeInCubic
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class CubicEase extends EasingFunction implements IEasingFunction {
  5161. /** @hidden */
  5162. easeInCore(gradient: number): number;
  5163. }
  5164. /**
  5165. * Easing function with an elastic shape (see link below).
  5166. * @see https://easings.net/#easeInElastic
  5167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5168. */
  5169. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5170. /** Defines the number of oscillations*/
  5171. oscillations: number;
  5172. /** Defines the amplitude of the oscillations*/
  5173. springiness: number;
  5174. /**
  5175. * Instantiates an elastic easing function
  5176. * @see https://easings.net/#easeInElastic
  5177. * @param oscillations Defines the number of oscillations
  5178. * @param springiness Defines the amplitude of the oscillations
  5179. */
  5180. constructor(
  5181. /** Defines the number of oscillations*/
  5182. oscillations?: number,
  5183. /** Defines the amplitude of the oscillations*/
  5184. springiness?: number);
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with an exponential shape (see link below).
  5190. * @see https://easings.net/#easeInExpo
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5194. /** Defines the exponent of the function */
  5195. exponent: number;
  5196. /**
  5197. * Instantiates an exponential easing function
  5198. * @see https://easings.net/#easeInExpo
  5199. * @param exponent Defines the exponent of the function
  5200. */
  5201. constructor(
  5202. /** Defines the exponent of the function */
  5203. exponent?: number);
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power shape (see link below).
  5209. * @see https://easings.net/#easeInQuad
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class PowerEase extends EasingFunction implements IEasingFunction {
  5213. /** Defines the power of the function */
  5214. power: number;
  5215. /**
  5216. * Instantiates an power base easing function
  5217. * @see https://easings.net/#easeInQuad
  5218. * @param power Defines the power of the function
  5219. */
  5220. constructor(
  5221. /** Defines the power of the function */
  5222. power?: number);
  5223. /** @hidden */
  5224. easeInCore(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a power of 2 shape (see link below).
  5228. * @see https://easings.net/#easeInQuad
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a power of 4 shape (see link below).
  5237. * @see https://easings.net/#easeInQuart
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 5 shape (see link below).
  5246. * @see https://easings.net/#easeInQuint
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a sin shape (see link below).
  5255. * @see https://easings.net/#easeInSine
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class SineEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a bezier shape (see link below).
  5264. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1: number;
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1: number;
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2: number;
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2: number;
  5276. /**
  5277. * Instantiates a bezier function
  5278. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5279. * @param x1 Defines the x component of the start tangent in the bezier curve
  5280. * @param y1 Defines the y component of the start tangent in the bezier curve
  5281. * @param x2 Defines the x component of the end tangent in the bezier curve
  5282. * @param y2 Defines the y component of the end tangent in the bezier curve
  5283. */
  5284. constructor(
  5285. /** Defines the x component of the start tangent in the bezier curve */
  5286. x1?: number,
  5287. /** Defines the y component of the start tangent in the bezier curve */
  5288. y1?: number,
  5289. /** Defines the x component of the end tangent in the bezier curve */
  5290. x2?: number,
  5291. /** Defines the y component of the end tangent in the bezier curve */
  5292. y2?: number);
  5293. /** @hidden */
  5294. easeInCore(gradient: number): number;
  5295. }
  5296. }
  5297. declare module "babylonjs/Maths/math.color" {
  5298. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5299. /**
  5300. * Class used to hold a RBG color
  5301. */
  5302. export class Color3 {
  5303. /**
  5304. * Defines the red component (between 0 and 1, default is 0)
  5305. */
  5306. r: number;
  5307. /**
  5308. * Defines the green component (between 0 and 1, default is 0)
  5309. */
  5310. g: number;
  5311. /**
  5312. * Defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. b: number;
  5315. /**
  5316. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5317. * @param r defines the red component (between 0 and 1, default is 0)
  5318. * @param g defines the green component (between 0 and 1, default is 0)
  5319. * @param b defines the blue component (between 0 and 1, default is 0)
  5320. */
  5321. constructor(
  5322. /**
  5323. * Defines the red component (between 0 and 1, default is 0)
  5324. */
  5325. r?: number,
  5326. /**
  5327. * Defines the green component (between 0 and 1, default is 0)
  5328. */
  5329. g?: number,
  5330. /**
  5331. * Defines the blue component (between 0 and 1, default is 0)
  5332. */
  5333. b?: number);
  5334. /**
  5335. * Creates a string with the Color3 current values
  5336. * @returns the string representation of the Color3 object
  5337. */
  5338. toString(): string;
  5339. /**
  5340. * Returns the string "Color3"
  5341. * @returns "Color3"
  5342. */
  5343. getClassName(): string;
  5344. /**
  5345. * Compute the Color3 hash code
  5346. * @returns an unique number that can be used to hash Color3 objects
  5347. */
  5348. getHashCode(): number;
  5349. /**
  5350. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5351. * @param array defines the array where to store the r,g,b components
  5352. * @param index defines an optional index in the target array to define where to start storing values
  5353. * @returns the current Color3 object
  5354. */
  5355. toArray(array: FloatArray, index?: number): Color3;
  5356. /**
  5357. * Returns a new Color4 object from the current Color3 and the given alpha
  5358. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5359. * @returns a new Color4 object
  5360. */
  5361. toColor4(alpha?: number): Color4;
  5362. /**
  5363. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5364. * @returns the new array
  5365. */
  5366. asArray(): number[];
  5367. /**
  5368. * Returns the luminance value
  5369. * @returns a float value
  5370. */
  5371. toLuminance(): number;
  5372. /**
  5373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5374. * @param otherColor defines the second operand
  5375. * @returns the new Color3 object
  5376. */
  5377. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5380. * @param otherColor defines the second operand
  5381. * @param result defines the Color3 object where to store the result
  5382. * @returns the current Color3
  5383. */
  5384. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5385. /**
  5386. * Determines equality between Color3 objects
  5387. * @param otherColor defines the second operand
  5388. * @returns true if the rgb values are equal to the given ones
  5389. */
  5390. equals(otherColor: DeepImmutable<Color3>): boolean;
  5391. /**
  5392. * Determines equality between the current Color3 object and a set of r,b,g values
  5393. * @param r defines the red component to check
  5394. * @param g defines the green component to check
  5395. * @param b defines the blue component to check
  5396. * @returns true if the rgb values are equal to the given ones
  5397. */
  5398. equalsFloats(r: number, g: number, b: number): boolean;
  5399. /**
  5400. * Multiplies in place each rgb value by scale
  5401. * @param scale defines the scaling factor
  5402. * @returns the updated Color3
  5403. */
  5404. scale(scale: number): Color3;
  5405. /**
  5406. * Multiplies the rgb values by scale and stores the result into "result"
  5407. * @param scale defines the scaling factor
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Scale the current Color3 values by a factor and add the result to a given Color3
  5414. * @param scale defines the scale factor
  5415. * @param result defines color to store the result into
  5416. * @returns the unmodified current Color3
  5417. */
  5418. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5419. /**
  5420. * Clamps the rgb values by the min and max values and stores the result into "result"
  5421. * @param min defines minimum clamping value (default is 0)
  5422. * @param max defines maximum clamping value (default is 1)
  5423. * @param result defines color to store the result into
  5424. * @returns the original Color3
  5425. */
  5426. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5427. /**
  5428. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5429. * @param otherColor defines the second operand
  5430. * @returns the new Color3
  5431. */
  5432. add(otherColor: DeepImmutable<Color3>): Color3;
  5433. /**
  5434. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5435. * @param otherColor defines the second operand
  5436. * @param result defines Color3 object to store the result into
  5437. * @returns the unmodified current Color3
  5438. */
  5439. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5440. /**
  5441. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5442. * @param otherColor defines the second operand
  5443. * @returns the new Color3
  5444. */
  5445. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5448. * @param otherColor defines the second operand
  5449. * @param result defines Color3 object to store the result into
  5450. * @returns the unmodified current Color3
  5451. */
  5452. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5453. /**
  5454. * Copy the current object
  5455. * @returns a new Color3 copied the current one
  5456. */
  5457. clone(): Color3;
  5458. /**
  5459. * Copies the rgb values from the source in the current Color3
  5460. * @param source defines the source Color3 object
  5461. * @returns the updated Color3 object
  5462. */
  5463. copyFrom(source: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Updates the Color3 rgb values from the given floats
  5466. * @param r defines the red component to read from
  5467. * @param g defines the green component to read from
  5468. * @param b defines the blue component to read from
  5469. * @returns the current Color3 object
  5470. */
  5471. copyFromFloats(r: number, g: number, b: number): Color3;
  5472. /**
  5473. * Updates the Color3 rgb values from the given floats
  5474. * @param r defines the red component to read from
  5475. * @param g defines the green component to read from
  5476. * @param b defines the blue component to read from
  5477. * @returns the current Color3 object
  5478. */
  5479. set(r: number, g: number, b: number): Color3;
  5480. /**
  5481. * Compute the Color3 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color3 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color3 converted from the current one to linear space
  5487. * @returns a new Color3 object
  5488. */
  5489. toLinearSpace(): Color3;
  5490. /**
  5491. * Converts current color in rgb space to HSV values
  5492. * @returns a new color3 representing the HSV values
  5493. */
  5494. toHSV(): Color3;
  5495. /**
  5496. * Converts current color in rgb space to HSV values
  5497. * @param result defines the Color3 where to store the HSV values
  5498. */
  5499. toHSVToRef(result: Color3): void;
  5500. /**
  5501. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5502. * @param convertedColor defines the Color3 object where to store the linear space version
  5503. * @returns the unmodified Color3
  5504. */
  5505. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5506. /**
  5507. * Computes a new Color3 converted from the current one to gamma space
  5508. * @returns a new Color3 object
  5509. */
  5510. toGammaSpace(): Color3;
  5511. /**
  5512. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5513. * @param convertedColor defines the Color3 object where to store the gamma space version
  5514. * @returns the unmodified Color3
  5515. */
  5516. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5517. private static _BlackReadOnly;
  5518. /**
  5519. * Convert Hue, saturation and value to a Color3 (RGB)
  5520. * @param hue defines the hue
  5521. * @param saturation defines the saturation
  5522. * @param value defines the value
  5523. * @param result defines the Color3 where to store the RGB values
  5524. */
  5525. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5526. /**
  5527. * Creates a new Color3 from the string containing valid hexadecimal values
  5528. * @param hex defines a string containing valid hexadecimal values
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromHexString(hex: string): Color3;
  5532. /**
  5533. * Creates a new Color3 from the starting index of the given array
  5534. * @param array defines the source array
  5535. * @param offset defines an offset in the source array
  5536. * @returns a new Color3 object
  5537. */
  5538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5539. /**
  5540. * Creates a new Color3 from integer values (< 256)
  5541. * @param r defines the red component to read from (value between 0 and 255)
  5542. * @param g defines the green component to read from (value between 0 and 255)
  5543. * @param b defines the blue component to read from (value between 0 and 255)
  5544. * @returns a new Color3 object
  5545. */
  5546. static FromInts(r: number, g: number, b: number): Color3;
  5547. /**
  5548. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5549. * @param start defines the start Color3 value
  5550. * @param end defines the end Color3 value
  5551. * @param amount defines the gradient value between start and end
  5552. * @returns a new Color3 object
  5553. */
  5554. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5555. /**
  5556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5557. * @param left defines the start value
  5558. * @param right defines the end value
  5559. * @param amount defines the gradient factor
  5560. * @param result defines the Color3 object where to store the result
  5561. */
  5562. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5563. /**
  5564. * Returns a Color3 value containing a red color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Red(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a green color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Green(): Color3;
  5573. /**
  5574. * Returns a Color3 value containing a blue color
  5575. * @returns a new Color3 object
  5576. */
  5577. static Blue(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a black color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Black(): Color3;
  5583. /**
  5584. * Gets a Color3 value containing a black color that must not be updated
  5585. */
  5586. static get BlackReadOnly(): DeepImmutable<Color3>;
  5587. /**
  5588. * Returns a Color3 value containing a white color
  5589. * @returns a new Color3 object
  5590. */
  5591. static White(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a purple color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Purple(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a magenta color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Magenta(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a yellow color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Yellow(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a gray color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Gray(): Color3;
  5612. /**
  5613. * Returns a Color3 value containing a teal color
  5614. * @returns a new Color3 object
  5615. */
  5616. static Teal(): Color3;
  5617. /**
  5618. * Returns a Color3 value containing a random color
  5619. * @returns a new Color3 object
  5620. */
  5621. static Random(): Color3;
  5622. }
  5623. /**
  5624. * Class used to hold a RBGA color
  5625. */
  5626. export class Color4 {
  5627. /**
  5628. * Defines the red component (between 0 and 1, default is 0)
  5629. */
  5630. r: number;
  5631. /**
  5632. * Defines the green component (between 0 and 1, default is 0)
  5633. */
  5634. g: number;
  5635. /**
  5636. * Defines the blue component (between 0 and 1, default is 0)
  5637. */
  5638. b: number;
  5639. /**
  5640. * Defines the alpha component (between 0 and 1, default is 1)
  5641. */
  5642. a: number;
  5643. /**
  5644. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5645. * @param r defines the red component (between 0 and 1, default is 0)
  5646. * @param g defines the green component (between 0 and 1, default is 0)
  5647. * @param b defines the blue component (between 0 and 1, default is 0)
  5648. * @param a defines the alpha component (between 0 and 1, default is 1)
  5649. */
  5650. constructor(
  5651. /**
  5652. * Defines the red component (between 0 and 1, default is 0)
  5653. */
  5654. r?: number,
  5655. /**
  5656. * Defines the green component (between 0 and 1, default is 0)
  5657. */
  5658. g?: number,
  5659. /**
  5660. * Defines the blue component (between 0 and 1, default is 0)
  5661. */
  5662. b?: number,
  5663. /**
  5664. * Defines the alpha component (between 0 and 1, default is 1)
  5665. */
  5666. a?: number);
  5667. /**
  5668. * Adds in place the given Color4 values to the current Color4 object
  5669. * @param right defines the second operand
  5670. * @returns the current updated Color4 object
  5671. */
  5672. addInPlace(right: DeepImmutable<Color4>): Color4;
  5673. /**
  5674. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5675. * @returns the new array
  5676. */
  5677. asArray(): number[];
  5678. /**
  5679. * Stores from the starting index in the given array the Color4 successive values
  5680. * @param array defines the array where to store the r,g,b components
  5681. * @param index defines an optional index in the target array to define where to start storing values
  5682. * @returns the current Color4 object
  5683. */
  5684. toArray(array: number[], index?: number): Color4;
  5685. /**
  5686. * Determines equality between Color4 objects
  5687. * @param otherColor defines the second operand
  5688. * @returns true if the rgba values are equal to the given ones
  5689. */
  5690. equals(otherColor: DeepImmutable<Color4>): boolean;
  5691. /**
  5692. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5693. * @param right defines the second operand
  5694. * @returns a new Color4 object
  5695. */
  5696. add(right: DeepImmutable<Color4>): Color4;
  5697. /**
  5698. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5699. * @param right defines the second operand
  5700. * @returns a new Color4 object
  5701. */
  5702. subtract(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5705. * @param right defines the second operand
  5706. * @param result defines the Color4 object where to store the result
  5707. * @returns the current Color4 object
  5708. */
  5709. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5710. /**
  5711. * Creates a new Color4 with the current Color4 values multiplied by scale
  5712. * @param scale defines the scaling factor to apply
  5713. * @returns a new Color4 object
  5714. */
  5715. scale(scale: number): Color4;
  5716. /**
  5717. * Multiplies the current Color4 values by scale and stores the result in "result"
  5718. * @param scale defines the scaling factor to apply
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the current unmodified Color4
  5721. */
  5722. scaleToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Scale the current Color4 values by a factor and add the result to a given Color4
  5725. * @param scale defines the scale factor
  5726. * @param result defines the Color4 object where to store the result
  5727. * @returns the unmodified current Color4
  5728. */
  5729. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5730. /**
  5731. * Clamps the rgb values by the min and max values and stores the result into "result"
  5732. * @param min defines minimum clamping value (default is 0)
  5733. * @param max defines maximum clamping value (default is 1)
  5734. * @param result defines color to store the result into.
  5735. * @returns the cuurent Color4
  5736. */
  5737. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5738. /**
  5739. * Multipy an Color4 value by another and return a new Color4 object
  5740. * @param color defines the Color4 value to multiply by
  5741. * @returns a new Color4 object
  5742. */
  5743. multiply(color: Color4): Color4;
  5744. /**
  5745. * Multipy a Color4 value by another and push the result in a reference value
  5746. * @param color defines the Color4 value to multiply by
  5747. * @param result defines the Color4 to fill the result in
  5748. * @returns the result Color4
  5749. */
  5750. multiplyToRef(color: Color4, result: Color4): Color4;
  5751. /**
  5752. * Creates a string with the Color4 current values
  5753. * @returns the string representation of the Color4 object
  5754. */
  5755. toString(): string;
  5756. /**
  5757. * Returns the string "Color4"
  5758. * @returns "Color4"
  5759. */
  5760. getClassName(): string;
  5761. /**
  5762. * Compute the Color4 hash code
  5763. * @returns an unique number that can be used to hash Color4 objects
  5764. */
  5765. getHashCode(): number;
  5766. /**
  5767. * Creates a new Color4 copied from the current one
  5768. * @returns a new Color4 object
  5769. */
  5770. clone(): Color4;
  5771. /**
  5772. * Copies the given Color4 values into the current one
  5773. * @param source defines the source Color4 object
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFrom(source: Color4): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Copies the given float values into the current one
  5788. * @param r defines the red component to read from
  5789. * @param g defines the green component to read from
  5790. * @param b defines the blue component to read from
  5791. * @param a defines the alpha component to read from
  5792. * @returns the current updated Color4 object
  5793. */
  5794. set(r: number, g: number, b: number, a: number): Color4;
  5795. /**
  5796. * Compute the Color4 hexadecimal code as a string
  5797. * @returns a string containing the hexadecimal representation of the Color4 object
  5798. */
  5799. toHexString(): string;
  5800. /**
  5801. * Computes a new Color4 converted from the current one to linear space
  5802. * @returns a new Color4 object
  5803. */
  5804. toLinearSpace(): Color4;
  5805. /**
  5806. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5807. * @param convertedColor defines the Color4 object where to store the linear space version
  5808. * @returns the unmodified Color4
  5809. */
  5810. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5811. /**
  5812. * Computes a new Color4 converted from the current one to gamma space
  5813. * @returns a new Color4 object
  5814. */
  5815. toGammaSpace(): Color4;
  5816. /**
  5817. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5818. * @param convertedColor defines the Color4 object where to store the gamma space version
  5819. * @returns the unmodified Color4
  5820. */
  5821. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5822. /**
  5823. * Creates a new Color4 from the string containing valid hexadecimal values
  5824. * @param hex defines a string containing valid hexadecimal values
  5825. * @returns a new Color4 object
  5826. */
  5827. static FromHexString(hex: string): Color4;
  5828. /**
  5829. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @returns a new Color4 object
  5834. */
  5835. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5836. /**
  5837. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5838. * @param left defines the start value
  5839. * @param right defines the end value
  5840. * @param amount defines the gradient factor
  5841. * @param result defines the Color4 object where to store data
  5842. */
  5843. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5844. /**
  5845. * Creates a new Color4 from a Color3 and an alpha value
  5846. * @param color3 defines the source Color3 to read from
  5847. * @param alpha defines the alpha component (1.0 by default)
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5851. /**
  5852. * Creates a new Color4 from the starting index element of the given array
  5853. * @param array defines the source array to read from
  5854. * @param offset defines the offset in the source array
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5858. /**
  5859. * Creates a new Color3 from integer values (< 256)
  5860. * @param r defines the red component to read from (value between 0 and 255)
  5861. * @param g defines the green component to read from (value between 0 and 255)
  5862. * @param b defines the blue component to read from (value between 0 and 255)
  5863. * @param a defines the alpha component to read from (value between 0 and 255)
  5864. * @returns a new Color3 object
  5865. */
  5866. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5867. /**
  5868. * Check the content of a given array and convert it to an array containing RGBA data
  5869. * If the original array was already containing count * 4 values then it is returned directly
  5870. * @param colors defines the array to check
  5871. * @param count defines the number of RGBA data to expect
  5872. * @returns an array containing count * 4 values (RGBA)
  5873. */
  5874. static CheckColors4(colors: number[], count: number): number[];
  5875. }
  5876. /**
  5877. * @hidden
  5878. */
  5879. export class TmpColors {
  5880. static Color3: Color3[];
  5881. static Color4: Color4[];
  5882. }
  5883. }
  5884. declare module "babylonjs/Animations/animationKey" {
  5885. /**
  5886. * Defines an interface which represents an animation key frame
  5887. */
  5888. export interface IAnimationKey {
  5889. /**
  5890. * Frame of the key frame
  5891. */
  5892. frame: number;
  5893. /**
  5894. * Value at the specifies key frame
  5895. */
  5896. value: any;
  5897. /**
  5898. * The input tangent for the cubic hermite spline
  5899. */
  5900. inTangent?: any;
  5901. /**
  5902. * The output tangent for the cubic hermite spline
  5903. */
  5904. outTangent?: any;
  5905. /**
  5906. * The animation interpolation type
  5907. */
  5908. interpolation?: AnimationKeyInterpolation;
  5909. }
  5910. /**
  5911. * Enum for the animation key frame interpolation type
  5912. */
  5913. export enum AnimationKeyInterpolation {
  5914. /**
  5915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5916. */
  5917. STEP = 1
  5918. }
  5919. }
  5920. declare module "babylonjs/Animations/animationRange" {
  5921. /**
  5922. * Represents the range of an animation
  5923. */
  5924. export class AnimationRange {
  5925. /**The name of the animation range**/
  5926. name: string;
  5927. /**The starting frame of the animation */
  5928. from: number;
  5929. /**The ending frame of the animation*/
  5930. to: number;
  5931. /**
  5932. * Initializes the range of an animation
  5933. * @param name The name of the animation range
  5934. * @param from The starting frame of the animation
  5935. * @param to The ending frame of the animation
  5936. */
  5937. constructor(
  5938. /**The name of the animation range**/
  5939. name: string,
  5940. /**The starting frame of the animation */
  5941. from: number,
  5942. /**The ending frame of the animation*/
  5943. to: number);
  5944. /**
  5945. * Makes a copy of the animation range
  5946. * @returns A copy of the animation range
  5947. */
  5948. clone(): AnimationRange;
  5949. }
  5950. }
  5951. declare module "babylonjs/Animations/animationEvent" {
  5952. /**
  5953. * Composed of a frame, and an action function
  5954. */
  5955. export class AnimationEvent {
  5956. /** The frame for which the event is triggered **/
  5957. frame: number;
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void;
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined;
  5962. /**
  5963. * Specifies if the animation event is done
  5964. */
  5965. isDone: boolean;
  5966. /**
  5967. * Initializes the animation event
  5968. * @param frame The frame for which the event is triggered
  5969. * @param action The event to perform when triggered
  5970. * @param onlyOnce Specifies if the event should be triggered only once
  5971. */
  5972. constructor(
  5973. /** The frame for which the event is triggered **/
  5974. frame: number,
  5975. /** The event to perform when triggered **/
  5976. action: (currentFrame: number) => void,
  5977. /** Specifies if the event should be triggered only once**/
  5978. onlyOnce?: boolean | undefined);
  5979. /** @hidden */
  5980. _clone(): AnimationEvent;
  5981. }
  5982. }
  5983. declare module "babylonjs/Behaviors/behavior" {
  5984. import { Nullable } from "babylonjs/types";
  5985. /**
  5986. * Interface used to define a behavior
  5987. */
  5988. export interface Behavior<T> {
  5989. /** gets or sets behavior's name */
  5990. name: string;
  5991. /**
  5992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5993. */
  5994. init(): void;
  5995. /**
  5996. * Called when the behavior is attached to a target
  5997. * @param target defines the target where the behavior is attached to
  5998. */
  5999. attach(target: T): void;
  6000. /**
  6001. * Called when the behavior is detached from its target
  6002. */
  6003. detach(): void;
  6004. }
  6005. /**
  6006. * Interface implemented by classes supporting behaviors
  6007. */
  6008. export interface IBehaviorAware<T> {
  6009. /**
  6010. * Attach a behavior
  6011. * @param behavior defines the behavior to attach
  6012. * @returns the current host
  6013. */
  6014. addBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Remove a behavior from the current object
  6017. * @param behavior defines the behavior to detach
  6018. * @returns the current host
  6019. */
  6020. removeBehavior(behavior: Behavior<T>): T;
  6021. /**
  6022. * Gets a behavior using its name to search
  6023. * @param name defines the name to search
  6024. * @returns the behavior or null if not found
  6025. */
  6026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6027. }
  6028. }
  6029. declare module "babylonjs/Misc/smartArray" {
  6030. /**
  6031. * Defines an array and its length.
  6032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6033. */
  6034. export interface ISmartArrayLike<T> {
  6035. /**
  6036. * The data of the array.
  6037. */
  6038. data: Array<T>;
  6039. /**
  6040. * The active length of the array.
  6041. */
  6042. length: number;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. */
  6047. export class SmartArray<T> implements ISmartArrayLike<T> {
  6048. /**
  6049. * The full set of data from the array.
  6050. */
  6051. data: Array<T>;
  6052. /**
  6053. * The active length of the array.
  6054. */
  6055. length: number;
  6056. protected _id: number;
  6057. /**
  6058. * Instantiates a Smart Array.
  6059. * @param capacity defines the default capacity of the array.
  6060. */
  6061. constructor(capacity: number);
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * @param value defines the object to push in the array.
  6065. */
  6066. push(value: T): void;
  6067. /**
  6068. * Iterates over the active data and apply the lambda to them.
  6069. * @param func defines the action to apply on each value.
  6070. */
  6071. forEach(func: (content: T) => void): void;
  6072. /**
  6073. * Sorts the full sets of data.
  6074. * @param compareFn defines the comparison function to apply.
  6075. */
  6076. sort(compareFn: (a: T, b: T) => number): void;
  6077. /**
  6078. * Resets the active data to an empty array.
  6079. */
  6080. reset(): void;
  6081. /**
  6082. * Releases all the data from the array as well as the array.
  6083. */
  6084. dispose(): void;
  6085. /**
  6086. * Concats the active data with a given array.
  6087. * @param array defines the data to concatenate with.
  6088. */
  6089. concat(array: any): void;
  6090. /**
  6091. * Returns the position of a value in the active data.
  6092. * @param value defines the value to find the index for
  6093. * @returns the index if found in the active data otherwise -1
  6094. */
  6095. indexOf(value: T): number;
  6096. /**
  6097. * Returns whether an element is part of the active data.
  6098. * @param value defines the value to look for
  6099. * @returns true if found in the active data otherwise false
  6100. */
  6101. contains(value: T): boolean;
  6102. private static _GlobalId;
  6103. }
  6104. /**
  6105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6106. * The data in this array can only be present once
  6107. */
  6108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6109. private _duplicateId;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6113. * @param value defines the object to push in the array.
  6114. */
  6115. push(value: T): void;
  6116. /**
  6117. * Pushes a value at the end of the active data.
  6118. * If the data is already present, it won t be added again
  6119. * @param value defines the object to push in the array.
  6120. * @returns true if added false if it was already present
  6121. */
  6122. pushNoDuplicate(value: T): boolean;
  6123. /**
  6124. * Resets the active data to an empty array.
  6125. */
  6126. reset(): void;
  6127. /**
  6128. * Concats the active data with a given array.
  6129. * This ensures no dupplicate will be present in the result.
  6130. * @param array defines the data to concatenate with.
  6131. */
  6132. concatWithNoDuplicate(array: any): void;
  6133. }
  6134. }
  6135. declare module "babylonjs/Cameras/cameraInputsManager" {
  6136. import { Nullable } from "babylonjs/types";
  6137. import { Camera } from "babylonjs/Cameras/camera";
  6138. /**
  6139. * @ignore
  6140. * This is a list of all the different input types that are available in the application.
  6141. * Fo instance: ArcRotateCameraGamepadInput...
  6142. */
  6143. export var CameraInputTypes: {};
  6144. /**
  6145. * This is the contract to implement in order to create a new input class.
  6146. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6147. */
  6148. export interface ICameraInput<TCamera extends Camera> {
  6149. /**
  6150. * Defines the camera the input is attached to.
  6151. */
  6152. camera: Nullable<TCamera>;
  6153. /**
  6154. * Gets the class name of the current intput.
  6155. * @returns the class name
  6156. */
  6157. getClassName(): string;
  6158. /**
  6159. * Get the friendly name associated with the input class.
  6160. * @returns the input friendly name
  6161. */
  6162. getSimpleName(): string;
  6163. /**
  6164. * Attach the input controls to a specific dom element to get the input from.
  6165. * @param element Defines the element the controls should be listened from
  6166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6167. */
  6168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6169. /**
  6170. * Detach the current controls from the specified dom element.
  6171. * @param element Defines the element to stop listening the inputs from
  6172. */
  6173. detachControl(element: Nullable<HTMLElement>): void;
  6174. /**
  6175. * Update the current camera state depending on the inputs that have been used this frame.
  6176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6177. */
  6178. checkInputs?: () => void;
  6179. }
  6180. /**
  6181. * Represents a map of input types to input instance or input index to input instance.
  6182. */
  6183. export interface CameraInputsMap<TCamera extends Camera> {
  6184. /**
  6185. * Accessor to the input by input type.
  6186. */
  6187. [name: string]: ICameraInput<TCamera>;
  6188. /**
  6189. * Accessor to the input by input index.
  6190. */
  6191. [idx: number]: ICameraInput<TCamera>;
  6192. }
  6193. /**
  6194. * This represents the input manager used within a camera.
  6195. * It helps dealing with all the different kind of input attached to a camera.
  6196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6197. */
  6198. export class CameraInputsManager<TCamera extends Camera> {
  6199. /**
  6200. * Defines the list of inputs attahed to the camera.
  6201. */
  6202. attached: CameraInputsMap<TCamera>;
  6203. /**
  6204. * Defines the dom element the camera is collecting inputs from.
  6205. * This is null if the controls have not been attached.
  6206. */
  6207. attachedElement: Nullable<HTMLElement>;
  6208. /**
  6209. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6210. */
  6211. noPreventDefault: boolean;
  6212. /**
  6213. * Defined the camera the input manager belongs to.
  6214. */
  6215. camera: TCamera;
  6216. /**
  6217. * Update the current camera state depending on the inputs that have been used this frame.
  6218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6219. */
  6220. checkInputs: () => void;
  6221. /**
  6222. * Instantiate a new Camera Input Manager.
  6223. * @param camera Defines the camera the input manager blongs to
  6224. */
  6225. constructor(camera: TCamera);
  6226. /**
  6227. * Add an input method to a camera
  6228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6229. * @param input camera input method
  6230. */
  6231. add(input: ICameraInput<TCamera>): void;
  6232. /**
  6233. * Remove a specific input method from a camera
  6234. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6235. * @param inputToRemove camera input method
  6236. */
  6237. remove(inputToRemove: ICameraInput<TCamera>): void;
  6238. /**
  6239. * Remove a specific input type from a camera
  6240. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6241. * @param inputType the type of the input to remove
  6242. */
  6243. removeByType(inputType: string): void;
  6244. private _addCheckInputs;
  6245. /**
  6246. * Attach the input controls to the currently attached dom element to listen the events from.
  6247. * @param input Defines the input to attach
  6248. */
  6249. attachInput(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6252. * @param element Defines the dom element to collect the events from
  6253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6254. */
  6255. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6256. /**
  6257. * Detach the current manager inputs controls from a specific dom element.
  6258. * @param element Defines the dom element to collect the events from
  6259. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6260. */
  6261. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6262. /**
  6263. * Rebuild the dynamic inputCheck function from the current list of
  6264. * defined inputs in the manager.
  6265. */
  6266. rebuildInputCheck(): void;
  6267. /**
  6268. * Remove all attached input methods from a camera
  6269. */
  6270. clear(): void;
  6271. /**
  6272. * Serialize the current input manager attached to a camera.
  6273. * This ensures than once parsed,
  6274. * the input associated to the camera will be identical to the current ones
  6275. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6276. */
  6277. serialize(serializedCamera: any): void;
  6278. /**
  6279. * Parses an input manager serialized JSON to restore the previous list of inputs
  6280. * and states associated to a camera.
  6281. * @param parsedCamera Defines the JSON to parse
  6282. */
  6283. parse(parsedCamera: any): void;
  6284. }
  6285. }
  6286. declare module "babylonjs/Meshes/buffer" {
  6287. import { Nullable, DataArray } from "babylonjs/types";
  6288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6289. /**
  6290. * Class used to store data that will be store in GPU memory
  6291. */
  6292. export class Buffer {
  6293. private _engine;
  6294. private _buffer;
  6295. /** @hidden */
  6296. _data: Nullable<DataArray>;
  6297. private _updatable;
  6298. private _instanced;
  6299. private _divisor;
  6300. /**
  6301. * Gets the byte stride.
  6302. */
  6303. readonly byteStride: number;
  6304. /**
  6305. * Constructor
  6306. * @param engine the engine
  6307. * @param data the data to use for this buffer
  6308. * @param updatable whether the data is updatable
  6309. * @param stride the stride (optional)
  6310. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6311. * @param instanced whether the buffer is instanced (optional)
  6312. * @param useBytes set to true if the stride in in bytes (optional)
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. */
  6315. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6316. /**
  6317. * Create a new VertexBuffer based on the current buffer
  6318. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6319. * @param offset defines offset in the buffer (0 by default)
  6320. * @param size defines the size in floats of attributes (position is 3 for instance)
  6321. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6322. * @param instanced defines if the vertex buffer contains indexed data
  6323. * @param useBytes defines if the offset and stride are in bytes *
  6324. * @param divisor sets an optional divisor for instances (1 by default)
  6325. * @returns the new vertex buffer
  6326. */
  6327. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6328. /**
  6329. * Gets a boolean indicating if the Buffer is updatable?
  6330. * @returns true if the buffer is updatable
  6331. */
  6332. isUpdatable(): boolean;
  6333. /**
  6334. * Gets current buffer's data
  6335. * @returns a DataArray or null
  6336. */
  6337. getData(): Nullable<DataArray>;
  6338. /**
  6339. * Gets underlying native buffer
  6340. * @returns underlying native buffer
  6341. */
  6342. getBuffer(): Nullable<DataBuffer>;
  6343. /**
  6344. * Gets the stride in float32 units (i.e. byte stride / 4).
  6345. * May not be an integer if the byte stride is not divisible by 4.
  6346. * @returns the stride in float32 units
  6347. * @deprecated Please use byteStride instead.
  6348. */
  6349. getStrideSize(): number;
  6350. /**
  6351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6352. * @param data defines the data to store
  6353. */
  6354. create(data?: Nullable<DataArray>): void;
  6355. /** @hidden */
  6356. _rebuild(): void;
  6357. /**
  6358. * Update current buffer data
  6359. * @param data defines the data to store
  6360. */
  6361. update(data: DataArray): void;
  6362. /**
  6363. * Updates the data directly.
  6364. * @param data the new data
  6365. * @param offset the new offset
  6366. * @param vertexCount the vertex count (optional)
  6367. * @param useBytes set to true if the offset is in bytes
  6368. */
  6369. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6370. /**
  6371. * Release all resources
  6372. */
  6373. dispose(): void;
  6374. }
  6375. /**
  6376. * Specialized buffer used to store vertex data
  6377. */
  6378. export class VertexBuffer {
  6379. /** @hidden */
  6380. _buffer: Buffer;
  6381. private _kind;
  6382. private _size;
  6383. private _ownsBuffer;
  6384. private _instanced;
  6385. private _instanceDivisor;
  6386. /**
  6387. * The byte type.
  6388. */
  6389. static readonly BYTE: number;
  6390. /**
  6391. * The unsigned byte type.
  6392. */
  6393. static readonly UNSIGNED_BYTE: number;
  6394. /**
  6395. * The short type.
  6396. */
  6397. static readonly SHORT: number;
  6398. /**
  6399. * The unsigned short type.
  6400. */
  6401. static readonly UNSIGNED_SHORT: number;
  6402. /**
  6403. * The integer type.
  6404. */
  6405. static readonly INT: number;
  6406. /**
  6407. * The unsigned integer type.
  6408. */
  6409. static readonly UNSIGNED_INT: number;
  6410. /**
  6411. * The float type.
  6412. */
  6413. static readonly FLOAT: number;
  6414. /**
  6415. * Gets or sets the instance divisor when in instanced mode
  6416. */
  6417. get instanceDivisor(): number;
  6418. set instanceDivisor(value: number);
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Gets the byte offset.
  6425. */
  6426. readonly byteOffset: number;
  6427. /**
  6428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6429. */
  6430. readonly normalized: boolean;
  6431. /**
  6432. * Gets the data type of each component in the array.
  6433. */
  6434. readonly type: number;
  6435. /**
  6436. * Constructor
  6437. * @param engine the engine
  6438. * @param data the data to use for this vertex buffer
  6439. * @param kind the vertex buffer kind
  6440. * @param updatable whether the data is updatable
  6441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6442. * @param stride the stride (optional)
  6443. * @param instanced whether the buffer is instanced (optional)
  6444. * @param offset the offset of the data (optional)
  6445. * @param size the number of components (optional)
  6446. * @param type the type of the component (optional)
  6447. * @param normalized whether the data contains normalized data (optional)
  6448. * @param useBytes set to true if stride and offset are in bytes (optional)
  6449. * @param divisor defines the instance divisor to use (1 by default)
  6450. */
  6451. 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);
  6452. /** @hidden */
  6453. _rebuild(): void;
  6454. /**
  6455. * Returns the kind of the VertexBuffer (string)
  6456. * @returns a string
  6457. */
  6458. getKind(): string;
  6459. /**
  6460. * Gets a boolean indicating if the VertexBuffer is updatable?
  6461. * @returns true if the buffer is updatable
  6462. */
  6463. isUpdatable(): boolean;
  6464. /**
  6465. * Gets current buffer's data
  6466. * @returns a DataArray or null
  6467. */
  6468. getData(): Nullable<DataArray>;
  6469. /**
  6470. * Gets underlying native buffer
  6471. * @returns underlying native buffer
  6472. */
  6473. getBuffer(): Nullable<DataBuffer>;
  6474. /**
  6475. * Gets the stride in float32 units (i.e. byte stride / 4).
  6476. * May not be an integer if the byte stride is not divisible by 4.
  6477. * @returns the stride in float32 units
  6478. * @deprecated Please use byteStride instead.
  6479. */
  6480. getStrideSize(): number;
  6481. /**
  6482. * Returns the offset as a multiple of the type byte length.
  6483. * @returns the offset in bytes
  6484. * @deprecated Please use byteOffset instead.
  6485. */
  6486. getOffset(): number;
  6487. /**
  6488. * Returns the number of components per vertex attribute (integer)
  6489. * @returns the size in float
  6490. */
  6491. getSize(): number;
  6492. /**
  6493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6494. * @returns true if this buffer is instanced
  6495. */
  6496. getIsInstanced(): boolean;
  6497. /**
  6498. * Returns the instancing divisor, zero for non-instanced (integer).
  6499. * @returns a number
  6500. */
  6501. getInstanceDivisor(): number;
  6502. /**
  6503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6504. * @param data defines the data to store
  6505. */
  6506. create(data?: DataArray): void;
  6507. /**
  6508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6509. * This function will create a new buffer if the current one is not updatable
  6510. * @param data defines the data to store
  6511. */
  6512. update(data: DataArray): void;
  6513. /**
  6514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6515. * Returns the directly updated WebGLBuffer.
  6516. * @param data the new data
  6517. * @param offset the new offset
  6518. * @param useBytes set to true if the offset is in bytes
  6519. */
  6520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6521. /**
  6522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6523. */
  6524. dispose(): void;
  6525. /**
  6526. * Enumerates each value of this vertex buffer as numbers.
  6527. * @param count the number of values to enumerate
  6528. * @param callback the callback function called for each value
  6529. */
  6530. forEach(count: number, callback: (value: number, index: number) => void): void;
  6531. /**
  6532. * Positions
  6533. */
  6534. static readonly PositionKind: string;
  6535. /**
  6536. * Normals
  6537. */
  6538. static readonly NormalKind: string;
  6539. /**
  6540. * Tangents
  6541. */
  6542. static readonly TangentKind: string;
  6543. /**
  6544. * Texture coordinates
  6545. */
  6546. static readonly UVKind: string;
  6547. /**
  6548. * Texture coordinates 2
  6549. */
  6550. static readonly UV2Kind: string;
  6551. /**
  6552. * Texture coordinates 3
  6553. */
  6554. static readonly UV3Kind: string;
  6555. /**
  6556. * Texture coordinates 4
  6557. */
  6558. static readonly UV4Kind: string;
  6559. /**
  6560. * Texture coordinates 5
  6561. */
  6562. static readonly UV5Kind: string;
  6563. /**
  6564. * Texture coordinates 6
  6565. */
  6566. static readonly UV6Kind: string;
  6567. /**
  6568. * Colors
  6569. */
  6570. static readonly ColorKind: string;
  6571. /**
  6572. * Matrix indices (for bones)
  6573. */
  6574. static readonly MatricesIndicesKind: string;
  6575. /**
  6576. * Matrix weights (for bones)
  6577. */
  6578. static readonly MatricesWeightsKind: string;
  6579. /**
  6580. * Additional matrix indices (for bones)
  6581. */
  6582. static readonly MatricesIndicesExtraKind: string;
  6583. /**
  6584. * Additional matrix weights (for bones)
  6585. */
  6586. static readonly MatricesWeightsExtraKind: string;
  6587. /**
  6588. * Deduces the stride given a kind.
  6589. * @param kind The kind string to deduce
  6590. * @returns The deduced stride
  6591. */
  6592. static DeduceStride(kind: string): number;
  6593. /**
  6594. * Gets the byte length of the given type.
  6595. * @param type the type
  6596. * @returns the number of bytes
  6597. */
  6598. static GetTypeByteLength(type: number): number;
  6599. /**
  6600. * Enumerates each value of the given parameters as numbers.
  6601. * @param data the data to enumerate
  6602. * @param byteOffset the byte offset of the data
  6603. * @param byteStride the byte stride of the data
  6604. * @param componentCount the number of components per element
  6605. * @param componentType the type of the component
  6606. * @param count the number of values to enumerate
  6607. * @param normalized whether the data is normalized
  6608. * @param callback the callback function called for each value
  6609. */
  6610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6611. private static _GetFloatValue;
  6612. }
  6613. }
  6614. declare module "babylonjs/Collisions/intersectionInfo" {
  6615. import { Nullable } from "babylonjs/types";
  6616. /**
  6617. * @hidden
  6618. */
  6619. export class IntersectionInfo {
  6620. bu: Nullable<number>;
  6621. bv: Nullable<number>;
  6622. distance: number;
  6623. faceId: number;
  6624. subMeshId: number;
  6625. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6626. }
  6627. }
  6628. declare module "babylonjs/Maths/math.plane" {
  6629. import { DeepImmutable } from "babylonjs/types";
  6630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6631. /**
  6632. * Represens a plane by the equation ax + by + cz + d = 0
  6633. */
  6634. export class Plane {
  6635. private static _TmpMatrix;
  6636. /**
  6637. * Normal of the plane (a,b,c)
  6638. */
  6639. normal: Vector3;
  6640. /**
  6641. * d component of the plane
  6642. */
  6643. d: number;
  6644. /**
  6645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6646. * @param a a component of the plane
  6647. * @param b b component of the plane
  6648. * @param c c component of the plane
  6649. * @param d d component of the plane
  6650. */
  6651. constructor(a: number, b: number, c: number, d: number);
  6652. /**
  6653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6654. */
  6655. asArray(): number[];
  6656. /**
  6657. * @returns a new plane copied from the current Plane.
  6658. */
  6659. clone(): Plane;
  6660. /**
  6661. * @returns the string "Plane".
  6662. */
  6663. getClassName(): string;
  6664. /**
  6665. * @returns the Plane hash code.
  6666. */
  6667. getHashCode(): number;
  6668. /**
  6669. * Normalize the current Plane in place.
  6670. * @returns the updated Plane.
  6671. */
  6672. normalize(): Plane;
  6673. /**
  6674. * Applies a transformation the plane and returns the result
  6675. * @param transformation the transformation matrix to be applied to the plane
  6676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6677. */
  6678. transform(transformation: DeepImmutable<Matrix>): Plane;
  6679. /**
  6680. * Calcualtte the dot product between the point and the plane normal
  6681. * @param point point to calculate the dot product with
  6682. * @returns the dot product (float) of the point coordinates and the plane normal.
  6683. */
  6684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Updates the current Plane from the plane defined by the three given points.
  6687. * @param point1 one of the points used to contruct the plane
  6688. * @param point2 one of the points used to contruct the plane
  6689. * @param point3 one of the points used to contruct the plane
  6690. * @returns the updated Plane.
  6691. */
  6692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6693. /**
  6694. * Checks if the plane is facing a given direction
  6695. * @param direction the direction to check if the plane is facing
  6696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6697. * @returns True is the vector "direction" is the same side than the plane normal.
  6698. */
  6699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6700. /**
  6701. * Calculates the distance to a point
  6702. * @param point point to calculate distance to
  6703. * @returns the signed distance (float) from the given point to the Plane.
  6704. */
  6705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6706. /**
  6707. * Creates a plane from an array
  6708. * @param array the array to create a plane from
  6709. * @returns a new Plane from the given array.
  6710. */
  6711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6712. /**
  6713. * Creates a plane from three points
  6714. * @param point1 point used to create the plane
  6715. * @param point2 point used to create the plane
  6716. * @param point3 point used to create the plane
  6717. * @returns a new Plane defined by the three given points.
  6718. */
  6719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6720. /**
  6721. * Creates a plane from an origin point and a normal
  6722. * @param origin origin of the plane to be constructed
  6723. * @param normal normal of the plane to be constructed
  6724. * @returns a new Plane the normal vector to this plane at the given origin point.
  6725. * Note : the vector "normal" is updated because normalized.
  6726. */
  6727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6728. /**
  6729. * Calculates the distance from a plane and a point
  6730. * @param origin origin of the plane to be constructed
  6731. * @param normal normal of the plane to be constructed
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6734. */
  6735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6736. }
  6737. }
  6738. declare module "babylonjs/Culling/boundingSphere" {
  6739. import { DeepImmutable } from "babylonjs/types";
  6740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6741. import { Plane } from "babylonjs/Maths/math.plane";
  6742. /**
  6743. * Class used to store bounding sphere information
  6744. */
  6745. export class BoundingSphere {
  6746. /**
  6747. * Gets the center of the bounding sphere in local space
  6748. */
  6749. readonly center: Vector3;
  6750. /**
  6751. * Radius of the bounding sphere in local space
  6752. */
  6753. radius: number;
  6754. /**
  6755. * Gets the center of the bounding sphere in world space
  6756. */
  6757. readonly centerWorld: Vector3;
  6758. /**
  6759. * Radius of the bounding sphere in world space
  6760. */
  6761. radiusWorld: number;
  6762. /**
  6763. * Gets the minimum vector in local space
  6764. */
  6765. readonly minimum: Vector3;
  6766. /**
  6767. * Gets the maximum vector in local space
  6768. */
  6769. readonly maximum: Vector3;
  6770. private _worldMatrix;
  6771. private static readonly TmpVector3;
  6772. /**
  6773. * Creates a new bounding sphere
  6774. * @param min defines the minimum vector (in local space)
  6775. * @param max defines the maximum vector (in local space)
  6776. * @param worldMatrix defines the new world matrix
  6777. */
  6778. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6779. /**
  6780. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6781. * @param min defines the new minimum vector (in local space)
  6782. * @param max defines the new maximum vector (in local space)
  6783. * @param worldMatrix defines the new world matrix
  6784. */
  6785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6786. /**
  6787. * Scale the current bounding sphere by applying a scale factor
  6788. * @param factor defines the scale factor to apply
  6789. * @returns the current bounding box
  6790. */
  6791. scale(factor: number): BoundingSphere;
  6792. /**
  6793. * Gets the world matrix of the bounding box
  6794. * @returns a matrix
  6795. */
  6796. getWorldMatrix(): DeepImmutable<Matrix>;
  6797. /** @hidden */
  6798. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6799. /**
  6800. * Tests if the bounding sphere is intersecting the frustum planes
  6801. * @param frustumPlanes defines the frustum planes to test
  6802. * @returns true if there is an intersection
  6803. */
  6804. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6805. /**
  6806. * Tests if the bounding sphere center is in between the frustum planes.
  6807. * Used for optimistic fast inclusion.
  6808. * @param frustumPlanes defines the frustum planes to test
  6809. * @returns true if the sphere center is in between the frustum planes
  6810. */
  6811. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6812. /**
  6813. * Tests if a point is inside the bounding sphere
  6814. * @param point defines the point to test
  6815. * @returns true if the point is inside the bounding sphere
  6816. */
  6817. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6818. /**
  6819. * Checks if two sphere intersct
  6820. * @param sphere0 sphere 0
  6821. * @param sphere1 sphere 1
  6822. * @returns true if the speres intersect
  6823. */
  6824. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6825. }
  6826. }
  6827. declare module "babylonjs/Culling/boundingBox" {
  6828. import { DeepImmutable } from "babylonjs/types";
  6829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6830. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6831. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6832. import { Plane } from "babylonjs/Maths/math.plane";
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module "babylonjs/Collisions/collider" {
  6978. import { Nullable, IndicesArray } from "babylonjs/types";
  6979. import { Vector3 } from "babylonjs/Maths/math.vector";
  6980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6981. import { Plane } from "babylonjs/Maths/math.plane";
  6982. /** @hidden */
  6983. export class Collider {
  6984. /** Define if a collision was found */
  6985. collisionFound: boolean;
  6986. /**
  6987. * Define last intersection point in local space
  6988. */
  6989. intersectionPoint: Vector3;
  6990. /**
  6991. * Define last collided mesh
  6992. */
  6993. collidedMesh: Nullable<AbstractMesh>;
  6994. private _collisionPoint;
  6995. private _planeIntersectionPoint;
  6996. private _tempVector;
  6997. private _tempVector2;
  6998. private _tempVector3;
  6999. private _tempVector4;
  7000. private _edge;
  7001. private _baseToVertex;
  7002. private _destinationPoint;
  7003. private _slidePlaneNormal;
  7004. private _displacementVector;
  7005. /** @hidden */
  7006. _radius: Vector3;
  7007. /** @hidden */
  7008. _retry: number;
  7009. private _velocity;
  7010. private _basePoint;
  7011. private _epsilon;
  7012. /** @hidden */
  7013. _velocityWorldLength: number;
  7014. /** @hidden */
  7015. _basePointWorld: Vector3;
  7016. private _velocityWorld;
  7017. private _normalizedVelocity;
  7018. /** @hidden */
  7019. _initialVelocity: Vector3;
  7020. /** @hidden */
  7021. _initialPosition: Vector3;
  7022. private _nearestDistance;
  7023. private _collisionMask;
  7024. get collisionMask(): number;
  7025. set collisionMask(mask: number);
  7026. /**
  7027. * Gets the plane normal used to compute the sliding response (in local space)
  7028. */
  7029. get slidePlaneNormal(): Vector3;
  7030. /** @hidden */
  7031. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7032. /** @hidden */
  7033. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7034. /** @hidden */
  7035. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */
  7037. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7038. /** @hidden */
  7039. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _getResponse(pos: Vector3, vel: Vector3): void;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingInfo" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7048. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. import { Collider } from "babylonjs/Collisions/collider";
  7051. /**
  7052. * Interface for cullable objects
  7053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7054. */
  7055. export interface ICullable {
  7056. /**
  7057. * Checks if the object or part of the object is in the frustum
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isInFrustum(frustumPlanes: Plane[]): boolean;
  7062. /**
  7063. * Checks if a cullable object (mesh...) is in the camera frustum
  7064. * Unlike isInFrustum this cheks the full bounding box
  7065. * @param frustumPlanes Camera near/planes
  7066. * @returns true if the object is in frustum otherwise false
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7069. }
  7070. /**
  7071. * Info for a bounding data of a mesh
  7072. */
  7073. export class BoundingInfo implements ICullable {
  7074. /**
  7075. * Bounding box for the mesh
  7076. */
  7077. readonly boundingBox: BoundingBox;
  7078. /**
  7079. * Bounding sphere for the mesh
  7080. */
  7081. readonly boundingSphere: BoundingSphere;
  7082. private _isLocked;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * Constructs bounding info
  7086. * @param minimum min vector of the bounding box/sphere
  7087. * @param maximum max vector of the bounding box/sphere
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * min vector of the bounding box/sphere
  7100. */
  7101. get minimum(): Vector3;
  7102. /**
  7103. * max vector of the bounding box/sphere
  7104. */
  7105. get maximum(): Vector3;
  7106. /**
  7107. * If the info is locked and won't be updated to avoid perf overhead
  7108. */
  7109. get isLocked(): boolean;
  7110. set isLocked(value: boolean);
  7111. /**
  7112. * Updates the bounding sphere and box
  7113. * @param world world matrix to be used to update
  7114. */
  7115. update(world: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7118. * @param center New center of the bounding info
  7119. * @param extend New extend of the bounding info
  7120. * @returns the current bounding info
  7121. */
  7122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7123. /**
  7124. * Scale the current bounding info by applying a scale factor
  7125. * @param factor defines the scale factor to apply
  7126. * @returns the current bounding info
  7127. */
  7128. scale(factor: number): BoundingInfo;
  7129. /**
  7130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7131. * @param frustumPlanes defines the frustum to test
  7132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7133. * @returns true if the bounding info is in the frustum planes
  7134. */
  7135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7136. /**
  7137. * Gets the world distance between the min and max points of the bounding box
  7138. */
  7139. get diagonalLength(): number;
  7140. /**
  7141. * Checks if a cullable object (mesh...) is in the camera frustum
  7142. * Unlike isInFrustum this cheks the full bounding box
  7143. * @param frustumPlanes Camera near/planes
  7144. * @returns true if the object is in frustum otherwise false
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /** @hidden */
  7148. _checkCollision(collider: Collider): boolean;
  7149. /**
  7150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7152. * @param point the point to check intersection with
  7153. * @returns if the point intersects
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7159. * @param boundingInfo the bounding info to check intersection with
  7160. * @param precise if the intersection should be done using OBB
  7161. * @returns if the bounding info intersects
  7162. */
  7163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7164. }
  7165. }
  7166. declare module "babylonjs/Maths/math.functions" {
  7167. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7168. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7169. /**
  7170. * Extracts minimum and maximum values from a list of indexed positions
  7171. * @param positions defines the positions to use
  7172. * @param indices defines the indices to the positions
  7173. * @param indexStart defines the start index
  7174. * @param indexCount defines the end index
  7175. * @param bias defines bias value to add to the result
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. /**
  7183. * Extracts minimum and maximum values from a list of positions
  7184. * @param positions defines the positions to use
  7185. * @param start defines the start index in the positions array
  7186. * @param count defines the number of positions to handle
  7187. * @param bias defines bias value to add to the result
  7188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7189. * @return minimum and maximum values
  7190. */
  7191. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7192. minimum: Vector3;
  7193. maximum: Vector3;
  7194. };
  7195. }
  7196. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7198. /** @hidden */
  7199. export class WebGLDataBuffer extends DataBuffer {
  7200. private _buffer;
  7201. constructor(resource: WebGLBuffer);
  7202. get underlyingResource(): any;
  7203. }
  7204. }
  7205. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7206. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7207. import { Nullable } from "babylonjs/types";
  7208. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7229. import { FloatArray, Nullable } from "babylonjs/types";
  7230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7232. module "babylonjs/Engines/thinEngine" {
  7233. interface ThinEngine {
  7234. /**
  7235. * Create an uniform buffer
  7236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7237. * @param elements defines the content of the uniform buffer
  7238. * @returns the webGL uniform buffer
  7239. */
  7240. createUniformBuffer(elements: FloatArray): DataBuffer;
  7241. /**
  7242. * Create a dynamic uniform buffer
  7243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7244. * @param elements defines the content of the uniform buffer
  7245. * @returns the webGL uniform buffer
  7246. */
  7247. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7248. /**
  7249. * Update an existing uniform buffer
  7250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7251. * @param uniformBuffer defines the target uniform buffer
  7252. * @param elements defines the content to update
  7253. * @param offset defines the offset in the uniform buffer where update should start
  7254. * @param count defines the size of the data to update
  7255. */
  7256. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7257. /**
  7258. * Bind an uniform buffer to the current webGL context
  7259. * @param buffer defines the buffer to bind
  7260. */
  7261. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7262. /**
  7263. * Bind a buffer to the current webGL context at a given location
  7264. * @param buffer defines the buffer to bind
  7265. * @param location defines the index where to bind the buffer
  7266. */
  7267. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7268. /**
  7269. * Bind a specific block at a given index in a specific shader program
  7270. * @param pipelineContext defines the pipeline context to use
  7271. * @param blockName defines the block name
  7272. * @param index defines the index where to bind the block
  7273. */
  7274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7275. }
  7276. }
  7277. }
  7278. declare module "babylonjs/Materials/uniformBuffer" {
  7279. import { Nullable, FloatArray } from "babylonjs/types";
  7280. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7281. import { Engine } from "babylonjs/Engines/engine";
  7282. import { Effect } from "babylonjs/Materials/effect";
  7283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { Color3 } from "babylonjs/Maths/math.color";
  7286. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7287. /**
  7288. * Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. */
  7297. export class UniformBuffer {
  7298. private _engine;
  7299. private _buffer;
  7300. private _data;
  7301. private _bufferData;
  7302. private _dynamic?;
  7303. private _uniformLocations;
  7304. private _uniformSizes;
  7305. private _uniformLocationPointer;
  7306. private _needSync;
  7307. private _noUBO;
  7308. private _currentEffect;
  7309. /** @hidden */
  7310. _alreadyBound: boolean;
  7311. private static _MAX_UNIFORM_SIZE;
  7312. private static _tempBuffer;
  7313. /**
  7314. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7319. /**
  7320. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7321. * This is dynamic to allow compat with webgl 1 and 2.
  7322. * You will need to pass the name of the uniform as well as the value.
  7323. */
  7324. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a single float in a uniform buffer.
  7327. * This is dynamic to allow compat with webgl 1 and 2.
  7328. * You will need to pass the name of the uniform as well as the value.
  7329. */
  7330. updateFloat: (name: string, x: number) => void;
  7331. /**
  7332. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7337. /**
  7338. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec4 of 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7355. /**
  7356. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7361. /**
  7362. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7367. /**
  7368. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7379. /**
  7380. * Instantiates a new Uniform buffer objects.
  7381. *
  7382. * Handles blocks of uniform on the GPU.
  7383. *
  7384. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7385. *
  7386. * For more information, please refer to :
  7387. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7388. * @param engine Define the engine the buffer is associated with
  7389. * @param data Define the data contained in the buffer
  7390. * @param dynamic Define if the buffer is updatable
  7391. */
  7392. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7393. /**
  7394. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7395. * or just falling back on setUniformXXX calls.
  7396. */
  7397. get useUbo(): boolean;
  7398. /**
  7399. * Indicates if the WebGL underlying uniform buffer is in sync
  7400. * with the javascript cache data.
  7401. */
  7402. get isSync(): boolean;
  7403. /**
  7404. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7405. * Also, a dynamic UniformBuffer will disable cache verification and always
  7406. * update the underlying WebGL uniform buffer to the GPU.
  7407. * @returns if Dynamic, otherwise false
  7408. */
  7409. isDynamic(): boolean;
  7410. /**
  7411. * The data cache on JS side.
  7412. * @returns the underlying data as a float array
  7413. */
  7414. getData(): Float32Array;
  7415. /**
  7416. * The underlying WebGL Uniform buffer.
  7417. * @returns the webgl buffer
  7418. */
  7419. getBuffer(): Nullable<DataBuffer>;
  7420. /**
  7421. * std140 layout specifies how to align data within an UBO structure.
  7422. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7423. * for specs.
  7424. */
  7425. private _fillAlignment;
  7426. /**
  7427. * Adds an uniform in the buffer.
  7428. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7429. * for the layout to be correct !
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param size Data size, or data directly.
  7432. */
  7433. addUniform(name: string, size: number | number[]): void;
  7434. /**
  7435. * Adds a Matrix 4x4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param mat A 4x4 matrix.
  7438. */
  7439. addMatrix(name: string, mat: Matrix): void;
  7440. /**
  7441. * Adds a vec2 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param x Define the x component value of the vec2
  7444. * @param y Define the y component value of the vec2
  7445. */
  7446. addFloat2(name: string, x: number, y: number): void;
  7447. /**
  7448. * Adds a vec3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. * @param x Define the x component value of the vec3
  7451. * @param y Define the y component value of the vec3
  7452. * @param z Define the z component value of the vec3
  7453. */
  7454. addFloat3(name: string, x: number, y: number, z: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param color Define the vec3 from a Color
  7459. */
  7460. addColor3(name: string, color: Color3): void;
  7461. /**
  7462. * Adds a vec4 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param color Define the rgb components from a Color
  7465. * @param alpha Define the a component of the vec4
  7466. */
  7467. addColor4(name: string, color: Color3, alpha: number): void;
  7468. /**
  7469. * Adds a vec3 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. * @param vector Define the vec3 components from a Vector
  7472. */
  7473. addVector3(name: string, vector: Vector3): void;
  7474. /**
  7475. * Adds a Matrix 3x3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. */
  7478. addMatrix3x3(name: string): void;
  7479. /**
  7480. * Adds a Matrix 2x2 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. */
  7483. addMatrix2x2(name: string): void;
  7484. /**
  7485. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7486. */
  7487. create(): void;
  7488. /** @hidden */
  7489. _rebuild(): void;
  7490. /**
  7491. * Updates the WebGL Uniform Buffer on the GPU.
  7492. * If the `dynamic` flag is set to true, no cache comparison is done.
  7493. * Otherwise, the buffer will be updated only if the cache differs.
  7494. */
  7495. update(): void;
  7496. /**
  7497. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7498. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7499. * @param data Define the flattened data
  7500. * @param size Define the size of the data.
  7501. */
  7502. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7503. private _valueCache;
  7504. private _cacheMatrix;
  7505. private _updateMatrix3x3ForUniform;
  7506. private _updateMatrix3x3ForEffect;
  7507. private _updateMatrix2x2ForEffect;
  7508. private _updateMatrix2x2ForUniform;
  7509. private _updateFloatForEffect;
  7510. private _updateFloatForUniform;
  7511. private _updateFloat2ForEffect;
  7512. private _updateFloat2ForUniform;
  7513. private _updateFloat3ForEffect;
  7514. private _updateFloat3ForUniform;
  7515. private _updateFloat4ForEffect;
  7516. private _updateFloat4ForUniform;
  7517. private _updateMatrixForEffect;
  7518. private _updateMatrixForUniform;
  7519. private _updateVector3ForEffect;
  7520. private _updateVector3ForUniform;
  7521. private _updateVector4ForEffect;
  7522. private _updateVector4ForUniform;
  7523. private _updateColor3ForEffect;
  7524. private _updateColor3ForUniform;
  7525. private _updateColor4ForEffect;
  7526. private _updateColor4ForUniform;
  7527. /**
  7528. * Sets a sampler uniform on the effect.
  7529. * @param name Define the name of the sampler.
  7530. * @param texture Define the texture to set in the sampler
  7531. */
  7532. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7533. /**
  7534. * Directly updates the value of the uniform in the cache AND on the GPU.
  7535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7536. * @param data Define the flattened data
  7537. */
  7538. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7539. /**
  7540. * Binds this uniform buffer to an effect.
  7541. * @param effect Define the effect to bind the buffer to
  7542. * @param name Name of the uniform block in the shader.
  7543. */
  7544. bindToEffect(effect: Effect, name: string): void;
  7545. /**
  7546. * Disposes the uniform buffer.
  7547. */
  7548. dispose(): void;
  7549. }
  7550. }
  7551. declare module "babylonjs/Misc/iInspectable" {
  7552. /**
  7553. * Enum that determines the text-wrapping mode to use.
  7554. */
  7555. export enum InspectableType {
  7556. /**
  7557. * Checkbox for booleans
  7558. */
  7559. Checkbox = 0,
  7560. /**
  7561. * Sliders for numbers
  7562. */
  7563. Slider = 1,
  7564. /**
  7565. * Vector3
  7566. */
  7567. Vector3 = 2,
  7568. /**
  7569. * Quaternions
  7570. */
  7571. Quaternion = 3,
  7572. /**
  7573. * Color3
  7574. */
  7575. Color3 = 4,
  7576. /**
  7577. * String
  7578. */
  7579. String = 5
  7580. }
  7581. /**
  7582. * Interface used to define custom inspectable properties.
  7583. * This interface is used by the inspector to display custom property grids
  7584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7585. */
  7586. export interface IInspectable {
  7587. /**
  7588. * Gets the label to display
  7589. */
  7590. label: string;
  7591. /**
  7592. * Gets the name of the property to edit
  7593. */
  7594. propertyName: string;
  7595. /**
  7596. * Gets the type of the editor to use
  7597. */
  7598. type: InspectableType;
  7599. /**
  7600. * Gets the minimum value of the property when using in "slider" mode
  7601. */
  7602. min?: number;
  7603. /**
  7604. * Gets the maximum value of the property when using in "slider" mode
  7605. */
  7606. max?: number;
  7607. /**
  7608. * Gets the setp to use when using in "slider" mode
  7609. */
  7610. step?: number;
  7611. }
  7612. }
  7613. declare module "babylonjs/Misc/timingTools" {
  7614. /**
  7615. * Class used to provide helper for timing
  7616. */
  7617. export class TimingTools {
  7618. /**
  7619. * Polyfill for setImmediate
  7620. * @param action defines the action to execute after the current execution block
  7621. */
  7622. static SetImmediate(action: () => void): void;
  7623. }
  7624. }
  7625. declare module "babylonjs/Misc/instantiationTools" {
  7626. /**
  7627. * Class used to enable instatition of objects by class name
  7628. */
  7629. export class InstantiationTools {
  7630. /**
  7631. * Use this object to register external classes like custom textures or material
  7632. * to allow the laoders to instantiate them
  7633. */
  7634. static RegisteredExternalClasses: {
  7635. [key: string]: Object;
  7636. };
  7637. /**
  7638. * Tries to instantiate a new object from a given class name
  7639. * @param className defines the class name to instantiate
  7640. * @returns the new object or null if the system was not able to do the instantiation
  7641. */
  7642. static Instantiate(className: string): any;
  7643. }
  7644. }
  7645. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7646. /**
  7647. * Define options used to create a depth texture
  7648. */
  7649. export class DepthTextureCreationOptions {
  7650. /** Specifies whether or not a stencil should be allocated in the texture */
  7651. generateStencil?: boolean;
  7652. /** Specifies whether or not bilinear filtering is enable on the texture */
  7653. bilinearFiltering?: boolean;
  7654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7655. comparisonFunction?: number;
  7656. /** Specifies if the created texture is a cube texture */
  7657. isCube?: boolean;
  7658. }
  7659. }
  7660. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7662. import { Nullable } from "babylonjs/types";
  7663. import { Scene } from "babylonjs/scene";
  7664. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7665. module "babylonjs/Engines/thinEngine" {
  7666. interface ThinEngine {
  7667. /**
  7668. * Creates a depth stencil cube texture.
  7669. * This is only available in WebGL 2.
  7670. * @param size The size of face edge in the cube texture.
  7671. * @param options The options defining the cube texture.
  7672. * @returns The cube texture
  7673. */
  7674. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7675. /**
  7676. * Creates a cube texture
  7677. * @param rootUrl defines the url where the files to load is located
  7678. * @param scene defines the current scene
  7679. * @param files defines the list of files to load (1 per face)
  7680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7681. * @param onLoad defines an optional callback raised when the texture is loaded
  7682. * @param onError defines an optional callback raised if there is an issue to load the texture
  7683. * @param format defines the format of the data
  7684. * @param forcedExtension defines the extension to use to pick the right loader
  7685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. 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;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @returns the cube texture as an InternalTexture
  7719. */
  7720. 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;
  7721. /** @hidden */
  7722. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7723. /** @hidden */
  7724. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7725. /** @hidden */
  7726. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7727. /** @hidden */
  7728. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7729. /**
  7730. * @hidden
  7731. */
  7732. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7733. }
  7734. }
  7735. }
  7736. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7737. import { Nullable } from "babylonjs/types";
  7738. import { Scene } from "babylonjs/scene";
  7739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7741. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7742. import { Observable } from "babylonjs/Misc/observable";
  7743. /**
  7744. * Class for creating a cube texture
  7745. */
  7746. export class CubeTexture extends BaseTexture {
  7747. private _delayedOnLoad;
  7748. /**
  7749. * Observable triggered once the texture has been loaded.
  7750. */
  7751. onLoadObservable: Observable<CubeTexture>;
  7752. /**
  7753. * The url of the texture
  7754. */
  7755. url: string;
  7756. /**
  7757. * Gets or sets the center of the bounding box associated with the cube texture.
  7758. * It must define where the camera used to render the texture was set
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. boundingBoxPosition: Vector3;
  7762. private _boundingBoxSize;
  7763. /**
  7764. * Gets or sets the size of the bounding box associated with the cube texture
  7765. * When defined, the cubemap will switch to local mode
  7766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7767. * @example https://www.babylonjs-playground.com/#RNASML
  7768. */
  7769. set boundingBoxSize(value: Vector3);
  7770. /**
  7771. * Returns the bounding box size
  7772. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7773. */
  7774. get boundingBoxSize(): Vector3;
  7775. protected _rotationY: number;
  7776. /**
  7777. * Sets texture matrix rotation angle around Y axis in radians.
  7778. */
  7779. set rotationY(value: number);
  7780. /**
  7781. * Gets texture matrix rotation angle around Y axis radians.
  7782. */
  7783. get rotationY(): number;
  7784. /**
  7785. * Are mip maps generated for this texture or not.
  7786. */
  7787. get noMipmap(): boolean;
  7788. private _noMipmap;
  7789. private _files;
  7790. protected _forcedExtension: Nullable<string>;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. 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);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. get isPrefiltered(): boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7848. */
  7849. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7850. /**
  7851. * Delays loading of the cube texture
  7852. * @param forcedExtension defines the extension to use
  7853. */
  7854. delayLoad(forcedExtension?: string): void;
  7855. /**
  7856. * Returns the reflection texture matrix
  7857. * @returns the reflection texture matrix
  7858. */
  7859. getReflectionTextureMatrix(): Matrix;
  7860. /**
  7861. * Sets the reflection texture matrix
  7862. * @param value Reflection texture matrix
  7863. */
  7864. setReflectionTextureMatrix(value: Matrix): void;
  7865. /**
  7866. * Parses text to create a cube texture
  7867. * @param parsedTexture define the serialized text to read from
  7868. * @param scene defines the hosting scene
  7869. * @param rootUrl defines the root url of the cube texture
  7870. * @returns a cube texture
  7871. */
  7872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7873. /**
  7874. * Makes a clone, or deep copy, of the cube texture
  7875. * @returns a new cube texture
  7876. */
  7877. clone(): CubeTexture;
  7878. }
  7879. }
  7880. declare module "babylonjs/Materials/materialDefines" {
  7881. /**
  7882. * Manages the defines for the Material
  7883. */
  7884. export class MaterialDefines {
  7885. /** @hidden */
  7886. protected _keys: string[];
  7887. private _isDirty;
  7888. /** @hidden */
  7889. _renderId: number;
  7890. /** @hidden */
  7891. _areLightsDirty: boolean;
  7892. /** @hidden */
  7893. _areLightsDisposed: boolean;
  7894. /** @hidden */
  7895. _areAttributesDirty: boolean;
  7896. /** @hidden */
  7897. _areTexturesDirty: boolean;
  7898. /** @hidden */
  7899. _areFresnelDirty: boolean;
  7900. /** @hidden */
  7901. _areMiscDirty: boolean;
  7902. /** @hidden */
  7903. _areImageProcessingDirty: boolean;
  7904. /** @hidden */
  7905. _normals: boolean;
  7906. /** @hidden */
  7907. _uvs: boolean;
  7908. /** @hidden */
  7909. _needNormals: boolean;
  7910. /** @hidden */
  7911. _needUVs: boolean;
  7912. [id: string]: any;
  7913. /**
  7914. * Specifies if the material needs to be re-calculated
  7915. */
  7916. get isDirty(): boolean;
  7917. /**
  7918. * Marks the material to indicate that it has been re-calculated
  7919. */
  7920. markAsProcessed(): void;
  7921. /**
  7922. * Marks the material to indicate that it needs to be re-calculated
  7923. */
  7924. markAsUnprocessed(): void;
  7925. /**
  7926. * Marks the material to indicate all of its defines need to be re-calculated
  7927. */
  7928. markAllAsDirty(): void;
  7929. /**
  7930. * Marks the material to indicate that image processing needs to be re-calculated
  7931. */
  7932. markAsImageProcessingDirty(): void;
  7933. /**
  7934. * Marks the material to indicate the lights need to be re-calculated
  7935. * @param disposed Defines whether the light is dirty due to dispose or not
  7936. */
  7937. markAsLightDirty(disposed?: boolean): void;
  7938. /**
  7939. * Marks the attribute state as changed
  7940. */
  7941. markAsAttributesDirty(): void;
  7942. /**
  7943. * Marks the texture state as changed
  7944. */
  7945. markAsTexturesDirty(): void;
  7946. /**
  7947. * Marks the fresnel state as changed
  7948. */
  7949. markAsFresnelDirty(): void;
  7950. /**
  7951. * Marks the misc state as changed
  7952. */
  7953. markAsMiscDirty(): void;
  7954. /**
  7955. * Rebuilds the material defines
  7956. */
  7957. rebuild(): void;
  7958. /**
  7959. * Specifies if two material defines are equal
  7960. * @param other - A material define instance to compare to
  7961. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7962. */
  7963. isEqual(other: MaterialDefines): boolean;
  7964. /**
  7965. * Clones this instance's defines to another instance
  7966. * @param other - material defines to clone values to
  7967. */
  7968. cloneTo(other: MaterialDefines): void;
  7969. /**
  7970. * Resets the material define values
  7971. */
  7972. reset(): void;
  7973. /**
  7974. * Converts the material define values to a string
  7975. * @returns - String of material define information
  7976. */
  7977. toString(): string;
  7978. }
  7979. }
  7980. declare module "babylonjs/Materials/colorCurves" {
  7981. import { Effect } from "babylonjs/Materials/effect";
  7982. /**
  7983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7985. * 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;
  7986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7987. */
  7988. export class ColorCurves {
  7989. private _dirty;
  7990. private _tempColor;
  7991. private _globalCurve;
  7992. private _highlightsCurve;
  7993. private _midtonesCurve;
  7994. private _shadowsCurve;
  7995. private _positiveCurve;
  7996. private _negativeCurve;
  7997. private _globalHue;
  7998. private _globalDensity;
  7999. private _globalSaturation;
  8000. private _globalExposure;
  8001. /**
  8002. * Gets the global Hue value.
  8003. * 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).
  8004. */
  8005. get globalHue(): number;
  8006. /**
  8007. * Sets the global Hue value.
  8008. * 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).
  8009. */
  8010. set globalHue(value: number);
  8011. /**
  8012. * Gets the global Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get globalDensity(): number;
  8017. /**
  8018. * Sets the global Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set globalDensity(value: number);
  8023. /**
  8024. * Gets the global Saturation value.
  8025. * 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.
  8026. */
  8027. get globalSaturation(): number;
  8028. /**
  8029. * Sets the global Saturation value.
  8030. * 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.
  8031. */
  8032. set globalSaturation(value: number);
  8033. /**
  8034. * Gets the global Exposure value.
  8035. * 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.
  8036. */
  8037. get globalExposure(): number;
  8038. /**
  8039. * Sets the global Exposure value.
  8040. * 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.
  8041. */
  8042. set globalExposure(value: number);
  8043. private _highlightsHue;
  8044. private _highlightsDensity;
  8045. private _highlightsSaturation;
  8046. private _highlightsExposure;
  8047. /**
  8048. * Gets the highlights Hue value.
  8049. * 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).
  8050. */
  8051. get highlightsHue(): number;
  8052. /**
  8053. * Sets the highlights Hue value.
  8054. * 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).
  8055. */
  8056. set highlightsHue(value: number);
  8057. /**
  8058. * Gets the highlights Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get highlightsDensity(): number;
  8063. /**
  8064. * Sets the highlights Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set highlightsDensity(value: number);
  8069. /**
  8070. * Gets the highlights Saturation value.
  8071. * 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.
  8072. */
  8073. get highlightsSaturation(): number;
  8074. /**
  8075. * Sets the highlights Saturation value.
  8076. * 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.
  8077. */
  8078. set highlightsSaturation(value: number);
  8079. /**
  8080. * Gets the highlights Exposure value.
  8081. * 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.
  8082. */
  8083. get highlightsExposure(): number;
  8084. /**
  8085. * Sets the highlights Exposure value.
  8086. * 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.
  8087. */
  8088. set highlightsExposure(value: number);
  8089. private _midtonesHue;
  8090. private _midtonesDensity;
  8091. private _midtonesSaturation;
  8092. private _midtonesExposure;
  8093. /**
  8094. * Gets the midtones Hue value.
  8095. * 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).
  8096. */
  8097. get midtonesHue(): number;
  8098. /**
  8099. * Sets the midtones Hue value.
  8100. * 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).
  8101. */
  8102. set midtonesHue(value: number);
  8103. /**
  8104. * Gets the midtones Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get midtonesDensity(): number;
  8109. /**
  8110. * Sets the midtones Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set midtonesDensity(value: number);
  8115. /**
  8116. * Gets the midtones Saturation value.
  8117. * 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.
  8118. */
  8119. get midtonesSaturation(): number;
  8120. /**
  8121. * Sets the midtones Saturation value.
  8122. * 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.
  8123. */
  8124. set midtonesSaturation(value: number);
  8125. /**
  8126. * Gets the midtones Exposure value.
  8127. * 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.
  8128. */
  8129. get midtonesExposure(): number;
  8130. /**
  8131. * Sets the midtones Exposure value.
  8132. * 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.
  8133. */
  8134. set midtonesExposure(value: number);
  8135. private _shadowsHue;
  8136. private _shadowsDensity;
  8137. private _shadowsSaturation;
  8138. private _shadowsExposure;
  8139. /**
  8140. * Gets the shadows Hue value.
  8141. * 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).
  8142. */
  8143. get shadowsHue(): number;
  8144. /**
  8145. * Sets the shadows Hue value.
  8146. * 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).
  8147. */
  8148. set shadowsHue(value: number);
  8149. /**
  8150. * Gets the shadows Density value.
  8151. * 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.
  8152. * Values less than zero provide a filter of opposite hue.
  8153. */
  8154. get shadowsDensity(): number;
  8155. /**
  8156. * Sets the shadows Density value.
  8157. * 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.
  8158. * Values less than zero provide a filter of opposite hue.
  8159. */
  8160. set shadowsDensity(value: number);
  8161. /**
  8162. * Gets the shadows Saturation value.
  8163. * 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.
  8164. */
  8165. get shadowsSaturation(): number;
  8166. /**
  8167. * Sets the shadows Saturation value.
  8168. * 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.
  8169. */
  8170. set shadowsSaturation(value: number);
  8171. /**
  8172. * Gets the shadows Exposure value.
  8173. * 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.
  8174. */
  8175. get shadowsExposure(): number;
  8176. /**
  8177. * Sets the shadows Exposure value.
  8178. * 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.
  8179. */
  8180. set shadowsExposure(value: number);
  8181. /**
  8182. * Returns the class name
  8183. * @returns The class name
  8184. */
  8185. getClassName(): string;
  8186. /**
  8187. * Binds the color curves to the shader.
  8188. * @param colorCurves The color curve to bind
  8189. * @param effect The effect to bind to
  8190. * @param positiveUniform The positive uniform shader parameter
  8191. * @param neutralUniform The neutral uniform shader parameter
  8192. * @param negativeUniform The negative uniform shader parameter
  8193. */
  8194. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8195. /**
  8196. * Prepare the list of uniforms associated with the ColorCurves effects.
  8197. * @param uniformsList The list of uniforms used in the effect
  8198. */
  8199. static PrepareUniforms(uniformsList: string[]): void;
  8200. /**
  8201. * Returns color grading data based on a hue, density, saturation and exposure value.
  8202. * @param filterHue The hue of the color filter.
  8203. * @param filterDensity The density of the color filter.
  8204. * @param saturation The saturation.
  8205. * @param exposure The exposure.
  8206. * @param result The result data container.
  8207. */
  8208. private getColorGradingDataToRef;
  8209. /**
  8210. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8211. * @param value The input slider value in range [-100,100].
  8212. * @returns Adjusted value.
  8213. */
  8214. private static applyColorGradingSliderNonlinear;
  8215. /**
  8216. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8217. * @param hue The hue (H) input.
  8218. * @param saturation The saturation (S) input.
  8219. * @param brightness The brightness (B) input.
  8220. * @result An RGBA color represented as Vector4.
  8221. */
  8222. private static fromHSBToRef;
  8223. /**
  8224. * Returns a value clamped between min and max
  8225. * @param value The value to clamp
  8226. * @param min The minimum of value
  8227. * @param max The maximum of value
  8228. * @returns The clamped value.
  8229. */
  8230. private static clamp;
  8231. /**
  8232. * Clones the current color curve instance.
  8233. * @return The cloned curves
  8234. */
  8235. clone(): ColorCurves;
  8236. /**
  8237. * Serializes the current color curve instance to a json representation.
  8238. * @return a JSON representation
  8239. */
  8240. serialize(): any;
  8241. /**
  8242. * Parses the color curve from a json representation.
  8243. * @param source the JSON source to parse
  8244. * @return The parsed curves
  8245. */
  8246. static Parse(source: any): ColorCurves;
  8247. }
  8248. }
  8249. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8250. import { Observable } from "babylonjs/Misc/observable";
  8251. import { Nullable } from "babylonjs/types";
  8252. import { Color4 } from "babylonjs/Maths/math.color";
  8253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8254. import { Effect } from "babylonjs/Materials/effect";
  8255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8256. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8257. /**
  8258. * Interface to follow in your material defines to integrate easily the
  8259. * Image proccessing functions.
  8260. * @hidden
  8261. */
  8262. export interface IImageProcessingConfigurationDefines {
  8263. IMAGEPROCESSING: boolean;
  8264. VIGNETTE: boolean;
  8265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8266. VIGNETTEBLENDMODEOPAQUE: boolean;
  8267. TONEMAPPING: boolean;
  8268. TONEMAPPING_ACES: boolean;
  8269. CONTRAST: boolean;
  8270. EXPOSURE: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. }
  8278. /**
  8279. * @hidden
  8280. */
  8281. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8282. IMAGEPROCESSING: boolean;
  8283. VIGNETTE: boolean;
  8284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8285. VIGNETTEBLENDMODEOPAQUE: boolean;
  8286. TONEMAPPING: boolean;
  8287. TONEMAPPING_ACES: boolean;
  8288. CONTRAST: boolean;
  8289. COLORCURVES: boolean;
  8290. COLORGRADING: boolean;
  8291. COLORGRADING3D: boolean;
  8292. SAMPLER3DGREENDEPTH: boolean;
  8293. SAMPLER3DBGRMAP: boolean;
  8294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8295. EXPOSURE: boolean;
  8296. constructor();
  8297. }
  8298. /**
  8299. * This groups together the common properties used for image processing either in direct forward pass
  8300. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8301. * or not.
  8302. */
  8303. export class ImageProcessingConfiguration {
  8304. /**
  8305. * Default tone mapping applied in BabylonJS.
  8306. */
  8307. static readonly TONEMAPPING_STANDARD: number;
  8308. /**
  8309. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8310. * to other engines rendering to increase portability.
  8311. */
  8312. static readonly TONEMAPPING_ACES: number;
  8313. /**
  8314. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8315. */
  8316. colorCurves: Nullable<ColorCurves>;
  8317. private _colorCurvesEnabled;
  8318. /**
  8319. * Gets wether the color curves effect is enabled.
  8320. */
  8321. get colorCurvesEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color curves effect is enabled.
  8324. */
  8325. set colorCurvesEnabled(value: boolean);
  8326. private _colorGradingTexture;
  8327. /**
  8328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8329. */
  8330. get colorGradingTexture(): Nullable<BaseTexture>;
  8331. /**
  8332. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8333. */
  8334. set colorGradingTexture(value: Nullable<BaseTexture>);
  8335. private _colorGradingEnabled;
  8336. /**
  8337. * Gets wether the color grading effect is enabled.
  8338. */
  8339. get colorGradingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the color grading effect is enabled.
  8342. */
  8343. set colorGradingEnabled(value: boolean);
  8344. private _colorGradingWithGreenDepth;
  8345. /**
  8346. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8347. */
  8348. get colorGradingWithGreenDepth(): boolean;
  8349. /**
  8350. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8351. */
  8352. set colorGradingWithGreenDepth(value: boolean);
  8353. private _colorGradingBGR;
  8354. /**
  8355. * Gets wether the color grading texture contains BGR values.
  8356. */
  8357. get colorGradingBGR(): boolean;
  8358. /**
  8359. * Sets wether the color grading texture contains BGR values.
  8360. */
  8361. set colorGradingBGR(value: boolean);
  8362. /** @hidden */
  8363. _exposure: number;
  8364. /**
  8365. * Gets the Exposure used in the effect.
  8366. */
  8367. get exposure(): number;
  8368. /**
  8369. * Sets the Exposure used in the effect.
  8370. */
  8371. set exposure(value: number);
  8372. private _toneMappingEnabled;
  8373. /**
  8374. * Gets wether the tone mapping effect is enabled.
  8375. */
  8376. get toneMappingEnabled(): boolean;
  8377. /**
  8378. * Sets wether the tone mapping effect is enabled.
  8379. */
  8380. set toneMappingEnabled(value: boolean);
  8381. private _toneMappingType;
  8382. /**
  8383. * Gets the type of tone mapping effect.
  8384. */
  8385. get toneMappingType(): number;
  8386. /**
  8387. * Sets the type of tone mapping effect used in BabylonJS.
  8388. */
  8389. set toneMappingType(value: number);
  8390. protected _contrast: number;
  8391. /**
  8392. * Gets the contrast used in the effect.
  8393. */
  8394. get contrast(): number;
  8395. /**
  8396. * Sets the contrast used in the effect.
  8397. */
  8398. set contrast(value: number);
  8399. /**
  8400. * Vignette stretch size.
  8401. */
  8402. vignetteStretch: number;
  8403. /**
  8404. * Vignette centre X Offset.
  8405. */
  8406. vignetteCentreX: number;
  8407. /**
  8408. * Vignette centre Y Offset.
  8409. */
  8410. vignetteCentreY: number;
  8411. /**
  8412. * Vignette weight or intensity of the vignette effect.
  8413. */
  8414. vignetteWeight: number;
  8415. /**
  8416. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8417. * if vignetteEnabled is set to true.
  8418. */
  8419. vignetteColor: Color4;
  8420. /**
  8421. * Camera field of view used by the Vignette effect.
  8422. */
  8423. vignetteCameraFov: number;
  8424. private _vignetteBlendMode;
  8425. /**
  8426. * Gets the vignette blend mode allowing different kind of effect.
  8427. */
  8428. get vignetteBlendMode(): number;
  8429. /**
  8430. * Sets the vignette blend mode allowing different kind of effect.
  8431. */
  8432. set vignetteBlendMode(value: number);
  8433. private _vignetteEnabled;
  8434. /**
  8435. * Gets wether the vignette effect is enabled.
  8436. */
  8437. get vignetteEnabled(): boolean;
  8438. /**
  8439. * Sets wether the vignette effect is enabled.
  8440. */
  8441. set vignetteEnabled(value: boolean);
  8442. private _applyByPostProcess;
  8443. /**
  8444. * Gets wether the image processing is applied through a post process or not.
  8445. */
  8446. get applyByPostProcess(): boolean;
  8447. /**
  8448. * Sets wether the image processing is applied through a post process or not.
  8449. */
  8450. set applyByPostProcess(value: boolean);
  8451. private _isEnabled;
  8452. /**
  8453. * Gets wether the image processing is enabled or not.
  8454. */
  8455. get isEnabled(): boolean;
  8456. /**
  8457. * Sets wether the image processing is enabled or not.
  8458. */
  8459. set isEnabled(value: boolean);
  8460. /**
  8461. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8462. */
  8463. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8464. /**
  8465. * Method called each time the image processing information changes requires to recompile the effect.
  8466. */
  8467. protected _updateParameters(): void;
  8468. /**
  8469. * Gets the current class name.
  8470. * @return "ImageProcessingConfiguration"
  8471. */
  8472. getClassName(): string;
  8473. /**
  8474. * Prepare the list of uniforms associated with the Image Processing effects.
  8475. * @param uniforms The list of uniforms used in the effect
  8476. * @param defines the list of defines currently in use
  8477. */
  8478. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8479. /**
  8480. * Prepare the list of samplers associated with the Image Processing effects.
  8481. * @param samplersList The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of defines associated to the shader.
  8487. * @param defines the list of defines to complete
  8488. * @param forPostProcess Define if we are currently in post process mode or not
  8489. */
  8490. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8491. /**
  8492. * Returns true if all the image processing information are ready.
  8493. * @returns True if ready, otherwise, false
  8494. */
  8495. isReady(): boolean;
  8496. /**
  8497. * Binds the image processing to the shader.
  8498. * @param effect The effect to bind to
  8499. * @param overrideAspectRatio Override the aspect ratio of the effect
  8500. */
  8501. bind(effect: Effect, overrideAspectRatio?: number): void;
  8502. /**
  8503. * Clones the current image processing instance.
  8504. * @return The cloned image processing
  8505. */
  8506. clone(): ImageProcessingConfiguration;
  8507. /**
  8508. * Serializes the current image processing instance to a json representation.
  8509. * @return a JSON representation
  8510. */
  8511. serialize(): any;
  8512. /**
  8513. * Parses the image processing from a json representation.
  8514. * @param source the JSON source to parse
  8515. * @return The parsed image processing
  8516. */
  8517. static Parse(source: any): ImageProcessingConfiguration;
  8518. private static _VIGNETTEMODE_MULTIPLY;
  8519. private static _VIGNETTEMODE_OPAQUE;
  8520. /**
  8521. * Used to apply the vignette as a mix with the pixel color.
  8522. */
  8523. static get VIGNETTEMODE_MULTIPLY(): number;
  8524. /**
  8525. * Used to apply the vignette as a replacement of the pixel color.
  8526. */
  8527. static get VIGNETTEMODE_OPAQUE(): number;
  8528. }
  8529. }
  8530. declare module "babylonjs/Shaders/postprocess.vertex" {
  8531. /** @hidden */
  8532. export var postprocessVertexShader: {
  8533. name: string;
  8534. shader: string;
  8535. };
  8536. }
  8537. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8540. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8541. module "babylonjs/Engines/thinEngine" {
  8542. interface ThinEngine {
  8543. /**
  8544. * Creates a new render target texture
  8545. * @param size defines the size of the texture
  8546. * @param options defines the options used to create the texture
  8547. * @returns a new render target texture stored in an InternalTexture
  8548. */
  8549. createRenderTargetTexture(size: number | {
  8550. width: number;
  8551. height: number;
  8552. layers?: number;
  8553. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8554. /**
  8555. * Creates a depth stencil texture.
  8556. * This is only available in WebGL 2 or with the depth texture extension available.
  8557. * @param size The size of face edge in the texture.
  8558. * @param options The options defining the texture.
  8559. * @returns The texture
  8560. */
  8561. createDepthStencilTexture(size: number | {
  8562. width: number;
  8563. height: number;
  8564. layers?: number;
  8565. }, options: DepthTextureCreationOptions): InternalTexture;
  8566. /** @hidden */
  8567. _createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. }
  8573. }
  8574. }
  8575. declare module "babylonjs/Maths/math.axis" {
  8576. import { Vector3 } from "babylonjs/Maths/math.vector";
  8577. /** Defines supported spaces */
  8578. export enum Space {
  8579. /** Local (object) space */
  8580. LOCAL = 0,
  8581. /** World space */
  8582. WORLD = 1,
  8583. /** Bone space */
  8584. BONE = 2
  8585. }
  8586. /** Defines the 3 main axes */
  8587. export class Axis {
  8588. /** X axis */
  8589. static X: Vector3;
  8590. /** Y axis */
  8591. static Y: Vector3;
  8592. /** Z axis */
  8593. static Z: Vector3;
  8594. }
  8595. }
  8596. declare module "babylonjs/Cameras/targetCamera" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Camera } from "babylonjs/Cameras/camera";
  8599. import { Scene } from "babylonjs/scene";
  8600. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8601. /**
  8602. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8603. * This is the base of the follow, arc rotate cameras and Free camera
  8604. * @see http://doc.babylonjs.com/features/cameras
  8605. */
  8606. export class TargetCamera extends Camera {
  8607. private static _RigCamTransformMatrix;
  8608. private static _TargetTransformMatrix;
  8609. private static _TargetFocalPoint;
  8610. /**
  8611. * Define the current direction the camera is moving to
  8612. */
  8613. cameraDirection: Vector3;
  8614. /**
  8615. * Define the current rotation the camera is rotating to
  8616. */
  8617. cameraRotation: Vector2;
  8618. /**
  8619. * When set, the up vector of the camera will be updated by the rotation of the camera
  8620. */
  8621. updateUpVectorFromRotation: boolean;
  8622. private _tmpQuaternion;
  8623. /**
  8624. * Define the current rotation of the camera
  8625. */
  8626. rotation: Vector3;
  8627. /**
  8628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8629. */
  8630. rotationQuaternion: Quaternion;
  8631. /**
  8632. * Define the current speed of the camera
  8633. */
  8634. speed: number;
  8635. /**
  8636. * Add constraint to the camera to prevent it to move freely in all directions and
  8637. * around all axis.
  8638. */
  8639. noRotationConstraint: boolean;
  8640. /**
  8641. * Define the current target of the camera as an object or a position.
  8642. */
  8643. lockedTarget: any;
  8644. /** @hidden */
  8645. _currentTarget: Vector3;
  8646. /** @hidden */
  8647. _initialFocalDistance: number;
  8648. /** @hidden */
  8649. _viewMatrix: Matrix;
  8650. /** @hidden */
  8651. _camMatrix: Matrix;
  8652. /** @hidden */
  8653. _cameraTransformMatrix: Matrix;
  8654. /** @hidden */
  8655. _cameraRotationMatrix: Matrix;
  8656. /** @hidden */
  8657. _referencePoint: Vector3;
  8658. /** @hidden */
  8659. _transformedReferencePoint: Vector3;
  8660. protected _globalCurrentTarget: Vector3;
  8661. protected _globalCurrentUpVector: Vector3;
  8662. /** @hidden */
  8663. _reset: () => void;
  8664. private _defaultUp;
  8665. /**
  8666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8667. * This is the base of the follow, arc rotate cameras and Free camera
  8668. * @see http://doc.babylonjs.com/features/cameras
  8669. * @param name Defines the name of the camera in the scene
  8670. * @param position Defines the start position of the camera in the scene
  8671. * @param scene Defines the scene the camera belongs to
  8672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8675. /**
  8676. * Gets the position in front of the camera at a given distance.
  8677. * @param distance The distance from the camera we want the position to be
  8678. * @returns the position
  8679. */
  8680. getFrontPosition(distance: number): Vector3;
  8681. /** @hidden */
  8682. _getLockedTargetPosition(): Nullable<Vector3>;
  8683. private _storedPosition;
  8684. private _storedRotation;
  8685. private _storedRotationQuaternion;
  8686. /**
  8687. * Store current camera state of the camera (fov, position, rotation, etc..)
  8688. * @returns the camera
  8689. */
  8690. storeState(): Camera;
  8691. /**
  8692. * Restored camera state. You must call storeState() first
  8693. * @returns whether it was successful or not
  8694. * @hidden
  8695. */
  8696. _restoreStateValues(): boolean;
  8697. /** @hidden */
  8698. _initCache(): void;
  8699. /** @hidden */
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. /** @hidden */
  8702. _isSynchronizedViewMatrix(): boolean;
  8703. /** @hidden */
  8704. _computeLocalCameraSpeed(): number;
  8705. /**
  8706. * Defines the target the camera should look at.
  8707. * @param target Defines the new target as a Vector or a mesh
  8708. */
  8709. setTarget(target: Vector3): void;
  8710. /**
  8711. * Return the current target position of the camera. This value is expressed in local space.
  8712. * @returns the target position
  8713. */
  8714. getTarget(): Vector3;
  8715. /** @hidden */
  8716. _decideIfNeedsToMove(): boolean;
  8717. /** @hidden */
  8718. _updatePosition(): void;
  8719. /** @hidden */
  8720. _checkInputs(): void;
  8721. protected _updateCameraRotationMatrix(): void;
  8722. /**
  8723. * 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)
  8724. * @returns the current camera
  8725. */
  8726. private _rotateUpVectorWithCameraRotationMatrix;
  8727. private _cachedRotationZ;
  8728. private _cachedQuaternionRotationZ;
  8729. /** @hidden */
  8730. _getViewMatrix(): Matrix;
  8731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8732. /**
  8733. * @hidden
  8734. */
  8735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8736. /**
  8737. * @hidden
  8738. */
  8739. _updateRigCameras(): void;
  8740. private _getRigCamPositionAndTarget;
  8741. /**
  8742. * Gets the current object class name.
  8743. * @return the class name
  8744. */
  8745. getClassName(): string;
  8746. }
  8747. }
  8748. declare module "babylonjs/Events/keyboardEvents" {
  8749. /**
  8750. * Gather the list of keyboard event types as constants.
  8751. */
  8752. export class KeyboardEventTypes {
  8753. /**
  8754. * The keydown event is fired when a key becomes active (pressed).
  8755. */
  8756. static readonly KEYDOWN: number;
  8757. /**
  8758. * The keyup event is fired when a key has been released.
  8759. */
  8760. static readonly KEYUP: number;
  8761. }
  8762. /**
  8763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8764. */
  8765. export class KeyboardInfo {
  8766. /**
  8767. * Defines the type of event (KeyboardEventTypes)
  8768. */
  8769. type: number;
  8770. /**
  8771. * Defines the related dom event
  8772. */
  8773. event: KeyboardEvent;
  8774. /**
  8775. * Instantiates a new keyboard info.
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. /**
  8791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8793. */
  8794. export class KeyboardInfoPre extends KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8805. */
  8806. skipOnPointerObservable: boolean;
  8807. /**
  8808. * Instantiates a new keyboard pre info.
  8809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8810. * @param type Defines the type of event (KeyboardEventTypes)
  8811. * @param event Defines the related dom event
  8812. */
  8813. constructor(
  8814. /**
  8815. * Defines the type of event (KeyboardEventTypes)
  8816. */
  8817. type: number,
  8818. /**
  8819. * Defines the related dom event
  8820. */
  8821. event: KeyboardEvent);
  8822. }
  8823. }
  8824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8825. import { Nullable } from "babylonjs/types";
  8826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8828. /**
  8829. * Manage the keyboard inputs to control the movement of a free camera.
  8830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8831. */
  8832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8833. /**
  8834. * Defines the camera the input is attached to.
  8835. */
  8836. camera: FreeCamera;
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8839. */
  8840. keysUp: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8843. */
  8844. keysDown: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8847. */
  8848. keysLeft: number[];
  8849. /**
  8850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8851. */
  8852. keysRight: number[];
  8853. private _keys;
  8854. private _onCanvasBlurObserver;
  8855. private _onKeyboardObserver;
  8856. private _engine;
  8857. private _scene;
  8858. /**
  8859. * Attach the input controls to a specific dom element to get the input from.
  8860. * @param element Defines the element the controls should be listened from
  8861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8862. */
  8863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8864. /**
  8865. * Detach the current controls from the specified dom element.
  8866. * @param element Defines the element to stop listening the inputs from
  8867. */
  8868. detachControl(element: Nullable<HTMLElement>): void;
  8869. /**
  8870. * Update the current camera state depending on the inputs that have been used this frame.
  8871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8872. */
  8873. checkInputs(): void;
  8874. /**
  8875. * Gets the class name of the current intput.
  8876. * @returns the class name
  8877. */
  8878. getClassName(): string;
  8879. /** @hidden */
  8880. _onLostFocus(): void;
  8881. /**
  8882. * Get the friendly name associated with the input class.
  8883. * @returns the input friendly name
  8884. */
  8885. getSimpleName(): string;
  8886. }
  8887. }
  8888. declare module "babylonjs/Lights/shadowLight" {
  8889. import { Camera } from "babylonjs/Cameras/camera";
  8890. import { Scene } from "babylonjs/scene";
  8891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8893. import { Light } from "babylonjs/Lights/light";
  8894. /**
  8895. * Interface describing all the common properties and methods a shadow light needs to implement.
  8896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8897. * as well as binding the different shadow properties to the effects.
  8898. */
  8899. export interface IShadowLight extends Light {
  8900. /**
  8901. * The light id in the scene (used in scene.findLighById for instance)
  8902. */
  8903. id: string;
  8904. /**
  8905. * The position the shdow will be casted from.
  8906. */
  8907. position: Vector3;
  8908. /**
  8909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8910. */
  8911. direction: Vector3;
  8912. /**
  8913. * The transformed position. Position of the light in world space taking parenting in account.
  8914. */
  8915. transformedPosition: Vector3;
  8916. /**
  8917. * The transformed direction. Direction of the light in world space taking parenting in account.
  8918. */
  8919. transformedDirection: Vector3;
  8920. /**
  8921. * The friendly name of the light in the scene.
  8922. */
  8923. name: string;
  8924. /**
  8925. * Defines the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. /**
  8929. * Defines the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Gets the scene the light belongs to.
  8939. * @returns The scene
  8940. */
  8941. getScene(): Scene;
  8942. /**
  8943. * Callback defining a custom Projection Matrix Builder.
  8944. * This can be used to override the default projection matrix computation.
  8945. */
  8946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8947. /**
  8948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8949. * @param matrix The materix to updated with the projection information
  8950. * @param viewMatrix The transform matrix of the light
  8951. * @param renderList The list of mesh to render in the map
  8952. * @returns The current light
  8953. */
  8954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8955. /**
  8956. * Gets the current depth scale used in ESM.
  8957. * @returns The scale
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8962. * @returns true if a cube texture needs to be use
  8963. */
  8964. needCube(): boolean;
  8965. /**
  8966. * Detects if the projection matrix requires to be recomputed this frame.
  8967. * @returns true if it requires to be recomputed otherwise, false.
  8968. */
  8969. needProjectionMatrixCompute(): boolean;
  8970. /**
  8971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8972. */
  8973. forceProjectionMatrixCompute(): void;
  8974. /**
  8975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8978. */
  8979. getShadowDirection(faceIndex?: number): Vector3;
  8980. /**
  8981. * Gets the minZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the min for
  8983. * @returns the depth min z
  8984. */
  8985. getDepthMinZ(activeCamera: Camera): number;
  8986. /**
  8987. * Gets the maxZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the max for
  8989. * @returns the depth max z
  8990. */
  8991. getDepthMaxZ(activeCamera: Camera): number;
  8992. }
  8993. /**
  8994. * Base implementation IShadowLight
  8995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8996. */
  8997. export abstract class ShadowLight extends Light implements IShadowLight {
  8998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8999. protected _position: Vector3;
  9000. protected _setPosition(value: Vector3): void;
  9001. /**
  9002. * Sets the position the shadow will be casted from. Also use as the light position for both
  9003. * point and spot lights.
  9004. */
  9005. get position(): Vector3;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. set position(value: Vector3);
  9011. protected _direction: Vector3;
  9012. protected _setDirection(value: Vector3): void;
  9013. /**
  9014. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. get direction(): Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9020. * Also use as the light direction on spot and directional lights.
  9021. */
  9022. set direction(value: Vector3);
  9023. protected _shadowMinZ: number;
  9024. /**
  9025. * Gets the shadow projection clipping minimum z value.
  9026. */
  9027. get shadowMinZ(): number;
  9028. /**
  9029. * Sets the shadow projection clipping minimum z value.
  9030. */
  9031. set shadowMinZ(value: number);
  9032. protected _shadowMaxZ: number;
  9033. /**
  9034. * Sets the shadow projection clipping maximum z value.
  9035. */
  9036. get shadowMaxZ(): number;
  9037. /**
  9038. * Gets the shadow projection clipping maximum z value.
  9039. */
  9040. set shadowMaxZ(value: number);
  9041. /**
  9042. * Callback defining a custom Projection Matrix Builder.
  9043. * This can be used to override the default projection matrix computation.
  9044. */
  9045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9046. /**
  9047. * The transformed position. Position of the light in world space taking parenting in account.
  9048. */
  9049. transformedPosition: Vector3;
  9050. /**
  9051. * The transformed direction. Direction of the light in world space taking parenting in account.
  9052. */
  9053. transformedDirection: Vector3;
  9054. private _needProjectionMatrixCompute;
  9055. /**
  9056. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9057. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9058. */
  9059. computeTransformedInformation(): boolean;
  9060. /**
  9061. * Return the depth scale used for the shadow map.
  9062. * @returns the depth scale.
  9063. */
  9064. getDepthScale(): number;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Returns the ShadowLight absolute position in the World.
  9073. * @returns the position vector in world space
  9074. */
  9075. getAbsolutePosition(): Vector3;
  9076. /**
  9077. * Sets the ShadowLight direction toward the passed target.
  9078. * @param target The point to target in local space
  9079. * @returns the updated ShadowLight direction
  9080. */
  9081. setDirectionToTarget(target: Vector3): Vector3;
  9082. /**
  9083. * Returns the light rotation in euler definition.
  9084. * @returns the x y z rotation in local space.
  9085. */
  9086. getRotation(): Vector3;
  9087. /**
  9088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9089. * @returns true if a cube texture needs to be use
  9090. */
  9091. needCube(): boolean;
  9092. /**
  9093. * Detects if the projection matrix requires to be recomputed this frame.
  9094. * @returns true if it requires to be recomputed otherwise, false.
  9095. */
  9096. needProjectionMatrixCompute(): boolean;
  9097. /**
  9098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9099. */
  9100. forceProjectionMatrixCompute(): void;
  9101. /** @hidden */
  9102. _initCache(): void;
  9103. /** @hidden */
  9104. _isSynchronized(): boolean;
  9105. /**
  9106. * Computes the world matrix of the node
  9107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9108. * @returns the world matrix
  9109. */
  9110. computeWorldMatrix(force?: boolean): Matrix;
  9111. /**
  9112. * Gets the minZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the min for
  9114. * @returns the depth min z
  9115. */
  9116. getDepthMinZ(activeCamera: Camera): number;
  9117. /**
  9118. * Gets the maxZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the max for
  9120. * @returns the depth max z
  9121. */
  9122. getDepthMaxZ(activeCamera: Camera): number;
  9123. /**
  9124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9125. * @param matrix The materix to updated with the projection information
  9126. * @param viewMatrix The transform matrix of the light
  9127. * @param renderList The list of mesh to render in the map
  9128. * @returns The current light
  9129. */
  9130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9131. }
  9132. }
  9133. declare module "babylonjs/Materials/effectFallbacks" {
  9134. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9135. import { Effect } from "babylonjs/Materials/effect";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. /**
  9138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9140. */
  9141. export class EffectFallbacks implements IEffectFallbacks {
  9142. private _defines;
  9143. private _currentRank;
  9144. private _maxRank;
  9145. private _mesh;
  9146. /**
  9147. * Removes the fallback from the bound mesh.
  9148. */
  9149. unBindMesh(): void;
  9150. /**
  9151. * Adds a fallback on the specified property.
  9152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9153. * @param define The name of the define in the shader
  9154. */
  9155. addFallback(rank: number, define: string): void;
  9156. /**
  9157. * Sets the mesh to use CPU skinning when needing to fallback.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param mesh The mesh to use the fallbacks.
  9160. */
  9161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9162. /**
  9163. * Checks to see if more fallbacks are still availible.
  9164. */
  9165. get hasMoreFallbacks(): boolean;
  9166. /**
  9167. * Removes the defines that should be removed when falling back.
  9168. * @param currentDefines defines the current define statements for the shader.
  9169. * @param effect defines the current effect we try to compile
  9170. * @returns The resulting defines with defines of the current rank removed.
  9171. */
  9172. reduce(currentDefines: string, effect: Effect): string;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/materialHelper" {
  9176. import { Nullable } from "babylonjs/types";
  9177. import { Scene } from "babylonjs/scene";
  9178. import { Engine } from "babylonjs/Engines/engine";
  9179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9180. import { Light } from "babylonjs/Lights/light";
  9181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9185. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9186. /**
  9187. * "Static Class" containing the most commonly used helper while dealing with material for
  9188. * rendering purpose.
  9189. *
  9190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9191. *
  9192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9193. */
  9194. export class MaterialHelper {
  9195. /**
  9196. * Bind the current view position to an effect.
  9197. * @param effect The effect to be bound
  9198. * @param scene The scene the eyes position is used from
  9199. */
  9200. static BindEyePosition(effect: Effect, scene: Scene): void;
  9201. /**
  9202. * Helps preparing the defines values about the UVs in used in the effect.
  9203. * UVs are shared as much as we can accross channels in the shaders.
  9204. * @param texture The texture we are preparing the UVs for
  9205. * @param defines The defines to update
  9206. * @param key The channel key "diffuse", "specular"... used in the shader
  9207. */
  9208. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9209. /**
  9210. * Binds a texture matrix value to its corrsponding uniform
  9211. * @param texture The texture to bind the matrix for
  9212. * @param uniformBuffer The uniform buffer receivin the data
  9213. * @param key The channel key "diffuse", "specular"... used in the shader
  9214. */
  9215. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9216. /**
  9217. * Gets the current status of the fog (should it be enabled?)
  9218. * @param mesh defines the mesh to evaluate for fog support
  9219. * @param scene defines the hosting scene
  9220. * @returns true if fog must be enabled
  9221. */
  9222. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9223. /**
  9224. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9225. * @param mesh defines the current mesh
  9226. * @param scene defines the current scene
  9227. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9228. * @param pointsCloud defines if point cloud rendering has to be turned on
  9229. * @param fogEnabled defines if fog has to be turned on
  9230. * @param alphaTest defines if alpha testing has to be turned on
  9231. * @param defines defines the current list of defines
  9232. */
  9233. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9234. /**
  9235. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9236. * @param scene defines the current scene
  9237. * @param engine defines the current engine
  9238. * @param defines specifies the list of active defines
  9239. * @param useInstances defines if instances have to be turned on
  9240. * @param useClipPlane defines if clip plane have to be turned on
  9241. */
  9242. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9243. /**
  9244. * Prepares the defines for bones
  9245. * @param mesh The mesh containing the geometry data we will draw
  9246. * @param defines The defines to update
  9247. */
  9248. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9249. /**
  9250. * Prepares the defines for morph targets
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9260. * @param useBones Precise whether bones should be used or not (override mesh info)
  9261. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9262. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9263. * @returns false if defines are considered not dirty and have not been checked
  9264. */
  9265. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9266. /**
  9267. * Prepares the defines related to multiview
  9268. * @param scene The scene we are intending to draw
  9269. * @param defines The defines to update
  9270. */
  9271. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param light The light the effect is compiling for
  9277. * @param lightIndex The index of the light
  9278. * @param defines The defines to update
  9279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9280. * @param state Defines the current state regarding what is needed (normals, etc...)
  9281. */
  9282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9283. needNormals: boolean;
  9284. needRebuild: boolean;
  9285. shadowEnabled: boolean;
  9286. specularEnabled: boolean;
  9287. lightmapMode: boolean;
  9288. }): void;
  9289. /**
  9290. * Prepares the defines related to the light information passed in parameter
  9291. * @param scene The scene we are intending to draw
  9292. * @param mesh The mesh the effect is compiling for
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9297. * @returns true if normals will be required for the rest of the effect
  9298. */
  9299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9300. /**
  9301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9302. * @param lightIndex defines the light index
  9303. * @param uniformsList The uniform list
  9304. * @param samplersList The sampler list
  9305. * @param projectedLightTexture defines if projected texture must be used
  9306. * @param uniformBuffersList defines an optional list of uniform buffers
  9307. */
  9308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9309. /**
  9310. * Prepares the uniforms and samplers list to be used in the effect
  9311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9312. * @param samplersList The sampler list
  9313. * @param defines The defines helping in the list generation
  9314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9315. */
  9316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9317. /**
  9318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9319. * @param defines The defines to update while falling back
  9320. * @param fallbacks The authorized effect fallbacks
  9321. * @param maxSimultaneousLights The maximum number of lights allowed
  9322. * @param rank the current rank of the Effect
  9323. * @returns The newly affected rank
  9324. */
  9325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9326. private static _TmpMorphInfluencers;
  9327. /**
  9328. * Prepares the list of attributes required for morph targets according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the morph targets attributes for
  9331. * @param influencers The number of influencers
  9332. */
  9333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9334. /**
  9335. * Prepares the list of attributes required for morph targets according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param mesh The mesh to prepare the morph targets attributes for
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9341. /**
  9342. * Prepares the list of attributes required for bones according to the effect defines.
  9343. * @param attribs The current list of supported attribs
  9344. * @param mesh The mesh to prepare the bones attributes for
  9345. * @param defines The current Defines of the effect
  9346. * @param fallbacks The current efffect fallback strategy
  9347. */
  9348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9349. /**
  9350. * Check and prepare the list of attributes required for instances according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param defines The current MaterialDefines of the effect
  9353. */
  9354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9355. /**
  9356. * Add the list of attributes required for instances to the attribs array.
  9357. * @param attribs The current list of supported attribs
  9358. */
  9359. static PushAttributesForInstances(attribs: string[]): void;
  9360. /**
  9361. * Binds the light information to the effect.
  9362. * @param light The light containing the generator
  9363. * @param effect The effect we are binding the data to
  9364. * @param lightIndex The light index in the effect used to render
  9365. */
  9366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9367. /**
  9368. * Binds the lights information from the scene to the effect for the given mesh.
  9369. * @param light Light to bind
  9370. * @param lightIndex Light index
  9371. * @param scene The scene where the light belongs to
  9372. * @param effect The effect we are binding the data to
  9373. * @param useSpecular Defines if specular is supported
  9374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9375. */
  9376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9377. /**
  9378. * Binds the lights information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param defines The generated defines for the effect
  9383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9385. */
  9386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9387. private static _tempFogColor;
  9388. /**
  9389. * Binds the fog information from the scene to the effect for the given mesh.
  9390. * @param scene The scene the lights belongs to
  9391. * @param mesh The mesh we are binding the information to render
  9392. * @param effect The effect we are binding the data to
  9393. * @param linearSpace Defines if the fog effect is applied in linear space
  9394. */
  9395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9396. /**
  9397. * Binds the bones information from the mesh to the effect.
  9398. * @param mesh The mesh we are binding the information to render
  9399. * @param effect The effect we are binding the data to
  9400. */
  9401. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9402. /**
  9403. * Binds the morph targets information from the mesh to the effect.
  9404. * @param abstractMesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9408. /**
  9409. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9410. * @param defines The generated defines used in the effect
  9411. * @param effect The effect we are binding the data to
  9412. * @param scene The scene we are willing to render with logarithmic scale for
  9413. */
  9414. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9415. /**
  9416. * Binds the clip plane information from the scene to the effect.
  9417. * @param scene The scene the clip plane information are extracted from
  9418. * @param effect The effect we are binding the data to
  9419. */
  9420. static BindClipPlane(effect: Effect, scene: Scene): void;
  9421. }
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9424. /** @hidden */
  9425. export var packingFunctions: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9431. /** @hidden */
  9432. export var clipPlaneFragmentDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9438. /** @hidden */
  9439. export var clipPlaneFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. /** @hidden */
  9449. export var shadowMapPixelShader: {
  9450. name: string;
  9451. shader: string;
  9452. };
  9453. }
  9454. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9455. /** @hidden */
  9456. export var bonesDeclaration: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9462. /** @hidden */
  9463. export var morphTargetsVertexGlobalDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9476. /** @hidden */
  9477. export var instancesDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9483. /** @hidden */
  9484. export var helperFunctions: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9490. /** @hidden */
  9491. export var clipPlaneVertexDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9518. /** @hidden */
  9519. export var clipPlaneVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9535. /** @hidden */
  9536. export var shadowMapVertexShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9542. /** @hidden */
  9543. export var depthBoxBlurPixelShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Culling/ray" {
  9549. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9550. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9553. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9554. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9555. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9556. import { Plane } from "babylonjs/Maths/math.plane";
  9557. /**
  9558. * Class representing a ray with position and direction
  9559. */
  9560. export class Ray {
  9561. /** origin point */
  9562. origin: Vector3;
  9563. /** direction */
  9564. direction: Vector3;
  9565. /** length of the ray */
  9566. length: number;
  9567. private static readonly TmpVector3;
  9568. private _tmpRay;
  9569. /**
  9570. * Creates a new ray
  9571. * @param origin origin point
  9572. * @param direction direction
  9573. * @param length length of the ray
  9574. */
  9575. constructor(
  9576. /** origin point */
  9577. origin: Vector3,
  9578. /** direction */
  9579. direction: Vector3,
  9580. /** length of the ray */
  9581. length?: number);
  9582. /**
  9583. * Checks if the ray intersects a box
  9584. * @param minimum bound of the box
  9585. * @param maximum bound of the box
  9586. * @param intersectionTreshold extra extend to be added to the box in all direction
  9587. * @returns if the box was hit
  9588. */
  9589. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9590. /**
  9591. * Checks if the ray intersects a box
  9592. * @param box the bounding box to check
  9593. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9594. * @returns if the box was hit
  9595. */
  9596. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9597. /**
  9598. * If the ray hits a sphere
  9599. * @param sphere the bounding sphere to check
  9600. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9601. * @returns true if it hits the sphere
  9602. */
  9603. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9604. /**
  9605. * If the ray hits a triange
  9606. * @param vertex0 triangle vertex
  9607. * @param vertex1 triangle vertex
  9608. * @param vertex2 triangle vertex
  9609. * @returns intersection information if hit
  9610. */
  9611. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9612. /**
  9613. * Checks if ray intersects a plane
  9614. * @param plane the plane to check
  9615. * @returns the distance away it was hit
  9616. */
  9617. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9618. /**
  9619. * Calculate the intercept of a ray on a given axis
  9620. * @param axis to check 'x' | 'y' | 'z'
  9621. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9622. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9623. */
  9624. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9625. /**
  9626. * Checks if ray intersects a mesh
  9627. * @param mesh the mesh to check
  9628. * @param fastCheck if only the bounding box should checked
  9629. * @returns picking info of the intersecton
  9630. */
  9631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9632. /**
  9633. * Checks if ray intersects a mesh
  9634. * @param meshes the meshes to check
  9635. * @param fastCheck if only the bounding box should checked
  9636. * @param results array to store result in
  9637. * @returns Array of picking infos
  9638. */
  9639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9640. private _comparePickingInfo;
  9641. private static smallnum;
  9642. private static rayl;
  9643. /**
  9644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9645. * @param sega the first point of the segment to test the intersection against
  9646. * @param segb the second point of the segment to test the intersection against
  9647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9649. */
  9650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9651. /**
  9652. * Update the ray from viewport position
  9653. * @param x position
  9654. * @param y y position
  9655. * @param viewportWidth viewport width
  9656. * @param viewportHeight viewport height
  9657. * @param world world matrix
  9658. * @param view view matrix
  9659. * @param projection projection matrix
  9660. * @returns this ray updated
  9661. */
  9662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9663. /**
  9664. * Creates a ray with origin and direction of 0,0,0
  9665. * @returns the new ray
  9666. */
  9667. static Zero(): Ray;
  9668. /**
  9669. * Creates a new ray from screen space and viewport
  9670. * @param x position
  9671. * @param y y position
  9672. * @param viewportWidth viewport width
  9673. * @param viewportHeight viewport height
  9674. * @param world world matrix
  9675. * @param view view matrix
  9676. * @param projection projection matrix
  9677. * @returns new ray
  9678. */
  9679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9680. /**
  9681. * 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
  9682. * transformed to the given world matrix.
  9683. * @param origin The origin point
  9684. * @param end The end point
  9685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9686. * @returns the new ray
  9687. */
  9688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9689. /**
  9690. * Transforms a ray by a matrix
  9691. * @param ray ray to transform
  9692. * @param matrix matrix to apply
  9693. * @returns the resulting new ray
  9694. */
  9695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9696. /**
  9697. * Transforms a ray by a matrix
  9698. * @param ray ray to transform
  9699. * @param matrix matrix to apply
  9700. * @param result ray to store result in
  9701. */
  9702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9703. /**
  9704. * Unproject a ray from screen space to object space
  9705. * @param sourceX defines the screen space x coordinate to use
  9706. * @param sourceY defines the screen space y coordinate to use
  9707. * @param viewportWidth defines the current width of the viewport
  9708. * @param viewportHeight defines the current height of the viewport
  9709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9710. * @param view defines the view matrix to use
  9711. * @param projection defines the projection matrix to use
  9712. */
  9713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9714. }
  9715. /**
  9716. * Type used to define predicate used to select faces when a mesh intersection is detected
  9717. */
  9718. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9719. module "babylonjs/scene" {
  9720. interface Scene {
  9721. /** @hidden */
  9722. _tempPickingRay: Nullable<Ray>;
  9723. /** @hidden */
  9724. _cachedRayForTransform: Ray;
  9725. /** @hidden */
  9726. _pickWithRayInverseMatrix: Matrix;
  9727. /** @hidden */
  9728. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9729. /** @hidden */
  9730. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9731. }
  9732. }
  9733. }
  9734. declare module "babylonjs/sceneComponent" {
  9735. import { Scene } from "babylonjs/scene";
  9736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9738. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9740. import { Nullable } from "babylonjs/types";
  9741. import { Camera } from "babylonjs/Cameras/camera";
  9742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9744. import { AbstractScene } from "babylonjs/abstractScene";
  9745. import { Mesh } from "babylonjs/Meshes/mesh";
  9746. /**
  9747. * Groups all the scene component constants in one place to ease maintenance.
  9748. * @hidden
  9749. */
  9750. export class SceneComponentConstants {
  9751. static readonly NAME_EFFECTLAYER: string;
  9752. static readonly NAME_LAYER: string;
  9753. static readonly NAME_LENSFLARESYSTEM: string;
  9754. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9755. static readonly NAME_PARTICLESYSTEM: string;
  9756. static readonly NAME_GAMEPAD: string;
  9757. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9758. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9759. static readonly NAME_DEPTHRENDERER: string;
  9760. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9761. static readonly NAME_SPRITE: string;
  9762. static readonly NAME_OUTLINERENDERER: string;
  9763. static readonly NAME_PROCEDURALTEXTURE: string;
  9764. static readonly NAME_SHADOWGENERATOR: string;
  9765. static readonly NAME_OCTREE: string;
  9766. static readonly NAME_PHYSICSENGINE: string;
  9767. static readonly NAME_AUDIO: string;
  9768. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9769. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9770. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9771. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9772. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9773. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9774. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9788. static readonly STEP_AFTERRENDER_AUDIO: number;
  9789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9794. static readonly STEP_POINTERMOVE_SPRITE: number;
  9795. static readonly STEP_POINTERDOWN_SPRITE: number;
  9796. static readonly STEP_POINTERUP_SPRITE: number;
  9797. }
  9798. /**
  9799. * This represents a scene component.
  9800. *
  9801. * This is used to decouple the dependency the scene is having on the different workloads like
  9802. * layers, post processes...
  9803. */
  9804. export interface ISceneComponent {
  9805. /**
  9806. * The name of the component. Each component must have a unique name.
  9807. */
  9808. name: string;
  9809. /**
  9810. * The scene the component belongs to.
  9811. */
  9812. scene: Scene;
  9813. /**
  9814. * Register the component to one instance of a scene.
  9815. */
  9816. register(): void;
  9817. /**
  9818. * Rebuilds the elements related to this component in case of
  9819. * context lost for instance.
  9820. */
  9821. rebuild(): void;
  9822. /**
  9823. * Disposes the component and the associated ressources.
  9824. */
  9825. dispose(): void;
  9826. }
  9827. /**
  9828. * This represents a SERIALIZABLE scene component.
  9829. *
  9830. * This extends Scene Component to add Serialization methods on top.
  9831. */
  9832. export interface ISceneSerializableComponent extends ISceneComponent {
  9833. /**
  9834. * Adds all the elements from the container to the scene
  9835. * @param container the container holding the elements
  9836. */
  9837. addFromContainer(container: AbstractScene): void;
  9838. /**
  9839. * Removes all the elements in the container from the scene
  9840. * @param container contains the elements to remove
  9841. * @param dispose if the removed element should be disposed (default: false)
  9842. */
  9843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9844. /**
  9845. * Serializes the component data to the specified json object
  9846. * @param serializationObject The object to serialize to
  9847. */
  9848. serialize(serializationObject: any): void;
  9849. }
  9850. /**
  9851. * Strong typing of a Mesh related stage step action
  9852. */
  9853. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9854. /**
  9855. * Strong typing of a Evaluate Sub Mesh related stage step action
  9856. */
  9857. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9858. /**
  9859. * Strong typing of a Active Mesh related stage step action
  9860. */
  9861. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9862. /**
  9863. * Strong typing of a Camera related stage step action
  9864. */
  9865. export type CameraStageAction = (camera: Camera) => void;
  9866. /**
  9867. * Strong typing of a Camera Frame buffer related stage step action
  9868. */
  9869. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9870. /**
  9871. * Strong typing of a Render Target related stage step action
  9872. */
  9873. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9874. /**
  9875. * Strong typing of a RenderingGroup related stage step action
  9876. */
  9877. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9878. /**
  9879. * Strong typing of a Mesh Render related stage step action
  9880. */
  9881. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9882. /**
  9883. * Strong typing of a simple stage step action
  9884. */
  9885. export type SimpleStageAction = () => void;
  9886. /**
  9887. * Strong typing of a render target action.
  9888. */
  9889. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9890. /**
  9891. * Strong typing of a pointer move action.
  9892. */
  9893. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9894. /**
  9895. * Strong typing of a pointer up/down action.
  9896. */
  9897. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9898. /**
  9899. * Representation of a stage in the scene (Basically a list of ordered steps)
  9900. * @hidden
  9901. */
  9902. export class Stage<T extends Function> extends Array<{
  9903. index: number;
  9904. component: ISceneComponent;
  9905. action: T;
  9906. }> {
  9907. /**
  9908. * Hide ctor from the rest of the world.
  9909. * @param items The items to add.
  9910. */
  9911. private constructor();
  9912. /**
  9913. * Creates a new Stage.
  9914. * @returns A new instance of a Stage
  9915. */
  9916. static Create<T extends Function>(): Stage<T>;
  9917. /**
  9918. * Registers a step in an ordered way in the targeted stage.
  9919. * @param index Defines the position to register the step in
  9920. * @param component Defines the component attached to the step
  9921. * @param action Defines the action to launch during the step
  9922. */
  9923. registerStep(index: number, component: ISceneComponent, action: T): void;
  9924. /**
  9925. * Clears all the steps from the stage.
  9926. */
  9927. clear(): void;
  9928. }
  9929. }
  9930. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Observable } from "babylonjs/Misc/observable";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Sprite } from "babylonjs/Sprites/sprite";
  9935. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9936. import { Ray } from "babylonjs/Culling/ray";
  9937. import { Camera } from "babylonjs/Cameras/camera";
  9938. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9939. import { ISceneComponent } from "babylonjs/sceneComponent";
  9940. module "babylonjs/scene" {
  9941. interface Scene {
  9942. /** @hidden */
  9943. _pointerOverSprite: Nullable<Sprite>;
  9944. /** @hidden */
  9945. _pickedDownSprite: Nullable<Sprite>;
  9946. /** @hidden */
  9947. _tempSpritePickingRay: Nullable<Ray>;
  9948. /**
  9949. * All of the sprite managers added to this scene
  9950. * @see http://doc.babylonjs.com/babylon101/sprites
  9951. */
  9952. spriteManagers: Array<ISpriteManager>;
  9953. /**
  9954. * An event triggered when sprites rendering is about to start
  9955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9956. */
  9957. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9958. /**
  9959. * An event triggered when sprites rendering is done
  9960. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9961. */
  9962. onAfterSpritesRenderingObservable: Observable<Scene>;
  9963. /** @hidden */
  9964. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9965. /** Launch a ray to try to pick a sprite in the scene
  9966. * @param x position on screen
  9967. * @param y position on screen
  9968. * @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
  9969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9970. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9971. * @returns a PickingInfo
  9972. */
  9973. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9974. /** Use the given ray to pick a sprite in the scene
  9975. * @param ray The ray (in world space) to use to pick meshes
  9976. * @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
  9977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9979. * @returns a PickingInfo
  9980. */
  9981. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9982. /** @hidden */
  9983. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9984. /** Launch a ray to try to pick sprites in the scene
  9985. * @param x position on screen
  9986. * @param y position on screen
  9987. * @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
  9988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9989. * @returns a PickingInfo array
  9990. */
  9991. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9992. /** Use the given ray to pick sprites in the scene
  9993. * @param ray The ray (in world space) to use to pick meshes
  9994. * @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
  9995. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9996. * @returns a PickingInfo array
  9997. */
  9998. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9999. /**
  10000. * Force the sprite under the pointer
  10001. * @param sprite defines the sprite to use
  10002. */
  10003. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10004. /**
  10005. * Gets the sprite under the pointer
  10006. * @returns a Sprite or null if no sprite is under the pointer
  10007. */
  10008. getPointerOverSprite(): Nullable<Sprite>;
  10009. }
  10010. }
  10011. /**
  10012. * Defines the sprite scene component responsible to manage sprites
  10013. * in a given scene.
  10014. */
  10015. export class SpriteSceneComponent implements ISceneComponent {
  10016. /**
  10017. * The component name helpfull to identify the component in the list of scene components.
  10018. */
  10019. readonly name: string;
  10020. /**
  10021. * The scene the component belongs to.
  10022. */
  10023. scene: Scene;
  10024. /** @hidden */
  10025. private _spritePredicate;
  10026. /**
  10027. * Creates a new instance of the component for the given scene
  10028. * @param scene Defines the scene to register the component in
  10029. */
  10030. constructor(scene: Scene);
  10031. /**
  10032. * Registers the component in a given scene
  10033. */
  10034. register(): void;
  10035. /**
  10036. * Rebuilds the elements related to this component in case of
  10037. * context lost for instance.
  10038. */
  10039. rebuild(): void;
  10040. /**
  10041. * Disposes the component and the associated ressources.
  10042. */
  10043. dispose(): void;
  10044. private _pickSpriteButKeepRay;
  10045. private _pointerMove;
  10046. private _pointerDown;
  10047. private _pointerUp;
  10048. }
  10049. }
  10050. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10051. /** @hidden */
  10052. export var fogFragmentDeclaration: {
  10053. name: string;
  10054. shader: string;
  10055. };
  10056. }
  10057. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10058. /** @hidden */
  10059. export var fogFragment: {
  10060. name: string;
  10061. shader: string;
  10062. };
  10063. }
  10064. declare module "babylonjs/Shaders/sprites.fragment" {
  10065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10066. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10067. /** @hidden */
  10068. export var spritesPixelShader: {
  10069. name: string;
  10070. shader: string;
  10071. };
  10072. }
  10073. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10074. /** @hidden */
  10075. export var fogVertexDeclaration: {
  10076. name: string;
  10077. shader: string;
  10078. };
  10079. }
  10080. declare module "babylonjs/Shaders/sprites.vertex" {
  10081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10082. /** @hidden */
  10083. export var spritesVertexShader: {
  10084. name: string;
  10085. shader: string;
  10086. };
  10087. }
  10088. declare module "babylonjs/Sprites/spriteManager" {
  10089. import { IDisposable, Scene } from "babylonjs/scene";
  10090. import { Nullable } from "babylonjs/types";
  10091. import { Observable } from "babylonjs/Misc/observable";
  10092. import { Sprite } from "babylonjs/Sprites/sprite";
  10093. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10094. import { Camera } from "babylonjs/Cameras/camera";
  10095. import { Texture } from "babylonjs/Materials/Textures/texture";
  10096. import "babylonjs/Shaders/sprites.fragment";
  10097. import "babylonjs/Shaders/sprites.vertex";
  10098. import { Ray } from "babylonjs/Culling/ray";
  10099. /**
  10100. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10101. */
  10102. export interface ISpriteManager extends IDisposable {
  10103. /**
  10104. * Restricts the camera to viewing objects with the same layerMask.
  10105. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10106. */
  10107. layerMask: number;
  10108. /**
  10109. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10110. */
  10111. isPickable: boolean;
  10112. /**
  10113. * Specifies the rendering group id for this mesh (0 by default)
  10114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10115. */
  10116. renderingGroupId: number;
  10117. /**
  10118. * Defines the list of sprites managed by the manager.
  10119. */
  10120. sprites: Array<Sprite>;
  10121. /**
  10122. * Tests the intersection of a sprite with a specific ray.
  10123. * @param ray The ray we are sending to test the collision
  10124. * @param camera The camera space we are sending rays in
  10125. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10126. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10127. * @returns picking info or null.
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Renders the list of sprites on screen.
  10140. */
  10141. render(): void;
  10142. }
  10143. /**
  10144. * Class used to manage multiple sprites on the same spritesheet
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class SpriteManager implements ISpriteManager {
  10148. /** defines the manager's name */
  10149. name: string;
  10150. /** Gets the list of sprites */
  10151. sprites: Sprite[];
  10152. /** Gets or sets the rendering group id (0 by default) */
  10153. renderingGroupId: number;
  10154. /** Gets or sets camera layer mask */
  10155. layerMask: number;
  10156. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10157. fogEnabled: boolean;
  10158. /** Gets or sets a boolean indicating if the sprites are pickable */
  10159. isPickable: boolean;
  10160. /** Defines the default width of a cell in the spritesheet */
  10161. cellWidth: number;
  10162. /** Defines the default height of a cell in the spritesheet */
  10163. cellHeight: number;
  10164. /** Associative array from JSON sprite data file */
  10165. private _cellData;
  10166. /** Array of sprite names from JSON sprite data file */
  10167. private _spriteMap;
  10168. /** True when packed cell data from JSON file is ready*/
  10169. private _packedAndReady;
  10170. /**
  10171. * An event triggered when the manager is disposed.
  10172. */
  10173. onDisposeObservable: Observable<SpriteManager>;
  10174. private _onDisposeObserver;
  10175. /**
  10176. * Callback called when the manager is disposed
  10177. */
  10178. set onDispose(callback: () => void);
  10179. private _capacity;
  10180. private _fromPacked;
  10181. private _spriteTexture;
  10182. private _epsilon;
  10183. private _scene;
  10184. private _vertexData;
  10185. private _buffer;
  10186. private _vertexBuffers;
  10187. private _indexBuffer;
  10188. private _effectBase;
  10189. private _effectFog;
  10190. /**
  10191. * Gets or sets the spritesheet texture
  10192. */
  10193. get texture(): Texture;
  10194. set texture(value: Texture);
  10195. private _blendMode;
  10196. /**
  10197. * Blend mode use to render the particle, it can be any of
  10198. * the static Constants.ALPHA_x properties provided in this class.
  10199. * Default value is Constants.ALPHA_COMBINE
  10200. */
  10201. get blendMode(): number;
  10202. set blendMode(blendMode: number);
  10203. /** Disables writing to the depth buffer when rendering the sprites.
  10204. * It can be handy to disable depth writing when using textures without alpha channel
  10205. * and setting some specific blend modes.
  10206. */
  10207. disableDepthWrite: boolean;
  10208. /**
  10209. * Creates a new sprite manager
  10210. * @param name defines the manager's name
  10211. * @param imgUrl defines the sprite sheet url
  10212. * @param capacity defines the maximum allowed number of sprites
  10213. * @param cellSize defines the size of a sprite cell
  10214. * @param scene defines the hosting scene
  10215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10216. * @param samplingMode defines the smapling mode to use with spritesheet
  10217. * @param fromPacked set to false; do not alter
  10218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10219. */
  10220. constructor(
  10221. /** defines the manager's name */
  10222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10223. private _makePacked;
  10224. private _appendSpriteVertex;
  10225. /**
  10226. * Intersects the sprites with a ray
  10227. * @param ray defines the ray to intersect with
  10228. * @param camera defines the current active camera
  10229. * @param predicate defines a predicate used to select candidate sprites
  10230. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10231. * @returns null if no hit or a PickingInfo
  10232. */
  10233. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10234. /**
  10235. * Intersects the sprites with a ray
  10236. * @param ray defines the ray to intersect with
  10237. * @param camera defines the current active camera
  10238. * @param predicate defines a predicate used to select candidate sprites
  10239. * @returns null if no hit or a PickingInfo array
  10240. */
  10241. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10242. /**
  10243. * Render all child sprites
  10244. */
  10245. render(): void;
  10246. /**
  10247. * Release associated resources
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Misc/gradients" {
  10253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10254. /** Interface used by value gradients (color, factor, ...) */
  10255. export interface IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. }
  10261. /** Class used to store color4 gradient */
  10262. export class ColorGradient implements IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. /**
  10268. * Gets or sets first associated color
  10269. */
  10270. color1: Color4;
  10271. /**
  10272. * Gets or sets second associated color
  10273. */
  10274. color2?: Color4;
  10275. /**
  10276. * Will get a color picked randomly between color1 and color2.
  10277. * If color2 is undefined then color1 will be used
  10278. * @param result defines the target Color4 to store the result in
  10279. */
  10280. getColorToRef(result: Color4): void;
  10281. }
  10282. /** Class used to store color 3 gradient */
  10283. export class Color3Gradient implements IValueGradient {
  10284. /**
  10285. * Gets or sets the gradient value (between 0 and 1)
  10286. */
  10287. gradient: number;
  10288. /**
  10289. * Gets or sets the associated color
  10290. */
  10291. color: Color3;
  10292. }
  10293. /** Class used to store factor gradient */
  10294. export class FactorGradient implements IValueGradient {
  10295. /**
  10296. * Gets or sets the gradient value (between 0 and 1)
  10297. */
  10298. gradient: number;
  10299. /**
  10300. * Gets or sets first associated factor
  10301. */
  10302. factor1: number;
  10303. /**
  10304. * Gets or sets second associated factor
  10305. */
  10306. factor2?: number;
  10307. /**
  10308. * Will get a number picked randomly between factor1 and factor2.
  10309. * If factor2 is undefined then factor1 will be used
  10310. * @returns the picked number
  10311. */
  10312. getFactor(): number;
  10313. }
  10314. /**
  10315. * Helper used to simplify some generic gradient tasks
  10316. */
  10317. export class GradientHelper {
  10318. /**
  10319. * Gets the current gradient from an array of IValueGradient
  10320. * @param ratio defines the current ratio to get
  10321. * @param gradients defines the array of IValueGradient
  10322. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10323. */
  10324. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Maths/math.size" {
  10328. /**
  10329. * Interface for the size containing width and height
  10330. */
  10331. export interface ISize {
  10332. /**
  10333. * Width
  10334. */
  10335. width: number;
  10336. /**
  10337. * Heighht
  10338. */
  10339. height: number;
  10340. }
  10341. /**
  10342. * Size containing widht and height
  10343. */
  10344. export class Size implements ISize {
  10345. /**
  10346. * Width
  10347. */
  10348. width: number;
  10349. /**
  10350. * Height
  10351. */
  10352. height: number;
  10353. /**
  10354. * Creates a Size object from the given width and height (floats).
  10355. * @param width width of the new size
  10356. * @param height height of the new size
  10357. */
  10358. constructor(width: number, height: number);
  10359. /**
  10360. * Returns a string with the Size width and height
  10361. * @returns a string with the Size width and height
  10362. */
  10363. toString(): string;
  10364. /**
  10365. * "Size"
  10366. * @returns the string "Size"
  10367. */
  10368. getClassName(): string;
  10369. /**
  10370. * Returns the Size hash code.
  10371. * @returns a hash code for a unique width and height
  10372. */
  10373. getHashCode(): number;
  10374. /**
  10375. * Updates the current size from the given one.
  10376. * @param src the given size
  10377. */
  10378. copyFrom(src: Size): void;
  10379. /**
  10380. * Updates in place the current Size from the given floats.
  10381. * @param width width of the new size
  10382. * @param height height of the new size
  10383. * @returns the updated Size.
  10384. */
  10385. copyFromFloats(width: number, height: number): Size;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width to set
  10389. * @param height height to set
  10390. * @returns the updated Size.
  10391. */
  10392. set(width: number, height: number): Size;
  10393. /**
  10394. * Multiplies the width and height by numbers
  10395. * @param w factor to multiple the width by
  10396. * @param h factor to multiple the height by
  10397. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10398. */
  10399. multiplyByFloats(w: number, h: number): Size;
  10400. /**
  10401. * Clones the size
  10402. * @returns a new Size copied from the given one.
  10403. */
  10404. clone(): Size;
  10405. /**
  10406. * True if the current Size and the given one width and height are strictly equal.
  10407. * @param other the other size to compare against
  10408. * @returns True if the current Size and the given one width and height are strictly equal.
  10409. */
  10410. equals(other: Size): boolean;
  10411. /**
  10412. * The surface of the Size : width * height (float).
  10413. */
  10414. get surface(): number;
  10415. /**
  10416. * Create a new size of zero
  10417. * @returns a new Size set to (0.0, 0.0)
  10418. */
  10419. static Zero(): Size;
  10420. /**
  10421. * Sums the width and height of two sizes
  10422. * @param otherSize size to add to this size
  10423. * @returns a new Size set as the addition result of the current Size and the given one.
  10424. */
  10425. add(otherSize: Size): Size;
  10426. /**
  10427. * Subtracts the width and height of two
  10428. * @param otherSize size to subtract to this size
  10429. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10430. */
  10431. subtract(otherSize: Size): Size;
  10432. /**
  10433. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10434. * @param start starting size to lerp between
  10435. * @param end end size to lerp between
  10436. * @param amount amount to lerp between the start and end values
  10437. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10438. */
  10439. static Lerp(start: Size, end: Size, amount: number): Size;
  10440. }
  10441. }
  10442. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10444. import { Nullable } from "babylonjs/types";
  10445. module "babylonjs/Engines/thinEngine" {
  10446. interface ThinEngine {
  10447. /**
  10448. * Creates a dynamic texture
  10449. * @param width defines the width of the texture
  10450. * @param height defines the height of the texture
  10451. * @param generateMipMaps defines if the engine should generate the mip levels
  10452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10453. * @returns the dynamic texture inside an InternalTexture
  10454. */
  10455. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10456. /**
  10457. * Update the content of a dynamic texture
  10458. * @param texture defines the texture to update
  10459. * @param canvas defines the canvas containing the source
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. * @param premulAlpha defines if alpha is stored as premultiplied
  10462. * @param format defines the format of the data
  10463. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10464. */
  10465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10466. }
  10467. }
  10468. }
  10469. declare module "babylonjs/Misc/canvasGenerator" {
  10470. /**
  10471. * Helper class used to generate a canvas to manipulate images
  10472. */
  10473. export class CanvasGenerator {
  10474. /**
  10475. * Create a new canvas (or offscreen canvas depending on the context)
  10476. * @param width defines the expected width
  10477. * @param height defines the expected height
  10478. * @return a new canvas or offscreen canvas
  10479. */
  10480. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10481. }
  10482. }
  10483. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10484. import { Scene } from "babylonjs/scene";
  10485. import { Texture } from "babylonjs/Materials/Textures/texture";
  10486. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10487. /**
  10488. * A class extending Texture allowing drawing on a texture
  10489. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10490. */
  10491. export class DynamicTexture extends Texture {
  10492. private _generateMipMaps;
  10493. private _canvas;
  10494. private _context;
  10495. private _engine;
  10496. /**
  10497. * Creates a DynamicTexture
  10498. * @param name defines the name of the texture
  10499. * @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
  10500. * @param scene defines the scene where you want the texture
  10501. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10502. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10503. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10504. */
  10505. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10506. /**
  10507. * Get the current class name of the texture useful for serialization or dynamic coding.
  10508. * @returns "DynamicTexture"
  10509. */
  10510. getClassName(): string;
  10511. /**
  10512. * Gets the current state of canRescale
  10513. */
  10514. get canRescale(): boolean;
  10515. private _recreate;
  10516. /**
  10517. * Scales the texture
  10518. * @param ratio the scale factor to apply to both width and height
  10519. */
  10520. scale(ratio: number): void;
  10521. /**
  10522. * Resizes the texture
  10523. * @param width the new width
  10524. * @param height the new height
  10525. */
  10526. scaleTo(width: number, height: number): void;
  10527. /**
  10528. * Gets the context of the canvas used by the texture
  10529. * @returns the canvas context of the dynamic texture
  10530. */
  10531. getContext(): CanvasRenderingContext2D;
  10532. /**
  10533. * Clears the texture
  10534. */
  10535. clear(): void;
  10536. /**
  10537. * Updates the texture
  10538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10539. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10540. */
  10541. update(invertY?: boolean, premulAlpha?: boolean): void;
  10542. /**
  10543. * Draws text onto the texture
  10544. * @param text defines the text to be drawn
  10545. * @param x defines the placement of the text from the left
  10546. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10547. * @param font defines the font to be used with font-style, font-size, font-name
  10548. * @param color defines the color used for the text
  10549. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10551. * @param update defines whether texture is immediately update (default is true)
  10552. */
  10553. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10554. /**
  10555. * Clones the texture
  10556. * @returns the clone of the texture.
  10557. */
  10558. clone(): DynamicTexture;
  10559. /**
  10560. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10561. * @returns a serialized dynamic texture object
  10562. */
  10563. serialize(): any;
  10564. /** @hidden */
  10565. _rebuild(): void;
  10566. }
  10567. }
  10568. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10569. import { Nullable } from "babylonjs/types";
  10570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10571. import { Scene } from "babylonjs/scene";
  10572. module "babylonjs/Engines/engine" {
  10573. interface Engine {
  10574. /**
  10575. * Creates a raw texture
  10576. * @param data defines the data to store in the texture
  10577. * @param width defines the width of the texture
  10578. * @param height defines the height of the texture
  10579. * @param format defines the format of the data
  10580. * @param generateMipMaps defines if the engine should generate the mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10583. * @param compression defines the compression used (null by default)
  10584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10585. * @returns the raw texture inside an InternalTexture
  10586. */
  10587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10588. /**
  10589. * Update a raw texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store in the texture
  10592. * @param format defines the format of the data
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store in the texture
  10600. * @param format defines the format of the data
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the compression used (null by default)
  10603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10604. */
  10605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10606. /**
  10607. * Creates a new raw cube texture
  10608. * @param data defines the array of data to use to create each face
  10609. * @param size defines the size of the textures
  10610. * @param format defines the format of the data
  10611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param compression defines the compression used (null by default)
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10619. /**
  10620. * Update a raw cube texture
  10621. * @param texture defines the texture to udpdate
  10622. * @param data defines the data to store
  10623. * @param format defines the data format
  10624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. */
  10627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10628. /**
  10629. * Update a raw cube texture
  10630. * @param texture defines the texture to udpdate
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the compression used (null by default)
  10636. */
  10637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10638. /**
  10639. * Update a raw cube texture
  10640. * @param texture defines the texture to udpdate
  10641. * @param data defines the data to store
  10642. * @param format defines the data format
  10643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10644. * @param invertY defines if data must be stored with Y axis inverted
  10645. * @param compression defines the compression used (null by default)
  10646. * @param level defines which level of the texture to update
  10647. */
  10648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10649. /**
  10650. * Creates a new raw cube texture from a specified url
  10651. * @param url defines the url where the data is located
  10652. * @param scene defines the current scene
  10653. * @param size defines the size of the textures
  10654. * @param format defines the format of the data
  10655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10656. * @param noMipmap defines if the engine should avoid generating the mip levels
  10657. * @param callback defines a callback used to extract texture data from loaded data
  10658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10659. * @param onLoad defines a callback called when texture is loaded
  10660. * @param onError defines a callback called if there is an error
  10661. * @returns the cube texture as an InternalTexture
  10662. */
  10663. 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;
  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. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param invertY defines if data must be stored with Y axis inverted
  10678. * @returns the cube texture as an InternalTexture
  10679. */
  10680. 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;
  10681. /**
  10682. * Creates a new raw 3D texture
  10683. * @param data defines the data used to create the texture
  10684. * @param width defines the width of the texture
  10685. * @param height defines the height of the texture
  10686. * @param depth defines the depth of the texture
  10687. * @param format defines the format of the texture
  10688. * @param generateMipMaps defines if the engine must generate mip levels
  10689. * @param invertY defines if data must be stored with Y axis inverted
  10690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10691. * @param compression defines the compressed used (can be null)
  10692. * @param textureType defines the compressed used (can be null)
  10693. * @returns a new raw 3D texture (stored in an InternalTexture)
  10694. */
  10695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10696. /**
  10697. * Update a raw 3D texture
  10698. * @param texture defines the texture to update
  10699. * @param data defines the data to store
  10700. * @param format defines the data format
  10701. * @param invertY defines if data must be stored with Y axis inverted
  10702. */
  10703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10704. /**
  10705. * Update a raw 3D texture
  10706. * @param texture defines the texture to update
  10707. * @param data defines the data to store
  10708. * @param format defines the data format
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param compression defines the used compression (can be null)
  10711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10712. */
  10713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10714. /**
  10715. * Creates a new raw 2D array texture
  10716. * @param data defines the data used to create the texture
  10717. * @param width defines the width of the texture
  10718. * @param height defines the height of the texture
  10719. * @param depth defines the number of layers of the texture
  10720. * @param format defines the format of the texture
  10721. * @param generateMipMaps defines if the engine must generate mip levels
  10722. * @param invertY defines if data must be stored with Y axis inverted
  10723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10724. * @param compression defines the compressed used (can be null)
  10725. * @param textureType defines the compressed used (can be null)
  10726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10727. */
  10728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10729. /**
  10730. * Update a raw 2D array texture
  10731. * @param texture defines the texture to update
  10732. * @param data defines the data to store
  10733. * @param format defines the data format
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. */
  10736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10737. /**
  10738. * Update a raw 2D array texture
  10739. * @param texture defines the texture to update
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param compression defines the used compression (can be null)
  10744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10745. */
  10746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10747. }
  10748. }
  10749. }
  10750. declare module "babylonjs/Materials/Textures/rawTexture" {
  10751. import { Scene } from "babylonjs/scene";
  10752. import { Texture } from "babylonjs/Materials/Textures/texture";
  10753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. private _engine;
  10765. /**
  10766. * Instantiates a new RawTexture.
  10767. * Raw texture can help creating a texture directly from an array of data.
  10768. * This can be super useful if you either get the data from an uncompressed source or
  10769. * if you wish to create your texture pixel by pixel.
  10770. * @param data define the array of data to use to create the texture
  10771. * @param width define the width of the texture
  10772. * @param height define the height of the texture
  10773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10774. * @param scene define the scene the texture belongs to
  10775. * @param generateMipMaps define whether mip maps should be generated or not
  10776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10779. */
  10780. constructor(data: ArrayBufferView, width: number, height: number,
  10781. /**
  10782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10783. */
  10784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10785. /**
  10786. * Updates the texture underlying data.
  10787. * @param data Define the new data of the texture
  10788. */
  10789. update(data: ArrayBufferView): void;
  10790. /**
  10791. * Creates a luminance texture from some data.
  10792. * @param data Define the texture data
  10793. * @param width Define the width of the texture
  10794. * @param height Define the height of the texture
  10795. * @param scene Define the scene the texture belongs to
  10796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10799. * @returns the luminance texture
  10800. */
  10801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10802. /**
  10803. * Creates a luminance alpha texture from some data.
  10804. * @param data Define the texture data
  10805. * @param width Define the width of the texture
  10806. * @param height Define the height of the texture
  10807. * @param scene Define the scene the texture belongs to
  10808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10811. * @returns the luminance alpha texture
  10812. */
  10813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10814. /**
  10815. * Creates an alpha texture from some data.
  10816. * @param data Define the texture data
  10817. * @param width Define the width of the texture
  10818. * @param height Define the height of the texture
  10819. * @param scene Define the scene the texture belongs to
  10820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10823. * @returns the alpha texture
  10824. */
  10825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10826. /**
  10827. * Creates a RGB texture from some data.
  10828. * @param data Define the texture data
  10829. * @param width Define the width of the texture
  10830. * @param height Define the height of the texture
  10831. * @param scene Define the scene the texture belongs to
  10832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10836. * @returns the RGB alpha texture
  10837. */
  10838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10839. /**
  10840. * Creates a RGBA texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10849. * @returns the RGBA texture
  10850. */
  10851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10852. /**
  10853. * Creates a R texture from some data.
  10854. * @param data Define the texture data
  10855. * @param width Define the width of the texture
  10856. * @param height Define the height of the texture
  10857. * @param scene Define the scene the texture belongs to
  10858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10862. * @returns the R texture
  10863. */
  10864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10865. }
  10866. }
  10867. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10868. import { Scene } from "babylonjs/scene";
  10869. import { ISceneComponent } from "babylonjs/sceneComponent";
  10870. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10871. module "babylonjs/abstractScene" {
  10872. interface AbstractScene {
  10873. /**
  10874. * The list of procedural textures added to the scene
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. */
  10877. proceduralTextures: Array<ProceduralTexture>;
  10878. }
  10879. }
  10880. /**
  10881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10882. * in a given scene.
  10883. */
  10884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10885. /**
  10886. * The component name helpfull to identify the component in the list of scene components.
  10887. */
  10888. readonly name: string;
  10889. /**
  10890. * The scene the component belongs to.
  10891. */
  10892. scene: Scene;
  10893. /**
  10894. * Creates a new instance of the component for the given scene
  10895. * @param scene Defines the scene to register the component in
  10896. */
  10897. constructor(scene: Scene);
  10898. /**
  10899. * Registers the component in a given scene
  10900. */
  10901. register(): void;
  10902. /**
  10903. * Rebuilds the elements related to this component in case of
  10904. * context lost for instance.
  10905. */
  10906. rebuild(): void;
  10907. /**
  10908. * Disposes the component and the associated ressources.
  10909. */
  10910. dispose(): void;
  10911. private _beforeClear;
  10912. }
  10913. }
  10914. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10916. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10917. module "babylonjs/Engines/thinEngine" {
  10918. interface ThinEngine {
  10919. /**
  10920. * Creates a new render target cube texture
  10921. * @param size defines the size of the texture
  10922. * @param options defines the options used to create the texture
  10923. * @returns a new render target cube texture stored in an InternalTexture
  10924. */
  10925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10926. }
  10927. }
  10928. }
  10929. declare module "babylonjs/Shaders/procedural.vertex" {
  10930. /** @hidden */
  10931. export var proceduralVertexShader: {
  10932. name: string;
  10933. shader: string;
  10934. };
  10935. }
  10936. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { Nullable } from "babylonjs/types";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10941. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10942. import { Effect } from "babylonjs/Materials/effect";
  10943. import { Texture } from "babylonjs/Materials/Textures/texture";
  10944. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10945. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10946. import "babylonjs/Shaders/procedural.vertex";
  10947. /**
  10948. * 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.
  10949. * This is the base class of any Procedural texture and contains most of the shareable code.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10951. */
  10952. export class ProceduralTexture extends Texture {
  10953. isCube: boolean;
  10954. /**
  10955. * Define if the texture is enabled or not (disabled texture will not render)
  10956. */
  10957. isEnabled: boolean;
  10958. /**
  10959. * Define if the texture must be cleared before rendering (default is true)
  10960. */
  10961. autoClear: boolean;
  10962. /**
  10963. * Callback called when the texture is generated
  10964. */
  10965. onGenerated: () => void;
  10966. /**
  10967. * Event raised when the texture is generated
  10968. */
  10969. onGeneratedObservable: Observable<ProceduralTexture>;
  10970. /** @hidden */
  10971. _generateMipMaps: boolean;
  10972. /** @hidden **/
  10973. _effect: Effect;
  10974. /** @hidden */
  10975. _textures: {
  10976. [key: string]: Texture;
  10977. };
  10978. private _size;
  10979. private _currentRefreshId;
  10980. private _frameId;
  10981. private _refreshRate;
  10982. private _vertexBuffers;
  10983. private _indexBuffer;
  10984. private _uniforms;
  10985. private _samplers;
  10986. private _fragment;
  10987. private _floats;
  10988. private _ints;
  10989. private _floatsArrays;
  10990. private _colors3;
  10991. private _colors4;
  10992. private _vectors2;
  10993. private _vectors3;
  10994. private _matrices;
  10995. private _fallbackTexture;
  10996. private _fallbackTextureUsed;
  10997. private _engine;
  10998. private _cachedDefines;
  10999. private _contentUpdateId;
  11000. private _contentData;
  11001. /**
  11002. * Instantiates a new procedural texture.
  11003. * 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.
  11004. * This is the base class of any Procedural texture and contains most of the shareable code.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11006. * @param name Define the name of the texture
  11007. * @param size Define the size of the texture to create
  11008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11009. * @param scene Define the scene the texture belongs to
  11010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11011. * @param generateMipMaps Define if the texture should creates mip maps or not
  11012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11013. */
  11014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11015. /**
  11016. * The effect that is created when initializing the post process.
  11017. * @returns The created effect corresponding the the postprocess.
  11018. */
  11019. getEffect(): Effect;
  11020. /**
  11021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11023. */
  11024. getContent(): Nullable<ArrayBufferView>;
  11025. private _createIndexBuffer;
  11026. /** @hidden */
  11027. _rebuild(): void;
  11028. /**
  11029. * Resets the texture in order to recreate its associated resources.
  11030. * This can be called in case of context loss
  11031. */
  11032. reset(): void;
  11033. protected _getDefines(): string;
  11034. /**
  11035. * Is the texture ready to be used ? (rendered at least once)
  11036. * @returns true if ready, otherwise, false.
  11037. */
  11038. isReady(): boolean;
  11039. /**
  11040. * Resets the refresh counter of the texture and start bak from scratch.
  11041. * Could be useful to regenerate the texture if it is setup to render only once.
  11042. */
  11043. resetRefreshCounter(): void;
  11044. /**
  11045. * Set the fragment shader to use in order to render the texture.
  11046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11047. */
  11048. setFragment(fragment: any): void;
  11049. /**
  11050. * Define the refresh rate of the texture or the rendering frequency.
  11051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11052. */
  11053. get refreshRate(): number;
  11054. set refreshRate(value: number);
  11055. /** @hidden */
  11056. _shouldRender(): boolean;
  11057. /**
  11058. * Get the size the texture is rendering at.
  11059. * @returns the size (texture is always squared)
  11060. */
  11061. getRenderSize(): number;
  11062. /**
  11063. * Resize the texture to new value.
  11064. * @param size Define the new size the texture should have
  11065. * @param generateMipMaps Define whether the new texture should create mip maps
  11066. */
  11067. resize(size: number, generateMipMaps: boolean): void;
  11068. private _checkUniform;
  11069. /**
  11070. * Set a texture in the shader program used to render.
  11071. * @param name Define the name of the uniform samplers as defined in the shader
  11072. * @param texture Define the texture to bind to this sampler
  11073. * @return the texture itself allowing "fluent" like uniform updates
  11074. */
  11075. setTexture(name: string, texture: Texture): ProceduralTexture;
  11076. /**
  11077. * Set a float in the shader.
  11078. * @param name Define the name of the uniform as defined in the shader
  11079. * @param value Define the value to give to the uniform
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setFloat(name: string, value: number): ProceduralTexture;
  11083. /**
  11084. * Set a int in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setInt(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set an array of floats in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setFloats(name: string, value: number[]): ProceduralTexture;
  11097. /**
  11098. * Set a vec3 in the shader from a Color3.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setColor3(name: string, value: Color3): ProceduralTexture;
  11104. /**
  11105. * Set a vec4 in the shader from a Color4.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor4(name: string, value: Color4): ProceduralTexture;
  11111. /**
  11112. * Set a vec2 in the shader from a Vector2.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setVector2(name: string, value: Vector2): ProceduralTexture;
  11118. /**
  11119. * Set a vec3 in the shader from a Vector3.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector3(name: string, value: Vector3): ProceduralTexture;
  11125. /**
  11126. * Set a mat4 in the shader from a MAtrix.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11132. /**
  11133. * Render the texture to its associated render target.
  11134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11135. */
  11136. render(useCameraPostProcess?: boolean): void;
  11137. /**
  11138. * Clone the texture.
  11139. * @returns the cloned texture
  11140. */
  11141. clone(): ProceduralTexture;
  11142. /**
  11143. * Dispose the texture and release its asoociated resources.
  11144. */
  11145. dispose(): void;
  11146. }
  11147. }
  11148. declare module "babylonjs/Particles/baseParticleSystem" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11154. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11155. import { Scene } from "babylonjs/scene";
  11156. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11157. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import { Color4 } from "babylonjs/Maths/math.color";
  11160. import { Animation } from "babylonjs/Animations/animation";
  11161. /**
  11162. * This represents the base class for particle system in Babylon.
  11163. * 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.
  11164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11165. * @example https://doc.babylonjs.com/babylon101/particles
  11166. */
  11167. export class BaseParticleSystem {
  11168. /**
  11169. * Source color is added to the destination color without alpha affecting the result
  11170. */
  11171. static BLENDMODE_ONEONE: number;
  11172. /**
  11173. * Blend current color and particle color using particle’s alpha
  11174. */
  11175. static BLENDMODE_STANDARD: number;
  11176. /**
  11177. * Add current color and particle color multiplied by particle’s alpha
  11178. */
  11179. static BLENDMODE_ADD: number;
  11180. /**
  11181. * Multiply current color with particle color
  11182. */
  11183. static BLENDMODE_MULTIPLY: number;
  11184. /**
  11185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11186. */
  11187. static BLENDMODE_MULTIPLYADD: number;
  11188. /**
  11189. * List of animations used by the particle system.
  11190. */
  11191. animations: Animation[];
  11192. /**
  11193. * The id of the Particle system.
  11194. */
  11195. id: string;
  11196. /**
  11197. * The friendly name of the Particle system.
  11198. */
  11199. name: string;
  11200. /**
  11201. * The rendering group used by the Particle system to chose when to render.
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * The emitter represents the Mesh or position we are attaching the particle system to.
  11206. */
  11207. emitter: Nullable<AbstractMesh | Vector3>;
  11208. /**
  11209. * The maximum number of particles to emit per frame
  11210. */
  11211. emitRate: number;
  11212. /**
  11213. * If you want to launch only a few particles at once, that can be done, as well.
  11214. */
  11215. manualEmitCount: number;
  11216. /**
  11217. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11218. */
  11219. updateSpeed: number;
  11220. /**
  11221. * The amount of time the particle system is running (depends of the overall update speed).
  11222. */
  11223. targetStopDuration: number;
  11224. /**
  11225. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11226. */
  11227. disposeOnStop: boolean;
  11228. /**
  11229. * Minimum power of emitting particles.
  11230. */
  11231. minEmitPower: number;
  11232. /**
  11233. * Maximum power of emitting particles.
  11234. */
  11235. maxEmitPower: number;
  11236. /**
  11237. * Minimum life time of emitting particles.
  11238. */
  11239. minLifeTime: number;
  11240. /**
  11241. * Maximum life time of emitting particles.
  11242. */
  11243. maxLifeTime: number;
  11244. /**
  11245. * Minimum Size of emitting particles.
  11246. */
  11247. minSize: number;
  11248. /**
  11249. * Maximum Size of emitting particles.
  11250. */
  11251. maxSize: number;
  11252. /**
  11253. * Minimum scale of emitting particles on X axis.
  11254. */
  11255. minScaleX: number;
  11256. /**
  11257. * Maximum scale of emitting particles on X axis.
  11258. */
  11259. maxScaleX: number;
  11260. /**
  11261. * Minimum scale of emitting particles on Y axis.
  11262. */
  11263. minScaleY: number;
  11264. /**
  11265. * Maximum scale of emitting particles on Y axis.
  11266. */
  11267. maxScaleY: number;
  11268. /**
  11269. * Gets or sets the minimal initial rotation in radians.
  11270. */
  11271. minInitialRotation: number;
  11272. /**
  11273. * Gets or sets the maximal initial rotation in radians.
  11274. */
  11275. maxInitialRotation: number;
  11276. /**
  11277. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11278. */
  11279. minAngularSpeed: number;
  11280. /**
  11281. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11282. */
  11283. maxAngularSpeed: number;
  11284. /**
  11285. * The texture used to render each particle. (this can be a spritesheet)
  11286. */
  11287. particleTexture: Nullable<Texture>;
  11288. /**
  11289. * The layer mask we are rendering the particles through.
  11290. */
  11291. layerMask: number;
  11292. /**
  11293. * This can help using your own shader to render the particle system.
  11294. * The according effect will be created
  11295. */
  11296. customShader: any;
  11297. /**
  11298. * By default particle system starts as soon as they are created. This prevents the
  11299. * automatic start to happen and let you decide when to start emitting particles.
  11300. */
  11301. preventAutoStart: boolean;
  11302. private _noiseTexture;
  11303. /**
  11304. * Gets or sets a texture used to add random noise to particle positions
  11305. */
  11306. get noiseTexture(): Nullable<ProceduralTexture>;
  11307. set noiseTexture(value: Nullable<ProceduralTexture>);
  11308. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11309. noiseStrength: Vector3;
  11310. /**
  11311. * Callback triggered when the particle animation is ending.
  11312. */
  11313. onAnimationEnd: Nullable<() => void>;
  11314. /**
  11315. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11316. */
  11317. blendMode: number;
  11318. /**
  11319. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11320. * to override the particles.
  11321. */
  11322. forceDepthWrite: boolean;
  11323. /** 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 */
  11324. preWarmCycles: number;
  11325. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11326. preWarmStepOffset: number;
  11327. /**
  11328. * 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)
  11329. */
  11330. spriteCellChangeSpeed: number;
  11331. /**
  11332. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11333. */
  11334. startSpriteCellID: number;
  11335. /**
  11336. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11337. */
  11338. endSpriteCellID: number;
  11339. /**
  11340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11341. */
  11342. spriteCellWidth: number;
  11343. /**
  11344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11345. */
  11346. spriteCellHeight: number;
  11347. /**
  11348. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11349. */
  11350. spriteRandomStartCell: boolean;
  11351. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11352. translationPivot: Vector2;
  11353. /** @hidden */
  11354. protected _isAnimationSheetEnabled: boolean;
  11355. /**
  11356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11357. */
  11358. beginAnimationOnStart: boolean;
  11359. /**
  11360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11361. */
  11362. beginAnimationFrom: number;
  11363. /**
  11364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11365. */
  11366. beginAnimationTo: number;
  11367. /**
  11368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11369. */
  11370. beginAnimationLoop: boolean;
  11371. /**
  11372. * Gets or sets a world offset applied to all particles
  11373. */
  11374. worldOffset: Vector3;
  11375. /**
  11376. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11377. */
  11378. get isAnimationSheetEnabled(): boolean;
  11379. set isAnimationSheetEnabled(value: boolean);
  11380. /**
  11381. * Get hosting scene
  11382. * @returns the scene
  11383. */
  11384. getScene(): Scene;
  11385. /**
  11386. * You can use gravity if you want to give an orientation to your particles.
  11387. */
  11388. gravity: Vector3;
  11389. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11390. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11391. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11392. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11393. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11394. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11395. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11396. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11397. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11399. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11400. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11401. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11402. /**
  11403. * Defines the delay in milliseconds before starting the system (0 by default)
  11404. */
  11405. startDelay: number;
  11406. /**
  11407. * Gets the current list of drag gradients.
  11408. * You must use addDragGradient and removeDragGradient to udpate this list
  11409. * @returns the list of drag gradients
  11410. */
  11411. getDragGradients(): Nullable<Array<FactorGradient>>;
  11412. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11413. limitVelocityDamping: number;
  11414. /**
  11415. * Gets the current list of limit velocity gradients.
  11416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11417. * @returns the list of limit velocity gradients
  11418. */
  11419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11420. /**
  11421. * Gets the current list of color gradients.
  11422. * You must use addColorGradient and removeColorGradient to udpate this list
  11423. * @returns the list of color gradients
  11424. */
  11425. getColorGradients(): Nullable<Array<ColorGradient>>;
  11426. /**
  11427. * Gets the current list of size gradients.
  11428. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11429. * @returns the list of size gradients
  11430. */
  11431. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11432. /**
  11433. * Gets the current list of color remap gradients.
  11434. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11435. * @returns the list of color remap gradients
  11436. */
  11437. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of alpha remap gradients.
  11440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11441. * @returns the list of alpha remap gradients
  11442. */
  11443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of life time gradients.
  11446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11447. * @returns the list of life time gradients
  11448. */
  11449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of angular speed gradients.
  11452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11453. * @returns the list of angular speed gradients
  11454. */
  11455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of velocity gradients.
  11458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11459. * @returns the list of velocity gradients
  11460. */
  11461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of start size gradients.
  11464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11465. * @returns the list of start size gradients
  11466. */
  11467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of emit rate gradients.
  11470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11471. * @returns the list of emit rate gradients
  11472. */
  11473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11477. */
  11478. get direction1(): Vector3;
  11479. set direction1(value: Vector3);
  11480. /**
  11481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11483. */
  11484. get direction2(): Vector3;
  11485. set direction2(value: Vector3);
  11486. /**
  11487. * 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.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get minEmitBox(): Vector3;
  11491. set minEmitBox(value: Vector3);
  11492. /**
  11493. * 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.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get maxEmitBox(): Vector3;
  11497. set maxEmitBox(value: Vector3);
  11498. /**
  11499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11504. */
  11505. color2: Color4;
  11506. /**
  11507. * Color the particle will have at the end of its lifetime
  11508. */
  11509. colorDead: Color4;
  11510. /**
  11511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11512. */
  11513. textureMask: Color4;
  11514. /**
  11515. * The particle emitter type defines the emitter used by the particle system.
  11516. * It can be for example box, sphere, or cone...
  11517. */
  11518. particleEmitterType: IParticleEmitterType;
  11519. /** @hidden */
  11520. _isSubEmitter: boolean;
  11521. /**
  11522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11524. */
  11525. billboardMode: number;
  11526. protected _isBillboardBased: boolean;
  11527. /**
  11528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11529. */
  11530. get isBillboardBased(): boolean;
  11531. set isBillboardBased(value: boolean);
  11532. /**
  11533. * The scene the particle system belongs to.
  11534. */
  11535. protected _scene: Scene;
  11536. /**
  11537. * Local cache of defines for image processing.
  11538. */
  11539. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11540. /**
  11541. * Default configuration related to image processing available in the standard Material.
  11542. */
  11543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11544. /**
  11545. * Gets the image processing configuration used either in this material.
  11546. */
  11547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11548. /**
  11549. * Sets the Default image processing configuration used either in the this material.
  11550. *
  11551. * If sets to null, the scene one is in use.
  11552. */
  11553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11554. /**
  11555. * Attaches a new image processing configuration to the Standard Material.
  11556. * @param configuration
  11557. */
  11558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11559. /** @hidden */
  11560. protected _reset(): void;
  11561. /** @hidden */
  11562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11563. /**
  11564. * Instantiates a particle system.
  11565. * 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.
  11566. * @param name The name of the particle system
  11567. */
  11568. constructor(name: string);
  11569. /**
  11570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11573. * @returns the emitter
  11574. */
  11575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11576. /**
  11577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11578. * @param radius The radius of the hemisphere to emit from
  11579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11580. * @returns the emitter
  11581. */
  11582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11583. /**
  11584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11585. * @param radius The radius of the sphere to emit from
  11586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11590. /**
  11591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11595. * @returns the emitter
  11596. */
  11597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11598. /**
  11599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11600. * @param radius The radius of the emission cylinder
  11601. * @param height The height of the emission cylinder
  11602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11604. * @returns the emitter
  11605. */
  11606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11607. /**
  11608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11609. * @param radius The radius of the cylinder to emit from
  11610. * @param height The height of the emission cylinder
  11611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11614. * @returns the emitter
  11615. */
  11616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11617. /**
  11618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11619. * @param radius The radius of the cone to emit from
  11620. * @param angle The base angle of the cone
  11621. * @returns the emitter
  11622. */
  11623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11624. /**
  11625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11630. * @returns the emitter
  11631. */
  11632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11633. }
  11634. }
  11635. declare module "babylonjs/Particles/subEmitter" {
  11636. import { Scene } from "babylonjs/scene";
  11637. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11638. /**
  11639. * Type of sub emitter
  11640. */
  11641. export enum SubEmitterType {
  11642. /**
  11643. * Attached to the particle over it's lifetime
  11644. */
  11645. ATTACHED = 0,
  11646. /**
  11647. * Created when the particle dies
  11648. */
  11649. END = 1
  11650. }
  11651. /**
  11652. * Sub emitter class used to emit particles from an existing particle
  11653. */
  11654. export class SubEmitter {
  11655. /**
  11656. * the particle system to be used by the sub emitter
  11657. */
  11658. particleSystem: ParticleSystem;
  11659. /**
  11660. * Type of the submitter (Default: END)
  11661. */
  11662. type: SubEmitterType;
  11663. /**
  11664. * 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)
  11665. * Note: This only is supported when using an emitter of type Mesh
  11666. */
  11667. inheritDirection: boolean;
  11668. /**
  11669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11670. */
  11671. inheritedVelocityAmount: number;
  11672. /**
  11673. * Creates a sub emitter
  11674. * @param particleSystem the particle system to be used by the sub emitter
  11675. */
  11676. constructor(
  11677. /**
  11678. * the particle system to be used by the sub emitter
  11679. */
  11680. particleSystem: ParticleSystem);
  11681. /**
  11682. * Clones the sub emitter
  11683. * @returns the cloned sub emitter
  11684. */
  11685. clone(): SubEmitter;
  11686. /**
  11687. * Serialize current object to a JSON object
  11688. * @returns the serialized object
  11689. */
  11690. serialize(): any;
  11691. /** @hidden */
  11692. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11693. /**
  11694. * Creates a new SubEmitter from a serialized JSON version
  11695. * @param serializationObject defines the JSON object to read from
  11696. * @param scene defines the hosting scene
  11697. * @param rootUrl defines the rootUrl for data loading
  11698. * @returns a new SubEmitter
  11699. */
  11700. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11701. /** Release associated resources */
  11702. dispose(): void;
  11703. }
  11704. }
  11705. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11706. /** @hidden */
  11707. export var imageProcessingDeclaration: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11713. /** @hidden */
  11714. export var imageProcessingFunctions: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/particles.fragment" {
  11720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11721. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11723. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11725. /** @hidden */
  11726. export var particlesPixelShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module "babylonjs/Shaders/particles.vertex" {
  11732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11734. /** @hidden */
  11735. export var particlesVertexShader: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Particles/particleSystem" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11743. import { Observable } from "babylonjs/Misc/observable";
  11744. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11745. import { Effect } from "babylonjs/Materials/effect";
  11746. import { Scene, IDisposable } from "babylonjs/scene";
  11747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11748. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11749. import { Particle } from "babylonjs/Particles/particle";
  11750. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11752. import "babylonjs/Shaders/particles.fragment";
  11753. import "babylonjs/Shaders/particles.vertex";
  11754. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11755. /**
  11756. * This represents a particle system in Babylon.
  11757. * 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.
  11758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11759. * @example https://doc.babylonjs.com/babylon101/particles
  11760. */
  11761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11762. /**
  11763. * Billboard mode will only apply to Y axis
  11764. */
  11765. static readonly BILLBOARDMODE_Y: number;
  11766. /**
  11767. * Billboard mode will apply to all axes
  11768. */
  11769. static readonly BILLBOARDMODE_ALL: number;
  11770. /**
  11771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11772. */
  11773. static readonly BILLBOARDMODE_STRETCHED: number;
  11774. /**
  11775. * This function can be defined to provide custom update for active particles.
  11776. * This function will be called instead of regular update (age, position, color, etc.).
  11777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11778. */
  11779. updateFunction: (particles: Particle[]) => void;
  11780. private _emitterWorldMatrix;
  11781. /**
  11782. * This function can be defined to specify initial direction for every new particle.
  11783. * It by default use the emitterType defined function
  11784. */
  11785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11786. /**
  11787. * This function can be defined to specify initial position for every new particle.
  11788. * It by default use the emitterType defined function
  11789. */
  11790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11791. /**
  11792. * @hidden
  11793. */
  11794. _inheritedVelocityOffset: Vector3;
  11795. /**
  11796. * An event triggered when the system is disposed
  11797. */
  11798. onDisposeObservable: Observable<ParticleSystem>;
  11799. private _onDisposeObserver;
  11800. /**
  11801. * Sets a callback that will be triggered when the system is disposed
  11802. */
  11803. set onDispose(callback: () => void);
  11804. private _particles;
  11805. private _epsilon;
  11806. private _capacity;
  11807. private _stockParticles;
  11808. private _newPartsExcess;
  11809. private _vertexData;
  11810. private _vertexBuffer;
  11811. private _vertexBuffers;
  11812. private _spriteBuffer;
  11813. private _indexBuffer;
  11814. private _effect;
  11815. private _customEffect;
  11816. private _cachedDefines;
  11817. private _scaledColorStep;
  11818. private _colorDiff;
  11819. private _scaledDirection;
  11820. private _scaledGravity;
  11821. private _currentRenderId;
  11822. private _alive;
  11823. private _useInstancing;
  11824. private _started;
  11825. private _stopped;
  11826. private _actualFrame;
  11827. private _scaledUpdateSpeed;
  11828. private _vertexBufferSize;
  11829. /** @hidden */
  11830. _currentEmitRateGradient: Nullable<FactorGradient>;
  11831. /** @hidden */
  11832. _currentEmitRate1: number;
  11833. /** @hidden */
  11834. _currentEmitRate2: number;
  11835. /** @hidden */
  11836. _currentStartSizeGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentStartSize1: number;
  11839. /** @hidden */
  11840. _currentStartSize2: number;
  11841. private readonly _rawTextureWidth;
  11842. private _rampGradientsTexture;
  11843. private _useRampGradients;
  11844. /** Gets or sets a boolean indicating that ramp gradients must be used
  11845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11846. */
  11847. get useRampGradients(): boolean;
  11848. set useRampGradients(value: boolean);
  11849. /**
  11850. * 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.
  11851. * 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: [])
  11852. */
  11853. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11854. private _subEmitters;
  11855. /**
  11856. * @hidden
  11857. * If the particle systems emitter should be disposed when the particle system is disposed
  11858. */
  11859. _disposeEmitterOnDispose: boolean;
  11860. /**
  11861. * The current active Sub-systems, this property is used by the root particle system only.
  11862. */
  11863. activeSubSystems: Array<ParticleSystem>;
  11864. private _rootParticleSystem;
  11865. /**
  11866. * Gets the current list of active particles
  11867. */
  11868. get particles(): Particle[];
  11869. /**
  11870. * Returns the string "ParticleSystem"
  11871. * @returns a string containing the class name
  11872. */
  11873. getClassName(): string;
  11874. /**
  11875. * Instantiates a particle system.
  11876. * 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.
  11877. * @param name The name of the particle system
  11878. * @param capacity The max number of particles alive at the same time
  11879. * @param scene The scene the particle system belongs to
  11880. * @param customEffect a custom effect used to change the way particles are rendered by default
  11881. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11882. * @param epsilon Offset used to render the particles
  11883. */
  11884. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11885. private _addFactorGradient;
  11886. private _removeFactorGradient;
  11887. /**
  11888. * Adds a new life time gradient
  11889. * @param gradient defines the gradient to use (between 0 and 1)
  11890. * @param factor defines the life time factor to affect to the specified gradient
  11891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11892. * @returns the current particle system
  11893. */
  11894. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11895. /**
  11896. * Remove a specific life time gradient
  11897. * @param gradient defines the gradient to remove
  11898. * @returns the current particle system
  11899. */
  11900. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11901. /**
  11902. * Adds a new size gradient
  11903. * @param gradient defines the gradient to use (between 0 and 1)
  11904. * @param factor defines the size factor to affect to the specified gradient
  11905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11906. * @returns the current particle system
  11907. */
  11908. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11909. /**
  11910. * Remove a specific size gradient
  11911. * @param gradient defines the gradient to remove
  11912. * @returns the current particle system
  11913. */
  11914. removeSizeGradient(gradient: number): IParticleSystem;
  11915. /**
  11916. * Adds a new color remap gradient
  11917. * @param gradient defines the gradient to use (between 0 and 1)
  11918. * @param min defines the color remap minimal range
  11919. * @param max defines the color remap maximal range
  11920. * @returns the current particle system
  11921. */
  11922. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11923. /**
  11924. * Remove a specific color remap gradient
  11925. * @param gradient defines the gradient to remove
  11926. * @returns the current particle system
  11927. */
  11928. removeColorRemapGradient(gradient: number): IParticleSystem;
  11929. /**
  11930. * Adds a new alpha remap gradient
  11931. * @param gradient defines the gradient to use (between 0 and 1)
  11932. * @param min defines the alpha remap minimal range
  11933. * @param max defines the alpha remap maximal range
  11934. * @returns the current particle system
  11935. */
  11936. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11937. /**
  11938. * Remove a specific alpha remap gradient
  11939. * @param gradient defines the gradient to remove
  11940. * @returns the current particle system
  11941. */
  11942. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11943. /**
  11944. * Adds a new angular speed gradient
  11945. * @param gradient defines the gradient to use (between 0 and 1)
  11946. * @param factor defines the angular speed to affect to the specified gradient
  11947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11948. * @returns the current particle system
  11949. */
  11950. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11951. /**
  11952. * Remove a specific angular speed gradient
  11953. * @param gradient defines the gradient to remove
  11954. * @returns the current particle system
  11955. */
  11956. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11957. /**
  11958. * Adds a new velocity gradient
  11959. * @param gradient defines the gradient to use (between 0 and 1)
  11960. * @param factor defines the velocity to affect to the specified gradient
  11961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11962. * @returns the current particle system
  11963. */
  11964. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11965. /**
  11966. * Remove a specific velocity gradient
  11967. * @param gradient defines the gradient to remove
  11968. * @returns the current particle system
  11969. */
  11970. removeVelocityGradient(gradient: number): IParticleSystem;
  11971. /**
  11972. * Adds a new limit velocity gradient
  11973. * @param gradient defines the gradient to use (between 0 and 1)
  11974. * @param factor defines the limit velocity value to affect to the specified gradient
  11975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11976. * @returns the current particle system
  11977. */
  11978. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11979. /**
  11980. * Remove a specific limit velocity gradient
  11981. * @param gradient defines the gradient to remove
  11982. * @returns the current particle system
  11983. */
  11984. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11985. /**
  11986. * Adds a new drag gradient
  11987. * @param gradient defines the gradient to use (between 0 and 1)
  11988. * @param factor defines the drag value to affect to the specified gradient
  11989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11990. * @returns the current particle system
  11991. */
  11992. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11993. /**
  11994. * Remove a specific drag gradient
  11995. * @param gradient defines the gradient to remove
  11996. * @returns the current particle system
  11997. */
  11998. removeDragGradient(gradient: number): IParticleSystem;
  11999. /**
  12000. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12001. * @param gradient defines the gradient to use (between 0 and 1)
  12002. * @param factor defines the emit rate value to affect to the specified gradient
  12003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12004. * @returns the current particle system
  12005. */
  12006. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12007. /**
  12008. * Remove a specific emit rate gradient
  12009. * @param gradient defines the gradient to remove
  12010. * @returns the current particle system
  12011. */
  12012. removeEmitRateGradient(gradient: number): IParticleSystem;
  12013. /**
  12014. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12015. * @param gradient defines the gradient to use (between 0 and 1)
  12016. * @param factor defines the start size value to affect to the specified gradient
  12017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12018. * @returns the current particle system
  12019. */
  12020. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12021. /**
  12022. * Remove a specific start size gradient
  12023. * @param gradient defines the gradient to remove
  12024. * @returns the current particle system
  12025. */
  12026. removeStartSizeGradient(gradient: number): IParticleSystem;
  12027. private _createRampGradientTexture;
  12028. /**
  12029. * Gets the current list of ramp gradients.
  12030. * You must use addRampGradient and removeRampGradient to udpate this list
  12031. * @returns the list of ramp gradients
  12032. */
  12033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12034. /**
  12035. * Adds a new ramp gradient used to remap particle colors
  12036. * @param gradient defines the gradient to use (between 0 and 1)
  12037. * @param color defines the color to affect to the specified gradient
  12038. * @returns the current particle system
  12039. */
  12040. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12041. /**
  12042. * Remove a specific ramp gradient
  12043. * @param gradient defines the gradient to remove
  12044. * @returns the current particle system
  12045. */
  12046. removeRampGradient(gradient: number): ParticleSystem;
  12047. /**
  12048. * Adds a new color gradient
  12049. * @param gradient defines the gradient to use (between 0 and 1)
  12050. * @param color1 defines the color to affect to the specified gradient
  12051. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12052. * @returns this particle system
  12053. */
  12054. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12055. /**
  12056. * Remove a specific color gradient
  12057. * @param gradient defines the gradient to remove
  12058. * @returns this particle system
  12059. */
  12060. removeColorGradient(gradient: number): IParticleSystem;
  12061. private _fetchR;
  12062. protected _reset(): void;
  12063. private _resetEffect;
  12064. private _createVertexBuffers;
  12065. private _createIndexBuffer;
  12066. /**
  12067. * Gets the maximum number of particles active at the same time.
  12068. * @returns The max number of active particles.
  12069. */
  12070. getCapacity(): number;
  12071. /**
  12072. * Gets whether there are still active particles in the system.
  12073. * @returns True if it is alive, otherwise false.
  12074. */
  12075. isAlive(): boolean;
  12076. /**
  12077. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12078. * @returns True if it has been started, otherwise false.
  12079. */
  12080. isStarted(): boolean;
  12081. private _prepareSubEmitterInternalArray;
  12082. /**
  12083. * Starts the particle system and begins to emit
  12084. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12085. */
  12086. start(delay?: number): void;
  12087. /**
  12088. * Stops the particle system.
  12089. * @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.
  12090. */
  12091. stop(stopSubEmitters?: boolean): void;
  12092. /**
  12093. * Remove all active particles
  12094. */
  12095. reset(): void;
  12096. /**
  12097. * @hidden (for internal use only)
  12098. */
  12099. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12100. /**
  12101. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12102. * Its lifetime will start back at 0.
  12103. */
  12104. recycleParticle: (particle: Particle) => void;
  12105. private _stopSubEmitters;
  12106. private _createParticle;
  12107. private _removeFromRoot;
  12108. private _emitFromParticle;
  12109. private _update;
  12110. /** @hidden */
  12111. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12112. /** @hidden */
  12113. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12114. /** @hidden */
  12115. private _getEffect;
  12116. /**
  12117. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12118. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12119. */
  12120. animate(preWarmOnly?: boolean): void;
  12121. private _appendParticleVertices;
  12122. /**
  12123. * Rebuilds the particle system.
  12124. */
  12125. rebuild(): void;
  12126. /**
  12127. * Is this system ready to be used/rendered
  12128. * @return true if the system is ready
  12129. */
  12130. isReady(): boolean;
  12131. private _render;
  12132. /**
  12133. * Renders the particle system in its current state.
  12134. * @returns the current number of particles
  12135. */
  12136. render(): number;
  12137. /**
  12138. * Disposes the particle system and free the associated resources
  12139. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12140. */
  12141. dispose(disposeTexture?: boolean): void;
  12142. /**
  12143. * Clones the particle system.
  12144. * @param name The name of the cloned object
  12145. * @param newEmitter The new emitter to use
  12146. * @returns the cloned particle system
  12147. */
  12148. clone(name: string, newEmitter: any): ParticleSystem;
  12149. /**
  12150. * Serializes the particle system to a JSON object.
  12151. * @returns the JSON object
  12152. */
  12153. serialize(): any;
  12154. /** @hidden */
  12155. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12156. /** @hidden */
  12157. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12158. /**
  12159. * Parses a JSON object to create a particle system.
  12160. * @param parsedParticleSystem The JSON object to parse
  12161. * @param scene The scene to create the particle system in
  12162. * @param rootUrl The root url to use to load external dependencies like texture
  12163. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12164. * @returns the Parsed particle system
  12165. */
  12166. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12167. }
  12168. }
  12169. declare module "babylonjs/Particles/particle" {
  12170. import { Nullable } from "babylonjs/types";
  12171. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12172. import { Color4 } from "babylonjs/Maths/math.color";
  12173. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12174. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12175. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12176. /**
  12177. * A particle represents one of the element emitted by a particle system.
  12178. * This is mainly define by its coordinates, direction, velocity and age.
  12179. */
  12180. export class Particle {
  12181. /**
  12182. * The particle system the particle belongs to.
  12183. */
  12184. particleSystem: ParticleSystem;
  12185. private static _Count;
  12186. /**
  12187. * Unique ID of the particle
  12188. */
  12189. id: number;
  12190. /**
  12191. * The world position of the particle in the scene.
  12192. */
  12193. position: Vector3;
  12194. /**
  12195. * The world direction of the particle in the scene.
  12196. */
  12197. direction: Vector3;
  12198. /**
  12199. * The color of the particle.
  12200. */
  12201. color: Color4;
  12202. /**
  12203. * The color change of the particle per step.
  12204. */
  12205. colorStep: Color4;
  12206. /**
  12207. * Defines how long will the life of the particle be.
  12208. */
  12209. lifeTime: number;
  12210. /**
  12211. * The current age of the particle.
  12212. */
  12213. age: number;
  12214. /**
  12215. * The current size of the particle.
  12216. */
  12217. size: number;
  12218. /**
  12219. * The current scale of the particle.
  12220. */
  12221. scale: Vector2;
  12222. /**
  12223. * The current angle of the particle.
  12224. */
  12225. angle: number;
  12226. /**
  12227. * Defines how fast is the angle changing.
  12228. */
  12229. angularSpeed: number;
  12230. /**
  12231. * Defines the cell index used by the particle to be rendered from a sprite.
  12232. */
  12233. cellIndex: number;
  12234. /**
  12235. * The information required to support color remapping
  12236. */
  12237. remapData: Vector4;
  12238. /** @hidden */
  12239. _randomCellOffset?: number;
  12240. /** @hidden */
  12241. _initialDirection: Nullable<Vector3>;
  12242. /** @hidden */
  12243. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12244. /** @hidden */
  12245. _initialStartSpriteCellID: number;
  12246. /** @hidden */
  12247. _initialEndSpriteCellID: number;
  12248. /** @hidden */
  12249. _currentColorGradient: Nullable<ColorGradient>;
  12250. /** @hidden */
  12251. _currentColor1: Color4;
  12252. /** @hidden */
  12253. _currentColor2: Color4;
  12254. /** @hidden */
  12255. _currentSizeGradient: Nullable<FactorGradient>;
  12256. /** @hidden */
  12257. _currentSize1: number;
  12258. /** @hidden */
  12259. _currentSize2: number;
  12260. /** @hidden */
  12261. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12262. /** @hidden */
  12263. _currentAngularSpeed1: number;
  12264. /** @hidden */
  12265. _currentAngularSpeed2: number;
  12266. /** @hidden */
  12267. _currentVelocityGradient: Nullable<FactorGradient>;
  12268. /** @hidden */
  12269. _currentVelocity1: number;
  12270. /** @hidden */
  12271. _currentVelocity2: number;
  12272. /** @hidden */
  12273. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12274. /** @hidden */
  12275. _currentLimitVelocity1: number;
  12276. /** @hidden */
  12277. _currentLimitVelocity2: number;
  12278. /** @hidden */
  12279. _currentDragGradient: Nullable<FactorGradient>;
  12280. /** @hidden */
  12281. _currentDrag1: number;
  12282. /** @hidden */
  12283. _currentDrag2: number;
  12284. /** @hidden */
  12285. _randomNoiseCoordinates1: Vector3;
  12286. /** @hidden */
  12287. _randomNoiseCoordinates2: Vector3;
  12288. /**
  12289. * Creates a new instance Particle
  12290. * @param particleSystem the particle system the particle belongs to
  12291. */
  12292. constructor(
  12293. /**
  12294. * The particle system the particle belongs to.
  12295. */
  12296. particleSystem: ParticleSystem);
  12297. private updateCellInfoFromSystem;
  12298. /**
  12299. * Defines how the sprite cell index is updated for the particle
  12300. */
  12301. updateCellIndex(): void;
  12302. /** @hidden */
  12303. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12304. /** @hidden */
  12305. _inheritParticleInfoToSubEmitters(): void;
  12306. /** @hidden */
  12307. _reset(): void;
  12308. /**
  12309. * Copy the properties of particle to another one.
  12310. * @param other the particle to copy the information to.
  12311. */
  12312. copyTo(other: Particle): void;
  12313. }
  12314. }
  12315. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12316. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12317. import { Effect } from "babylonjs/Materials/effect";
  12318. import { Particle } from "babylonjs/Particles/particle";
  12319. import { Scene } from "babylonjs/scene";
  12320. /**
  12321. * Particle emitter represents a volume emitting particles.
  12322. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12323. */
  12324. export interface IParticleEmitterType {
  12325. /**
  12326. * Called by the particle System when the direction is computed for the created particle.
  12327. * @param worldMatrix is the world matrix of the particle system
  12328. * @param directionToUpdate is the direction vector to update with the result
  12329. * @param particle is the particle we are computed the direction for
  12330. */
  12331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12332. /**
  12333. * Called by the particle System when the position is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param positionToUpdate is the position vector to update with the result
  12336. * @param particle is the particle we are computed the position for
  12337. */
  12338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Clones the current emitter and returns a copy of it
  12341. * @returns the new emitter
  12342. */
  12343. clone(): IParticleEmitterType;
  12344. /**
  12345. * Called by the GPUParticleSystem to setup the update shader
  12346. * @param effect defines the update shader
  12347. */
  12348. applyToShader(effect: Effect): void;
  12349. /**
  12350. * Returns a string to use to update the GPU particles update shader
  12351. * @returns the effect defines string
  12352. */
  12353. getEffectDefines(): string;
  12354. /**
  12355. * Returns a string representing the class name
  12356. * @returns a string containing the class name
  12357. */
  12358. getClassName(): string;
  12359. /**
  12360. * Serializes the particle system to a JSON object.
  12361. * @returns the JSON object
  12362. */
  12363. serialize(): any;
  12364. /**
  12365. * Parse properties from a JSON object
  12366. * @param serializationObject defines the JSON object
  12367. * @param scene defines the hosting scene
  12368. */
  12369. parse(serializationObject: any, scene: Scene): void;
  12370. }
  12371. }
  12372. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12373. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12374. import { Effect } from "babylonjs/Materials/effect";
  12375. import { Particle } from "babylonjs/Particles/particle";
  12376. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12377. /**
  12378. * Particle emitter emitting particles from the inside of a box.
  12379. * It emits the particles randomly between 2 given directions.
  12380. */
  12381. export class BoxParticleEmitter implements IParticleEmitterType {
  12382. /**
  12383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12384. */
  12385. direction1: Vector3;
  12386. /**
  12387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12388. */
  12389. direction2: Vector3;
  12390. /**
  12391. * 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.
  12392. */
  12393. minEmitBox: Vector3;
  12394. /**
  12395. * 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.
  12396. */
  12397. maxEmitBox: Vector3;
  12398. /**
  12399. * Creates a new instance BoxParticleEmitter
  12400. */
  12401. constructor();
  12402. /**
  12403. * Called by the particle System when the direction is computed for the created particle.
  12404. * @param worldMatrix is the world matrix of the particle system
  12405. * @param directionToUpdate is the direction vector to update with the result
  12406. * @param particle is the particle we are computed the direction for
  12407. */
  12408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12409. /**
  12410. * Called by the particle System when the position is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param positionToUpdate is the position vector to update with the result
  12413. * @param particle is the particle we are computed the position for
  12414. */
  12415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Clones the current emitter and returns a copy of it
  12418. * @returns the new emitter
  12419. */
  12420. clone(): BoxParticleEmitter;
  12421. /**
  12422. * Called by the GPUParticleSystem to setup the update shader
  12423. * @param effect defines the update shader
  12424. */
  12425. applyToShader(effect: Effect): void;
  12426. /**
  12427. * Returns a string to use to update the GPU particles update shader
  12428. * @returns a string containng the defines string
  12429. */
  12430. getEffectDefines(): string;
  12431. /**
  12432. * Returns the string "BoxParticleEmitter"
  12433. * @returns a string containing the class name
  12434. */
  12435. getClassName(): string;
  12436. /**
  12437. * Serializes the particle system to a JSON object.
  12438. * @returns the JSON object
  12439. */
  12440. serialize(): any;
  12441. /**
  12442. * Parse properties from a JSON object
  12443. * @param serializationObject defines the JSON object
  12444. */
  12445. parse(serializationObject: any): void;
  12446. }
  12447. }
  12448. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12449. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12450. import { Effect } from "babylonjs/Materials/effect";
  12451. import { Particle } from "babylonjs/Particles/particle";
  12452. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12453. /**
  12454. * Particle emitter emitting particles from the inside of a cone.
  12455. * It emits the particles alongside the cone volume from the base to the particle.
  12456. * The emission direction might be randomized.
  12457. */
  12458. export class ConeParticleEmitter implements IParticleEmitterType {
  12459. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12460. directionRandomizer: number;
  12461. private _radius;
  12462. private _angle;
  12463. private _height;
  12464. /**
  12465. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12466. */
  12467. radiusRange: number;
  12468. /**
  12469. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12470. */
  12471. heightRange: number;
  12472. /**
  12473. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12474. */
  12475. emitFromSpawnPointOnly: boolean;
  12476. /**
  12477. * Gets or sets the radius of the emission cone
  12478. */
  12479. get radius(): number;
  12480. set radius(value: number);
  12481. /**
  12482. * Gets or sets the angle of the emission cone
  12483. */
  12484. get angle(): number;
  12485. set angle(value: number);
  12486. private _buildHeight;
  12487. /**
  12488. * Creates a new instance ConeParticleEmitter
  12489. * @param radius the radius of the emission cone (1 by default)
  12490. * @param angle the cone base angle (PI by default)
  12491. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12492. */
  12493. constructor(radius?: number, angle?: number,
  12494. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12495. directionRandomizer?: number);
  12496. /**
  12497. * Called by the particle System when the direction is computed for the created particle.
  12498. * @param worldMatrix is the world matrix of the particle system
  12499. * @param directionToUpdate is the direction vector to update with the result
  12500. * @param particle is the particle we are computed the direction for
  12501. */
  12502. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12503. /**
  12504. * Called by the particle System when the position is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param positionToUpdate is the position vector to update with the result
  12507. * @param particle is the particle we are computed the position for
  12508. */
  12509. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Clones the current emitter and returns a copy of it
  12512. * @returns the new emitter
  12513. */
  12514. clone(): ConeParticleEmitter;
  12515. /**
  12516. * Called by the GPUParticleSystem to setup the update shader
  12517. * @param effect defines the update shader
  12518. */
  12519. applyToShader(effect: Effect): void;
  12520. /**
  12521. * Returns a string to use to update the GPU particles update shader
  12522. * @returns a string containng the defines string
  12523. */
  12524. getEffectDefines(): string;
  12525. /**
  12526. * Returns the string "ConeParticleEmitter"
  12527. * @returns a string containing the class name
  12528. */
  12529. getClassName(): string;
  12530. /**
  12531. * Serializes the particle system to a JSON object.
  12532. * @returns the JSON object
  12533. */
  12534. serialize(): any;
  12535. /**
  12536. * Parse properties from a JSON object
  12537. * @param serializationObject defines the JSON object
  12538. */
  12539. parse(serializationObject: any): void;
  12540. }
  12541. }
  12542. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12543. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12544. import { Effect } from "babylonjs/Materials/effect";
  12545. import { Particle } from "babylonjs/Particles/particle";
  12546. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12547. /**
  12548. * Particle emitter emitting particles from the inside of a cylinder.
  12549. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12550. */
  12551. export class CylinderParticleEmitter implements IParticleEmitterType {
  12552. /**
  12553. * The radius of the emission cylinder.
  12554. */
  12555. radius: number;
  12556. /**
  12557. * The height of the emission cylinder.
  12558. */
  12559. height: number;
  12560. /**
  12561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12562. */
  12563. radiusRange: number;
  12564. /**
  12565. * How much to randomize the particle direction [0-1].
  12566. */
  12567. directionRandomizer: number;
  12568. /**
  12569. * Creates a new instance CylinderParticleEmitter
  12570. * @param radius the radius of the emission cylinder (1 by default)
  12571. * @param height the height of the emission cylinder (1 by default)
  12572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12573. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12574. */
  12575. constructor(
  12576. /**
  12577. * The radius of the emission cylinder.
  12578. */
  12579. radius?: number,
  12580. /**
  12581. * The height of the emission cylinder.
  12582. */
  12583. height?: number,
  12584. /**
  12585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12586. */
  12587. radiusRange?: number,
  12588. /**
  12589. * How much to randomize the particle direction [0-1].
  12590. */
  12591. directionRandomizer?: number);
  12592. /**
  12593. * Called by the particle System when the direction is computed for the created particle.
  12594. * @param worldMatrix is the world matrix of the particle system
  12595. * @param directionToUpdate is the direction vector to update with the result
  12596. * @param particle is the particle we are computed the direction for
  12597. */
  12598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12599. /**
  12600. * Called by the particle System when the position is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param positionToUpdate is the position vector to update with the result
  12603. * @param particle is the particle we are computed the position for
  12604. */
  12605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Clones the current emitter and returns a copy of it
  12608. * @returns the new emitter
  12609. */
  12610. clone(): CylinderParticleEmitter;
  12611. /**
  12612. * Called by the GPUParticleSystem to setup the update shader
  12613. * @param effect defines the update shader
  12614. */
  12615. applyToShader(effect: Effect): void;
  12616. /**
  12617. * Returns a string to use to update the GPU particles update shader
  12618. * @returns a string containng the defines string
  12619. */
  12620. getEffectDefines(): string;
  12621. /**
  12622. * Returns the string "CylinderParticleEmitter"
  12623. * @returns a string containing the class name
  12624. */
  12625. getClassName(): string;
  12626. /**
  12627. * Serializes the particle system to a JSON object.
  12628. * @returns the JSON object
  12629. */
  12630. serialize(): any;
  12631. /**
  12632. * Parse properties from a JSON object
  12633. * @param serializationObject defines the JSON object
  12634. */
  12635. parse(serializationObject: any): void;
  12636. }
  12637. /**
  12638. * Particle emitter emitting particles from the inside of a cylinder.
  12639. * It emits the particles randomly between two vectors.
  12640. */
  12641. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12642. /**
  12643. * The min limit of the emission direction.
  12644. */
  12645. direction1: Vector3;
  12646. /**
  12647. * The max limit of the emission direction.
  12648. */
  12649. direction2: Vector3;
  12650. /**
  12651. * Creates a new instance CylinderDirectedParticleEmitter
  12652. * @param radius the radius of the emission cylinder (1 by default)
  12653. * @param height the height of the emission cylinder (1 by default)
  12654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12655. * @param direction1 the min limit of the emission direction (up vector by default)
  12656. * @param direction2 the max limit of the emission direction (up vector by default)
  12657. */
  12658. constructor(radius?: number, height?: number, radiusRange?: number,
  12659. /**
  12660. * The min limit of the emission direction.
  12661. */
  12662. direction1?: Vector3,
  12663. /**
  12664. * The max limit of the emission direction.
  12665. */
  12666. direction2?: Vector3);
  12667. /**
  12668. * Called by the particle System when the direction is computed for the created particle.
  12669. * @param worldMatrix is the world matrix of the particle system
  12670. * @param directionToUpdate is the direction vector to update with the result
  12671. * @param particle is the particle we are computed the direction for
  12672. */
  12673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12674. /**
  12675. * Clones the current emitter and returns a copy of it
  12676. * @returns the new emitter
  12677. */
  12678. clone(): CylinderDirectedParticleEmitter;
  12679. /**
  12680. * Called by the GPUParticleSystem to setup the update shader
  12681. * @param effect defines the update shader
  12682. */
  12683. applyToShader(effect: Effect): void;
  12684. /**
  12685. * Returns a string to use to update the GPU particles update shader
  12686. * @returns a string containng the defines string
  12687. */
  12688. getEffectDefines(): string;
  12689. /**
  12690. * Returns the string "CylinderDirectedParticleEmitter"
  12691. * @returns a string containing the class name
  12692. */
  12693. getClassName(): string;
  12694. /**
  12695. * Serializes the particle system to a JSON object.
  12696. * @returns the JSON object
  12697. */
  12698. serialize(): any;
  12699. /**
  12700. * Parse properties from a JSON object
  12701. * @param serializationObject defines the JSON object
  12702. */
  12703. parse(serializationObject: any): void;
  12704. }
  12705. }
  12706. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12707. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12708. import { Effect } from "babylonjs/Materials/effect";
  12709. import { Particle } from "babylonjs/Particles/particle";
  12710. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12711. /**
  12712. * Particle emitter emitting particles from the inside of a hemisphere.
  12713. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12714. */
  12715. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12716. /**
  12717. * The radius of the emission hemisphere.
  12718. */
  12719. radius: number;
  12720. /**
  12721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12722. */
  12723. radiusRange: number;
  12724. /**
  12725. * How much to randomize the particle direction [0-1].
  12726. */
  12727. directionRandomizer: number;
  12728. /**
  12729. * Creates a new instance HemisphericParticleEmitter
  12730. * @param radius the radius of the emission hemisphere (1 by default)
  12731. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12733. */
  12734. constructor(
  12735. /**
  12736. * The radius of the emission hemisphere.
  12737. */
  12738. radius?: number,
  12739. /**
  12740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12741. */
  12742. radiusRange?: number,
  12743. /**
  12744. * How much to randomize the particle direction [0-1].
  12745. */
  12746. directionRandomizer?: number);
  12747. /**
  12748. * Called by the particle System when the direction is computed for the created particle.
  12749. * @param worldMatrix is the world matrix of the particle system
  12750. * @param directionToUpdate is the direction vector to update with the result
  12751. * @param particle is the particle we are computed the direction for
  12752. */
  12753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12754. /**
  12755. * Called by the particle System when the position is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param positionToUpdate is the position vector to update with the result
  12758. * @param particle is the particle we are computed the position for
  12759. */
  12760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Clones the current emitter and returns a copy of it
  12763. * @returns the new emitter
  12764. */
  12765. clone(): HemisphericParticleEmitter;
  12766. /**
  12767. * Called by the GPUParticleSystem to setup the update shader
  12768. * @param effect defines the update shader
  12769. */
  12770. applyToShader(effect: Effect): void;
  12771. /**
  12772. * Returns a string to use to update the GPU particles update shader
  12773. * @returns a string containng the defines string
  12774. */
  12775. getEffectDefines(): string;
  12776. /**
  12777. * Returns the string "HemisphericParticleEmitter"
  12778. * @returns a string containing the class name
  12779. */
  12780. getClassName(): string;
  12781. /**
  12782. * Serializes the particle system to a JSON object.
  12783. * @returns the JSON object
  12784. */
  12785. serialize(): any;
  12786. /**
  12787. * Parse properties from a JSON object
  12788. * @param serializationObject defines the JSON object
  12789. */
  12790. parse(serializationObject: any): void;
  12791. }
  12792. }
  12793. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12794. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12795. import { Effect } from "babylonjs/Materials/effect";
  12796. import { Particle } from "babylonjs/Particles/particle";
  12797. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12798. /**
  12799. * Particle emitter emitting particles from a point.
  12800. * It emits the particles randomly between 2 given directions.
  12801. */
  12802. export class PointParticleEmitter implements IParticleEmitterType {
  12803. /**
  12804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12805. */
  12806. direction1: Vector3;
  12807. /**
  12808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12809. */
  12810. direction2: Vector3;
  12811. /**
  12812. * Creates a new instance PointParticleEmitter
  12813. */
  12814. constructor();
  12815. /**
  12816. * Called by the particle System when the direction is computed for the created particle.
  12817. * @param worldMatrix is the world matrix of the particle system
  12818. * @param directionToUpdate is the direction vector to update with the result
  12819. * @param particle is the particle we are computed the direction for
  12820. */
  12821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12822. /**
  12823. * Called by the particle System when the position is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param positionToUpdate is the position vector to update with the result
  12826. * @param particle is the particle we are computed the position for
  12827. */
  12828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Clones the current emitter and returns a copy of it
  12831. * @returns the new emitter
  12832. */
  12833. clone(): PointParticleEmitter;
  12834. /**
  12835. * Called by the GPUParticleSystem to setup the update shader
  12836. * @param effect defines the update shader
  12837. */
  12838. applyToShader(effect: Effect): void;
  12839. /**
  12840. * Returns a string to use to update the GPU particles update shader
  12841. * @returns a string containng the defines string
  12842. */
  12843. getEffectDefines(): string;
  12844. /**
  12845. * Returns the string "PointParticleEmitter"
  12846. * @returns a string containing the class name
  12847. */
  12848. getClassName(): string;
  12849. /**
  12850. * Serializes the particle system to a JSON object.
  12851. * @returns the JSON object
  12852. */
  12853. serialize(): any;
  12854. /**
  12855. * Parse properties from a JSON object
  12856. * @param serializationObject defines the JSON object
  12857. */
  12858. parse(serializationObject: any): void;
  12859. }
  12860. }
  12861. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12862. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12863. import { Effect } from "babylonjs/Materials/effect";
  12864. import { Particle } from "babylonjs/Particles/particle";
  12865. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12866. /**
  12867. * Particle emitter emitting particles from the inside of a sphere.
  12868. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12869. */
  12870. export class SphereParticleEmitter implements IParticleEmitterType {
  12871. /**
  12872. * The radius of the emission sphere.
  12873. */
  12874. radius: number;
  12875. /**
  12876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12877. */
  12878. radiusRange: number;
  12879. /**
  12880. * How much to randomize the particle direction [0-1].
  12881. */
  12882. directionRandomizer: number;
  12883. /**
  12884. * Creates a new instance SphereParticleEmitter
  12885. * @param radius the radius of the emission sphere (1 by default)
  12886. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12887. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12888. */
  12889. constructor(
  12890. /**
  12891. * The radius of the emission sphere.
  12892. */
  12893. radius?: number,
  12894. /**
  12895. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12896. */
  12897. radiusRange?: number,
  12898. /**
  12899. * How much to randomize the particle direction [0-1].
  12900. */
  12901. directionRandomizer?: number);
  12902. /**
  12903. * Called by the particle System when the direction is computed for the created particle.
  12904. * @param worldMatrix is the world matrix of the particle system
  12905. * @param directionToUpdate is the direction vector to update with the result
  12906. * @param particle is the particle we are computed the direction for
  12907. */
  12908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12909. /**
  12910. * Called by the particle System when the position is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param positionToUpdate is the position vector to update with the result
  12913. * @param particle is the particle we are computed the position for
  12914. */
  12915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Clones the current emitter and returns a copy of it
  12918. * @returns the new emitter
  12919. */
  12920. clone(): SphereParticleEmitter;
  12921. /**
  12922. * Called by the GPUParticleSystem to setup the update shader
  12923. * @param effect defines the update shader
  12924. */
  12925. applyToShader(effect: Effect): void;
  12926. /**
  12927. * Returns a string to use to update the GPU particles update shader
  12928. * @returns a string containng the defines string
  12929. */
  12930. getEffectDefines(): string;
  12931. /**
  12932. * Returns the string "SphereParticleEmitter"
  12933. * @returns a string containing the class name
  12934. */
  12935. getClassName(): string;
  12936. /**
  12937. * Serializes the particle system to a JSON object.
  12938. * @returns the JSON object
  12939. */
  12940. serialize(): any;
  12941. /**
  12942. * Parse properties from a JSON object
  12943. * @param serializationObject defines the JSON object
  12944. */
  12945. parse(serializationObject: any): void;
  12946. }
  12947. /**
  12948. * Particle emitter emitting particles from the inside of a sphere.
  12949. * It emits the particles randomly between two vectors.
  12950. */
  12951. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12952. /**
  12953. * The min limit of the emission direction.
  12954. */
  12955. direction1: Vector3;
  12956. /**
  12957. * The max limit of the emission direction.
  12958. */
  12959. direction2: Vector3;
  12960. /**
  12961. * Creates a new instance SphereDirectedParticleEmitter
  12962. * @param radius the radius of the emission sphere (1 by default)
  12963. * @param direction1 the min limit of the emission direction (up vector by default)
  12964. * @param direction2 the max limit of the emission direction (up vector by default)
  12965. */
  12966. constructor(radius?: number,
  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. * Called by the particle System when the direction is computed for the created particle.
  12977. * @param worldMatrix is the world matrix of the particle system
  12978. * @param directionToUpdate is the direction vector to update with the result
  12979. * @param particle is the particle we are computed the direction for
  12980. */
  12981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12982. /**
  12983. * Clones the current emitter and returns a copy of it
  12984. * @returns the new emitter
  12985. */
  12986. clone(): SphereDirectedParticleEmitter;
  12987. /**
  12988. * Called by the GPUParticleSystem to setup the update shader
  12989. * @param effect defines the update shader
  12990. */
  12991. applyToShader(effect: Effect): void;
  12992. /**
  12993. * Returns a string to use to update the GPU particles update shader
  12994. * @returns a string containng the defines string
  12995. */
  12996. getEffectDefines(): string;
  12997. /**
  12998. * Returns the string "SphereDirectedParticleEmitter"
  12999. * @returns a string containing the class name
  13000. */
  13001. getClassName(): string;
  13002. /**
  13003. * Serializes the particle system to a JSON object.
  13004. * @returns the JSON object
  13005. */
  13006. serialize(): any;
  13007. /**
  13008. * Parse properties from a JSON object
  13009. * @param serializationObject defines the JSON object
  13010. */
  13011. parse(serializationObject: any): void;
  13012. }
  13013. }
  13014. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13015. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13016. import { Effect } from "babylonjs/Materials/effect";
  13017. import { Particle } from "babylonjs/Particles/particle";
  13018. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13019. import { Nullable } from "babylonjs/types";
  13020. /**
  13021. * Particle emitter emitting particles from a custom list of positions.
  13022. */
  13023. export class CustomParticleEmitter implements IParticleEmitterType {
  13024. /**
  13025. * Gets or sets the position generator that will create the inital position of each particle.
  13026. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13027. */
  13028. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13029. /**
  13030. * Gets or sets the destination generator that will create the final destination of each particle.
  13031. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13032. */
  13033. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13034. /**
  13035. * Creates a new instance CustomParticleEmitter
  13036. */
  13037. constructor();
  13038. /**
  13039. * Called by the particle System when the direction is computed for the created particle.
  13040. * @param worldMatrix is the world matrix of the particle system
  13041. * @param directionToUpdate is the direction vector to update with the result
  13042. * @param particle is the particle we are computed the direction for
  13043. */
  13044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13045. /**
  13046. * Called by the particle System when the position is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param positionToUpdate is the position vector to update with the result
  13049. * @param particle is the particle we are computed the position for
  13050. */
  13051. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Clones the current emitter and returns a copy of it
  13054. * @returns the new emitter
  13055. */
  13056. clone(): CustomParticleEmitter;
  13057. /**
  13058. * Called by the GPUParticleSystem to setup the update shader
  13059. * @param effect defines the update shader
  13060. */
  13061. applyToShader(effect: Effect): void;
  13062. /**
  13063. * Returns a string to use to update the GPU particles update shader
  13064. * @returns a string containng the defines string
  13065. */
  13066. getEffectDefines(): string;
  13067. /**
  13068. * Returns the string "PointParticleEmitter"
  13069. * @returns a string containing the class name
  13070. */
  13071. getClassName(): string;
  13072. /**
  13073. * Serializes the particle system to a JSON object.
  13074. * @returns the JSON object
  13075. */
  13076. serialize(): any;
  13077. /**
  13078. * Parse properties from a JSON object
  13079. * @param serializationObject defines the JSON object
  13080. */
  13081. parse(serializationObject: any): void;
  13082. }
  13083. }
  13084. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13085. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13086. import { Effect } from "babylonjs/Materials/effect";
  13087. import { Particle } from "babylonjs/Particles/particle";
  13088. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13089. import { Scene } from "babylonjs/scene";
  13090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13091. /**
  13092. * Particle emitter emitting particles from the inside of a box.
  13093. * It emits the particles randomly between 2 given directions.
  13094. */
  13095. export class MeshParticleEmitter implements IParticleEmitterType {
  13096. /** Defines the mesh to use as source */
  13097. mesh?: AbstractMesh | undefined;
  13098. private _indices;
  13099. private _positions;
  13100. private _normals;
  13101. private _storedNormal;
  13102. /**
  13103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13104. */
  13105. direction1: Vector3;
  13106. /**
  13107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13108. */
  13109. direction2: Vector3;
  13110. /**
  13111. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13112. */
  13113. useMeshNormalsForDirection: boolean;
  13114. /**
  13115. * Creates a new instance MeshParticleEmitter
  13116. * @param mesh defines the mesh to use as source
  13117. */
  13118. constructor(
  13119. /** Defines the mesh to use as source */
  13120. mesh?: AbstractMesh | undefined);
  13121. /**
  13122. * Called by the particle System when the direction is computed for the created particle.
  13123. * @param worldMatrix is the world matrix of the particle system
  13124. * @param directionToUpdate is the direction vector to update with the result
  13125. * @param particle is the particle we are computed the direction for
  13126. */
  13127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13128. /**
  13129. * Called by the particle System when the position is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param positionToUpdate is the position vector to update with the result
  13132. * @param particle is the particle we are computed the position for
  13133. */
  13134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Clones the current emitter and returns a copy of it
  13137. * @returns the new emitter
  13138. */
  13139. clone(): MeshParticleEmitter;
  13140. /**
  13141. * Called by the GPUParticleSystem to setup the update shader
  13142. * @param effect defines the update shader
  13143. */
  13144. applyToShader(effect: Effect): void;
  13145. /**
  13146. * Returns a string to use to update the GPU particles update shader
  13147. * @returns a string containng the defines string
  13148. */
  13149. getEffectDefines(): string;
  13150. /**
  13151. * Returns the string "BoxParticleEmitter"
  13152. * @returns a string containing the class name
  13153. */
  13154. getClassName(): string;
  13155. /**
  13156. * Serializes the particle system to a JSON object.
  13157. * @returns the JSON object
  13158. */
  13159. serialize(): any;
  13160. /**
  13161. * Parse properties from a JSON object
  13162. * @param serializationObject defines the JSON object
  13163. * @param scene defines the hosting scene
  13164. */
  13165. parse(serializationObject: any, scene: Scene): void;
  13166. }
  13167. }
  13168. declare module "babylonjs/Particles/EmitterTypes/index" {
  13169. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13170. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13171. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13172. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13173. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13174. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13175. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13176. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13178. }
  13179. declare module "babylonjs/Particles/IParticleSystem" {
  13180. import { Nullable } from "babylonjs/types";
  13181. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13182. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13185. import { Texture } from "babylonjs/Materials/Textures/texture";
  13186. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13187. import { Scene } from "babylonjs/scene";
  13188. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13189. import { Animation } from "babylonjs/Animations/animation";
  13190. /**
  13191. * Interface representing a particle system in Babylon.js.
  13192. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13193. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13194. */
  13195. export interface IParticleSystem {
  13196. /**
  13197. * List of animations used by the particle system.
  13198. */
  13199. animations: Animation[];
  13200. /**
  13201. * The id of the Particle system.
  13202. */
  13203. id: string;
  13204. /**
  13205. * The name of the Particle system.
  13206. */
  13207. name: string;
  13208. /**
  13209. * The emitter represents the Mesh or position we are attaching the particle system to.
  13210. */
  13211. emitter: Nullable<AbstractMesh | Vector3>;
  13212. /**
  13213. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13214. */
  13215. isBillboardBased: boolean;
  13216. /**
  13217. * The rendering group used by the Particle system to chose when to render.
  13218. */
  13219. renderingGroupId: number;
  13220. /**
  13221. * The layer mask we are rendering the particles through.
  13222. */
  13223. layerMask: number;
  13224. /**
  13225. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13226. */
  13227. updateSpeed: number;
  13228. /**
  13229. * The amount of time the particle system is running (depends of the overall update speed).
  13230. */
  13231. targetStopDuration: number;
  13232. /**
  13233. * The texture used to render each particle. (this can be a spritesheet)
  13234. */
  13235. particleTexture: Nullable<Texture>;
  13236. /**
  13237. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13238. */
  13239. blendMode: number;
  13240. /**
  13241. * Minimum life time of emitting particles.
  13242. */
  13243. minLifeTime: number;
  13244. /**
  13245. * Maximum life time of emitting particles.
  13246. */
  13247. maxLifeTime: number;
  13248. /**
  13249. * Minimum Size of emitting particles.
  13250. */
  13251. minSize: number;
  13252. /**
  13253. * Maximum Size of emitting particles.
  13254. */
  13255. maxSize: number;
  13256. /**
  13257. * Minimum scale of emitting particles on X axis.
  13258. */
  13259. minScaleX: number;
  13260. /**
  13261. * Maximum scale of emitting particles on X axis.
  13262. */
  13263. maxScaleX: number;
  13264. /**
  13265. * Minimum scale of emitting particles on Y axis.
  13266. */
  13267. minScaleY: number;
  13268. /**
  13269. * Maximum scale of emitting particles on Y axis.
  13270. */
  13271. maxScaleY: number;
  13272. /**
  13273. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13274. */
  13275. color1: Color4;
  13276. /**
  13277. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13278. */
  13279. color2: Color4;
  13280. /**
  13281. * Color the particle will have at the end of its lifetime.
  13282. */
  13283. colorDead: Color4;
  13284. /**
  13285. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13286. */
  13287. emitRate: number;
  13288. /**
  13289. * You can use gravity if you want to give an orientation to your particles.
  13290. */
  13291. gravity: Vector3;
  13292. /**
  13293. * Minimum power of emitting particles.
  13294. */
  13295. minEmitPower: number;
  13296. /**
  13297. * Maximum power of emitting particles.
  13298. */
  13299. maxEmitPower: number;
  13300. /**
  13301. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13302. */
  13303. minAngularSpeed: number;
  13304. /**
  13305. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13306. */
  13307. maxAngularSpeed: number;
  13308. /**
  13309. * Gets or sets the minimal initial rotation in radians.
  13310. */
  13311. minInitialRotation: number;
  13312. /**
  13313. * Gets or sets the maximal initial rotation in radians.
  13314. */
  13315. maxInitialRotation: number;
  13316. /**
  13317. * The particle emitter type defines the emitter used by the particle system.
  13318. * It can be for example box, sphere, or cone...
  13319. */
  13320. particleEmitterType: Nullable<IParticleEmitterType>;
  13321. /**
  13322. * Defines the delay in milliseconds before starting the system (0 by default)
  13323. */
  13324. startDelay: number;
  13325. /**
  13326. * 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
  13327. */
  13328. preWarmCycles: number;
  13329. /**
  13330. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13331. */
  13332. preWarmStepOffset: number;
  13333. /**
  13334. * 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)
  13335. */
  13336. spriteCellChangeSpeed: number;
  13337. /**
  13338. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13339. */
  13340. startSpriteCellID: number;
  13341. /**
  13342. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13343. */
  13344. endSpriteCellID: number;
  13345. /**
  13346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13347. */
  13348. spriteCellWidth: number;
  13349. /**
  13350. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13351. */
  13352. spriteCellHeight: number;
  13353. /**
  13354. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13355. */
  13356. spriteRandomStartCell: boolean;
  13357. /**
  13358. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13359. */
  13360. isAnimationSheetEnabled: boolean;
  13361. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13362. translationPivot: Vector2;
  13363. /**
  13364. * Gets or sets a texture used to add random noise to particle positions
  13365. */
  13366. noiseTexture: Nullable<BaseTexture>;
  13367. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13368. noiseStrength: Vector3;
  13369. /**
  13370. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13371. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13372. */
  13373. billboardMode: number;
  13374. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13375. limitVelocityDamping: number;
  13376. /**
  13377. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13378. */
  13379. beginAnimationOnStart: boolean;
  13380. /**
  13381. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13382. */
  13383. beginAnimationFrom: number;
  13384. /**
  13385. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13386. */
  13387. beginAnimationTo: number;
  13388. /**
  13389. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13390. */
  13391. beginAnimationLoop: boolean;
  13392. /**
  13393. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13394. */
  13395. disposeOnStop: boolean;
  13396. /**
  13397. * Gets the maximum number of particles active at the same time.
  13398. * @returns The max number of active particles.
  13399. */
  13400. getCapacity(): number;
  13401. /**
  13402. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13403. * @returns True if it has been started, otherwise false.
  13404. */
  13405. isStarted(): boolean;
  13406. /**
  13407. * Animates the particle system for this frame.
  13408. */
  13409. animate(): void;
  13410. /**
  13411. * Renders the particle system in its current state.
  13412. * @returns the current number of particles
  13413. */
  13414. render(): number;
  13415. /**
  13416. * Dispose the particle system and frees its associated resources.
  13417. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13418. */
  13419. dispose(disposeTexture?: boolean): void;
  13420. /**
  13421. * Clones the particle system.
  13422. * @param name The name of the cloned object
  13423. * @param newEmitter The new emitter to use
  13424. * @returns the cloned particle system
  13425. */
  13426. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13427. /**
  13428. * Serializes the particle system to a JSON object.
  13429. * @returns the JSON object
  13430. */
  13431. serialize(): any;
  13432. /**
  13433. * Rebuild the particle system
  13434. */
  13435. rebuild(): void;
  13436. /**
  13437. * Starts the particle system and begins to emit
  13438. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13439. */
  13440. start(delay?: number): void;
  13441. /**
  13442. * Stops the particle system.
  13443. */
  13444. stop(): void;
  13445. /**
  13446. * Remove all active particles
  13447. */
  13448. reset(): void;
  13449. /**
  13450. * Is this system ready to be used/rendered
  13451. * @return true if the system is ready
  13452. */
  13453. isReady(): boolean;
  13454. /**
  13455. * Adds a new color gradient
  13456. * @param gradient defines the gradient to use (between 0 and 1)
  13457. * @param color1 defines the color to affect to the specified gradient
  13458. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13459. * @returns the current particle system
  13460. */
  13461. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13462. /**
  13463. * Remove a specific color gradient
  13464. * @param gradient defines the gradient to remove
  13465. * @returns the current particle system
  13466. */
  13467. removeColorGradient(gradient: number): IParticleSystem;
  13468. /**
  13469. * Adds a new size gradient
  13470. * @param gradient defines the gradient to use (between 0 and 1)
  13471. * @param factor defines the size factor to affect to the specified gradient
  13472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13473. * @returns the current particle system
  13474. */
  13475. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13476. /**
  13477. * Remove a specific size gradient
  13478. * @param gradient defines the gradient to remove
  13479. * @returns the current particle system
  13480. */
  13481. removeSizeGradient(gradient: number): IParticleSystem;
  13482. /**
  13483. * Gets the current list of color gradients.
  13484. * You must use addColorGradient and removeColorGradient to udpate this list
  13485. * @returns the list of color gradients
  13486. */
  13487. getColorGradients(): Nullable<Array<ColorGradient>>;
  13488. /**
  13489. * Gets the current list of size gradients.
  13490. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13491. * @returns the list of size gradients
  13492. */
  13493. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13494. /**
  13495. * Gets the current list of angular speed gradients.
  13496. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13497. * @returns the list of angular speed gradients
  13498. */
  13499. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13500. /**
  13501. * Adds a new angular speed gradient
  13502. * @param gradient defines the gradient to use (between 0 and 1)
  13503. * @param factor defines the angular speed to affect to the specified gradient
  13504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13505. * @returns the current particle system
  13506. */
  13507. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13508. /**
  13509. * Remove a specific angular speed gradient
  13510. * @param gradient defines the gradient to remove
  13511. * @returns the current particle system
  13512. */
  13513. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13514. /**
  13515. * Gets the current list of velocity gradients.
  13516. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13517. * @returns the list of velocity gradients
  13518. */
  13519. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13520. /**
  13521. * Adds a new velocity gradient
  13522. * @param gradient defines the gradient to use (between 0 and 1)
  13523. * @param factor defines the velocity to affect to the specified gradient
  13524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13525. * @returns the current particle system
  13526. */
  13527. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13528. /**
  13529. * Remove a specific velocity gradient
  13530. * @param gradient defines the gradient to remove
  13531. * @returns the current particle system
  13532. */
  13533. removeVelocityGradient(gradient: number): IParticleSystem;
  13534. /**
  13535. * Gets the current list of limit velocity gradients.
  13536. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13537. * @returns the list of limit velocity gradients
  13538. */
  13539. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13540. /**
  13541. * Adds a new limit velocity gradient
  13542. * @param gradient defines the gradient to use (between 0 and 1)
  13543. * @param factor defines the limit velocity to affect to the specified gradient
  13544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13545. * @returns the current particle system
  13546. */
  13547. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13548. /**
  13549. * Remove a specific limit velocity gradient
  13550. * @param gradient defines the gradient to remove
  13551. * @returns the current particle system
  13552. */
  13553. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13554. /**
  13555. * Adds a new drag gradient
  13556. * @param gradient defines the gradient to use (between 0 and 1)
  13557. * @param factor defines the drag to affect to the specified gradient
  13558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13559. * @returns the current particle system
  13560. */
  13561. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13562. /**
  13563. * Remove a specific drag gradient
  13564. * @param gradient defines the gradient to remove
  13565. * @returns the current particle system
  13566. */
  13567. removeDragGradient(gradient: number): IParticleSystem;
  13568. /**
  13569. * Gets the current list of drag gradients.
  13570. * You must use addDragGradient and removeDragGradient to udpate this list
  13571. * @returns the list of drag gradients
  13572. */
  13573. getDragGradients(): Nullable<Array<FactorGradient>>;
  13574. /**
  13575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13576. * @param gradient defines the gradient to use (between 0 and 1)
  13577. * @param factor defines the emit rate to affect to the specified gradient
  13578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13579. * @returns the current particle system
  13580. */
  13581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13582. /**
  13583. * Remove a specific emit rate gradient
  13584. * @param gradient defines the gradient to remove
  13585. * @returns the current particle system
  13586. */
  13587. removeEmitRateGradient(gradient: number): IParticleSystem;
  13588. /**
  13589. * Gets the current list of emit rate gradients.
  13590. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13591. * @returns the list of emit rate gradients
  13592. */
  13593. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13594. /**
  13595. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13596. * @param gradient defines the gradient to use (between 0 and 1)
  13597. * @param factor defines the start size to affect to the specified gradient
  13598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13599. * @returns the current particle system
  13600. */
  13601. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13602. /**
  13603. * Remove a specific start size gradient
  13604. * @param gradient defines the gradient to remove
  13605. * @returns the current particle system
  13606. */
  13607. removeStartSizeGradient(gradient: number): IParticleSystem;
  13608. /**
  13609. * Gets the current list of start size gradients.
  13610. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13611. * @returns the list of start size gradients
  13612. */
  13613. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13614. /**
  13615. * Adds a new life time gradient
  13616. * @param gradient defines the gradient to use (between 0 and 1)
  13617. * @param factor defines the life time factor to affect to the specified gradient
  13618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13619. * @returns the current particle system
  13620. */
  13621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13622. /**
  13623. * Remove a specific life time gradient
  13624. * @param gradient defines the gradient to remove
  13625. * @returns the current particle system
  13626. */
  13627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13628. /**
  13629. * Gets the current list of life time gradients.
  13630. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13631. * @returns the list of life time gradients
  13632. */
  13633. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13634. /**
  13635. * Gets the current list of color gradients.
  13636. * You must use addColorGradient and removeColorGradient to udpate this list
  13637. * @returns the list of color gradients
  13638. */
  13639. getColorGradients(): Nullable<Array<ColorGradient>>;
  13640. /**
  13641. * Adds a new ramp gradient used to remap particle colors
  13642. * @param gradient defines the gradient to use (between 0 and 1)
  13643. * @param color defines the color to affect to the specified gradient
  13644. * @returns the current particle system
  13645. */
  13646. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13647. /**
  13648. * Gets the current list of ramp gradients.
  13649. * You must use addRampGradient and removeRampGradient to udpate this list
  13650. * @returns the list of ramp gradients
  13651. */
  13652. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13653. /** Gets or sets a boolean indicating that ramp gradients must be used
  13654. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13655. */
  13656. useRampGradients: boolean;
  13657. /**
  13658. * Adds a new color remap gradient
  13659. * @param gradient defines the gradient to use (between 0 and 1)
  13660. * @param min defines the color remap minimal range
  13661. * @param max defines the color remap maximal range
  13662. * @returns the current particle system
  13663. */
  13664. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13665. /**
  13666. * Gets the current list of color remap gradients.
  13667. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13668. * @returns the list of color remap gradients
  13669. */
  13670. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13671. /**
  13672. * Adds a new alpha remap gradient
  13673. * @param gradient defines the gradient to use (between 0 and 1)
  13674. * @param min defines the alpha remap minimal range
  13675. * @param max defines the alpha remap maximal range
  13676. * @returns the current particle system
  13677. */
  13678. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13679. /**
  13680. * Gets the current list of alpha remap gradients.
  13681. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13682. * @returns the list of alpha remap gradients
  13683. */
  13684. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13685. /**
  13686. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13689. * @returns the emitter
  13690. */
  13691. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13692. /**
  13693. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13694. * @param radius The radius of the hemisphere to emit from
  13695. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13696. * @returns the emitter
  13697. */
  13698. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13699. /**
  13700. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13701. * @param radius The radius of the sphere to emit from
  13702. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13706. /**
  13707. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13711. * @returns the emitter
  13712. */
  13713. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13714. /**
  13715. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13716. * @param radius The radius of the emission cylinder
  13717. * @param height The height of the emission cylinder
  13718. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13719. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13720. * @returns the emitter
  13721. */
  13722. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13723. /**
  13724. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13725. * @param radius The radius of the cylinder to emit from
  13726. * @param height The height of the emission cylinder
  13727. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13730. * @returns the emitter
  13731. */
  13732. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13733. /**
  13734. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13735. * @param radius The radius of the cone to emit from
  13736. * @param angle The base angle of the cone
  13737. * @returns the emitter
  13738. */
  13739. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13740. /**
  13741. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13742. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13743. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13744. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13745. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13746. * @returns the emitter
  13747. */
  13748. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13749. /**
  13750. * Get hosting scene
  13751. * @returns the scene
  13752. */
  13753. getScene(): Scene;
  13754. }
  13755. }
  13756. declare module "babylonjs/Meshes/transformNode" {
  13757. import { DeepImmutable } from "babylonjs/types";
  13758. import { Observable } from "babylonjs/Misc/observable";
  13759. import { Nullable } from "babylonjs/types";
  13760. import { Camera } from "babylonjs/Cameras/camera";
  13761. import { Scene } from "babylonjs/scene";
  13762. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13763. import { Node } from "babylonjs/node";
  13764. import { Bone } from "babylonjs/Bones/bone";
  13765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13766. import { Space } from "babylonjs/Maths/math.axis";
  13767. /**
  13768. * 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.
  13769. * @see https://doc.babylonjs.com/how_to/transformnode
  13770. */
  13771. export class TransformNode extends Node {
  13772. /**
  13773. * Object will not rotate to face the camera
  13774. */
  13775. static BILLBOARDMODE_NONE: number;
  13776. /**
  13777. * Object will rotate to face the camera but only on the x axis
  13778. */
  13779. static BILLBOARDMODE_X: number;
  13780. /**
  13781. * Object will rotate to face the camera but only on the y axis
  13782. */
  13783. static BILLBOARDMODE_Y: number;
  13784. /**
  13785. * Object will rotate to face the camera but only on the z axis
  13786. */
  13787. static BILLBOARDMODE_Z: number;
  13788. /**
  13789. * Object will rotate to face the camera
  13790. */
  13791. static BILLBOARDMODE_ALL: number;
  13792. /**
  13793. * Object will rotate to face the camera's position instead of orientation
  13794. */
  13795. static BILLBOARDMODE_USE_POSITION: number;
  13796. private _forward;
  13797. private _forwardInverted;
  13798. private _up;
  13799. private _right;
  13800. private _rightInverted;
  13801. private _position;
  13802. private _rotation;
  13803. private _rotationQuaternion;
  13804. protected _scaling: Vector3;
  13805. protected _isDirty: boolean;
  13806. private _transformToBoneReferal;
  13807. private _isAbsoluteSynced;
  13808. private _billboardMode;
  13809. /**
  13810. * Gets or sets the billboard mode. Default is 0.
  13811. *
  13812. * | Value | Type | Description |
  13813. * | --- | --- | --- |
  13814. * | 0 | BILLBOARDMODE_NONE | |
  13815. * | 1 | BILLBOARDMODE_X | |
  13816. * | 2 | BILLBOARDMODE_Y | |
  13817. * | 4 | BILLBOARDMODE_Z | |
  13818. * | 7 | BILLBOARDMODE_ALL | |
  13819. *
  13820. */
  13821. get billboardMode(): number;
  13822. set billboardMode(value: number);
  13823. private _preserveParentRotationForBillboard;
  13824. /**
  13825. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13826. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13827. */
  13828. get preserveParentRotationForBillboard(): boolean;
  13829. set preserveParentRotationForBillboard(value: boolean);
  13830. /**
  13831. * 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
  13832. */
  13833. scalingDeterminant: number;
  13834. private _infiniteDistance;
  13835. /**
  13836. * Gets or sets the distance of the object to max, often used by skybox
  13837. */
  13838. get infiniteDistance(): boolean;
  13839. set infiniteDistance(value: boolean);
  13840. /**
  13841. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13842. * By default the system will update normals to compensate
  13843. */
  13844. ignoreNonUniformScaling: boolean;
  13845. /**
  13846. * 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
  13847. */
  13848. reIntegrateRotationIntoRotationQuaternion: boolean;
  13849. /** @hidden */
  13850. _poseMatrix: Nullable<Matrix>;
  13851. /** @hidden */
  13852. _localMatrix: Matrix;
  13853. private _usePivotMatrix;
  13854. private _absolutePosition;
  13855. private _absoluteScaling;
  13856. private _absoluteRotationQuaternion;
  13857. private _pivotMatrix;
  13858. private _pivotMatrixInverse;
  13859. protected _postMultiplyPivotMatrix: boolean;
  13860. protected _isWorldMatrixFrozen: boolean;
  13861. /** @hidden */
  13862. _indexInSceneTransformNodesArray: number;
  13863. /**
  13864. * An event triggered after the world matrix is updated
  13865. */
  13866. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13867. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13868. /**
  13869. * Gets a string identifying the name of the class
  13870. * @returns "TransformNode" string
  13871. */
  13872. getClassName(): string;
  13873. /**
  13874. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13875. */
  13876. get position(): Vector3;
  13877. set position(newPosition: Vector3);
  13878. /**
  13879. * 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)).
  13880. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13881. */
  13882. get rotation(): Vector3;
  13883. set rotation(newRotation: Vector3);
  13884. /**
  13885. * 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)).
  13886. */
  13887. get scaling(): Vector3;
  13888. set scaling(newScaling: Vector3);
  13889. /**
  13890. * 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).
  13891. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13892. */
  13893. get rotationQuaternion(): Nullable<Quaternion>;
  13894. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13895. /**
  13896. * The forward direction of that transform in world space.
  13897. */
  13898. get forward(): Vector3;
  13899. /**
  13900. * The up direction of that transform in world space.
  13901. */
  13902. get up(): Vector3;
  13903. /**
  13904. * The right direction of that transform in world space.
  13905. */
  13906. get right(): Vector3;
  13907. /**
  13908. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13909. * @param matrix the matrix to copy the pose from
  13910. * @returns this TransformNode.
  13911. */
  13912. updatePoseMatrix(matrix: Matrix): TransformNode;
  13913. /**
  13914. * Returns the mesh Pose matrix.
  13915. * @returns the pose matrix
  13916. */
  13917. getPoseMatrix(): Matrix;
  13918. /** @hidden */
  13919. _isSynchronized(): boolean;
  13920. /** @hidden */
  13921. _initCache(): void;
  13922. /**
  13923. * Flag the transform node as dirty (Forcing it to update everything)
  13924. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13925. * @returns this transform node
  13926. */
  13927. markAsDirty(property: string): TransformNode;
  13928. /**
  13929. * Returns the current mesh absolute position.
  13930. * Returns a Vector3.
  13931. */
  13932. get absolutePosition(): Vector3;
  13933. /**
  13934. * Returns the current mesh absolute scaling.
  13935. * Returns a Vector3.
  13936. */
  13937. get absoluteScaling(): Vector3;
  13938. /**
  13939. * Returns the current mesh absolute rotation.
  13940. * Returns a Quaternion.
  13941. */
  13942. get absoluteRotationQuaternion(): Quaternion;
  13943. /**
  13944. * Sets a new matrix to apply before all other transformation
  13945. * @param matrix defines the transform matrix
  13946. * @returns the current TransformNode
  13947. */
  13948. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13949. /**
  13950. * Sets a new pivot matrix to the current node
  13951. * @param matrix defines the new pivot matrix to use
  13952. * @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
  13953. * @returns the current TransformNode
  13954. */
  13955. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13956. /**
  13957. * Returns the mesh pivot matrix.
  13958. * Default : Identity.
  13959. * @returns the matrix
  13960. */
  13961. getPivotMatrix(): Matrix;
  13962. /**
  13963. * Instantiate (when possible) or clone that node with its hierarchy
  13964. * @param newParent defines the new parent to use for the instance (or clone)
  13965. * @param options defines options to configure how copy is done
  13966. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13967. * @returns an instance (or a clone) of the current node with its hiearchy
  13968. */
  13969. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13970. doNotInstantiate: boolean;
  13971. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13972. /**
  13973. * Prevents the World matrix to be computed any longer
  13974. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13975. * @returns the TransformNode.
  13976. */
  13977. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13978. /**
  13979. * Allows back the World matrix computation.
  13980. * @returns the TransformNode.
  13981. */
  13982. unfreezeWorldMatrix(): this;
  13983. /**
  13984. * True if the World matrix has been frozen.
  13985. */
  13986. get isWorldMatrixFrozen(): boolean;
  13987. /**
  13988. * Retuns the mesh absolute position in the World.
  13989. * @returns a Vector3.
  13990. */
  13991. getAbsolutePosition(): Vector3;
  13992. /**
  13993. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13994. * @param absolutePosition the absolute position to set
  13995. * @returns the TransformNode.
  13996. */
  13997. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13998. /**
  13999. * Sets the mesh position in its local space.
  14000. * @param vector3 the position to set in localspace
  14001. * @returns the TransformNode.
  14002. */
  14003. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14004. /**
  14005. * Returns the mesh position in the local space from the current World matrix values.
  14006. * @returns a new Vector3.
  14007. */
  14008. getPositionExpressedInLocalSpace(): Vector3;
  14009. /**
  14010. * Translates the mesh along the passed Vector3 in its local space.
  14011. * @param vector3 the distance to translate in localspace
  14012. * @returns the TransformNode.
  14013. */
  14014. locallyTranslate(vector3: Vector3): TransformNode;
  14015. private static _lookAtVectorCache;
  14016. /**
  14017. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14018. * @param targetPoint the position (must be in same space as current mesh) to look at
  14019. * @param yawCor optional yaw (y-axis) correction in radians
  14020. * @param pitchCor optional pitch (x-axis) correction in radians
  14021. * @param rollCor optional roll (z-axis) correction in radians
  14022. * @param space the choosen space of the target
  14023. * @returns the TransformNode.
  14024. */
  14025. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14026. /**
  14027. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14028. * This Vector3 is expressed in the World space.
  14029. * @param localAxis axis to rotate
  14030. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14031. */
  14032. getDirection(localAxis: Vector3): Vector3;
  14033. /**
  14034. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14035. * localAxis is expressed in the mesh local space.
  14036. * result is computed in the Wordl space from the mesh World matrix.
  14037. * @param localAxis axis to rotate
  14038. * @param result the resulting transformnode
  14039. * @returns this TransformNode.
  14040. */
  14041. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14042. /**
  14043. * Sets this transform node rotation to the given local axis.
  14044. * @param localAxis the axis in local space
  14045. * @param yawCor optional yaw (y-axis) correction in radians
  14046. * @param pitchCor optional pitch (x-axis) correction in radians
  14047. * @param rollCor optional roll (z-axis) correction in radians
  14048. * @returns this TransformNode
  14049. */
  14050. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14051. /**
  14052. * Sets a new pivot point to the current node
  14053. * @param point defines the new pivot point to use
  14054. * @param space defines if the point is in world or local space (local by default)
  14055. * @returns the current TransformNode
  14056. */
  14057. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14058. /**
  14059. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14060. * @returns the pivot point
  14061. */
  14062. getPivotPoint(): Vector3;
  14063. /**
  14064. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14065. * @param result the vector3 to store the result
  14066. * @returns this TransformNode.
  14067. */
  14068. getPivotPointToRef(result: Vector3): TransformNode;
  14069. /**
  14070. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14071. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14072. */
  14073. getAbsolutePivotPoint(): Vector3;
  14074. /**
  14075. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14076. * @param result vector3 to store the result
  14077. * @returns this TransformNode.
  14078. */
  14079. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14080. /**
  14081. * Defines the passed node as the parent of the current node.
  14082. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14083. * @see https://doc.babylonjs.com/how_to/parenting
  14084. * @param node the node ot set as the parent
  14085. * @returns this TransformNode.
  14086. */
  14087. setParent(node: Nullable<Node>): TransformNode;
  14088. private _nonUniformScaling;
  14089. /**
  14090. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14091. */
  14092. get nonUniformScaling(): boolean;
  14093. /** @hidden */
  14094. _updateNonUniformScalingState(value: boolean): boolean;
  14095. /**
  14096. * Attach the current TransformNode to another TransformNode associated with a bone
  14097. * @param bone Bone affecting the TransformNode
  14098. * @param affectedTransformNode TransformNode associated with the bone
  14099. * @returns this object
  14100. */
  14101. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14102. /**
  14103. * Detach the transform node if its associated with a bone
  14104. * @returns this object
  14105. */
  14106. detachFromBone(): TransformNode;
  14107. private static _rotationAxisCache;
  14108. /**
  14109. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14110. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14112. * The passed axis is also normalized.
  14113. * @param axis the axis to rotate around
  14114. * @param amount the amount to rotate in radians
  14115. * @param space Space to rotate in (Default: local)
  14116. * @returns the TransformNode.
  14117. */
  14118. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14119. /**
  14120. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14121. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14122. * The passed axis is also normalized. .
  14123. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14124. * @param point the point to rotate around
  14125. * @param axis the axis to rotate around
  14126. * @param amount the amount to rotate in radians
  14127. * @returns the TransformNode
  14128. */
  14129. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14130. /**
  14131. * Translates the mesh along the axis vector for the passed distance in the given space.
  14132. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14133. * @param axis the axis to translate in
  14134. * @param distance the distance to translate
  14135. * @param space Space to rotate in (Default: local)
  14136. * @returns the TransformNode.
  14137. */
  14138. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14139. /**
  14140. * Adds a rotation step to the mesh current rotation.
  14141. * x, y, z are Euler angles expressed in radians.
  14142. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14143. * This means this rotation is made in the mesh local space only.
  14144. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14145. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14146. * ```javascript
  14147. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14148. * ```
  14149. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14150. * 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.
  14151. * @param x Rotation to add
  14152. * @param y Rotation to add
  14153. * @param z Rotation to add
  14154. * @returns the TransformNode.
  14155. */
  14156. addRotation(x: number, y: number, z: number): TransformNode;
  14157. /**
  14158. * @hidden
  14159. */
  14160. protected _getEffectiveParent(): Nullable<Node>;
  14161. /**
  14162. * Computes the world matrix of the node
  14163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14164. * @returns the world matrix
  14165. */
  14166. computeWorldMatrix(force?: boolean): Matrix;
  14167. /**
  14168. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14169. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14170. */
  14171. resetLocalMatrix(independentOfChildren?: boolean): void;
  14172. protected _afterComputeWorldMatrix(): void;
  14173. /**
  14174. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14175. * @param func callback function to add
  14176. *
  14177. * @returns the TransformNode.
  14178. */
  14179. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14180. /**
  14181. * Removes a registered callback function.
  14182. * @param func callback function to remove
  14183. * @returns the TransformNode.
  14184. */
  14185. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14186. /**
  14187. * Gets the position of the current mesh in camera space
  14188. * @param camera defines the camera to use
  14189. * @returns a position
  14190. */
  14191. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14192. /**
  14193. * Returns the distance from the mesh to the active camera
  14194. * @param camera defines the camera to use
  14195. * @returns the distance
  14196. */
  14197. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14198. /**
  14199. * Clone the current transform node
  14200. * @param name Name of the new clone
  14201. * @param newParent New parent for the clone
  14202. * @param doNotCloneChildren Do not clone children hierarchy
  14203. * @returns the new transform node
  14204. */
  14205. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14206. /**
  14207. * Serializes the objects information.
  14208. * @param currentSerializationObject defines the object to serialize in
  14209. * @returns the serialized object
  14210. */
  14211. serialize(currentSerializationObject?: any): any;
  14212. /**
  14213. * Returns a new TransformNode object parsed from the source provided.
  14214. * @param parsedTransformNode is the source.
  14215. * @param scene the scne the object belongs to
  14216. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14217. * @returns a new TransformNode object parsed from the source provided.
  14218. */
  14219. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14220. /**
  14221. * Get all child-transformNodes of this node
  14222. * @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
  14223. * @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
  14224. * @returns an array of TransformNode
  14225. */
  14226. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14227. /**
  14228. * Releases resources associated with this transform node.
  14229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14231. */
  14232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14233. /**
  14234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14238. * @returns the current mesh
  14239. */
  14240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14241. private _syncAbsoluteScalingAndRotation;
  14242. }
  14243. }
  14244. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14245. /**
  14246. * Class used to override all child animations of a given target
  14247. */
  14248. export class AnimationPropertiesOverride {
  14249. /**
  14250. * Gets or sets a value indicating if animation blending must be used
  14251. */
  14252. enableBlending: boolean;
  14253. /**
  14254. * Gets or sets the blending speed to use when enableBlending is true
  14255. */
  14256. blendingSpeed: number;
  14257. /**
  14258. * Gets or sets the default loop mode to use
  14259. */
  14260. loopMode: number;
  14261. }
  14262. }
  14263. declare module "babylonjs/Bones/bone" {
  14264. import { Skeleton } from "babylonjs/Bones/skeleton";
  14265. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14266. import { Nullable } from "babylonjs/types";
  14267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14268. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14269. import { Node } from "babylonjs/node";
  14270. import { Space } from "babylonjs/Maths/math.axis";
  14271. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14272. /**
  14273. * Class used to store bone information
  14274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14275. */
  14276. export class Bone extends Node {
  14277. /**
  14278. * defines the bone name
  14279. */
  14280. name: string;
  14281. private static _tmpVecs;
  14282. private static _tmpQuat;
  14283. private static _tmpMats;
  14284. /**
  14285. * Gets the list of child bones
  14286. */
  14287. children: Bone[];
  14288. /** Gets the animations associated with this bone */
  14289. animations: import("babylonjs/Animations/animation").Animation[];
  14290. /**
  14291. * Gets or sets bone length
  14292. */
  14293. length: number;
  14294. /**
  14295. * @hidden Internal only
  14296. * Set this value to map this bone to a different index in the transform matrices
  14297. * Set this value to -1 to exclude the bone from the transform matrices
  14298. */
  14299. _index: Nullable<number>;
  14300. private _skeleton;
  14301. private _localMatrix;
  14302. private _restPose;
  14303. private _baseMatrix;
  14304. private _absoluteTransform;
  14305. private _invertedAbsoluteTransform;
  14306. private _parent;
  14307. private _scalingDeterminant;
  14308. private _worldTransform;
  14309. private _localScaling;
  14310. private _localRotation;
  14311. private _localPosition;
  14312. private _needToDecompose;
  14313. private _needToCompose;
  14314. /** @hidden */
  14315. _linkedTransformNode: Nullable<TransformNode>;
  14316. /** @hidden */
  14317. _waitingTransformNodeId: Nullable<string>;
  14318. /** @hidden */
  14319. get _matrix(): Matrix;
  14320. /** @hidden */
  14321. set _matrix(value: Matrix);
  14322. /**
  14323. * Create a new bone
  14324. * @param name defines the bone name
  14325. * @param skeleton defines the parent skeleton
  14326. * @param parentBone defines the parent (can be null if the bone is the root)
  14327. * @param localMatrix defines the local matrix
  14328. * @param restPose defines the rest pose matrix
  14329. * @param baseMatrix defines the base matrix
  14330. * @param index defines index of the bone in the hiearchy
  14331. */
  14332. constructor(
  14333. /**
  14334. * defines the bone name
  14335. */
  14336. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14337. /**
  14338. * Gets the current object class name.
  14339. * @return the class name
  14340. */
  14341. getClassName(): string;
  14342. /**
  14343. * Gets the parent skeleton
  14344. * @returns a skeleton
  14345. */
  14346. getSkeleton(): Skeleton;
  14347. /**
  14348. * Gets parent bone
  14349. * @returns a bone or null if the bone is the root of the bone hierarchy
  14350. */
  14351. getParent(): Nullable<Bone>;
  14352. /**
  14353. * Returns an array containing the root bones
  14354. * @returns an array containing the root bones
  14355. */
  14356. getChildren(): Array<Bone>;
  14357. /**
  14358. * Gets the node index in matrix array generated for rendering
  14359. * @returns the node index
  14360. */
  14361. getIndex(): number;
  14362. /**
  14363. * Sets the parent bone
  14364. * @param parent defines the parent (can be null if the bone is the root)
  14365. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14366. */
  14367. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14368. /**
  14369. * Gets the local matrix
  14370. * @returns a matrix
  14371. */
  14372. getLocalMatrix(): Matrix;
  14373. /**
  14374. * Gets the base matrix (initial matrix which remains unchanged)
  14375. * @returns a matrix
  14376. */
  14377. getBaseMatrix(): Matrix;
  14378. /**
  14379. * Gets the rest pose matrix
  14380. * @returns a matrix
  14381. */
  14382. getRestPose(): Matrix;
  14383. /**
  14384. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14385. */
  14386. getWorldMatrix(): Matrix;
  14387. /**
  14388. * Sets the local matrix to rest pose matrix
  14389. */
  14390. returnToRest(): void;
  14391. /**
  14392. * Gets the inverse of the absolute transform matrix.
  14393. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14394. * @returns a matrix
  14395. */
  14396. getInvertedAbsoluteTransform(): Matrix;
  14397. /**
  14398. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14399. * @returns a matrix
  14400. */
  14401. getAbsoluteTransform(): Matrix;
  14402. /**
  14403. * Links with the given transform node.
  14404. * The local matrix of this bone is copied from the transform node every frame.
  14405. * @param transformNode defines the transform node to link to
  14406. */
  14407. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14408. /**
  14409. * Gets the node used to drive the bone's transformation
  14410. * @returns a transform node or null
  14411. */
  14412. getTransformNode(): Nullable<TransformNode>;
  14413. /** Gets or sets current position (in local space) */
  14414. get position(): Vector3;
  14415. set position(newPosition: Vector3);
  14416. /** Gets or sets current rotation (in local space) */
  14417. get rotation(): Vector3;
  14418. set rotation(newRotation: Vector3);
  14419. /** Gets or sets current rotation quaternion (in local space) */
  14420. get rotationQuaternion(): Quaternion;
  14421. set rotationQuaternion(newRotation: Quaternion);
  14422. /** Gets or sets current scaling (in local space) */
  14423. get scaling(): Vector3;
  14424. set scaling(newScaling: Vector3);
  14425. /**
  14426. * Gets the animation properties override
  14427. */
  14428. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14429. private _decompose;
  14430. private _compose;
  14431. /**
  14432. * Update the base and local matrices
  14433. * @param matrix defines the new base or local matrix
  14434. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14435. * @param updateLocalMatrix defines if the local matrix should be updated
  14436. */
  14437. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14438. /** @hidden */
  14439. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14440. /**
  14441. * Flag the bone as dirty (Forcing it to update everything)
  14442. */
  14443. markAsDirty(): void;
  14444. /** @hidden */
  14445. _markAsDirtyAndCompose(): void;
  14446. private _markAsDirtyAndDecompose;
  14447. /**
  14448. * Translate the bone in local or world space
  14449. * @param vec The amount to translate the bone
  14450. * @param space The space that the translation is in
  14451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14452. */
  14453. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14454. /**
  14455. * Set the postion of the bone in local or world space
  14456. * @param position The position to set the bone
  14457. * @param space The space that the position is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the absolute position of the bone (world space)
  14463. * @param position The position to set the bone
  14464. * @param mesh The mesh that this bone is attached to
  14465. */
  14466. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14467. /**
  14468. * Scale the bone on the x, y and z axes (in local space)
  14469. * @param x The amount to scale the bone on the x axis
  14470. * @param y The amount to scale the bone on the y axis
  14471. * @param z The amount to scale the bone on the z axis
  14472. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14473. */
  14474. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14475. /**
  14476. * Set the bone scaling in local space
  14477. * @param scale defines the scaling vector
  14478. */
  14479. setScale(scale: Vector3): void;
  14480. /**
  14481. * Gets the current scaling in local space
  14482. * @returns the current scaling vector
  14483. */
  14484. getScale(): Vector3;
  14485. /**
  14486. * Gets the current scaling in local space and stores it in a target vector
  14487. * @param result defines the target vector
  14488. */
  14489. getScaleToRef(result: Vector3): void;
  14490. /**
  14491. * Set the yaw, pitch, and roll of the bone in local or world space
  14492. * @param yaw The rotation of the bone on the y axis
  14493. * @param pitch The rotation of the bone on the x axis
  14494. * @param roll The rotation of the bone on the z axis
  14495. * @param space The space that the axes of rotation are in
  14496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14497. */
  14498. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14499. /**
  14500. * Add a rotation to the bone on an axis in local or world space
  14501. * @param axis The axis to rotate the bone on
  14502. * @param amount The amount to rotate the bone
  14503. * @param space The space that the axis is in
  14504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14505. */
  14506. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14507. /**
  14508. * Set the rotation of the bone to a particular axis angle in local or world space
  14509. * @param axis The axis to rotate the bone on
  14510. * @param angle The angle that the bone should be rotated to
  14511. * @param space The space that the axis is in
  14512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14513. */
  14514. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14515. /**
  14516. * Set the euler rotation of the bone in local of world space
  14517. * @param rotation The euler rotation that the bone should be set to
  14518. * @param space The space that the rotation is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the quaternion rotation of the bone in local of world space
  14524. * @param quat The quaternion rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the rotation matrix of the bone in local of world space
  14531. * @param rotMat The rotation matrix that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14536. private _rotateWithMatrix;
  14537. private _getNegativeRotationToRef;
  14538. /**
  14539. * Get the position of the bone in local or world space
  14540. * @param space The space that the returned position is in
  14541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14542. * @returns The position of the bone
  14543. */
  14544. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14545. /**
  14546. * Copy the position of the bone to a vector3 in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @param result The vector3 to copy the position to
  14550. */
  14551. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14552. /**
  14553. * Get the absolute position of the bone (world space)
  14554. * @param mesh The mesh that this bone is attached to
  14555. * @returns The absolute position of the bone
  14556. */
  14557. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14558. /**
  14559. * Copy the absolute position of the bone (world space) to the result param
  14560. * @param mesh The mesh that this bone is attached to
  14561. * @param result The vector3 to copy the absolute position to
  14562. */
  14563. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14564. /**
  14565. * Compute the absolute transforms of this bone and its children
  14566. */
  14567. computeAbsoluteTransforms(): void;
  14568. /**
  14569. * Get the world direction from an axis that is in the local space of the bone
  14570. * @param localAxis The local direction that is used to compute the world direction
  14571. * @param mesh The mesh that this bone is attached to
  14572. * @returns The world direction
  14573. */
  14574. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14575. /**
  14576. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @param result The vector3 that the world direction will be copied to
  14580. */
  14581. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14582. /**
  14583. * Get the euler rotation of the bone in local or world space
  14584. * @param space The space that the rotation should be in
  14585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14586. * @returns The euler rotation
  14587. */
  14588. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14589. /**
  14590. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @param result The vector3 that the rotation should be copied to
  14594. */
  14595. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14596. /**
  14597. * Get the quaternion rotation of the bone in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @returns The quaternion rotation
  14601. */
  14602. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14603. /**
  14604. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @param result The quaternion that the rotation should be copied to
  14608. */
  14609. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14610. /**
  14611. * Get the rotation matrix of the bone in local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @returns The rotation matrix
  14615. */
  14616. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14617. /**
  14618. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @param result The quaternion that the rotation should be copied to
  14622. */
  14623. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14624. /**
  14625. * Get the world position of a point that is in the local space of the bone
  14626. * @param position The local position
  14627. * @param mesh The mesh that this bone is attached to
  14628. * @returns The world position
  14629. */
  14630. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @param result The vector3 that the world position should be copied to
  14636. */
  14637. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14638. /**
  14639. * Get the local position of a point that is in world space
  14640. * @param position The world position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @returns The local position
  14643. */
  14644. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14645. /**
  14646. * Get the local position of a point that is in world space and copy it to the result param
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @param result The vector3 that the local position should be copied to
  14650. */
  14651. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14652. }
  14653. }
  14654. declare module "babylonjs/Animations/runtimeAnimation" {
  14655. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14656. import { Animatable } from "babylonjs/Animations/animatable";
  14657. import { Scene } from "babylonjs/scene";
  14658. /**
  14659. * Defines a runtime animation
  14660. */
  14661. export class RuntimeAnimation {
  14662. private _events;
  14663. /**
  14664. * The current frame of the runtime animation
  14665. */
  14666. private _currentFrame;
  14667. /**
  14668. * The animation used by the runtime animation
  14669. */
  14670. private _animation;
  14671. /**
  14672. * The target of the runtime animation
  14673. */
  14674. private _target;
  14675. /**
  14676. * The initiating animatable
  14677. */
  14678. private _host;
  14679. /**
  14680. * The original value of the runtime animation
  14681. */
  14682. private _originalValue;
  14683. /**
  14684. * The original blend value of the runtime animation
  14685. */
  14686. private _originalBlendValue;
  14687. /**
  14688. * The offsets cache of the runtime animation
  14689. */
  14690. private _offsetsCache;
  14691. /**
  14692. * The high limits cache of the runtime animation
  14693. */
  14694. private _highLimitsCache;
  14695. /**
  14696. * Specifies if the runtime animation has been stopped
  14697. */
  14698. private _stopped;
  14699. /**
  14700. * The blending factor of the runtime animation
  14701. */
  14702. private _blendingFactor;
  14703. /**
  14704. * The BabylonJS scene
  14705. */
  14706. private _scene;
  14707. /**
  14708. * The current value of the runtime animation
  14709. */
  14710. private _currentValue;
  14711. /** @hidden */
  14712. _animationState: _IAnimationState;
  14713. /**
  14714. * The active target of the runtime animation
  14715. */
  14716. private _activeTargets;
  14717. private _currentActiveTarget;
  14718. private _directTarget;
  14719. /**
  14720. * The target path of the runtime animation
  14721. */
  14722. private _targetPath;
  14723. /**
  14724. * The weight of the runtime animation
  14725. */
  14726. private _weight;
  14727. /**
  14728. * The ratio offset of the runtime animation
  14729. */
  14730. private _ratioOffset;
  14731. /**
  14732. * The previous delay of the runtime animation
  14733. */
  14734. private _previousDelay;
  14735. /**
  14736. * The previous ratio of the runtime animation
  14737. */
  14738. private _previousRatio;
  14739. private _enableBlending;
  14740. private _keys;
  14741. private _minFrame;
  14742. private _maxFrame;
  14743. private _minValue;
  14744. private _maxValue;
  14745. private _targetIsArray;
  14746. /**
  14747. * Gets the current frame of the runtime animation
  14748. */
  14749. get currentFrame(): number;
  14750. /**
  14751. * Gets the weight of the runtime animation
  14752. */
  14753. get weight(): number;
  14754. /**
  14755. * Gets the current value of the runtime animation
  14756. */
  14757. get currentValue(): any;
  14758. /**
  14759. * Gets the target path of the runtime animation
  14760. */
  14761. get targetPath(): string;
  14762. /**
  14763. * Gets the actual target of the runtime animation
  14764. */
  14765. get target(): any;
  14766. /** @hidden */
  14767. _onLoop: () => void;
  14768. /**
  14769. * Create a new RuntimeAnimation object
  14770. * @param target defines the target of the animation
  14771. * @param animation defines the source animation object
  14772. * @param scene defines the hosting scene
  14773. * @param host defines the initiating Animatable
  14774. */
  14775. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14776. private _preparePath;
  14777. /**
  14778. * Gets the animation from the runtime animation
  14779. */
  14780. get animation(): Animation;
  14781. /**
  14782. * Resets the runtime animation to the beginning
  14783. * @param restoreOriginal defines whether to restore the target property to the original value
  14784. */
  14785. reset(restoreOriginal?: boolean): void;
  14786. /**
  14787. * Specifies if the runtime animation is stopped
  14788. * @returns Boolean specifying if the runtime animation is stopped
  14789. */
  14790. isStopped(): boolean;
  14791. /**
  14792. * Disposes of the runtime animation
  14793. */
  14794. dispose(): void;
  14795. /**
  14796. * Apply the interpolated value to the target
  14797. * @param currentValue defines the value computed by the animation
  14798. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14799. */
  14800. setValue(currentValue: any, weight: number): void;
  14801. private _getOriginalValues;
  14802. private _setValue;
  14803. /**
  14804. * Gets the loop pmode of the runtime animation
  14805. * @returns Loop Mode
  14806. */
  14807. private _getCorrectLoopMode;
  14808. /**
  14809. * Move the current animation to a given frame
  14810. * @param frame defines the frame to move to
  14811. */
  14812. goToFrame(frame: number): void;
  14813. /**
  14814. * @hidden Internal use only
  14815. */
  14816. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14817. /**
  14818. * Execute the current animation
  14819. * @param delay defines the delay to add to the current frame
  14820. * @param from defines the lower bound of the animation range
  14821. * @param to defines the upper bound of the animation range
  14822. * @param loop defines if the current animation must loop
  14823. * @param speedRatio defines the current speed ratio
  14824. * @param weight defines the weight of the animation (default is -1 so no weight)
  14825. * @param onLoop optional callback called when animation loops
  14826. * @returns a boolean indicating if the animation is running
  14827. */
  14828. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14829. }
  14830. }
  14831. declare module "babylonjs/Animations/animatable" {
  14832. import { Animation } from "babylonjs/Animations/animation";
  14833. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14834. import { Nullable } from "babylonjs/types";
  14835. import { Observable } from "babylonjs/Misc/observable";
  14836. import { Scene } from "babylonjs/scene";
  14837. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14838. import { Node } from "babylonjs/node";
  14839. /**
  14840. * Class used to store an actual running animation
  14841. */
  14842. export class Animatable {
  14843. /** defines the target object */
  14844. target: any;
  14845. /** defines the starting frame number (default is 0) */
  14846. fromFrame: number;
  14847. /** defines the ending frame number (default is 100) */
  14848. toFrame: number;
  14849. /** defines if the animation must loop (default is false) */
  14850. loopAnimation: boolean;
  14851. /** defines a callback to call when animation ends if it is not looping */
  14852. onAnimationEnd?: (() => void) | null | undefined;
  14853. /** defines a callback to call when animation loops */
  14854. onAnimationLoop?: (() => void) | null | undefined;
  14855. private _localDelayOffset;
  14856. private _pausedDelay;
  14857. private _runtimeAnimations;
  14858. private _paused;
  14859. private _scene;
  14860. private _speedRatio;
  14861. private _weight;
  14862. private _syncRoot;
  14863. /**
  14864. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14865. * This will only apply for non looping animation (default is true)
  14866. */
  14867. disposeOnEnd: boolean;
  14868. /**
  14869. * Gets a boolean indicating if the animation has started
  14870. */
  14871. animationStarted: boolean;
  14872. /**
  14873. * Observer raised when the animation ends
  14874. */
  14875. onAnimationEndObservable: Observable<Animatable>;
  14876. /**
  14877. * Observer raised when the animation loops
  14878. */
  14879. onAnimationLoopObservable: Observable<Animatable>;
  14880. /**
  14881. * Gets the root Animatable used to synchronize and normalize animations
  14882. */
  14883. get syncRoot(): Nullable<Animatable>;
  14884. /**
  14885. * Gets the current frame of the first RuntimeAnimation
  14886. * Used to synchronize Animatables
  14887. */
  14888. get masterFrame(): number;
  14889. /**
  14890. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14891. */
  14892. get weight(): number;
  14893. set weight(value: number);
  14894. /**
  14895. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14896. */
  14897. get speedRatio(): number;
  14898. set speedRatio(value: number);
  14899. /**
  14900. * Creates a new Animatable
  14901. * @param scene defines the hosting scene
  14902. * @param target defines the target object
  14903. * @param fromFrame defines the starting frame number (default is 0)
  14904. * @param toFrame defines the ending frame number (default is 100)
  14905. * @param loopAnimation defines if the animation must loop (default is false)
  14906. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14907. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14908. * @param animations defines a group of animation to add to the new Animatable
  14909. * @param onAnimationLoop defines a callback to call when animation loops
  14910. */
  14911. constructor(scene: Scene,
  14912. /** defines the target object */
  14913. target: any,
  14914. /** defines the starting frame number (default is 0) */
  14915. fromFrame?: number,
  14916. /** defines the ending frame number (default is 100) */
  14917. toFrame?: number,
  14918. /** defines if the animation must loop (default is false) */
  14919. loopAnimation?: boolean, speedRatio?: number,
  14920. /** defines a callback to call when animation ends if it is not looping */
  14921. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14922. /** defines a callback to call when animation loops */
  14923. onAnimationLoop?: (() => void) | null | undefined);
  14924. /**
  14925. * Synchronize and normalize current Animatable with a source Animatable
  14926. * This is useful when using animation weights and when animations are not of the same length
  14927. * @param root defines the root Animatable to synchronize with
  14928. * @returns the current Animatable
  14929. */
  14930. syncWith(root: Animatable): Animatable;
  14931. /**
  14932. * Gets the list of runtime animations
  14933. * @returns an array of RuntimeAnimation
  14934. */
  14935. getAnimations(): RuntimeAnimation[];
  14936. /**
  14937. * Adds more animations to the current animatable
  14938. * @param target defines the target of the animations
  14939. * @param animations defines the new animations to add
  14940. */
  14941. appendAnimations(target: any, animations: Animation[]): void;
  14942. /**
  14943. * Gets the source animation for a specific property
  14944. * @param property defines the propertyu to look for
  14945. * @returns null or the source animation for the given property
  14946. */
  14947. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14948. /**
  14949. * Gets the runtime animation for a specific property
  14950. * @param property defines the propertyu to look for
  14951. * @returns null or the runtime animation for the given property
  14952. */
  14953. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14954. /**
  14955. * Resets the animatable to its original state
  14956. */
  14957. reset(): void;
  14958. /**
  14959. * Allows the animatable to blend with current running animations
  14960. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14961. * @param blendingSpeed defines the blending speed to use
  14962. */
  14963. enableBlending(blendingSpeed: number): void;
  14964. /**
  14965. * Disable animation blending
  14966. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14967. */
  14968. disableBlending(): void;
  14969. /**
  14970. * Jump directly to a given frame
  14971. * @param frame defines the frame to jump to
  14972. */
  14973. goToFrame(frame: number): void;
  14974. /**
  14975. * Pause the animation
  14976. */
  14977. pause(): void;
  14978. /**
  14979. * Restart the animation
  14980. */
  14981. restart(): void;
  14982. private _raiseOnAnimationEnd;
  14983. /**
  14984. * Stop and delete the current animation
  14985. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14986. * @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)
  14987. */
  14988. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14989. /**
  14990. * Wait asynchronously for the animation to end
  14991. * @returns a promise which will be fullfilled when the animation ends
  14992. */
  14993. waitAsync(): Promise<Animatable>;
  14994. /** @hidden */
  14995. _animate(delay: number): boolean;
  14996. }
  14997. module "babylonjs/scene" {
  14998. interface Scene {
  14999. /** @hidden */
  15000. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15001. /** @hidden */
  15002. _processLateAnimationBindingsForMatrices(holder: {
  15003. totalWeight: number;
  15004. animations: RuntimeAnimation[];
  15005. originalValue: Matrix;
  15006. }): any;
  15007. /** @hidden */
  15008. _processLateAnimationBindingsForQuaternions(holder: {
  15009. totalWeight: number;
  15010. animations: RuntimeAnimation[];
  15011. originalValue: Quaternion;
  15012. }, refQuaternion: Quaternion): Quaternion;
  15013. /** @hidden */
  15014. _processLateAnimationBindings(): void;
  15015. /**
  15016. * Will start the animation sequence of a given target
  15017. * @param target defines the target
  15018. * @param from defines from which frame should animation start
  15019. * @param to defines until which frame should animation run.
  15020. * @param weight defines the weight to apply to the animation (1.0 by default)
  15021. * @param loop defines if the animation loops
  15022. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15023. * @param onAnimationEnd defines the function to be executed when the animation ends
  15024. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15025. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15026. * @param onAnimationLoop defines the callback to call when an animation loops
  15027. * @returns the animatable object created for this animation
  15028. */
  15029. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  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 loop defines if the animation loops
  15036. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15037. * @param onAnimationEnd defines the function to be executed when the animation ends
  15038. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15039. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15040. * @param targetMask defines if the target should be animate 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. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15045. /**
  15046. * Will start the animation sequence of a given target and its hierarchy
  15047. * @param target defines the target
  15048. * @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.
  15049. * @param from defines from which frame should animation start
  15050. * @param to defines until which frame should animation run.
  15051. * @param loop defines if the animation loops
  15052. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15053. * @param onAnimationEnd defines the function to be executed when the animation ends
  15054. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15055. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15056. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15057. * @param onAnimationLoop defines the callback to call when an animation loops
  15058. * @returns the list of created animatables
  15059. */
  15060. 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[];
  15061. /**
  15062. * Begin a new animation on a given node
  15063. * @param target defines the target where the animation will take place
  15064. * @param animations defines the list of animations to start
  15065. * @param from defines the initial value
  15066. * @param to defines the final value
  15067. * @param loop defines if you want animation to loop (off by default)
  15068. * @param speedRatio defines the speed ratio to apply to all animations
  15069. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15070. * @param onAnimationLoop defines the callback to call when an animation loops
  15071. * @returns the list of created animatables
  15072. */
  15073. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15074. /**
  15075. * Begin a new animation on a given node and its hierarchy
  15076. * @param target defines the root node where the animation will take place
  15077. * @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.
  15078. * @param animations defines the list of animations to start
  15079. * @param from defines the initial value
  15080. * @param to defines the final value
  15081. * @param loop defines if you want animation to loop (off by default)
  15082. * @param speedRatio defines the speed ratio to apply to all animations
  15083. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15084. * @param onAnimationLoop defines the callback to call when an animation loops
  15085. * @returns the list of animatables created for all nodes
  15086. */
  15087. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15088. /**
  15089. * Gets the animatable associated with a specific target
  15090. * @param target defines the target of the animatable
  15091. * @returns the required animatable if found
  15092. */
  15093. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15094. /**
  15095. * Gets all animatables associated with a given target
  15096. * @param target defines the target to look animatables for
  15097. * @returns an array of Animatables
  15098. */
  15099. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15100. /**
  15101. * Stops and removes all animations that have been applied to the scene
  15102. */
  15103. stopAllAnimations(): void;
  15104. /**
  15105. * Gets the current delta time used by animation engine
  15106. */
  15107. deltaTime: number;
  15108. }
  15109. }
  15110. module "babylonjs/Bones/bone" {
  15111. interface Bone {
  15112. /**
  15113. * Copy an animation range from another bone
  15114. * @param source defines the source bone
  15115. * @param rangeName defines the range name to copy
  15116. * @param frameOffset defines the frame offset
  15117. * @param rescaleAsRequired defines if rescaling must be applied if required
  15118. * @param skelDimensionsRatio defines the scaling ratio
  15119. * @returns true if operation was successful
  15120. */
  15121. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15122. }
  15123. }
  15124. }
  15125. declare module "babylonjs/Bones/skeleton" {
  15126. import { Bone } from "babylonjs/Bones/bone";
  15127. import { Observable } from "babylonjs/Misc/observable";
  15128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15129. import { Scene } from "babylonjs/scene";
  15130. import { Nullable } from "babylonjs/types";
  15131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15133. import { Animatable } from "babylonjs/Animations/animatable";
  15134. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15135. import { Animation } from "babylonjs/Animations/animation";
  15136. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15137. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15139. /**
  15140. * Class used to handle skinning animations
  15141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15142. */
  15143. export class Skeleton implements IAnimatable {
  15144. /** defines the skeleton name */
  15145. name: string;
  15146. /** defines the skeleton Id */
  15147. id: string;
  15148. /**
  15149. * Defines the list of child bones
  15150. */
  15151. bones: Bone[];
  15152. /**
  15153. * Defines an estimate of the dimension of the skeleton at rest
  15154. */
  15155. dimensionsAtRest: Vector3;
  15156. /**
  15157. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15158. */
  15159. needInitialSkinMatrix: boolean;
  15160. /**
  15161. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15162. */
  15163. overrideMesh: Nullable<AbstractMesh>;
  15164. /**
  15165. * Gets the list of animations attached to this skeleton
  15166. */
  15167. animations: Array<Animation>;
  15168. private _scene;
  15169. private _isDirty;
  15170. private _transformMatrices;
  15171. private _transformMatrixTexture;
  15172. private _meshesWithPoseMatrix;
  15173. private _animatables;
  15174. private _identity;
  15175. private _synchronizedWithMesh;
  15176. private _ranges;
  15177. private _lastAbsoluteTransformsUpdateId;
  15178. private _canUseTextureForBones;
  15179. private _uniqueId;
  15180. /** @hidden */
  15181. _numBonesWithLinkedTransformNode: number;
  15182. /** @hidden */
  15183. _hasWaitingData: Nullable<boolean>;
  15184. /**
  15185. * Specifies if the skeleton should be serialized
  15186. */
  15187. doNotSerialize: boolean;
  15188. private _useTextureToStoreBoneMatrices;
  15189. /**
  15190. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15191. * Please note that this option is not available if the hardware does not support it
  15192. */
  15193. get useTextureToStoreBoneMatrices(): boolean;
  15194. set useTextureToStoreBoneMatrices(value: boolean);
  15195. private _animationPropertiesOverride;
  15196. /**
  15197. * Gets or sets the animation properties override
  15198. */
  15199. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15200. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15201. /**
  15202. * List of inspectable custom properties (used by the Inspector)
  15203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15204. */
  15205. inspectableCustomProperties: IInspectable[];
  15206. /**
  15207. * An observable triggered before computing the skeleton's matrices
  15208. */
  15209. onBeforeComputeObservable: Observable<Skeleton>;
  15210. /**
  15211. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15212. */
  15213. get isUsingTextureForMatrices(): boolean;
  15214. /**
  15215. * Gets the unique ID of this skeleton
  15216. */
  15217. get uniqueId(): number;
  15218. /**
  15219. * Creates a new skeleton
  15220. * @param name defines the skeleton name
  15221. * @param id defines the skeleton Id
  15222. * @param scene defines the hosting scene
  15223. */
  15224. constructor(
  15225. /** defines the skeleton name */
  15226. name: string,
  15227. /** defines the skeleton Id */
  15228. id: string, scene: Scene);
  15229. /**
  15230. * Gets the current object class name.
  15231. * @return the class name
  15232. */
  15233. getClassName(): string;
  15234. /**
  15235. * Returns an array containing the root bones
  15236. * @returns an array containing the root bones
  15237. */
  15238. getChildren(): Array<Bone>;
  15239. /**
  15240. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15241. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15242. * @returns a Float32Array containing matrices data
  15243. */
  15244. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15245. /**
  15246. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15247. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15248. * @returns a raw texture containing the data
  15249. */
  15250. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15251. /**
  15252. * Gets the current hosting scene
  15253. * @returns a scene object
  15254. */
  15255. getScene(): Scene;
  15256. /**
  15257. * Gets a string representing the current skeleton data
  15258. * @param fullDetails defines a boolean indicating if we want a verbose version
  15259. * @returns a string representing the current skeleton data
  15260. */
  15261. toString(fullDetails?: boolean): string;
  15262. /**
  15263. * Get bone's index searching by name
  15264. * @param name defines bone's name to search for
  15265. * @return the indice of the bone. Returns -1 if not found
  15266. */
  15267. getBoneIndexByName(name: string): number;
  15268. /**
  15269. * Creater a new animation range
  15270. * @param name defines the name of the range
  15271. * @param from defines the start key
  15272. * @param to defines the end key
  15273. */
  15274. createAnimationRange(name: string, from: number, to: number): void;
  15275. /**
  15276. * Delete a specific animation range
  15277. * @param name defines the name of the range
  15278. * @param deleteFrames defines if frames must be removed as well
  15279. */
  15280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15281. /**
  15282. * Gets a specific animation range
  15283. * @param name defines the name of the range to look for
  15284. * @returns the requested animation range or null if not found
  15285. */
  15286. getAnimationRange(name: string): Nullable<AnimationRange>;
  15287. /**
  15288. * Gets the list of all animation ranges defined on this skeleton
  15289. * @returns an array
  15290. */
  15291. getAnimationRanges(): Nullable<AnimationRange>[];
  15292. /**
  15293. * Copy animation range from a source skeleton.
  15294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15295. * @param source defines the source skeleton
  15296. * @param name defines the name of the range to copy
  15297. * @param rescaleAsRequired defines if rescaling must be applied if required
  15298. * @returns true if operation was successful
  15299. */
  15300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15301. /**
  15302. * Forces the skeleton to go to rest pose
  15303. */
  15304. returnToRest(): void;
  15305. private _getHighestAnimationFrame;
  15306. /**
  15307. * Begin a specific animation range
  15308. * @param name defines the name of the range to start
  15309. * @param loop defines if looping must be turned on (false by default)
  15310. * @param speedRatio defines the speed ratio to apply (1 by default)
  15311. * @param onAnimationEnd defines a callback which will be called when animation will end
  15312. * @returns a new animatable
  15313. */
  15314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15315. /** @hidden */
  15316. _markAsDirty(): void;
  15317. /** @hidden */
  15318. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15319. /** @hidden */
  15320. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15321. private _computeTransformMatrices;
  15322. /**
  15323. * Build all resources required to render a skeleton
  15324. */
  15325. prepare(): void;
  15326. /**
  15327. * Gets the list of animatables currently running for this skeleton
  15328. * @returns an array of animatables
  15329. */
  15330. getAnimatables(): IAnimatable[];
  15331. /**
  15332. * Clone the current skeleton
  15333. * @param name defines the name of the new skeleton
  15334. * @param id defines the id of the new skeleton
  15335. * @returns the new skeleton
  15336. */
  15337. clone(name: string, id?: string): Skeleton;
  15338. /**
  15339. * Enable animation blending for this skeleton
  15340. * @param blendingSpeed defines the blending speed to apply
  15341. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15342. */
  15343. enableBlending(blendingSpeed?: number): void;
  15344. /**
  15345. * Releases all resources associated with the current skeleton
  15346. */
  15347. dispose(): void;
  15348. /**
  15349. * Serialize the skeleton in a JSON object
  15350. * @returns a JSON object
  15351. */
  15352. serialize(): any;
  15353. /**
  15354. * Creates a new skeleton from serialized data
  15355. * @param parsedSkeleton defines the serialized data
  15356. * @param scene defines the hosting scene
  15357. * @returns a new skeleton
  15358. */
  15359. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15360. /**
  15361. * Compute all node absolute transforms
  15362. * @param forceUpdate defines if computation must be done even if cache is up to date
  15363. */
  15364. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15365. /**
  15366. * Gets the root pose matrix
  15367. * @returns a matrix
  15368. */
  15369. getPoseMatrix(): Nullable<Matrix>;
  15370. /**
  15371. * Sorts bones per internal index
  15372. */
  15373. sortBones(): void;
  15374. private _sortBones;
  15375. }
  15376. }
  15377. declare module "babylonjs/Meshes/instancedMesh" {
  15378. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15379. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15380. import { Camera } from "babylonjs/Cameras/camera";
  15381. import { Node } from "babylonjs/node";
  15382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15383. import { Mesh } from "babylonjs/Meshes/mesh";
  15384. import { Material } from "babylonjs/Materials/material";
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Light } from "babylonjs/Lights/light";
  15387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15388. /**
  15389. * Creates an instance based on a source mesh.
  15390. */
  15391. export class InstancedMesh extends AbstractMesh {
  15392. private _sourceMesh;
  15393. private _currentLOD;
  15394. /** @hidden */
  15395. _indexInSourceMeshInstanceArray: number;
  15396. constructor(name: string, source: Mesh);
  15397. /**
  15398. * Returns the string "InstancedMesh".
  15399. */
  15400. getClassName(): string;
  15401. /** Gets the list of lights affecting that mesh */
  15402. get lightSources(): Light[];
  15403. _resyncLightSources(): void;
  15404. _resyncLightSource(light: Light): void;
  15405. _removeLightSource(light: Light, dispose: boolean): void;
  15406. /**
  15407. * If the source mesh receives shadows
  15408. */
  15409. get receiveShadows(): boolean;
  15410. /**
  15411. * The material of the source mesh
  15412. */
  15413. get material(): Nullable<Material>;
  15414. /**
  15415. * Visibility of the source mesh
  15416. */
  15417. get visibility(): number;
  15418. /**
  15419. * Skeleton of the source mesh
  15420. */
  15421. get skeleton(): Nullable<Skeleton>;
  15422. /**
  15423. * Rendering ground id of the source mesh
  15424. */
  15425. get renderingGroupId(): number;
  15426. set renderingGroupId(value: number);
  15427. /**
  15428. * Returns the total number of vertices (integer).
  15429. */
  15430. getTotalVertices(): number;
  15431. /**
  15432. * Returns a positive integer : the total number of indices in this mesh geometry.
  15433. * @returns the numner of indices or zero if the mesh has no geometry.
  15434. */
  15435. getTotalIndices(): number;
  15436. /**
  15437. * The source mesh of the instance
  15438. */
  15439. get sourceMesh(): Mesh;
  15440. /**
  15441. * Is this node ready to be used/rendered
  15442. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15443. * @return {boolean} is it ready
  15444. */
  15445. isReady(completeCheck?: boolean): boolean;
  15446. /**
  15447. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15448. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15449. * @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.
  15450. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15451. */
  15452. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15453. /**
  15454. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15455. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15456. * The `data` are either a numeric array either a Float32Array.
  15457. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15458. * 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).
  15459. * Note that a new underlying VertexBuffer object is created each call.
  15460. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15461. *
  15462. * Possible `kind` values :
  15463. * - VertexBuffer.PositionKind
  15464. * - VertexBuffer.UVKind
  15465. * - VertexBuffer.UV2Kind
  15466. * - VertexBuffer.UV3Kind
  15467. * - VertexBuffer.UV4Kind
  15468. * - VertexBuffer.UV5Kind
  15469. * - VertexBuffer.UV6Kind
  15470. * - VertexBuffer.ColorKind
  15471. * - VertexBuffer.MatricesIndicesKind
  15472. * - VertexBuffer.MatricesIndicesExtraKind
  15473. * - VertexBuffer.MatricesWeightsKind
  15474. * - VertexBuffer.MatricesWeightsExtraKind
  15475. *
  15476. * Returns the Mesh.
  15477. */
  15478. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15479. /**
  15480. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15481. * If the mesh has no geometry, it is simply returned as it is.
  15482. * The `data` are either a numeric array either a Float32Array.
  15483. * No new underlying VertexBuffer object is created.
  15484. * 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.
  15485. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15486. *
  15487. * Possible `kind` values :
  15488. * - VertexBuffer.PositionKind
  15489. * - VertexBuffer.UVKind
  15490. * - VertexBuffer.UV2Kind
  15491. * - VertexBuffer.UV3Kind
  15492. * - VertexBuffer.UV4Kind
  15493. * - VertexBuffer.UV5Kind
  15494. * - VertexBuffer.UV6Kind
  15495. * - VertexBuffer.ColorKind
  15496. * - VertexBuffer.MatricesIndicesKind
  15497. * - VertexBuffer.MatricesIndicesExtraKind
  15498. * - VertexBuffer.MatricesWeightsKind
  15499. * - VertexBuffer.MatricesWeightsExtraKind
  15500. *
  15501. * Returns the Mesh.
  15502. */
  15503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15504. /**
  15505. * Sets the mesh indices.
  15506. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15507. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15508. * This method creates a new index buffer each call.
  15509. * Returns the Mesh.
  15510. */
  15511. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15512. /**
  15513. * Boolean : True if the mesh owns the requested kind of data.
  15514. */
  15515. isVerticesDataPresent(kind: string): boolean;
  15516. /**
  15517. * Returns an array of indices (IndicesArray).
  15518. */
  15519. getIndices(): Nullable<IndicesArray>;
  15520. get _positions(): Nullable<Vector3[]>;
  15521. /**
  15522. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15523. * This means the mesh underlying bounding box and sphere are recomputed.
  15524. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15525. * @returns the current mesh
  15526. */
  15527. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15528. /** @hidden */
  15529. _preActivate(): InstancedMesh;
  15530. /** @hidden */
  15531. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15532. /** @hidden */
  15533. _postActivate(): void;
  15534. getWorldMatrix(): Matrix;
  15535. get isAnInstance(): boolean;
  15536. /**
  15537. * Returns the current associated LOD AbstractMesh.
  15538. */
  15539. getLOD(camera: Camera): AbstractMesh;
  15540. /** @hidden */
  15541. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15542. /** @hidden */
  15543. _syncSubMeshes(): InstancedMesh;
  15544. /** @hidden */
  15545. _generatePointsArray(): boolean;
  15546. /**
  15547. * Creates a new InstancedMesh from the current mesh.
  15548. * - name (string) : the cloned mesh name
  15549. * - newParent (optional Node) : the optional Node to parent the clone to.
  15550. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15551. *
  15552. * Returns the clone.
  15553. */
  15554. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15555. /**
  15556. * Disposes the InstancedMesh.
  15557. * Returns nothing.
  15558. */
  15559. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15560. }
  15561. module "babylonjs/Meshes/mesh" {
  15562. interface Mesh {
  15563. /**
  15564. * Register a custom buffer that will be instanced
  15565. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15566. * @param kind defines the buffer kind
  15567. * @param stride defines the stride in floats
  15568. */
  15569. registerInstancedBuffer(kind: string, stride: number): void;
  15570. /** @hidden */
  15571. _userInstancedBuffersStorage: {
  15572. data: {
  15573. [key: string]: Float32Array;
  15574. };
  15575. sizes: {
  15576. [key: string]: number;
  15577. };
  15578. vertexBuffers: {
  15579. [key: string]: Nullable<VertexBuffer>;
  15580. };
  15581. strides: {
  15582. [key: string]: number;
  15583. };
  15584. };
  15585. }
  15586. }
  15587. module "babylonjs/Meshes/abstractMesh" {
  15588. interface AbstractMesh {
  15589. /**
  15590. * Object used to store instanced buffers defined by user
  15591. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15592. */
  15593. instancedBuffers: {
  15594. [key: string]: any;
  15595. };
  15596. }
  15597. }
  15598. }
  15599. declare module "babylonjs/Materials/shaderMaterial" {
  15600. import { Scene } from "babylonjs/scene";
  15601. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15603. import { Mesh } from "babylonjs/Meshes/mesh";
  15604. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15606. import { Texture } from "babylonjs/Materials/Textures/texture";
  15607. import { Material } from "babylonjs/Materials/material";
  15608. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15609. /**
  15610. * Defines the options associated with the creation of a shader material.
  15611. */
  15612. export interface IShaderMaterialOptions {
  15613. /**
  15614. * Does the material work in alpha blend mode
  15615. */
  15616. needAlphaBlending: boolean;
  15617. /**
  15618. * Does the material work in alpha test mode
  15619. */
  15620. needAlphaTesting: boolean;
  15621. /**
  15622. * The list of attribute names used in the shader
  15623. */
  15624. attributes: string[];
  15625. /**
  15626. * The list of unifrom names used in the shader
  15627. */
  15628. uniforms: string[];
  15629. /**
  15630. * The list of UBO names used in the shader
  15631. */
  15632. uniformBuffers: string[];
  15633. /**
  15634. * The list of sampler names used in the shader
  15635. */
  15636. samplers: string[];
  15637. /**
  15638. * The list of defines used in the shader
  15639. */
  15640. defines: string[];
  15641. }
  15642. /**
  15643. * 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.
  15644. *
  15645. * This returned material effects how the mesh will look based on the code in the shaders.
  15646. *
  15647. * @see http://doc.babylonjs.com/how_to/shader_material
  15648. */
  15649. export class ShaderMaterial extends Material {
  15650. private _shaderPath;
  15651. private _options;
  15652. private _textures;
  15653. private _textureArrays;
  15654. private _floats;
  15655. private _ints;
  15656. private _floatsArrays;
  15657. private _colors3;
  15658. private _colors3Arrays;
  15659. private _colors4;
  15660. private _colors4Arrays;
  15661. private _vectors2;
  15662. private _vectors3;
  15663. private _vectors4;
  15664. private _matrices;
  15665. private _matrixArrays;
  15666. private _matrices3x3;
  15667. private _matrices2x2;
  15668. private _vectors2Arrays;
  15669. private _vectors3Arrays;
  15670. private _vectors4Arrays;
  15671. private _cachedWorldViewMatrix;
  15672. private _cachedWorldViewProjectionMatrix;
  15673. private _renderId;
  15674. private _multiview;
  15675. /**
  15676. * Instantiate a new shader material.
  15677. * 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.
  15678. * This returned material effects how the mesh will look based on the code in the shaders.
  15679. * @see http://doc.babylonjs.com/how_to/shader_material
  15680. * @param name Define the name of the material in the scene
  15681. * @param scene Define the scene the material belongs to
  15682. * @param shaderPath Defines the route to the shader code in one of three ways:
  15683. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15684. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15685. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15686. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15687. * @param options Define the options used to create the shader
  15688. */
  15689. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15690. /**
  15691. * Gets the shader path used to define the shader code
  15692. * It can be modified to trigger a new compilation
  15693. */
  15694. get shaderPath(): any;
  15695. /**
  15696. * Sets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. set shaderPath(shaderPath: any);
  15700. /**
  15701. * Gets the options used to compile the shader.
  15702. * They can be modified to trigger a new compilation
  15703. */
  15704. get options(): IShaderMaterialOptions;
  15705. /**
  15706. * Gets the current class name of the material e.g. "ShaderMaterial"
  15707. * Mainly use in serialization.
  15708. * @returns the class name
  15709. */
  15710. getClassName(): string;
  15711. /**
  15712. * Specifies if the material will require alpha blending
  15713. * @returns a boolean specifying if alpha blending is needed
  15714. */
  15715. needAlphaBlending(): boolean;
  15716. /**
  15717. * Specifies if this material should be rendered in alpha test mode
  15718. * @returns a boolean specifying if an alpha test is needed.
  15719. */
  15720. needAlphaTesting(): boolean;
  15721. private _checkUniform;
  15722. /**
  15723. * Set a texture in the shader.
  15724. * @param name Define the name of the uniform samplers as defined in the shader
  15725. * @param texture Define the texture to bind to this sampler
  15726. * @return the material itself allowing "fluent" like uniform updates
  15727. */
  15728. setTexture(name: string, texture: Texture): ShaderMaterial;
  15729. /**
  15730. * Set a texture array in the shader.
  15731. * @param name Define the name of the uniform sampler array as defined in the shader
  15732. * @param textures Define the list of textures to bind to this sampler
  15733. * @return the material itself allowing "fluent" like uniform updates
  15734. */
  15735. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15736. /**
  15737. * Set a float in the shader.
  15738. * @param name Define the name of the uniform as defined in the shader
  15739. * @param value Define the value to give to the uniform
  15740. * @return the material itself allowing "fluent" like uniform updates
  15741. */
  15742. setFloat(name: string, value: number): ShaderMaterial;
  15743. /**
  15744. * Set a int in the shader.
  15745. * @param name Define the name of the uniform as defined in the shader
  15746. * @param value Define the value to give to the uniform
  15747. * @return the material itself allowing "fluent" like uniform updates
  15748. */
  15749. setInt(name: string, value: number): ShaderMaterial;
  15750. /**
  15751. * Set an array of floats in the shader.
  15752. * @param name Define the name of the uniform as defined in the shader
  15753. * @param value Define the value to give to the uniform
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setFloats(name: string, value: number[]): ShaderMaterial;
  15757. /**
  15758. * Set a vec3 in the shader from a Color3.
  15759. * @param name Define the name of the uniform as defined in the shader
  15760. * @param value Define the value to give to the uniform
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setColor3(name: string, value: Color3): ShaderMaterial;
  15764. /**
  15765. * Set a vec3 array in the shader from a Color3 array.
  15766. * @param name Define the name of the uniform as defined in the shader
  15767. * @param value Define the value to give to the uniform
  15768. * @return the material itself allowing "fluent" like uniform updates
  15769. */
  15770. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15771. /**
  15772. * Set a vec4 in the shader from a Color4.
  15773. * @param name Define the name of the uniform as defined in the shader
  15774. * @param value Define the value to give to the uniform
  15775. * @return the material itself allowing "fluent" like uniform updates
  15776. */
  15777. setColor4(name: string, value: Color4): ShaderMaterial;
  15778. /**
  15779. * Set a vec4 array in the shader from a Color4 array.
  15780. * @param name Define the name of the uniform as defined in the shader
  15781. * @param value Define the value to give to the uniform
  15782. * @return the material itself allowing "fluent" like uniform updates
  15783. */
  15784. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15785. /**
  15786. * Set a vec2 in the shader from a Vector2.
  15787. * @param name Define the name of the uniform as defined in the shader
  15788. * @param value Define the value to give to the uniform
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setVector2(name: string, value: Vector2): ShaderMaterial;
  15792. /**
  15793. * Set a vec3 in the shader from a Vector3.
  15794. * @param name Define the name of the uniform as defined in the shader
  15795. * @param value Define the value to give to the uniform
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setVector3(name: string, value: Vector3): ShaderMaterial;
  15799. /**
  15800. * Set a vec4 in the shader from a Vector4.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setVector4(name: string, value: Vector4): ShaderMaterial;
  15806. /**
  15807. * Set a mat4 in the shader from a Matrix.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15813. /**
  15814. * Set a float32Array in the shader from a matrix array.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15820. /**
  15821. * Set a mat3 in the shader from a Float32Array.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15827. /**
  15828. * Set a mat2 in the shader from a Float32Array.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15834. /**
  15835. * Set a vec2 array in the shader from a number array.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setArray2(name: string, value: number[]): ShaderMaterial;
  15841. /**
  15842. * Set a vec3 array in the shader from a number array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setArray3(name: string, value: number[]): ShaderMaterial;
  15848. /**
  15849. * Set a vec4 array in the shader from a number array.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setArray4(name: string, value: number[]): ShaderMaterial;
  15855. private _checkCache;
  15856. /**
  15857. * Specifies that the submesh is ready to be used
  15858. * @param mesh defines the mesh to check
  15859. * @param subMesh defines which submesh to check
  15860. * @param useInstances specifies that instances should be used
  15861. * @returns a boolean indicating that the submesh is ready or not
  15862. */
  15863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15864. /**
  15865. * Checks if the material is ready to render the requested mesh
  15866. * @param mesh Define the mesh to render
  15867. * @param useInstances Define whether or not the material is used with instances
  15868. * @returns true if ready, otherwise false
  15869. */
  15870. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15871. /**
  15872. * Binds the world matrix to the material
  15873. * @param world defines the world transformation matrix
  15874. */
  15875. bindOnlyWorldMatrix(world: Matrix): void;
  15876. /**
  15877. * Binds the material to the mesh
  15878. * @param world defines the world transformation matrix
  15879. * @param mesh defines the mesh to bind the material to
  15880. */
  15881. bind(world: Matrix, mesh?: Mesh): void;
  15882. /**
  15883. * Gets the active textures from the material
  15884. * @returns an array of textures
  15885. */
  15886. getActiveTextures(): BaseTexture[];
  15887. /**
  15888. * Specifies if the material uses a texture
  15889. * @param texture defines the texture to check against the material
  15890. * @returns a boolean specifying if the material uses the texture
  15891. */
  15892. hasTexture(texture: BaseTexture): boolean;
  15893. /**
  15894. * Makes a duplicate of the material, and gives it a new name
  15895. * @param name defines the new name for the duplicated material
  15896. * @returns the cloned material
  15897. */
  15898. clone(name: string): ShaderMaterial;
  15899. /**
  15900. * Disposes the material
  15901. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15902. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15903. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15904. */
  15905. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15906. /**
  15907. * Serializes this material in a JSON representation
  15908. * @returns the serialized material object
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Creates a shader material from parsed shader material data
  15913. * @param source defines the JSON represnetation of the material
  15914. * @param scene defines the hosting scene
  15915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15916. * @returns a new material
  15917. */
  15918. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15919. }
  15920. }
  15921. declare module "babylonjs/Shaders/color.fragment" {
  15922. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15924. /** @hidden */
  15925. export var colorPixelShader: {
  15926. name: string;
  15927. shader: string;
  15928. };
  15929. }
  15930. declare module "babylonjs/Shaders/color.vertex" {
  15931. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15932. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15933. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15934. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15935. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15936. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15937. /** @hidden */
  15938. export var colorVertexShader: {
  15939. name: string;
  15940. shader: string;
  15941. };
  15942. }
  15943. declare module "babylonjs/Meshes/linesMesh" {
  15944. import { Nullable } from "babylonjs/types";
  15945. import { Scene } from "babylonjs/scene";
  15946. import { Color3 } from "babylonjs/Maths/math.color";
  15947. import { Node } from "babylonjs/node";
  15948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15949. import { Mesh } from "babylonjs/Meshes/mesh";
  15950. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15951. import { Effect } from "babylonjs/Materials/effect";
  15952. import { Material } from "babylonjs/Materials/material";
  15953. import "babylonjs/Shaders/color.fragment";
  15954. import "babylonjs/Shaders/color.vertex";
  15955. /**
  15956. * Line mesh
  15957. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15958. */
  15959. export class LinesMesh extends Mesh {
  15960. /**
  15961. * If vertex color should be applied to the mesh
  15962. */
  15963. readonly useVertexColor?: boolean | undefined;
  15964. /**
  15965. * If vertex alpha should be applied to the mesh
  15966. */
  15967. readonly useVertexAlpha?: boolean | undefined;
  15968. /**
  15969. * Color of the line (Default: White)
  15970. */
  15971. color: Color3;
  15972. /**
  15973. * Alpha of the line (Default: 1)
  15974. */
  15975. alpha: number;
  15976. /**
  15977. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15978. * This margin is expressed in world space coordinates, so its value may vary.
  15979. * Default value is 0.1
  15980. */
  15981. intersectionThreshold: number;
  15982. private _colorShader;
  15983. private color4;
  15984. /**
  15985. * Creates a new LinesMesh
  15986. * @param name defines the name
  15987. * @param scene defines the hosting scene
  15988. * @param parent defines the parent mesh if any
  15989. * @param source defines the optional source LinesMesh used to clone data from
  15990. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15991. * When false, achieved by calling a clone(), also passing False.
  15992. * This will make creation of children, recursive.
  15993. * @param useVertexColor defines if this LinesMesh supports vertex color
  15994. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15995. */
  15996. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15997. /**
  15998. * If vertex color should be applied to the mesh
  15999. */
  16000. useVertexColor?: boolean | undefined,
  16001. /**
  16002. * If vertex alpha should be applied to the mesh
  16003. */
  16004. useVertexAlpha?: boolean | undefined);
  16005. private _addClipPlaneDefine;
  16006. private _removeClipPlaneDefine;
  16007. isReady(): boolean;
  16008. /**
  16009. * Returns the string "LineMesh"
  16010. */
  16011. getClassName(): string;
  16012. /**
  16013. * @hidden
  16014. */
  16015. get material(): Material;
  16016. /**
  16017. * @hidden
  16018. */
  16019. set material(value: Material);
  16020. /**
  16021. * @hidden
  16022. */
  16023. get checkCollisions(): boolean;
  16024. /** @hidden */
  16025. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16026. /** @hidden */
  16027. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16028. /**
  16029. * Disposes of the line mesh
  16030. * @param doNotRecurse If children should be disposed
  16031. */
  16032. dispose(doNotRecurse?: boolean): void;
  16033. /**
  16034. * Returns a new LineMesh object cloned from the current one.
  16035. */
  16036. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16037. /**
  16038. * Creates a new InstancedLinesMesh object from the mesh model.
  16039. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16040. * @param name defines the name of the new instance
  16041. * @returns a new InstancedLinesMesh
  16042. */
  16043. createInstance(name: string): InstancedLinesMesh;
  16044. }
  16045. /**
  16046. * Creates an instance based on a source LinesMesh
  16047. */
  16048. export class InstancedLinesMesh extends InstancedMesh {
  16049. /**
  16050. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16051. * This margin is expressed in world space coordinates, so its value may vary.
  16052. * Initilized with the intersectionThreshold value of the source LinesMesh
  16053. */
  16054. intersectionThreshold: number;
  16055. constructor(name: string, source: LinesMesh);
  16056. /**
  16057. * Returns the string "InstancedLinesMesh".
  16058. */
  16059. getClassName(): string;
  16060. }
  16061. }
  16062. declare module "babylonjs/Shaders/line.fragment" {
  16063. /** @hidden */
  16064. export var linePixelShader: {
  16065. name: string;
  16066. shader: string;
  16067. };
  16068. }
  16069. declare module "babylonjs/Shaders/line.vertex" {
  16070. /** @hidden */
  16071. export var lineVertexShader: {
  16072. name: string;
  16073. shader: string;
  16074. };
  16075. }
  16076. declare module "babylonjs/Rendering/edgesRenderer" {
  16077. import { Nullable } from "babylonjs/types";
  16078. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16080. import { Vector3 } from "babylonjs/Maths/math.vector";
  16081. import { IDisposable } from "babylonjs/scene";
  16082. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16083. import "babylonjs/Shaders/line.fragment";
  16084. import "babylonjs/Shaders/line.vertex";
  16085. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16086. module "babylonjs/Meshes/abstractMesh" {
  16087. interface AbstractMesh {
  16088. /**
  16089. * Gets the edgesRenderer associated with the mesh
  16090. */
  16091. edgesRenderer: Nullable<EdgesRenderer>;
  16092. }
  16093. }
  16094. module "babylonjs/Meshes/linesMesh" {
  16095. interface LinesMesh {
  16096. /**
  16097. * Enables the edge rendering mode on the mesh.
  16098. * This mode makes the mesh edges visible
  16099. * @param epsilon defines the maximal distance between two angles to detect a face
  16100. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16101. * @returns the currentAbstractMesh
  16102. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16103. */
  16104. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16105. }
  16106. }
  16107. module "babylonjs/Meshes/linesMesh" {
  16108. interface InstancedLinesMesh {
  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 current InstancedLinesMesh
  16115. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16116. */
  16117. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16118. }
  16119. }
  16120. /**
  16121. * Defines the minimum contract an Edges renderer should follow.
  16122. */
  16123. export interface IEdgesRenderer extends IDisposable {
  16124. /**
  16125. * Gets or sets a boolean indicating if the edgesRenderer is active
  16126. */
  16127. isEnabled: boolean;
  16128. /**
  16129. * Renders the edges of the attached mesh,
  16130. */
  16131. render(): void;
  16132. /**
  16133. * Checks wether or not the edges renderer is ready to render.
  16134. * @return true if ready, otherwise false.
  16135. */
  16136. isReady(): boolean;
  16137. }
  16138. /**
  16139. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16140. */
  16141. export class EdgesRenderer implements IEdgesRenderer {
  16142. /**
  16143. * Define the size of the edges with an orthographic camera
  16144. */
  16145. edgesWidthScalerForOrthographic: number;
  16146. /**
  16147. * Define the size of the edges with a perspective camera
  16148. */
  16149. edgesWidthScalerForPerspective: number;
  16150. protected _source: AbstractMesh;
  16151. protected _linesPositions: number[];
  16152. protected _linesNormals: number[];
  16153. protected _linesIndices: number[];
  16154. protected _epsilon: number;
  16155. protected _indicesCount: number;
  16156. protected _lineShader: ShaderMaterial;
  16157. protected _ib: DataBuffer;
  16158. protected _buffers: {
  16159. [key: string]: Nullable<VertexBuffer>;
  16160. };
  16161. protected _checkVerticesInsteadOfIndices: boolean;
  16162. private _meshRebuildObserver;
  16163. private _meshDisposeObserver;
  16164. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16165. isEnabled: boolean;
  16166. /**
  16167. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16168. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16169. * @param source Mesh used to create edges
  16170. * @param epsilon sum of angles in adjacency to check for edge
  16171. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16172. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16173. */
  16174. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16175. protected _prepareRessources(): void;
  16176. /** @hidden */
  16177. _rebuild(): void;
  16178. /**
  16179. * Releases the required resources for the edges renderer
  16180. */
  16181. dispose(): void;
  16182. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16183. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16184. /**
  16185. * Checks if the pair of p0 and p1 is en edge
  16186. * @param faceIndex
  16187. * @param edge
  16188. * @param faceNormals
  16189. * @param p0
  16190. * @param p1
  16191. * @private
  16192. */
  16193. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16194. /**
  16195. * push line into the position, normal and index buffer
  16196. * @protected
  16197. */
  16198. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16199. /**
  16200. * Generates lines edges from adjacencjes
  16201. * @private
  16202. */
  16203. _generateEdgesLines(): void;
  16204. /**
  16205. * Checks wether or not the edges renderer is ready to render.
  16206. * @return true if ready, otherwise false.
  16207. */
  16208. isReady(): boolean;
  16209. /**
  16210. * Renders the edges of the attached mesh,
  16211. */
  16212. render(): void;
  16213. }
  16214. /**
  16215. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16216. */
  16217. export class LineEdgesRenderer extends EdgesRenderer {
  16218. /**
  16219. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16220. * @param source LineMesh used to generate edges
  16221. * @param epsilon not important (specified angle for edge detection)
  16222. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16223. */
  16224. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16225. /**
  16226. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16227. */
  16228. _generateEdgesLines(): void;
  16229. }
  16230. }
  16231. declare module "babylonjs/Rendering/renderingGroup" {
  16232. import { SmartArray } from "babylonjs/Misc/smartArray";
  16233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16235. import { Nullable } from "babylonjs/types";
  16236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16237. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16238. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16239. import { Material } from "babylonjs/Materials/material";
  16240. import { Scene } from "babylonjs/scene";
  16241. /**
  16242. * This represents the object necessary to create a rendering group.
  16243. * This is exclusively used and created by the rendering manager.
  16244. * To modify the behavior, you use the available helpers in your scene or meshes.
  16245. * @hidden
  16246. */
  16247. export class RenderingGroup {
  16248. index: number;
  16249. private static _zeroVector;
  16250. private _scene;
  16251. private _opaqueSubMeshes;
  16252. private _transparentSubMeshes;
  16253. private _alphaTestSubMeshes;
  16254. private _depthOnlySubMeshes;
  16255. private _particleSystems;
  16256. private _spriteManagers;
  16257. private _opaqueSortCompareFn;
  16258. private _alphaTestSortCompareFn;
  16259. private _transparentSortCompareFn;
  16260. private _renderOpaque;
  16261. private _renderAlphaTest;
  16262. private _renderTransparent;
  16263. /** @hidden */
  16264. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16265. onBeforeTransparentRendering: () => void;
  16266. /**
  16267. * Set the opaque sort comparison function.
  16268. * If null the sub meshes will be render in the order they were created
  16269. */
  16270. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16271. /**
  16272. * Set the alpha test sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the transparent sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Creates a new rendering group.
  16283. * @param index The rendering group index
  16284. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16285. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16286. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16287. */
  16288. 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>);
  16289. /**
  16290. * Render all the sub meshes contained in the group.
  16291. * @param customRenderFunction Used to override the default render behaviour of the group.
  16292. * @returns true if rendered some submeshes.
  16293. */
  16294. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16295. /**
  16296. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16297. * @param subMeshes The submeshes to render
  16298. */
  16299. private renderOpaqueSorted;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderAlphaTestSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderTransparentSorted;
  16310. /**
  16311. * Renders the submeshes in a specified order.
  16312. * @param subMeshes The submeshes to sort before render
  16313. * @param sortCompareFn The comparison function use to sort
  16314. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16315. * @param transparent Specifies to activate blending if true
  16316. */
  16317. private static renderSorted;
  16318. /**
  16319. * Renders the submeshes in the order they were dispatched (no sort applied).
  16320. * @param subMeshes The submeshes to render
  16321. */
  16322. private static renderUnsorted;
  16323. /**
  16324. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16325. * are rendered back to front if in the same alpha index.
  16326. *
  16327. * @param a The first submesh
  16328. * @param b The second submesh
  16329. * @returns The result of the comparison
  16330. */
  16331. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16332. /**
  16333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16334. * are rendered back to front.
  16335. *
  16336. * @param a The first submesh
  16337. * @param b The second submesh
  16338. * @returns The result of the comparison
  16339. */
  16340. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16341. /**
  16342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16343. * are rendered front to back (prevent overdraw).
  16344. *
  16345. * @param a The first submesh
  16346. * @param b The second submesh
  16347. * @returns The result of the comparison
  16348. */
  16349. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16350. /**
  16351. * Resets the different lists of submeshes to prepare a new frame.
  16352. */
  16353. prepare(): void;
  16354. dispose(): void;
  16355. /**
  16356. * Inserts the submesh in its correct queue depending on its material.
  16357. * @param subMesh The submesh to dispatch
  16358. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16359. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16360. */
  16361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16362. dispatchSprites(spriteManager: ISpriteManager): void;
  16363. dispatchParticles(particleSystem: IParticleSystem): void;
  16364. private _renderParticles;
  16365. private _renderSprites;
  16366. }
  16367. }
  16368. declare module "babylonjs/Rendering/renderingManager" {
  16369. import { Nullable } from "babylonjs/types";
  16370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16371. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16372. import { SmartArray } from "babylonjs/Misc/smartArray";
  16373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16375. import { Material } from "babylonjs/Materials/material";
  16376. import { Scene } from "babylonjs/scene";
  16377. import { Camera } from "babylonjs/Cameras/camera";
  16378. /**
  16379. * Interface describing the different options available in the rendering manager
  16380. * regarding Auto Clear between groups.
  16381. */
  16382. export interface IRenderingManagerAutoClearSetup {
  16383. /**
  16384. * Defines whether or not autoclear is enable.
  16385. */
  16386. autoClear: boolean;
  16387. /**
  16388. * Defines whether or not to autoclear the depth buffer.
  16389. */
  16390. depth: boolean;
  16391. /**
  16392. * Defines whether or not to autoclear the stencil buffer.
  16393. */
  16394. stencil: boolean;
  16395. }
  16396. /**
  16397. * This class is used by the onRenderingGroupObservable
  16398. */
  16399. export class RenderingGroupInfo {
  16400. /**
  16401. * The Scene that being rendered
  16402. */
  16403. scene: Scene;
  16404. /**
  16405. * The camera currently used for the rendering pass
  16406. */
  16407. camera: Nullable<Camera>;
  16408. /**
  16409. * The ID of the renderingGroup being processed
  16410. */
  16411. renderingGroupId: number;
  16412. }
  16413. /**
  16414. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16415. * It is enable to manage the different groups as well as the different necessary sort functions.
  16416. * This should not be used directly aside of the few static configurations
  16417. */
  16418. export class RenderingManager {
  16419. /**
  16420. * The max id used for rendering groups (not included)
  16421. */
  16422. static MAX_RENDERINGGROUPS: number;
  16423. /**
  16424. * The min id used for rendering groups (included)
  16425. */
  16426. static MIN_RENDERINGGROUPS: number;
  16427. /**
  16428. * Used to globally prevent autoclearing scenes.
  16429. */
  16430. static AUTOCLEAR: boolean;
  16431. /**
  16432. * @hidden
  16433. */
  16434. _useSceneAutoClearSetup: boolean;
  16435. private _scene;
  16436. private _renderingGroups;
  16437. private _depthStencilBufferAlreadyCleaned;
  16438. private _autoClearDepthStencil;
  16439. private _customOpaqueSortCompareFn;
  16440. private _customAlphaTestSortCompareFn;
  16441. private _customTransparentSortCompareFn;
  16442. private _renderingGroupInfo;
  16443. /**
  16444. * Instantiates a new rendering group for a particular scene
  16445. * @param scene Defines the scene the groups belongs to
  16446. */
  16447. constructor(scene: Scene);
  16448. private _clearDepthStencilBuffer;
  16449. /**
  16450. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16451. * @hidden
  16452. */
  16453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16454. /**
  16455. * Resets the different information of the group to prepare a new frame
  16456. * @hidden
  16457. */
  16458. reset(): void;
  16459. /**
  16460. * Dispose and release the group and its associated resources.
  16461. * @hidden
  16462. */
  16463. dispose(): void;
  16464. /**
  16465. * Clear the info related to rendering groups preventing retention points during dispose.
  16466. */
  16467. freeRenderingGroups(): void;
  16468. private _prepareRenderingGroup;
  16469. /**
  16470. * Add a sprite manager to the rendering manager in order to render it this frame.
  16471. * @param spriteManager Define the sprite manager to render
  16472. */
  16473. dispatchSprites(spriteManager: ISpriteManager): void;
  16474. /**
  16475. * Add a particle system to the rendering manager in order to render it this frame.
  16476. * @param particleSystem Define the particle system to render
  16477. */
  16478. dispatchParticles(particleSystem: IParticleSystem): void;
  16479. /**
  16480. * Add a submesh to the manager in order to render it this frame
  16481. * @param subMesh The submesh to dispatch
  16482. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16483. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16484. */
  16485. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16486. /**
  16487. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16488. * This allowed control for front to back rendering or reversly depending of the special needs.
  16489. *
  16490. * @param renderingGroupId The rendering group id corresponding to its index
  16491. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16492. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16493. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16494. */
  16495. 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;
  16496. /**
  16497. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16498. *
  16499. * @param renderingGroupId The rendering group id corresponding to its index
  16500. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16501. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16502. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16503. */
  16504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16505. /**
  16506. * Gets the current auto clear configuration for one rendering group of the rendering
  16507. * manager.
  16508. * @param index the rendering group index to get the information for
  16509. * @returns The auto clear setup for the requested rendering group
  16510. */
  16511. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16512. }
  16513. }
  16514. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16515. import { SmartArray } from "babylonjs/Misc/smartArray";
  16516. import { Nullable } from "babylonjs/types";
  16517. import { Scene } from "babylonjs/scene";
  16518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16521. import { Mesh } from "babylonjs/Meshes/mesh";
  16522. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16524. import { Effect } from "babylonjs/Materials/effect";
  16525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16526. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16527. import "babylonjs/Shaders/shadowMap.fragment";
  16528. import "babylonjs/Shaders/shadowMap.vertex";
  16529. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16530. import { Observable } from "babylonjs/Misc/observable";
  16531. /**
  16532. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16533. */
  16534. export interface ICustomShaderOptions {
  16535. /**
  16536. * Gets or sets the custom shader name to use
  16537. */
  16538. shaderName: string;
  16539. /**
  16540. * The list of attribute names used in the shader
  16541. */
  16542. attributes?: string[];
  16543. /**
  16544. * The list of unifrom names used in the shader
  16545. */
  16546. uniforms?: string[];
  16547. /**
  16548. * The list of sampler names used in the shader
  16549. */
  16550. samplers?: string[];
  16551. /**
  16552. * The list of defines used in the shader
  16553. */
  16554. defines?: string[];
  16555. }
  16556. /**
  16557. * Interface to implement to create a shadow generator compatible with BJS.
  16558. */
  16559. export interface IShadowGenerator {
  16560. /**
  16561. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16562. * @returns The render target texture if present otherwise, null
  16563. */
  16564. getShadowMap(): Nullable<RenderTargetTexture>;
  16565. /**
  16566. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16567. * @param subMesh The submesh we want to render in the shadow map
  16568. * @param useInstances Defines wether will draw in the map using instances
  16569. * @returns true if ready otherwise, false
  16570. */
  16571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16572. /**
  16573. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16574. * @param defines Defines of the material we want to update
  16575. * @param lightIndex Index of the light in the enabled light list of the material
  16576. */
  16577. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16578. /**
  16579. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16580. * defined in the generator but impacting the effect).
  16581. * It implies the unifroms available on the materials are the standard BJS ones.
  16582. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16583. * @param effect The effect we are binfing the information for
  16584. */
  16585. bindShadowLight(lightIndex: string, effect: Effect): void;
  16586. /**
  16587. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16588. * (eq to shadow prjection matrix * light transform matrix)
  16589. * @returns The transform matrix used to create the shadow map
  16590. */
  16591. getTransformMatrix(): Matrix;
  16592. /**
  16593. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16594. * Cube and 2D textures for instance.
  16595. */
  16596. recreateShadowMap(): void;
  16597. /**
  16598. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16599. * @param onCompiled Callback triggered at the and of the effects compilation
  16600. * @param options Sets of optional options forcing the compilation with different modes
  16601. */
  16602. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16603. useInstances: boolean;
  16604. }>): void;
  16605. /**
  16606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16607. * @param options Sets of optional options forcing the compilation with different modes
  16608. * @returns A promise that resolves when the compilation completes
  16609. */
  16610. forceCompilationAsync(options?: Partial<{
  16611. useInstances: boolean;
  16612. }>): Promise<void>;
  16613. /**
  16614. * Serializes the shadow generator setup to a json object.
  16615. * @returns The serialized JSON object
  16616. */
  16617. serialize(): any;
  16618. /**
  16619. * Disposes the Shadow map and related Textures and effects.
  16620. */
  16621. dispose(): void;
  16622. }
  16623. /**
  16624. * Default implementation IShadowGenerator.
  16625. * This is the main object responsible of generating shadows in the framework.
  16626. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16627. */
  16628. export class ShadowGenerator implements IShadowGenerator {
  16629. /**
  16630. * Name of the shadow generator class
  16631. */
  16632. static CLASSNAME: string;
  16633. /**
  16634. * Shadow generator mode None: no filtering applied.
  16635. */
  16636. static readonly FILTER_NONE: number;
  16637. /**
  16638. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16639. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16640. */
  16641. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16642. /**
  16643. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16644. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16645. */
  16646. static readonly FILTER_POISSONSAMPLING: number;
  16647. /**
  16648. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16649. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16650. */
  16651. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16652. /**
  16653. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16654. * edge artifacts on steep falloff.
  16655. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16656. */
  16657. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16658. /**
  16659. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16660. * edge artifacts on steep falloff.
  16661. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16662. */
  16663. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16664. /**
  16665. * Shadow generator mode PCF: Percentage Closer Filtering
  16666. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16667. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16668. */
  16669. static readonly FILTER_PCF: number;
  16670. /**
  16671. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16672. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16673. * Contact Hardening
  16674. */
  16675. static readonly FILTER_PCSS: number;
  16676. /**
  16677. * Reserved for PCF and PCSS
  16678. * Highest Quality.
  16679. *
  16680. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16681. *
  16682. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16683. */
  16684. static readonly QUALITY_HIGH: number;
  16685. /**
  16686. * Reserved for PCF and PCSS
  16687. * Good tradeoff for quality/perf cross devices
  16688. *
  16689. * Execute PCF on a 3*3 kernel.
  16690. *
  16691. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16692. */
  16693. static readonly QUALITY_MEDIUM: number;
  16694. /**
  16695. * Reserved for PCF and PCSS
  16696. * The lowest quality but the fastest.
  16697. *
  16698. * Execute PCF on a 1*1 kernel.
  16699. *
  16700. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16701. */
  16702. static readonly QUALITY_LOW: number;
  16703. /** Gets or sets the custom shader name to use */
  16704. customShaderOptions: ICustomShaderOptions;
  16705. /**
  16706. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16707. */
  16708. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16709. /**
  16710. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16711. */
  16712. onAfterShadowMapRenderObservable: Observable<Effect>;
  16713. /**
  16714. * Observable triggered before a mesh is rendered in the shadow map.
  16715. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16716. */
  16717. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16718. /**
  16719. * Observable triggered after a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16721. */
  16722. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. protected _bias: number;
  16724. /**
  16725. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16726. */
  16727. get bias(): number;
  16728. /**
  16729. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16730. */
  16731. set bias(bias: number);
  16732. protected _normalBias: number;
  16733. /**
  16734. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16735. */
  16736. get normalBias(): number;
  16737. /**
  16738. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16739. */
  16740. set normalBias(normalBias: number);
  16741. protected _blurBoxOffset: number;
  16742. /**
  16743. * Gets the blur box offset: offset applied during the blur pass.
  16744. * Only useful if useKernelBlur = false
  16745. */
  16746. get blurBoxOffset(): number;
  16747. /**
  16748. * Sets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. set blurBoxOffset(value: number);
  16752. protected _blurScale: number;
  16753. /**
  16754. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16755. * 2 means half of the size.
  16756. */
  16757. get blurScale(): number;
  16758. /**
  16759. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. set blurScale(value: number);
  16763. protected _blurKernel: number;
  16764. /**
  16765. * Gets the blur kernel: kernel size of the blur pass.
  16766. * Only useful if useKernelBlur = true
  16767. */
  16768. get blurKernel(): number;
  16769. /**
  16770. * Sets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. set blurKernel(value: number);
  16774. protected _useKernelBlur: boolean;
  16775. /**
  16776. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16777. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16778. */
  16779. get useKernelBlur(): boolean;
  16780. /**
  16781. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. set useKernelBlur(value: boolean);
  16785. protected _depthScale: number;
  16786. /**
  16787. * Gets the depth scale used in ESM mode.
  16788. */
  16789. get depthScale(): number;
  16790. /**
  16791. * Sets the depth scale used in ESM mode.
  16792. * This can override the scale stored on the light.
  16793. */
  16794. set depthScale(value: number);
  16795. protected _validateFilter(filter: number): number;
  16796. protected _filter: number;
  16797. /**
  16798. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16800. */
  16801. get filter(): number;
  16802. /**
  16803. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. set filter(value: number);
  16807. /**
  16808. * Gets if the current filter is set to Poisson Sampling.
  16809. */
  16810. get usePoissonSampling(): boolean;
  16811. /**
  16812. * Sets the current filter to Poisson Sampling.
  16813. */
  16814. set usePoissonSampling(value: boolean);
  16815. /**
  16816. * Gets if the current filter is set to ESM.
  16817. */
  16818. get useExponentialShadowMap(): boolean;
  16819. /**
  16820. * Sets the current filter is to ESM.
  16821. */
  16822. set useExponentialShadowMap(value: boolean);
  16823. /**
  16824. * Gets if the current filter is set to filtered ESM.
  16825. */
  16826. get useBlurExponentialShadowMap(): boolean;
  16827. /**
  16828. * Gets if the current filter is set to filtered ESM.
  16829. */
  16830. set useBlurExponentialShadowMap(value: boolean);
  16831. /**
  16832. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16833. * exponential to prevent steep falloff artifacts).
  16834. */
  16835. get useCloseExponentialShadowMap(): boolean;
  16836. /**
  16837. * Sets the current filter to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. set useCloseExponentialShadowMap(value: boolean);
  16841. /**
  16842. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. get useBlurCloseExponentialShadowMap(): boolean;
  16846. /**
  16847. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. set useBlurCloseExponentialShadowMap(value: boolean);
  16851. /**
  16852. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16853. */
  16854. get usePercentageCloserFiltering(): boolean;
  16855. /**
  16856. * Sets the current filter to "PCF" (percentage closer filtering).
  16857. */
  16858. set usePercentageCloserFiltering(value: boolean);
  16859. protected _filteringQuality: number;
  16860. /**
  16861. * Gets the PCF or PCSS Quality.
  16862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16863. */
  16864. get filteringQuality(): number;
  16865. /**
  16866. * Sets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. set filteringQuality(filteringQuality: number);
  16870. /**
  16871. * Gets if the current filter is set to "PCSS" (contact hardening).
  16872. */
  16873. get useContactHardeningShadow(): boolean;
  16874. /**
  16875. * Sets the current filter to "PCSS" (contact hardening).
  16876. */
  16877. set useContactHardeningShadow(value: boolean);
  16878. protected _contactHardeningLightSizeUVRatio: number;
  16879. /**
  16880. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16881. * Using a ratio helps keeping shape stability independently of the map size.
  16882. *
  16883. * It does not account for the light projection as it was having too much
  16884. * instability during the light setup or during light position changes.
  16885. *
  16886. * Only valid if useContactHardeningShadow is true.
  16887. */
  16888. get contactHardeningLightSizeUVRatio(): number;
  16889. /**
  16890. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16891. * Using a ratio helps keeping shape stability independently of the map size.
  16892. *
  16893. * It does not account for the light projection as it was having too much
  16894. * instability during the light setup or during light position changes.
  16895. *
  16896. * Only valid if useContactHardeningShadow is true.
  16897. */
  16898. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16899. protected _darkness: number;
  16900. /** Gets or sets the actual darkness of a shadow */
  16901. get darkness(): number;
  16902. set darkness(value: number);
  16903. /**
  16904. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16905. * 0 means strongest and 1 would means no shadow.
  16906. * @returns the darkness.
  16907. */
  16908. getDarkness(): number;
  16909. /**
  16910. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16911. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16912. * @returns the shadow generator allowing fluent coding.
  16913. */
  16914. setDarkness(darkness: number): ShadowGenerator;
  16915. protected _transparencyShadow: boolean;
  16916. /** Gets or sets the ability to have transparent shadow */
  16917. get transparencyShadow(): boolean;
  16918. set transparencyShadow(value: boolean);
  16919. /**
  16920. * Sets the ability to have transparent shadow (boolean).
  16921. * @param transparent True if transparent else False
  16922. * @returns the shadow generator allowing fluent coding
  16923. */
  16924. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16925. protected _shadowMap: Nullable<RenderTargetTexture>;
  16926. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16927. /**
  16928. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16929. * @returns The render target texture if present otherwise, null
  16930. */
  16931. getShadowMap(): Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16934. * @returns The render target texture if the shadow map is present otherwise, null
  16935. */
  16936. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the class name of that object
  16939. * @returns "ShadowGenerator"
  16940. */
  16941. getClassName(): string;
  16942. /**
  16943. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16944. * @param mesh Mesh to add
  16945. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16946. * @returns the Shadow Generator itself
  16947. */
  16948. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16949. /**
  16950. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16951. * @param mesh Mesh to remove
  16952. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16953. * @returns the Shadow Generator itself
  16954. */
  16955. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16956. /**
  16957. * Controls the extent to which the shadows fade out at the edge of the frustum
  16958. */
  16959. frustumEdgeFalloff: number;
  16960. protected _light: IShadowLight;
  16961. /**
  16962. * Returns the associated light object.
  16963. * @returns the light generating the shadow
  16964. */
  16965. getLight(): IShadowLight;
  16966. /**
  16967. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16968. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16969. * It might on the other hand introduce peter panning.
  16970. */
  16971. forceBackFacesOnly: boolean;
  16972. protected _scene: Scene;
  16973. protected _lightDirection: Vector3;
  16974. protected _effect: Effect;
  16975. protected _viewMatrix: Matrix;
  16976. protected _projectionMatrix: Matrix;
  16977. protected _transformMatrix: Matrix;
  16978. protected _cachedPosition: Vector3;
  16979. protected _cachedDirection: Vector3;
  16980. protected _cachedDefines: string;
  16981. protected _currentRenderID: number;
  16982. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16983. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16984. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16985. protected _blurPostProcesses: PostProcess[];
  16986. protected _mapSize: number;
  16987. protected _currentFaceIndex: number;
  16988. protected _currentFaceIndexCache: number;
  16989. protected _textureType: number;
  16990. protected _defaultTextureMatrix: Matrix;
  16991. protected _storedUniqueId: Nullable<number>;
  16992. /** @hidden */
  16993. static _SceneComponentInitialization: (scene: Scene) => void;
  16994. /**
  16995. * Creates a ShadowGenerator object.
  16996. * A ShadowGenerator is the required tool to use the shadows.
  16997. * Each light casting shadows needs to use its own ShadowGenerator.
  16998. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16999. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17000. * @param light The light object generating the shadows.
  17001. * @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.
  17002. */
  17003. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17004. protected _initializeGenerator(): void;
  17005. protected _createTargetRenderTexture(): void;
  17006. protected _initializeShadowMap(): void;
  17007. protected _initializeBlurRTTAndPostProcesses(): void;
  17008. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17009. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17010. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17011. protected _applyFilterValues(): void;
  17012. /**
  17013. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17014. * @param onCompiled Callback triggered at the and of the effects compilation
  17015. * @param options Sets of optional options forcing the compilation with different modes
  17016. */
  17017. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17018. useInstances: boolean;
  17019. }>): void;
  17020. /**
  17021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17022. * @param options Sets of optional options forcing the compilation with different modes
  17023. * @returns A promise that resolves when the compilation completes
  17024. */
  17025. forceCompilationAsync(options?: Partial<{
  17026. useInstances: boolean;
  17027. }>): Promise<void>;
  17028. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17029. /**
  17030. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17031. * @param subMesh The submesh we want to render in the shadow map
  17032. * @param useInstances Defines wether will draw in the map using instances
  17033. * @returns true if ready otherwise, false
  17034. */
  17035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17036. /**
  17037. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17038. * @param defines Defines of the material we want to update
  17039. * @param lightIndex Index of the light in the enabled light list of the material
  17040. */
  17041. prepareDefines(defines: any, lightIndex: number): void;
  17042. /**
  17043. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17044. * defined in the generator but impacting the effect).
  17045. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17046. * @param effect The effect we are binfing the information for
  17047. */
  17048. bindShadowLight(lightIndex: string, effect: Effect): void;
  17049. /**
  17050. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17051. * (eq to shadow prjection matrix * light transform matrix)
  17052. * @returns The transform matrix used to create the shadow map
  17053. */
  17054. getTransformMatrix(): Matrix;
  17055. /**
  17056. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17057. * Cube and 2D textures for instance.
  17058. */
  17059. recreateShadowMap(): void;
  17060. protected _disposeBlurPostProcesses(): void;
  17061. protected _disposeRTTandPostProcesses(): void;
  17062. /**
  17063. * Disposes the ShadowGenerator.
  17064. * Returns nothing.
  17065. */
  17066. dispose(): void;
  17067. /**
  17068. * Serializes the shadow generator setup to a json object.
  17069. * @returns The serialized JSON object
  17070. */
  17071. serialize(): any;
  17072. /**
  17073. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17074. * @param parsedShadowGenerator The JSON object to parse
  17075. * @param scene The scene to create the shadow map for
  17076. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17077. * @returns The parsed shadow generator
  17078. */
  17079. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17080. }
  17081. }
  17082. declare module "babylonjs/Lights/light" {
  17083. import { Nullable } from "babylonjs/types";
  17084. import { Scene } from "babylonjs/scene";
  17085. import { Vector3 } from "babylonjs/Maths/math.vector";
  17086. import { Color3 } from "babylonjs/Maths/math.color";
  17087. import { Node } from "babylonjs/node";
  17088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17089. import { Effect } from "babylonjs/Materials/effect";
  17090. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17091. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17092. /**
  17093. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17094. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17095. * 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.
  17096. */
  17097. export abstract class Light extends Node {
  17098. /**
  17099. * Falloff Default: light is falling off following the material specification:
  17100. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17101. */
  17102. static readonly FALLOFF_DEFAULT: number;
  17103. /**
  17104. * Falloff Physical: light is falling off following the inverse squared distance law.
  17105. */
  17106. static readonly FALLOFF_PHYSICAL: number;
  17107. /**
  17108. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17109. * to enhance interoperability with other engines.
  17110. */
  17111. static readonly FALLOFF_GLTF: number;
  17112. /**
  17113. * Falloff Standard: light is falling off like in the standard material
  17114. * to enhance interoperability with other materials.
  17115. */
  17116. static readonly FALLOFF_STANDARD: number;
  17117. /**
  17118. * If every light affecting the material is in this lightmapMode,
  17119. * material.lightmapTexture adds or multiplies
  17120. * (depends on material.useLightmapAsShadowmap)
  17121. * after every other light calculations.
  17122. */
  17123. static readonly LIGHTMAP_DEFAULT: number;
  17124. /**
  17125. * material.lightmapTexture as only diffuse lighting from this light
  17126. * adds only specular lighting from this light
  17127. * adds dynamic shadows
  17128. */
  17129. static readonly LIGHTMAP_SPECULAR: number;
  17130. /**
  17131. * material.lightmapTexture as only lighting
  17132. * no light calculation from this light
  17133. * only adds dynamic shadows from this light
  17134. */
  17135. static readonly LIGHTMAP_SHADOWSONLY: number;
  17136. /**
  17137. * Each light type uses the default quantity according to its type:
  17138. * point/spot lights use luminous intensity
  17139. * directional lights use illuminance
  17140. */
  17141. static readonly INTENSITYMODE_AUTOMATIC: number;
  17142. /**
  17143. * lumen (lm)
  17144. */
  17145. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17146. /**
  17147. * candela (lm/sr)
  17148. */
  17149. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17150. /**
  17151. * lux (lm/m^2)
  17152. */
  17153. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17154. /**
  17155. * nit (cd/m^2)
  17156. */
  17157. static readonly INTENSITYMODE_LUMINANCE: number;
  17158. /**
  17159. * Light type const id of the point light.
  17160. */
  17161. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17162. /**
  17163. * Light type const id of the directional light.
  17164. */
  17165. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17166. /**
  17167. * Light type const id of the spot light.
  17168. */
  17169. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17170. /**
  17171. * Light type const id of the hemispheric light.
  17172. */
  17173. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17174. /**
  17175. * Diffuse gives the basic color to an object.
  17176. */
  17177. diffuse: Color3;
  17178. /**
  17179. * Specular produces a highlight color on an object.
  17180. * Note: This is note affecting PBR materials.
  17181. */
  17182. specular: Color3;
  17183. /**
  17184. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17185. * falling off base on range or angle.
  17186. * This can be set to any values in Light.FALLOFF_x.
  17187. *
  17188. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17189. * other types of materials.
  17190. */
  17191. falloffType: number;
  17192. /**
  17193. * Strength of the light.
  17194. * Note: By default it is define in the framework own unit.
  17195. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17196. */
  17197. intensity: number;
  17198. private _range;
  17199. protected _inverseSquaredRange: number;
  17200. /**
  17201. * Defines how far from the source the light is impacting in scene units.
  17202. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17203. */
  17204. get range(): number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. set range(value: number);
  17210. /**
  17211. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17212. * of light.
  17213. */
  17214. private _photometricScale;
  17215. private _intensityMode;
  17216. /**
  17217. * Gets the photometric scale used to interpret the intensity.
  17218. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17219. */
  17220. get intensityMode(): number;
  17221. /**
  17222. * Sets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. set intensityMode(value: number);
  17226. private _radius;
  17227. /**
  17228. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17229. */
  17230. get radius(): number;
  17231. /**
  17232. * sets the light radius used by PBR Materials to simulate soft area lights.
  17233. */
  17234. set radius(value: number);
  17235. private _renderPriority;
  17236. /**
  17237. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17238. * exceeding the number allowed of the materials.
  17239. */
  17240. renderPriority: number;
  17241. private _shadowEnabled;
  17242. /**
  17243. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17244. * the current shadow generator.
  17245. */
  17246. get shadowEnabled(): boolean;
  17247. /**
  17248. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. set shadowEnabled(value: boolean);
  17252. private _includedOnlyMeshes;
  17253. /**
  17254. * Gets the only meshes impacted by this light.
  17255. */
  17256. get includedOnlyMeshes(): AbstractMesh[];
  17257. /**
  17258. * Sets the only meshes impacted by this light.
  17259. */
  17260. set includedOnlyMeshes(value: AbstractMesh[]);
  17261. private _excludedMeshes;
  17262. /**
  17263. * Gets the meshes not impacted by this light.
  17264. */
  17265. get excludedMeshes(): AbstractMesh[];
  17266. /**
  17267. * Sets the meshes not impacted by this light.
  17268. */
  17269. set excludedMeshes(value: AbstractMesh[]);
  17270. private _excludeWithLayerMask;
  17271. /**
  17272. * Gets the layer id use to find what meshes are not impacted by the light.
  17273. * Inactive if 0
  17274. */
  17275. get excludeWithLayerMask(): number;
  17276. /**
  17277. * Sets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. set excludeWithLayerMask(value: number);
  17281. private _includeOnlyWithLayerMask;
  17282. /**
  17283. * Gets the layer id use to find what meshes are impacted by the light.
  17284. * Inactive if 0
  17285. */
  17286. get includeOnlyWithLayerMask(): number;
  17287. /**
  17288. * Sets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. set includeOnlyWithLayerMask(value: number);
  17292. private _lightmapMode;
  17293. /**
  17294. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17295. */
  17296. get lightmapMode(): number;
  17297. /**
  17298. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17299. */
  17300. set lightmapMode(value: number);
  17301. /**
  17302. * Shadow generator associted to the light.
  17303. * @hidden Internal use only.
  17304. */
  17305. _shadowGenerator: Nullable<IShadowGenerator>;
  17306. /**
  17307. * @hidden Internal use only.
  17308. */
  17309. _excludedMeshesIds: string[];
  17310. /**
  17311. * @hidden Internal use only.
  17312. */
  17313. _includedOnlyMeshesIds: string[];
  17314. /**
  17315. * The current light unifom buffer.
  17316. * @hidden Internal use only.
  17317. */
  17318. _uniformBuffer: UniformBuffer;
  17319. /** @hidden */
  17320. _renderId: number;
  17321. /**
  17322. * Creates a Light object in the scene.
  17323. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17324. * @param name The firendly name of the light
  17325. * @param scene The scene the light belongs too
  17326. */
  17327. constructor(name: string, scene: Scene);
  17328. protected abstract _buildUniformLayout(): void;
  17329. /**
  17330. * Sets the passed Effect "effect" with the Light information.
  17331. * @param effect The effect to update
  17332. * @param lightIndex The index of the light in the effect to update
  17333. * @returns The light
  17334. */
  17335. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17336. /**
  17337. * Sets the passed Effect "effect" with the Light textures.
  17338. * @param effect The effect to update
  17339. * @param lightIndex The index of the light in the effect to update
  17340. * @returns The light
  17341. */
  17342. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17343. /**
  17344. * Binds the lights information from the scene to the effect for the given mesh.
  17345. * @param lightIndex Light index
  17346. * @param scene The scene where the light belongs to
  17347. * @param effect The effect we are binding the data to
  17348. * @param useSpecular Defines if specular is supported
  17349. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17350. */
  17351. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17352. /**
  17353. * Sets the passed Effect "effect" with the Light information.
  17354. * @param effect The effect to update
  17355. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17356. * @returns The light
  17357. */
  17358. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17359. /**
  17360. * Returns the string "Light".
  17361. * @returns the class name
  17362. */
  17363. getClassName(): string;
  17364. /** @hidden */
  17365. readonly _isLight: boolean;
  17366. /**
  17367. * Converts the light information to a readable string for debug purpose.
  17368. * @param fullDetails Supports for multiple levels of logging within scene loading
  17369. * @returns the human readable light info
  17370. */
  17371. toString(fullDetails?: boolean): string;
  17372. /** @hidden */
  17373. protected _syncParentEnabledState(): void;
  17374. /**
  17375. * Set the enabled state of this node.
  17376. * @param value - the new enabled state
  17377. */
  17378. setEnabled(value: boolean): void;
  17379. /**
  17380. * Returns the Light associated shadow generator if any.
  17381. * @return the associated shadow generator.
  17382. */
  17383. getShadowGenerator(): Nullable<IShadowGenerator>;
  17384. /**
  17385. * Returns a Vector3, the absolute light position in the World.
  17386. * @returns the world space position of the light
  17387. */
  17388. getAbsolutePosition(): Vector3;
  17389. /**
  17390. * Specifies if the light will affect the passed mesh.
  17391. * @param mesh The mesh to test against the light
  17392. * @return true the mesh is affected otherwise, false.
  17393. */
  17394. canAffectMesh(mesh: AbstractMesh): boolean;
  17395. /**
  17396. * Sort function to order lights for rendering.
  17397. * @param a First Light object to compare to second.
  17398. * @param b Second Light object to compare first.
  17399. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17400. */
  17401. static CompareLightsPriority(a: Light, b: Light): number;
  17402. /**
  17403. * Releases resources associated with this node.
  17404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17406. */
  17407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17408. /**
  17409. * Returns the light type ID (integer).
  17410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17411. */
  17412. getTypeID(): number;
  17413. /**
  17414. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17415. * @returns the scaled intensity in intensity mode unit
  17416. */
  17417. getScaledIntensity(): number;
  17418. /**
  17419. * Returns a new Light object, named "name", from the current one.
  17420. * @param name The name of the cloned light
  17421. * @returns the new created light
  17422. */
  17423. clone(name: string): Nullable<Light>;
  17424. /**
  17425. * Serializes the current light into a Serialization object.
  17426. * @returns the serialized object.
  17427. */
  17428. serialize(): any;
  17429. /**
  17430. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17431. * This new light is named "name" and added to the passed scene.
  17432. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17433. * @param name The friendly name of the light
  17434. * @param scene The scene the new light will belong to
  17435. * @returns the constructor function
  17436. */
  17437. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17438. /**
  17439. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17440. * @param parsedLight The JSON representation of the light
  17441. * @param scene The scene to create the parsed light in
  17442. * @returns the created light after parsing
  17443. */
  17444. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17445. private _hookArrayForExcluded;
  17446. private _hookArrayForIncludedOnly;
  17447. private _resyncMeshes;
  17448. /**
  17449. * Forces the meshes to update their light related information in their rendering used effects
  17450. * @hidden Internal Use Only
  17451. */
  17452. _markMeshesAsLightDirty(): void;
  17453. /**
  17454. * Recomputes the cached photometric scale if needed.
  17455. */
  17456. private _computePhotometricScale;
  17457. /**
  17458. * Returns the Photometric Scale according to the light type and intensity mode.
  17459. */
  17460. private _getPhotometricScale;
  17461. /**
  17462. * Reorder the light in the scene according to their defined priority.
  17463. * @hidden Internal Use Only
  17464. */
  17465. _reorderLightsInScene(): void;
  17466. /**
  17467. * Prepares the list of defines specific to the light type.
  17468. * @param defines the list of defines
  17469. * @param lightIndex defines the index of the light for the effect
  17470. */
  17471. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17472. }
  17473. }
  17474. declare module "babylonjs/Actions/action" {
  17475. import { Observable } from "babylonjs/Misc/observable";
  17476. import { Condition } from "babylonjs/Actions/condition";
  17477. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17478. import { ActionManager } from "babylonjs/Actions/actionManager";
  17479. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17480. /**
  17481. * Interface used to define Action
  17482. */
  17483. export interface IAction {
  17484. /**
  17485. * Trigger for the action
  17486. */
  17487. trigger: number;
  17488. /** Options of the trigger */
  17489. triggerOptions: any;
  17490. /**
  17491. * Gets the trigger parameters
  17492. * @returns the trigger parameters
  17493. */
  17494. getTriggerParameter(): any;
  17495. /**
  17496. * Internal only - executes current action event
  17497. * @hidden
  17498. */
  17499. _executeCurrent(evt?: ActionEvent): void;
  17500. /**
  17501. * Serialize placeholder for child classes
  17502. * @param parent of child
  17503. * @returns the serialized object
  17504. */
  17505. serialize(parent: any): any;
  17506. /**
  17507. * Internal only
  17508. * @hidden
  17509. */
  17510. _prepare(): void;
  17511. /**
  17512. * Internal only - manager for action
  17513. * @hidden
  17514. */
  17515. _actionManager: AbstractActionManager;
  17516. /**
  17517. * Adds action to chain of actions, may be a DoNothingAction
  17518. * @param action defines the next action to execute
  17519. * @returns The action passed in
  17520. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17521. */
  17522. then(action: IAction): IAction;
  17523. }
  17524. /**
  17525. * The action to be carried out following a trigger
  17526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17527. */
  17528. export class Action implements IAction {
  17529. /** the trigger, with or without parameters, for the action */
  17530. triggerOptions: any;
  17531. /**
  17532. * Trigger for the action
  17533. */
  17534. trigger: number;
  17535. /**
  17536. * Internal only - manager for action
  17537. * @hidden
  17538. */
  17539. _actionManager: ActionManager;
  17540. private _nextActiveAction;
  17541. private _child;
  17542. private _condition?;
  17543. private _triggerParameter;
  17544. /**
  17545. * An event triggered prior to action being executed.
  17546. */
  17547. onBeforeExecuteObservable: Observable<Action>;
  17548. /**
  17549. * Creates a new Action
  17550. * @param triggerOptions the trigger, with or without parameters, for the action
  17551. * @param condition an optional determinant of action
  17552. */
  17553. constructor(
  17554. /** the trigger, with or without parameters, for the action */
  17555. triggerOptions: any, condition?: Condition);
  17556. /**
  17557. * Internal only
  17558. * @hidden
  17559. */
  17560. _prepare(): void;
  17561. /**
  17562. * Gets the trigger parameters
  17563. * @returns the trigger parameters
  17564. */
  17565. getTriggerParameter(): any;
  17566. /**
  17567. * Internal only - executes current action event
  17568. * @hidden
  17569. */
  17570. _executeCurrent(evt?: ActionEvent): void;
  17571. /**
  17572. * Execute placeholder for child classes
  17573. * @param evt optional action event
  17574. */
  17575. execute(evt?: ActionEvent): void;
  17576. /**
  17577. * Skips to next active action
  17578. */
  17579. skipToNextActiveAction(): void;
  17580. /**
  17581. * Adds action to chain of actions, may be a DoNothingAction
  17582. * @param action defines the next action to execute
  17583. * @returns The action passed in
  17584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17585. */
  17586. then(action: Action): Action;
  17587. /**
  17588. * Internal only
  17589. * @hidden
  17590. */
  17591. _getProperty(propertyPath: string): string;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getEffectiveTarget(target: any, propertyPath: string): any;
  17597. /**
  17598. * Serialize placeholder for child classes
  17599. * @param parent of child
  17600. * @returns the serialized object
  17601. */
  17602. serialize(parent: any): any;
  17603. /**
  17604. * Internal only called by serialize
  17605. * @hidden
  17606. */
  17607. protected _serialize(serializedAction: any, parent?: any): any;
  17608. /**
  17609. * Internal only
  17610. * @hidden
  17611. */
  17612. static _SerializeValueAsString: (value: any) => string;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17618. name: string;
  17619. targetType: string;
  17620. value: string;
  17621. };
  17622. }
  17623. }
  17624. declare module "babylonjs/Actions/condition" {
  17625. import { ActionManager } from "babylonjs/Actions/actionManager";
  17626. /**
  17627. * A Condition applied to an Action
  17628. */
  17629. export class Condition {
  17630. /**
  17631. * Internal only - manager for action
  17632. * @hidden
  17633. */
  17634. _actionManager: ActionManager;
  17635. /**
  17636. * Internal only
  17637. * @hidden
  17638. */
  17639. _evaluationId: number;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _currentResult: boolean;
  17645. /**
  17646. * Creates a new Condition
  17647. * @param actionManager the manager of the action the condition is applied to
  17648. */
  17649. constructor(actionManager: ActionManager);
  17650. /**
  17651. * Check if the current condition is valid
  17652. * @returns a boolean
  17653. */
  17654. isValid(): boolean;
  17655. /**
  17656. * Internal only
  17657. * @hidden
  17658. */
  17659. _getProperty(propertyPath: string): string;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getEffectiveTarget(target: any, propertyPath: string): any;
  17665. /**
  17666. * Serialize placeholder for child classes
  17667. * @returns the serialized object
  17668. */
  17669. serialize(): any;
  17670. /**
  17671. * Internal only
  17672. * @hidden
  17673. */
  17674. protected _serialize(serializedCondition: any): any;
  17675. }
  17676. /**
  17677. * Defines specific conditional operators as extensions of Condition
  17678. */
  17679. export class ValueCondition extends Condition {
  17680. /** path to specify the property of the target the conditional operator uses */
  17681. propertyPath: string;
  17682. /** the value compared by the conditional operator against the current value of the property */
  17683. value: any;
  17684. /** the conditional operator, default ValueCondition.IsEqual */
  17685. operator: number;
  17686. /**
  17687. * Internal only
  17688. * @hidden
  17689. */
  17690. private static _IsEqual;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsDifferent;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsGreater;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsLesser;
  17706. /**
  17707. * returns the number for IsEqual
  17708. */
  17709. static get IsEqual(): number;
  17710. /**
  17711. * Returns the number for IsDifferent
  17712. */
  17713. static get IsDifferent(): number;
  17714. /**
  17715. * Returns the number for IsGreater
  17716. */
  17717. static get IsGreater(): number;
  17718. /**
  17719. * Returns the number for IsLesser
  17720. */
  17721. static get IsLesser(): number;
  17722. /**
  17723. * Internal only The action manager for the condition
  17724. * @hidden
  17725. */
  17726. _actionManager: ActionManager;
  17727. /**
  17728. * Internal only
  17729. * @hidden
  17730. */
  17731. private _target;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _effectiveTarget;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _property;
  17742. /**
  17743. * Creates a new ValueCondition
  17744. * @param actionManager manager for the action the condition applies to
  17745. * @param target for the action
  17746. * @param propertyPath path to specify the property of the target the conditional operator uses
  17747. * @param value the value compared by the conditional operator against the current value of the property
  17748. * @param operator the conditional operator, default ValueCondition.IsEqual
  17749. */
  17750. constructor(actionManager: ActionManager, target: any,
  17751. /** path to specify the property of the target the conditional operator uses */
  17752. propertyPath: string,
  17753. /** the value compared by the conditional operator against the current value of the property */
  17754. value: any,
  17755. /** the conditional operator, default ValueCondition.IsEqual */
  17756. operator?: number);
  17757. /**
  17758. * Compares the given value with the property value for the specified conditional operator
  17759. * @returns the result of the comparison
  17760. */
  17761. isValid(): boolean;
  17762. /**
  17763. * Serialize the ValueCondition into a JSON compatible object
  17764. * @returns serialization object
  17765. */
  17766. serialize(): any;
  17767. /**
  17768. * Gets the name of the conditional operator for the ValueCondition
  17769. * @param operator the conditional operator
  17770. * @returns the name
  17771. */
  17772. static GetOperatorName(operator: number): string;
  17773. }
  17774. /**
  17775. * Defines a predicate condition as an extension of Condition
  17776. */
  17777. export class PredicateCondition extends Condition {
  17778. /** defines the predicate function used to validate the condition */
  17779. predicate: () => boolean;
  17780. /**
  17781. * Internal only - manager for action
  17782. * @hidden
  17783. */
  17784. _actionManager: ActionManager;
  17785. /**
  17786. * Creates a new PredicateCondition
  17787. * @param actionManager manager for the action the condition applies to
  17788. * @param predicate defines the predicate function used to validate the condition
  17789. */
  17790. constructor(actionManager: ActionManager,
  17791. /** defines the predicate function used to validate the condition */
  17792. predicate: () => boolean);
  17793. /**
  17794. * @returns the validity of the predicate condition
  17795. */
  17796. isValid(): boolean;
  17797. }
  17798. /**
  17799. * Defines a state condition as an extension of Condition
  17800. */
  17801. export class StateCondition extends Condition {
  17802. /** Value to compare with target state */
  17803. value: string;
  17804. /**
  17805. * Internal only - manager for action
  17806. * @hidden
  17807. */
  17808. _actionManager: ActionManager;
  17809. /**
  17810. * Internal only
  17811. * @hidden
  17812. */
  17813. private _target;
  17814. /**
  17815. * Creates a new StateCondition
  17816. * @param actionManager manager for the action the condition applies to
  17817. * @param target of the condition
  17818. * @param value to compare with target state
  17819. */
  17820. constructor(actionManager: ActionManager, target: any,
  17821. /** Value to compare with target state */
  17822. value: string);
  17823. /**
  17824. * Gets a boolean indicating if the current condition is met
  17825. * @returns the validity of the state
  17826. */
  17827. isValid(): boolean;
  17828. /**
  17829. * Serialize the StateCondition into a JSON compatible object
  17830. * @returns serialization object
  17831. */
  17832. serialize(): any;
  17833. }
  17834. }
  17835. declare module "babylonjs/Actions/directActions" {
  17836. import { Action } from "babylonjs/Actions/action";
  17837. import { Condition } from "babylonjs/Actions/condition";
  17838. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17839. /**
  17840. * This defines an action responsible to toggle a boolean once triggered.
  17841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17842. */
  17843. export class SwitchBooleanAction extends Action {
  17844. /**
  17845. * The path to the boolean property in the target object
  17846. */
  17847. propertyPath: string;
  17848. private _target;
  17849. private _effectiveTarget;
  17850. private _property;
  17851. /**
  17852. * Instantiate the action
  17853. * @param triggerOptions defines the trigger options
  17854. * @param target defines the object containing the boolean
  17855. * @param propertyPath defines the path to the boolean property in the target object
  17856. * @param condition defines the trigger related conditions
  17857. */
  17858. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17859. /** @hidden */
  17860. _prepare(): void;
  17861. /**
  17862. * Execute the action toggle the boolean value.
  17863. */
  17864. execute(): void;
  17865. /**
  17866. * Serializes the actions and its related information.
  17867. * @param parent defines the object to serialize in
  17868. * @returns the serialized object
  17869. */
  17870. serialize(parent: any): any;
  17871. }
  17872. /**
  17873. * This defines an action responsible to set a the state field of the target
  17874. * to a desired value once triggered.
  17875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17876. */
  17877. export class SetStateAction extends Action {
  17878. /**
  17879. * The value to store in the state field.
  17880. */
  17881. value: string;
  17882. private _target;
  17883. /**
  17884. * Instantiate the action
  17885. * @param triggerOptions defines the trigger options
  17886. * @param target defines the object containing the state property
  17887. * @param value defines the value to store in the state field
  17888. * @param condition defines the trigger related conditions
  17889. */
  17890. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17891. /**
  17892. * Execute the action and store the value on the target state property.
  17893. */
  17894. execute(): void;
  17895. /**
  17896. * Serializes the actions and its related information.
  17897. * @param parent defines the object to serialize in
  17898. * @returns the serialized object
  17899. */
  17900. serialize(parent: any): any;
  17901. }
  17902. /**
  17903. * This defines an action responsible to set a property of the target
  17904. * to a desired value once triggered.
  17905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17906. */
  17907. export class SetValueAction extends Action {
  17908. /**
  17909. * The path of the property to set in the target.
  17910. */
  17911. propertyPath: string;
  17912. /**
  17913. * The value to set in the property
  17914. */
  17915. value: any;
  17916. private _target;
  17917. private _effectiveTarget;
  17918. private _property;
  17919. /**
  17920. * Instantiate the action
  17921. * @param triggerOptions defines the trigger options
  17922. * @param target defines the object containing the property
  17923. * @param propertyPath defines the path of the property to set in the target
  17924. * @param value defines the value to set in the property
  17925. * @param condition defines the trigger related conditions
  17926. */
  17927. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17928. /** @hidden */
  17929. _prepare(): void;
  17930. /**
  17931. * Execute the action and set the targetted property to the desired value.
  17932. */
  17933. execute(): void;
  17934. /**
  17935. * Serializes the actions and its related information.
  17936. * @param parent defines the object to serialize in
  17937. * @returns the serialized object
  17938. */
  17939. serialize(parent: any): any;
  17940. }
  17941. /**
  17942. * This defines an action responsible to increment the target value
  17943. * to a desired value once triggered.
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17945. */
  17946. export class IncrementValueAction extends Action {
  17947. /**
  17948. * The path of the property to increment in the target.
  17949. */
  17950. propertyPath: string;
  17951. /**
  17952. * The value we should increment the property by.
  17953. */
  17954. value: any;
  17955. private _target;
  17956. private _effectiveTarget;
  17957. private _property;
  17958. /**
  17959. * Instantiate the action
  17960. * @param triggerOptions defines the trigger options
  17961. * @param target defines the object containing the property
  17962. * @param propertyPath defines the path of the property to increment in the target
  17963. * @param value defines the value value we should increment the property by
  17964. * @param condition defines the trigger related conditions
  17965. */
  17966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17967. /** @hidden */
  17968. _prepare(): void;
  17969. /**
  17970. * Execute the action and increment the target of the value amount.
  17971. */
  17972. execute(): void;
  17973. /**
  17974. * Serializes the actions and its related information.
  17975. * @param parent defines the object to serialize in
  17976. * @returns the serialized object
  17977. */
  17978. serialize(parent: any): any;
  17979. }
  17980. /**
  17981. * This defines an action responsible to start an animation once triggered.
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17983. */
  17984. export class PlayAnimationAction extends Action {
  17985. /**
  17986. * Where the animation should start (animation frame)
  17987. */
  17988. from: number;
  17989. /**
  17990. * Where the animation should stop (animation frame)
  17991. */
  17992. to: number;
  17993. /**
  17994. * Define if the animation should loop or stop after the first play.
  17995. */
  17996. loop?: boolean;
  17997. private _target;
  17998. /**
  17999. * Instantiate the action
  18000. * @param triggerOptions defines the trigger options
  18001. * @param target defines the target animation or animation name
  18002. * @param from defines from where the animation should start (animation frame)
  18003. * @param end defines where the animation should stop (animation frame)
  18004. * @param loop defines if the animation should loop or stop after the first play
  18005. * @param condition defines the trigger related conditions
  18006. */
  18007. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18008. /** @hidden */
  18009. _prepare(): void;
  18010. /**
  18011. * Execute the action and play the animation.
  18012. */
  18013. execute(): void;
  18014. /**
  18015. * Serializes the actions and its related information.
  18016. * @param parent defines the object to serialize in
  18017. * @returns the serialized object
  18018. */
  18019. serialize(parent: any): any;
  18020. }
  18021. /**
  18022. * This defines an action responsible to stop an animation once triggered.
  18023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18024. */
  18025. export class StopAnimationAction extends Action {
  18026. private _target;
  18027. /**
  18028. * Instantiate the action
  18029. * @param triggerOptions defines the trigger options
  18030. * @param target defines the target animation or animation name
  18031. * @param condition defines the trigger related conditions
  18032. */
  18033. constructor(triggerOptions: any, target: any, condition?: Condition);
  18034. /** @hidden */
  18035. _prepare(): void;
  18036. /**
  18037. * Execute the action and stop the animation.
  18038. */
  18039. execute(): void;
  18040. /**
  18041. * Serializes the actions and its related information.
  18042. * @param parent defines the object to serialize in
  18043. * @returns the serialized object
  18044. */
  18045. serialize(parent: any): any;
  18046. }
  18047. /**
  18048. * This defines an action responsible that does nothing once triggered.
  18049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18050. */
  18051. export class DoNothingAction extends Action {
  18052. /**
  18053. * Instantiate the action
  18054. * @param triggerOptions defines the trigger options
  18055. * @param condition defines the trigger related conditions
  18056. */
  18057. constructor(triggerOptions?: any, condition?: Condition);
  18058. /**
  18059. * Execute the action and do nothing.
  18060. */
  18061. execute(): void;
  18062. /**
  18063. * Serializes the actions and its related information.
  18064. * @param parent defines the object to serialize in
  18065. * @returns the serialized object
  18066. */
  18067. serialize(parent: any): any;
  18068. }
  18069. /**
  18070. * This defines an action responsible to trigger several actions once triggered.
  18071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18072. */
  18073. export class CombineAction extends Action {
  18074. /**
  18075. * The list of aggregated animations to run.
  18076. */
  18077. children: Action[];
  18078. /**
  18079. * Instantiate the action
  18080. * @param triggerOptions defines the trigger options
  18081. * @param children defines the list of aggregated animations to run
  18082. * @param condition defines the trigger related conditions
  18083. */
  18084. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18085. /** @hidden */
  18086. _prepare(): void;
  18087. /**
  18088. * Execute the action and executes all the aggregated actions.
  18089. */
  18090. execute(evt: ActionEvent): void;
  18091. /**
  18092. * Serializes the actions and its related information.
  18093. * @param parent defines the object to serialize in
  18094. * @returns the serialized object
  18095. */
  18096. serialize(parent: any): any;
  18097. }
  18098. /**
  18099. * This defines an action responsible to run code (external event) once triggered.
  18100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18101. */
  18102. export class ExecuteCodeAction extends Action {
  18103. /**
  18104. * The callback function to run.
  18105. */
  18106. func: (evt: ActionEvent) => void;
  18107. /**
  18108. * Instantiate the action
  18109. * @param triggerOptions defines the trigger options
  18110. * @param func defines the callback function to run
  18111. * @param condition defines the trigger related conditions
  18112. */
  18113. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18114. /**
  18115. * Execute the action and run the attached code.
  18116. */
  18117. execute(evt: ActionEvent): void;
  18118. }
  18119. /**
  18120. * This defines an action responsible to set the parent property of the target once triggered.
  18121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18122. */
  18123. export class SetParentAction extends Action {
  18124. private _parent;
  18125. private _target;
  18126. /**
  18127. * Instantiate the action
  18128. * @param triggerOptions defines the trigger options
  18129. * @param target defines the target containing the parent property
  18130. * @param parent defines from where the animation should start (animation frame)
  18131. * @param condition defines the trigger related conditions
  18132. */
  18133. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18134. /** @hidden */
  18135. _prepare(): void;
  18136. /**
  18137. * Execute the action and set the parent property.
  18138. */
  18139. execute(): void;
  18140. /**
  18141. * Serializes the actions and its related information.
  18142. * @param parent defines the object to serialize in
  18143. * @returns the serialized object
  18144. */
  18145. serialize(parent: any): any;
  18146. }
  18147. }
  18148. declare module "babylonjs/Actions/actionManager" {
  18149. import { Nullable } from "babylonjs/types";
  18150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18151. import { Scene } from "babylonjs/scene";
  18152. import { IAction } from "babylonjs/Actions/action";
  18153. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18154. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18155. /**
  18156. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18157. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18159. */
  18160. export class ActionManager extends AbstractActionManager {
  18161. /**
  18162. * Nothing
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18164. */
  18165. static readonly NothingTrigger: number;
  18166. /**
  18167. * On pick
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly OnPickTrigger: number;
  18171. /**
  18172. * On left pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnLeftPickTrigger: number;
  18176. /**
  18177. * On right pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnRightPickTrigger: number;
  18181. /**
  18182. * On center pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnCenterPickTrigger: number;
  18186. /**
  18187. * On pick down
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnPickDownTrigger: number;
  18191. /**
  18192. * On double pick
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnDoublePickTrigger: number;
  18196. /**
  18197. * On pick up
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnPickUpTrigger: number;
  18201. /**
  18202. * On pick out.
  18203. * This trigger will only be raised if you also declared a OnPickDown
  18204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18205. */
  18206. static readonly OnPickOutTrigger: number;
  18207. /**
  18208. * On long press
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnLongPressTrigger: number;
  18212. /**
  18213. * On pointer over
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnPointerOverTrigger: number;
  18217. /**
  18218. * On pointer out
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOutTrigger: number;
  18222. /**
  18223. * On every frame
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnEveryFrameTrigger: number;
  18227. /**
  18228. * On intersection enter
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnIntersectionEnterTrigger: number;
  18232. /**
  18233. * On intersection exit
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionExitTrigger: number;
  18237. /**
  18238. * On key down
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnKeyDownTrigger: number;
  18242. /**
  18243. * On key up
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyUpTrigger: number;
  18247. private _scene;
  18248. /**
  18249. * Creates a new action manager
  18250. * @param scene defines the hosting scene
  18251. */
  18252. constructor(scene: Scene);
  18253. /**
  18254. * Releases all associated resources
  18255. */
  18256. dispose(): void;
  18257. /**
  18258. * Gets hosting scene
  18259. * @returns the hosting scene
  18260. */
  18261. getScene(): Scene;
  18262. /**
  18263. * Does this action manager handles actions of any of the given triggers
  18264. * @param triggers defines the triggers to be tested
  18265. * @return a boolean indicating whether one (or more) of the triggers is handled
  18266. */
  18267. hasSpecificTriggers(triggers: number[]): boolean;
  18268. /**
  18269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18270. * speed.
  18271. * @param triggerA defines the trigger to be tested
  18272. * @param triggerB defines the trigger to be tested
  18273. * @return a boolean indicating whether one (or more) of the triggers is handled
  18274. */
  18275. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18276. /**
  18277. * Does this action manager handles actions of a given trigger
  18278. * @param trigger defines the trigger to be tested
  18279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18280. * @return whether the trigger is handled
  18281. */
  18282. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18283. /**
  18284. * Does this action manager has pointer triggers
  18285. */
  18286. get hasPointerTriggers(): boolean;
  18287. /**
  18288. * Does this action manager has pick triggers
  18289. */
  18290. get hasPickTriggers(): boolean;
  18291. /**
  18292. * Registers an action to this action manager
  18293. * @param action defines the action to be registered
  18294. * @return the action amended (prepared) after registration
  18295. */
  18296. registerAction(action: IAction): Nullable<IAction>;
  18297. /**
  18298. * Unregisters an action to this action manager
  18299. * @param action defines the action to be unregistered
  18300. * @return a boolean indicating whether the action has been unregistered
  18301. */
  18302. unregisterAction(action: IAction): Boolean;
  18303. /**
  18304. * Process a specific trigger
  18305. * @param trigger defines the trigger to process
  18306. * @param evt defines the event details to be processed
  18307. */
  18308. processTrigger(trigger: number, evt?: IActionEvent): void;
  18309. /** @hidden */
  18310. _getEffectiveTarget(target: any, propertyPath: string): any;
  18311. /** @hidden */
  18312. _getProperty(propertyPath: string): string;
  18313. /**
  18314. * Serialize this manager to a JSON object
  18315. * @param name defines the property name to store this manager
  18316. * @returns a JSON representation of this manager
  18317. */
  18318. serialize(name: string): any;
  18319. /**
  18320. * Creates a new ActionManager from a JSON data
  18321. * @param parsedActions defines the JSON data to read from
  18322. * @param object defines the hosting mesh
  18323. * @param scene defines the hosting scene
  18324. */
  18325. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18326. /**
  18327. * Get a trigger name by index
  18328. * @param trigger defines the trigger index
  18329. * @returns a trigger name
  18330. */
  18331. static GetTriggerName(trigger: number): string;
  18332. }
  18333. }
  18334. declare module "babylonjs/Sprites/sprite" {
  18335. import { Vector3 } from "babylonjs/Maths/math.vector";
  18336. import { Nullable } from "babylonjs/types";
  18337. import { ActionManager } from "babylonjs/Actions/actionManager";
  18338. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18339. import { Color4 } from "babylonjs/Maths/math.color";
  18340. /**
  18341. * Class used to represent a sprite
  18342. * @see http://doc.babylonjs.com/babylon101/sprites
  18343. */
  18344. export class Sprite {
  18345. /** defines the name */
  18346. name: string;
  18347. /** Gets or sets the current world position */
  18348. position: Vector3;
  18349. /** Gets or sets the main color */
  18350. color: Color4;
  18351. /** Gets or sets the width */
  18352. width: number;
  18353. /** Gets or sets the height */
  18354. height: number;
  18355. /** Gets or sets rotation angle */
  18356. angle: number;
  18357. /** Gets or sets the cell index in the sprite sheet */
  18358. cellIndex: number;
  18359. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18360. cellRef: string;
  18361. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18362. invertU: number;
  18363. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18364. invertV: number;
  18365. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18366. disposeWhenFinishedAnimating: boolean;
  18367. /** Gets the list of attached animations */
  18368. animations: Animation[];
  18369. /** Gets or sets a boolean indicating if the sprite can be picked */
  18370. isPickable: boolean;
  18371. /**
  18372. * Gets or sets the associated action manager
  18373. */
  18374. actionManager: Nullable<ActionManager>;
  18375. private _animationStarted;
  18376. private _loopAnimation;
  18377. private _fromIndex;
  18378. private _toIndex;
  18379. private _delay;
  18380. private _direction;
  18381. private _manager;
  18382. private _time;
  18383. private _onAnimationEnd;
  18384. /**
  18385. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18386. */
  18387. isVisible: boolean;
  18388. /**
  18389. * Gets or sets the sprite size
  18390. */
  18391. get size(): number;
  18392. set size(value: number);
  18393. /**
  18394. * Creates a new Sprite
  18395. * @param name defines the name
  18396. * @param manager defines the manager
  18397. */
  18398. constructor(
  18399. /** defines the name */
  18400. name: string, manager: ISpriteManager);
  18401. /**
  18402. * Starts an animation
  18403. * @param from defines the initial key
  18404. * @param to defines the end key
  18405. * @param loop defines if the animation must loop
  18406. * @param delay defines the start delay (in ms)
  18407. * @param onAnimationEnd defines a callback to call when animation ends
  18408. */
  18409. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18410. /** Stops current animation (if any) */
  18411. stopAnimation(): void;
  18412. /** @hidden */
  18413. _animate(deltaTime: number): void;
  18414. /** Release associated resources */
  18415. dispose(): void;
  18416. }
  18417. }
  18418. declare module "babylonjs/Collisions/pickingInfo" {
  18419. import { Nullable } from "babylonjs/types";
  18420. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18422. import { Sprite } from "babylonjs/Sprites/sprite";
  18423. import { Ray } from "babylonjs/Culling/ray";
  18424. /**
  18425. * Information about the result of picking within a scene
  18426. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18427. */
  18428. export class PickingInfo {
  18429. /** @hidden */
  18430. _pickingUnavailable: boolean;
  18431. /**
  18432. * If the pick collided with an object
  18433. */
  18434. hit: boolean;
  18435. /**
  18436. * Distance away where the pick collided
  18437. */
  18438. distance: number;
  18439. /**
  18440. * The location of pick collision
  18441. */
  18442. pickedPoint: Nullable<Vector3>;
  18443. /**
  18444. * The mesh corresponding the the pick collision
  18445. */
  18446. pickedMesh: Nullable<AbstractMesh>;
  18447. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18448. bu: number;
  18449. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18450. bv: number;
  18451. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18452. faceId: number;
  18453. /** Id of the the submesh that was picked */
  18454. subMeshId: number;
  18455. /** If a sprite was picked, this will be the sprite the pick collided with */
  18456. pickedSprite: Nullable<Sprite>;
  18457. /**
  18458. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18459. */
  18460. originMesh: Nullable<AbstractMesh>;
  18461. /**
  18462. * The ray that was used to perform the picking.
  18463. */
  18464. ray: Nullable<Ray>;
  18465. /**
  18466. * Gets the normal correspodning to the face the pick collided with
  18467. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18468. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18469. * @returns The normal correspodning to the face the pick collided with
  18470. */
  18471. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18472. /**
  18473. * Gets the texture coordinates of where the pick occured
  18474. * @returns the vector containing the coordnates of the texture
  18475. */
  18476. getTextureCoordinates(): Nullable<Vector2>;
  18477. }
  18478. }
  18479. declare module "babylonjs/Events/pointerEvents" {
  18480. import { Nullable } from "babylonjs/types";
  18481. import { Vector2 } from "babylonjs/Maths/math.vector";
  18482. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18483. import { Ray } from "babylonjs/Culling/ray";
  18484. /**
  18485. * Gather the list of pointer event types as constants.
  18486. */
  18487. export class PointerEventTypes {
  18488. /**
  18489. * 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.
  18490. */
  18491. static readonly POINTERDOWN: number;
  18492. /**
  18493. * The pointerup event is fired when a pointer is no longer active.
  18494. */
  18495. static readonly POINTERUP: number;
  18496. /**
  18497. * The pointermove event is fired when a pointer changes coordinates.
  18498. */
  18499. static readonly POINTERMOVE: number;
  18500. /**
  18501. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18502. */
  18503. static readonly POINTERWHEEL: number;
  18504. /**
  18505. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18506. */
  18507. static readonly POINTERPICK: number;
  18508. /**
  18509. * The pointertap event is fired when a the object has been touched and released without drag.
  18510. */
  18511. static readonly POINTERTAP: number;
  18512. /**
  18513. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18514. */
  18515. static readonly POINTERDOUBLETAP: number;
  18516. }
  18517. /**
  18518. * Base class of pointer info types.
  18519. */
  18520. export class PointerInfoBase {
  18521. /**
  18522. * Defines the type of event (PointerEventTypes)
  18523. */
  18524. type: number;
  18525. /**
  18526. * Defines the related dom event
  18527. */
  18528. event: PointerEvent | MouseWheelEvent;
  18529. /**
  18530. * Instantiates the base class of pointers info.
  18531. * @param type Defines the type of event (PointerEventTypes)
  18532. * @param event Defines the related dom event
  18533. */
  18534. constructor(
  18535. /**
  18536. * Defines the type of event (PointerEventTypes)
  18537. */
  18538. type: number,
  18539. /**
  18540. * Defines the related dom event
  18541. */
  18542. event: PointerEvent | MouseWheelEvent);
  18543. }
  18544. /**
  18545. * This class is used to store pointer related info for the onPrePointerObservable event.
  18546. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18547. */
  18548. export class PointerInfoPre extends PointerInfoBase {
  18549. /**
  18550. * Ray from a pointer if availible (eg. 6dof controller)
  18551. */
  18552. ray: Nullable<Ray>;
  18553. /**
  18554. * Defines the local position of the pointer on the canvas.
  18555. */
  18556. localPosition: Vector2;
  18557. /**
  18558. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18559. */
  18560. skipOnPointerObservable: boolean;
  18561. /**
  18562. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18563. * @param type Defines the type of event (PointerEventTypes)
  18564. * @param event Defines the related dom event
  18565. * @param localX Defines the local x coordinates of the pointer when the event occured
  18566. * @param localY Defines the local y coordinates of the pointer when the event occured
  18567. */
  18568. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18569. }
  18570. /**
  18571. * This type contains all the data related to a pointer event in Babylon.js.
  18572. * 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.
  18573. */
  18574. export class PointerInfo extends PointerInfoBase {
  18575. /**
  18576. * Defines the picking info associated to the info (if any)\
  18577. */
  18578. pickInfo: Nullable<PickingInfo>;
  18579. /**
  18580. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18581. * @param type Defines the type of event (PointerEventTypes)
  18582. * @param event Defines the related dom event
  18583. * @param pickInfo Defines the picking info associated to the info (if any)\
  18584. */
  18585. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18586. /**
  18587. * Defines the picking info associated to the info (if any)\
  18588. */
  18589. pickInfo: Nullable<PickingInfo>);
  18590. }
  18591. /**
  18592. * Data relating to a touch event on the screen.
  18593. */
  18594. export interface PointerTouch {
  18595. /**
  18596. * X coordinate of touch.
  18597. */
  18598. x: number;
  18599. /**
  18600. * Y coordinate of touch.
  18601. */
  18602. y: number;
  18603. /**
  18604. * Id of touch. Unique for each finger.
  18605. */
  18606. pointerId: number;
  18607. /**
  18608. * Event type passed from DOM.
  18609. */
  18610. type: any;
  18611. }
  18612. }
  18613. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18614. import { Observable } from "babylonjs/Misc/observable";
  18615. import { Nullable } from "babylonjs/types";
  18616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18617. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18618. /**
  18619. * Manage the mouse inputs to control the movement of a free camera.
  18620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18621. */
  18622. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18623. /**
  18624. * Define if touch is enabled in the mouse input
  18625. */
  18626. touchEnabled: boolean;
  18627. /**
  18628. * Defines the camera the input is attached to.
  18629. */
  18630. camera: FreeCamera;
  18631. /**
  18632. * Defines the buttons associated with the input to handle camera move.
  18633. */
  18634. buttons: number[];
  18635. /**
  18636. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18637. */
  18638. angularSensibility: number;
  18639. private _pointerInput;
  18640. private _onMouseMove;
  18641. private _observer;
  18642. private previousPosition;
  18643. /**
  18644. * Observable for when a pointer move event occurs containing the move offset
  18645. */
  18646. onPointerMovedObservable: Observable<{
  18647. offsetX: number;
  18648. offsetY: number;
  18649. }>;
  18650. /**
  18651. * @hidden
  18652. * If the camera should be rotated automatically based on pointer movement
  18653. */
  18654. _allowCameraRotation: boolean;
  18655. /**
  18656. * Manage the mouse inputs to control the movement of a free camera.
  18657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18658. * @param touchEnabled Defines if touch is enabled or not
  18659. */
  18660. constructor(
  18661. /**
  18662. * Define if touch is enabled in the mouse input
  18663. */
  18664. touchEnabled?: boolean);
  18665. /**
  18666. * Attach the input controls to a specific dom element to get the input from.
  18667. * @param element Defines the element the controls should be listened from
  18668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18669. */
  18670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18671. /**
  18672. * Called on JS contextmenu event.
  18673. * Override this method to provide functionality.
  18674. */
  18675. protected onContextMenu(evt: PointerEvent): void;
  18676. /**
  18677. * Detach the current controls from the specified dom element.
  18678. * @param element Defines the element to stop listening the inputs from
  18679. */
  18680. detachControl(element: Nullable<HTMLElement>): void;
  18681. /**
  18682. * Gets the class name of the current intput.
  18683. * @returns the class name
  18684. */
  18685. getClassName(): string;
  18686. /**
  18687. * Get the friendly name associated with the input class.
  18688. * @returns the input friendly name
  18689. */
  18690. getSimpleName(): string;
  18691. }
  18692. }
  18693. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18694. import { Nullable } from "babylonjs/types";
  18695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18697. /**
  18698. * Manage the touch inputs to control the movement of a free camera.
  18699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18700. */
  18701. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18702. /**
  18703. * Defines the camera the input is attached to.
  18704. */
  18705. camera: FreeCamera;
  18706. /**
  18707. * Defines the touch sensibility for rotation.
  18708. * The higher the faster.
  18709. */
  18710. touchAngularSensibility: number;
  18711. /**
  18712. * Defines the touch sensibility for move.
  18713. * The higher the faster.
  18714. */
  18715. touchMoveSensibility: number;
  18716. private _offsetX;
  18717. private _offsetY;
  18718. private _pointerPressed;
  18719. private _pointerInput;
  18720. private _observer;
  18721. private _onLostFocus;
  18722. /**
  18723. * Attach the input controls to a specific dom element to get the input from.
  18724. * @param element Defines the element the controls should be listened from
  18725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18726. */
  18727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18728. /**
  18729. * Detach the current controls from the specified dom element.
  18730. * @param element Defines the element to stop listening the inputs from
  18731. */
  18732. detachControl(element: Nullable<HTMLElement>): void;
  18733. /**
  18734. * Update the current camera state depending on the inputs that have been used this frame.
  18735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18736. */
  18737. checkInputs(): void;
  18738. /**
  18739. * Gets the class name of the current intput.
  18740. * @returns the class name
  18741. */
  18742. getClassName(): string;
  18743. /**
  18744. * Get the friendly name associated with the input class.
  18745. * @returns the input friendly name
  18746. */
  18747. getSimpleName(): string;
  18748. }
  18749. }
  18750. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18751. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18752. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18753. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18754. import { Nullable } from "babylonjs/types";
  18755. /**
  18756. * Default Inputs manager for the FreeCamera.
  18757. * It groups all the default supported inputs for ease of use.
  18758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18759. */
  18760. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18761. /**
  18762. * @hidden
  18763. */
  18764. _mouseInput: Nullable<FreeCameraMouseInput>;
  18765. /**
  18766. * Instantiates a new FreeCameraInputsManager.
  18767. * @param camera Defines the camera the inputs belong to
  18768. */
  18769. constructor(camera: FreeCamera);
  18770. /**
  18771. * Add keyboard input support to the input manager.
  18772. * @returns the current input manager
  18773. */
  18774. addKeyboard(): FreeCameraInputsManager;
  18775. /**
  18776. * Add mouse input support to the input manager.
  18777. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18778. * @returns the current input manager
  18779. */
  18780. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18781. /**
  18782. * Removes the mouse input support from the manager
  18783. * @returns the current input manager
  18784. */
  18785. removeMouse(): FreeCameraInputsManager;
  18786. /**
  18787. * Add touch input support to the input manager.
  18788. * @returns the current input manager
  18789. */
  18790. addTouch(): FreeCameraInputsManager;
  18791. /**
  18792. * Remove all attached input methods from a camera
  18793. */
  18794. clear(): void;
  18795. }
  18796. }
  18797. declare module "babylonjs/Cameras/freeCamera" {
  18798. import { Vector3 } from "babylonjs/Maths/math.vector";
  18799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18800. import { Scene } from "babylonjs/scene";
  18801. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18802. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18803. /**
  18804. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18805. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18807. */
  18808. export class FreeCamera extends TargetCamera {
  18809. /**
  18810. * Define the collision ellipsoid of the camera.
  18811. * This is helpful to simulate a camera body like the player body around the camera
  18812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18813. */
  18814. ellipsoid: Vector3;
  18815. /**
  18816. * Define an offset for the position of the ellipsoid around the camera.
  18817. * This can be helpful to determine the center of the body near the gravity center of the body
  18818. * instead of its head.
  18819. */
  18820. ellipsoidOffset: Vector3;
  18821. /**
  18822. * Enable or disable collisions of the camera with the rest of the scene objects.
  18823. */
  18824. checkCollisions: boolean;
  18825. /**
  18826. * Enable or disable gravity on the camera.
  18827. */
  18828. applyGravity: boolean;
  18829. /**
  18830. * Define the input manager associated to the camera.
  18831. */
  18832. inputs: FreeCameraInputsManager;
  18833. /**
  18834. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18835. * Higher values reduce sensitivity.
  18836. */
  18837. get angularSensibility(): number;
  18838. /**
  18839. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. set angularSensibility(value: number);
  18843. /**
  18844. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18845. */
  18846. get keysUp(): number[];
  18847. set keysUp(value: number[]);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18850. */
  18851. get keysDown(): number[];
  18852. set keysDown(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18855. */
  18856. get keysLeft(): number[];
  18857. set keysLeft(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18860. */
  18861. get keysRight(): number[];
  18862. set keysRight(value: number[]);
  18863. /**
  18864. * Event raised when the camera collide with a mesh in the scene.
  18865. */
  18866. onCollide: (collidedMesh: AbstractMesh) => void;
  18867. private _collider;
  18868. private _needMoveForGravity;
  18869. private _oldPosition;
  18870. private _diffPosition;
  18871. private _newPosition;
  18872. /** @hidden */
  18873. _localDirection: Vector3;
  18874. /** @hidden */
  18875. _transformedDirection: Vector3;
  18876. /**
  18877. * Instantiates a Free Camera.
  18878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18879. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18881. * @param name Define the name of the camera in the scene
  18882. * @param position Define the start position of the camera in the scene
  18883. * @param scene Define the scene the camera belongs to
  18884. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18885. */
  18886. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18887. /**
  18888. * Attached controls to the current camera.
  18889. * @param element Defines the element the controls should be listened from
  18890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18891. */
  18892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18893. /**
  18894. * Detach the current controls from the camera.
  18895. * The camera will stop reacting to inputs.
  18896. * @param element Defines the element to stop listening the inputs from
  18897. */
  18898. detachControl(element: HTMLElement): void;
  18899. private _collisionMask;
  18900. /**
  18901. * Define a collision mask to limit the list of object the camera can collide with
  18902. */
  18903. get collisionMask(): number;
  18904. set collisionMask(mask: number);
  18905. /** @hidden */
  18906. _collideWithWorld(displacement: Vector3): void;
  18907. private _onCollisionPositionChange;
  18908. /** @hidden */
  18909. _checkInputs(): void;
  18910. /** @hidden */
  18911. _decideIfNeedsToMove(): boolean;
  18912. /** @hidden */
  18913. _updatePosition(): void;
  18914. /**
  18915. * Destroy the camera and release the current resources hold by it.
  18916. */
  18917. dispose(): void;
  18918. /**
  18919. * Gets the current object class name.
  18920. * @return the class name
  18921. */
  18922. getClassName(): string;
  18923. }
  18924. }
  18925. declare module "babylonjs/Gamepads/gamepad" {
  18926. import { Observable } from "babylonjs/Misc/observable";
  18927. /**
  18928. * Represents a gamepad control stick position
  18929. */
  18930. export class StickValues {
  18931. /**
  18932. * The x component of the control stick
  18933. */
  18934. x: number;
  18935. /**
  18936. * The y component of the control stick
  18937. */
  18938. y: number;
  18939. /**
  18940. * Initializes the gamepad x and y control stick values
  18941. * @param x The x component of the gamepad control stick value
  18942. * @param y The y component of the gamepad control stick value
  18943. */
  18944. constructor(
  18945. /**
  18946. * The x component of the control stick
  18947. */
  18948. x: number,
  18949. /**
  18950. * The y component of the control stick
  18951. */
  18952. y: number);
  18953. }
  18954. /**
  18955. * An interface which manages callbacks for gamepad button changes
  18956. */
  18957. export interface GamepadButtonChanges {
  18958. /**
  18959. * Called when a gamepad has been changed
  18960. */
  18961. changed: boolean;
  18962. /**
  18963. * Called when a gamepad press event has been triggered
  18964. */
  18965. pressChanged: boolean;
  18966. /**
  18967. * Called when a touch event has been triggered
  18968. */
  18969. touchChanged: boolean;
  18970. /**
  18971. * Called when a value has changed
  18972. */
  18973. valueChanged: boolean;
  18974. }
  18975. /**
  18976. * Represents a gamepad
  18977. */
  18978. export class Gamepad {
  18979. /**
  18980. * The id of the gamepad
  18981. */
  18982. id: string;
  18983. /**
  18984. * The index of the gamepad
  18985. */
  18986. index: number;
  18987. /**
  18988. * The browser gamepad
  18989. */
  18990. browserGamepad: any;
  18991. /**
  18992. * Specifies what type of gamepad this represents
  18993. */
  18994. type: number;
  18995. private _leftStick;
  18996. private _rightStick;
  18997. /** @hidden */
  18998. _isConnected: boolean;
  18999. private _leftStickAxisX;
  19000. private _leftStickAxisY;
  19001. private _rightStickAxisX;
  19002. private _rightStickAxisY;
  19003. /**
  19004. * Triggered when the left control stick has been changed
  19005. */
  19006. private _onleftstickchanged;
  19007. /**
  19008. * Triggered when the right control stick has been changed
  19009. */
  19010. private _onrightstickchanged;
  19011. /**
  19012. * Represents a gamepad controller
  19013. */
  19014. static GAMEPAD: number;
  19015. /**
  19016. * Represents a generic controller
  19017. */
  19018. static GENERIC: number;
  19019. /**
  19020. * Represents an XBox controller
  19021. */
  19022. static XBOX: number;
  19023. /**
  19024. * Represents a pose-enabled controller
  19025. */
  19026. static POSE_ENABLED: number;
  19027. /**
  19028. * Represents an Dual Shock controller
  19029. */
  19030. static DUALSHOCK: number;
  19031. /**
  19032. * Specifies whether the left control stick should be Y-inverted
  19033. */
  19034. protected _invertLeftStickY: boolean;
  19035. /**
  19036. * Specifies if the gamepad has been connected
  19037. */
  19038. get isConnected(): boolean;
  19039. /**
  19040. * Initializes the gamepad
  19041. * @param id The id of the gamepad
  19042. * @param index The index of the gamepad
  19043. * @param browserGamepad The browser gamepad
  19044. * @param leftStickX The x component of the left joystick
  19045. * @param leftStickY The y component of the left joystick
  19046. * @param rightStickX The x component of the right joystick
  19047. * @param rightStickY The y component of the right joystick
  19048. */
  19049. constructor(
  19050. /**
  19051. * The id of the gamepad
  19052. */
  19053. id: string,
  19054. /**
  19055. * The index of the gamepad
  19056. */
  19057. index: number,
  19058. /**
  19059. * The browser gamepad
  19060. */
  19061. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19062. /**
  19063. * Callback triggered when the left joystick has changed
  19064. * @param callback
  19065. */
  19066. onleftstickchanged(callback: (values: StickValues) => void): void;
  19067. /**
  19068. * Callback triggered when the right joystick has changed
  19069. * @param callback
  19070. */
  19071. onrightstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Gets the left joystick
  19074. */
  19075. get leftStick(): StickValues;
  19076. /**
  19077. * Sets the left joystick values
  19078. */
  19079. set leftStick(newValues: StickValues);
  19080. /**
  19081. * Gets the right joystick
  19082. */
  19083. get rightStick(): StickValues;
  19084. /**
  19085. * Sets the right joystick value
  19086. */
  19087. set rightStick(newValues: StickValues);
  19088. /**
  19089. * Updates the gamepad joystick positions
  19090. */
  19091. update(): void;
  19092. /**
  19093. * Disposes the gamepad
  19094. */
  19095. dispose(): void;
  19096. }
  19097. /**
  19098. * Represents a generic gamepad
  19099. */
  19100. export class GenericPad extends Gamepad {
  19101. private _buttons;
  19102. private _onbuttondown;
  19103. private _onbuttonup;
  19104. /**
  19105. * Observable triggered when a button has been pressed
  19106. */
  19107. onButtonDownObservable: Observable<number>;
  19108. /**
  19109. * Observable triggered when a button has been released
  19110. */
  19111. onButtonUpObservable: Observable<number>;
  19112. /**
  19113. * Callback triggered when a button has been pressed
  19114. * @param callback Called when a button has been pressed
  19115. */
  19116. onbuttondown(callback: (buttonPressed: number) => void): void;
  19117. /**
  19118. * Callback triggered when a button has been released
  19119. * @param callback Called when a button has been released
  19120. */
  19121. onbuttonup(callback: (buttonReleased: number) => void): void;
  19122. /**
  19123. * Initializes the generic gamepad
  19124. * @param id The id of the generic gamepad
  19125. * @param index The index of the generic gamepad
  19126. * @param browserGamepad The browser gamepad
  19127. */
  19128. constructor(id: string, index: number, browserGamepad: any);
  19129. private _setButtonValue;
  19130. /**
  19131. * Updates the generic gamepad
  19132. */
  19133. update(): void;
  19134. /**
  19135. * Disposes the generic gamepad
  19136. */
  19137. dispose(): void;
  19138. }
  19139. }
  19140. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19141. import { Observable } from "babylonjs/Misc/observable";
  19142. import { Nullable } from "babylonjs/types";
  19143. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19146. import { Ray } from "babylonjs/Culling/ray";
  19147. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19148. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19149. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19150. /**
  19151. * Defines the types of pose enabled controllers that are supported
  19152. */
  19153. export enum PoseEnabledControllerType {
  19154. /**
  19155. * HTC Vive
  19156. */
  19157. VIVE = 0,
  19158. /**
  19159. * Oculus Rift
  19160. */
  19161. OCULUS = 1,
  19162. /**
  19163. * Windows mixed reality
  19164. */
  19165. WINDOWS = 2,
  19166. /**
  19167. * Samsung gear VR
  19168. */
  19169. GEAR_VR = 3,
  19170. /**
  19171. * Google Daydream
  19172. */
  19173. DAYDREAM = 4,
  19174. /**
  19175. * Generic
  19176. */
  19177. GENERIC = 5
  19178. }
  19179. /**
  19180. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19181. */
  19182. export interface MutableGamepadButton {
  19183. /**
  19184. * Value of the button/trigger
  19185. */
  19186. value: number;
  19187. /**
  19188. * If the button/trigger is currently touched
  19189. */
  19190. touched: boolean;
  19191. /**
  19192. * If the button/trigger is currently pressed
  19193. */
  19194. pressed: boolean;
  19195. }
  19196. /**
  19197. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19198. * @hidden
  19199. */
  19200. export interface ExtendedGamepadButton extends GamepadButton {
  19201. /**
  19202. * If the button/trigger is currently pressed
  19203. */
  19204. readonly pressed: boolean;
  19205. /**
  19206. * If the button/trigger is currently touched
  19207. */
  19208. readonly touched: boolean;
  19209. /**
  19210. * Value of the button/trigger
  19211. */
  19212. readonly value: number;
  19213. }
  19214. /** @hidden */
  19215. export interface _GamePadFactory {
  19216. /**
  19217. * Returns whether or not the current gamepad can be created for this type of controller.
  19218. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19219. * @returns true if it can be created, otherwise false
  19220. */
  19221. canCreate(gamepadInfo: any): boolean;
  19222. /**
  19223. * Creates a new instance of the Gamepad.
  19224. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19225. * @returns the new gamepad instance
  19226. */
  19227. create(gamepadInfo: any): Gamepad;
  19228. }
  19229. /**
  19230. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19231. */
  19232. export class PoseEnabledControllerHelper {
  19233. /** @hidden */
  19234. static _ControllerFactories: _GamePadFactory[];
  19235. /** @hidden */
  19236. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19237. /**
  19238. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19239. * @param vrGamepad the gamepad to initialized
  19240. * @returns a vr controller of the type the gamepad identified as
  19241. */
  19242. static InitiateController(vrGamepad: any): Gamepad;
  19243. }
  19244. /**
  19245. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19246. */
  19247. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19248. /**
  19249. * If the controller is used in a webXR session
  19250. */
  19251. isXR: boolean;
  19252. private _deviceRoomPosition;
  19253. private _deviceRoomRotationQuaternion;
  19254. /**
  19255. * The device position in babylon space
  19256. */
  19257. devicePosition: Vector3;
  19258. /**
  19259. * The device rotation in babylon space
  19260. */
  19261. deviceRotationQuaternion: Quaternion;
  19262. /**
  19263. * The scale factor of the device in babylon space
  19264. */
  19265. deviceScaleFactor: number;
  19266. /**
  19267. * (Likely devicePosition should be used instead) The device position in its room space
  19268. */
  19269. position: Vector3;
  19270. /**
  19271. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19272. */
  19273. rotationQuaternion: Quaternion;
  19274. /**
  19275. * The type of controller (Eg. Windows mixed reality)
  19276. */
  19277. controllerType: PoseEnabledControllerType;
  19278. protected _calculatedPosition: Vector3;
  19279. private _calculatedRotation;
  19280. /**
  19281. * The raw pose from the device
  19282. */
  19283. rawPose: DevicePose;
  19284. private _trackPosition;
  19285. private _maxRotationDistFromHeadset;
  19286. private _draggedRoomRotation;
  19287. /**
  19288. * @hidden
  19289. */
  19290. _disableTrackPosition(fixedPosition: Vector3): void;
  19291. /**
  19292. * Internal, the mesh attached to the controller
  19293. * @hidden
  19294. */
  19295. _mesh: Nullable<AbstractMesh>;
  19296. private _poseControlledCamera;
  19297. private _leftHandSystemQuaternion;
  19298. /**
  19299. * Internal, matrix used to convert room space to babylon space
  19300. * @hidden
  19301. */
  19302. _deviceToWorld: Matrix;
  19303. /**
  19304. * Node to be used when casting a ray from the controller
  19305. * @hidden
  19306. */
  19307. _pointingPoseNode: Nullable<TransformNode>;
  19308. /**
  19309. * Name of the child mesh that can be used to cast a ray from the controller
  19310. */
  19311. static readonly POINTING_POSE: string;
  19312. /**
  19313. * Creates a new PoseEnabledController from a gamepad
  19314. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19315. */
  19316. constructor(browserGamepad: any);
  19317. private _workingMatrix;
  19318. /**
  19319. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19320. */
  19321. update(): void;
  19322. /**
  19323. * Updates only the pose device and mesh without doing any button event checking
  19324. */
  19325. protected _updatePoseAndMesh(): void;
  19326. /**
  19327. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19328. * @param poseData raw pose fromthe device
  19329. */
  19330. updateFromDevice(poseData: DevicePose): void;
  19331. /**
  19332. * @hidden
  19333. */
  19334. _meshAttachedObservable: Observable<AbstractMesh>;
  19335. /**
  19336. * Attaches a mesh to the controller
  19337. * @param mesh the mesh to be attached
  19338. */
  19339. attachToMesh(mesh: AbstractMesh): void;
  19340. /**
  19341. * Attaches the controllers mesh to a camera
  19342. * @param camera the camera the mesh should be attached to
  19343. */
  19344. attachToPoseControlledCamera(camera: TargetCamera): void;
  19345. /**
  19346. * Disposes of the controller
  19347. */
  19348. dispose(): void;
  19349. /**
  19350. * The mesh that is attached to the controller
  19351. */
  19352. get mesh(): Nullable<AbstractMesh>;
  19353. /**
  19354. * Gets the ray of the controller in the direction the controller is pointing
  19355. * @param length the length the resulting ray should be
  19356. * @returns a ray in the direction the controller is pointing
  19357. */
  19358. getForwardRay(length?: number): Ray;
  19359. }
  19360. }
  19361. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19362. import { Observable } from "babylonjs/Misc/observable";
  19363. import { Scene } from "babylonjs/scene";
  19364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19365. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19366. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19367. import { Nullable } from "babylonjs/types";
  19368. /**
  19369. * Defines the WebVRController object that represents controllers tracked in 3D space
  19370. */
  19371. export abstract class WebVRController extends PoseEnabledController {
  19372. /**
  19373. * Internal, the default controller model for the controller
  19374. */
  19375. protected _defaultModel: Nullable<AbstractMesh>;
  19376. /**
  19377. * Fired when the trigger state has changed
  19378. */
  19379. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19380. /**
  19381. * Fired when the main button state has changed
  19382. */
  19383. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19384. /**
  19385. * Fired when the secondary button state has changed
  19386. */
  19387. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19388. /**
  19389. * Fired when the pad state has changed
  19390. */
  19391. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19392. /**
  19393. * Fired when controllers stick values have changed
  19394. */
  19395. onPadValuesChangedObservable: Observable<StickValues>;
  19396. /**
  19397. * Array of button availible on the controller
  19398. */
  19399. protected _buttons: Array<MutableGamepadButton>;
  19400. private _onButtonStateChange;
  19401. /**
  19402. * Fired when a controller button's state has changed
  19403. * @param callback the callback containing the button that was modified
  19404. */
  19405. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19406. /**
  19407. * X and Y axis corresponding to the controllers joystick
  19408. */
  19409. pad: StickValues;
  19410. /**
  19411. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19412. */
  19413. hand: string;
  19414. /**
  19415. * The default controller model for the controller
  19416. */
  19417. get defaultModel(): Nullable<AbstractMesh>;
  19418. /**
  19419. * Creates a new WebVRController from a gamepad
  19420. * @param vrGamepad the gamepad that the WebVRController should be created from
  19421. */
  19422. constructor(vrGamepad: any);
  19423. /**
  19424. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19425. */
  19426. update(): void;
  19427. /**
  19428. * Function to be called when a button is modified
  19429. */
  19430. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19431. /**
  19432. * Loads a mesh and attaches it to the controller
  19433. * @param scene the scene the mesh should be added to
  19434. * @param meshLoaded callback for when the mesh has been loaded
  19435. */
  19436. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19437. private _setButtonValue;
  19438. private _changes;
  19439. private _checkChanges;
  19440. /**
  19441. * Disposes of th webVRCOntroller
  19442. */
  19443. dispose(): void;
  19444. }
  19445. }
  19446. declare module "babylonjs/Lights/hemisphericLight" {
  19447. import { Nullable } from "babylonjs/types";
  19448. import { Scene } from "babylonjs/scene";
  19449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19450. import { Color3 } from "babylonjs/Maths/math.color";
  19451. import { Effect } from "babylonjs/Materials/effect";
  19452. import { Light } from "babylonjs/Lights/light";
  19453. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19454. /**
  19455. * The HemisphericLight simulates the ambient environment light,
  19456. * so the passed direction is the light reflection direction, not the incoming direction.
  19457. */
  19458. export class HemisphericLight extends Light {
  19459. /**
  19460. * The groundColor is the light in the opposite direction to the one specified during creation.
  19461. * 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.
  19462. */
  19463. groundColor: Color3;
  19464. /**
  19465. * The light reflection direction, not the incoming direction.
  19466. */
  19467. direction: Vector3;
  19468. /**
  19469. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19470. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19471. * The HemisphericLight can't cast shadows.
  19472. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19473. * @param name The friendly name of the light
  19474. * @param direction The direction of the light reflection
  19475. * @param scene The scene the light belongs to
  19476. */
  19477. constructor(name: string, direction: Vector3, scene: Scene);
  19478. protected _buildUniformLayout(): void;
  19479. /**
  19480. * Returns the string "HemisphericLight".
  19481. * @return The class name
  19482. */
  19483. getClassName(): string;
  19484. /**
  19485. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19486. * Returns the updated direction.
  19487. * @param target The target the direction should point to
  19488. * @return The computed direction
  19489. */
  19490. setDirectionToTarget(target: Vector3): Vector3;
  19491. /**
  19492. * Returns the shadow generator associated to the light.
  19493. * @returns Always null for hemispheric lights because it does not support shadows.
  19494. */
  19495. getShadowGenerator(): Nullable<IShadowGenerator>;
  19496. /**
  19497. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19498. * @param effect The effect to update
  19499. * @param lightIndex The index of the light in the effect to update
  19500. * @returns The hemispheric light
  19501. */
  19502. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19503. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19504. /**
  19505. * Computes the world matrix of the node
  19506. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19507. * @param useWasUpdatedFlag defines a reserved property
  19508. * @returns the world matrix
  19509. */
  19510. computeWorldMatrix(): Matrix;
  19511. /**
  19512. * Returns the integer 3.
  19513. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19514. */
  19515. getTypeID(): number;
  19516. /**
  19517. * Prepares the list of defines specific to the light type.
  19518. * @param defines the list of defines
  19519. * @param lightIndex defines the index of the light for the effect
  19520. */
  19521. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19522. }
  19523. }
  19524. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19525. /** @hidden */
  19526. export var vrMultiviewToSingleviewPixelShader: {
  19527. name: string;
  19528. shader: string;
  19529. };
  19530. }
  19531. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19532. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19533. import { Scene } from "babylonjs/scene";
  19534. /**
  19535. * Renders to multiple views with a single draw call
  19536. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19537. */
  19538. export class MultiviewRenderTarget extends RenderTargetTexture {
  19539. /**
  19540. * Creates a multiview render target
  19541. * @param scene scene used with the render target
  19542. * @param size the size of the render target (used for each view)
  19543. */
  19544. constructor(scene: Scene, size?: number | {
  19545. width: number;
  19546. height: number;
  19547. } | {
  19548. ratio: number;
  19549. });
  19550. /**
  19551. * @hidden
  19552. * @param faceIndex the face index, if its a cube texture
  19553. */
  19554. _bindFrameBuffer(faceIndex?: number): void;
  19555. /**
  19556. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19557. * @returns the view count
  19558. */
  19559. getViewCount(): number;
  19560. }
  19561. }
  19562. declare module "babylonjs/Maths/math.frustum" {
  19563. import { Matrix } from "babylonjs/Maths/math.vector";
  19564. import { DeepImmutable } from "babylonjs/types";
  19565. import { Plane } from "babylonjs/Maths/math.plane";
  19566. /**
  19567. * Represents a camera frustum
  19568. */
  19569. export class Frustum {
  19570. /**
  19571. * Gets the planes representing the frustum
  19572. * @param transform matrix to be applied to the returned planes
  19573. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19574. */
  19575. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19576. /**
  19577. * Gets the near frustum plane transformed by the transform matrix
  19578. * @param transform transformation matrix to be applied to the resulting frustum plane
  19579. * @param frustumPlane the resuling frustum plane
  19580. */
  19581. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19582. /**
  19583. * Gets the far frustum plane transformed by the transform matrix
  19584. * @param transform transformation matrix to be applied to the resulting frustum plane
  19585. * @param frustumPlane the resuling frustum plane
  19586. */
  19587. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19588. /**
  19589. * Gets the left frustum plane transformed by the transform matrix
  19590. * @param transform transformation matrix to be applied to the resulting frustum plane
  19591. * @param frustumPlane the resuling frustum plane
  19592. */
  19593. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19594. /**
  19595. * Gets the right frustum plane transformed by the transform matrix
  19596. * @param transform transformation matrix to be applied to the resulting frustum plane
  19597. * @param frustumPlane the resuling frustum plane
  19598. */
  19599. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19600. /**
  19601. * Gets the top frustum plane transformed by the transform matrix
  19602. * @param transform transformation matrix to be applied to the resulting frustum plane
  19603. * @param frustumPlane the resuling frustum plane
  19604. */
  19605. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19606. /**
  19607. * Gets the bottom frustum plane transformed by the transform matrix
  19608. * @param transform transformation matrix to be applied to the resulting frustum plane
  19609. * @param frustumPlane the resuling frustum plane
  19610. */
  19611. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19612. /**
  19613. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19614. * @param transform transformation matrix to be applied to the resulting frustum planes
  19615. * @param frustumPlanes the resuling frustum planes
  19616. */
  19617. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19618. }
  19619. }
  19620. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19621. import { Camera } from "babylonjs/Cameras/camera";
  19622. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19623. import { Nullable } from "babylonjs/types";
  19624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19625. import { Matrix } from "babylonjs/Maths/math.vector";
  19626. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19627. module "babylonjs/Engines/engine" {
  19628. interface Engine {
  19629. /**
  19630. * Creates a new multiview render target
  19631. * @param width defines the width of the texture
  19632. * @param height defines the height of the texture
  19633. * @returns the created multiview texture
  19634. */
  19635. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19636. /**
  19637. * Binds a multiview framebuffer to be drawn to
  19638. * @param multiviewTexture texture to bind
  19639. */
  19640. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19641. }
  19642. }
  19643. module "babylonjs/Cameras/camera" {
  19644. interface Camera {
  19645. /**
  19646. * @hidden
  19647. * 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)
  19648. */
  19649. _useMultiviewToSingleView: boolean;
  19650. /**
  19651. * @hidden
  19652. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19653. */
  19654. _multiviewTexture: Nullable<RenderTargetTexture>;
  19655. /**
  19656. * @hidden
  19657. * ensures the multiview texture of the camera exists and has the specified width/height
  19658. * @param width height to set on the multiview texture
  19659. * @param height width to set on the multiview texture
  19660. */
  19661. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19662. }
  19663. }
  19664. module "babylonjs/scene" {
  19665. interface Scene {
  19666. /** @hidden */
  19667. _transformMatrixR: Matrix;
  19668. /** @hidden */
  19669. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19670. /** @hidden */
  19671. _createMultiviewUbo(): void;
  19672. /** @hidden */
  19673. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19674. /** @hidden */
  19675. _renderMultiviewToSingleView(camera: Camera): void;
  19676. }
  19677. }
  19678. }
  19679. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19680. import { Camera } from "babylonjs/Cameras/camera";
  19681. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19682. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19683. import "babylonjs/Engines/Extensions/engine.multiview";
  19684. /**
  19685. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19686. * This will not be used for webXR as it supports displaying texture arrays directly
  19687. */
  19688. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19689. /**
  19690. * Initializes a VRMultiviewToSingleview
  19691. * @param name name of the post process
  19692. * @param camera camera to be applied to
  19693. * @param scaleFactor scaling factor to the size of the output texture
  19694. */
  19695. constructor(name: string, camera: Camera, scaleFactor: number);
  19696. }
  19697. }
  19698. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19699. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Size } from "babylonjs/Maths/math.size";
  19702. import { Observable } from "babylonjs/Misc/observable";
  19703. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19704. /**
  19705. * Interface used to define additional presentation attributes
  19706. */
  19707. export interface IVRPresentationAttributes {
  19708. /**
  19709. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19710. */
  19711. highRefreshRate: boolean;
  19712. /**
  19713. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19714. */
  19715. foveationLevel: number;
  19716. }
  19717. module "babylonjs/Engines/engine" {
  19718. interface Engine {
  19719. /** @hidden */
  19720. _vrDisplay: any;
  19721. /** @hidden */
  19722. _vrSupported: boolean;
  19723. /** @hidden */
  19724. _oldSize: Size;
  19725. /** @hidden */
  19726. _oldHardwareScaleFactor: number;
  19727. /** @hidden */
  19728. _vrExclusivePointerMode: boolean;
  19729. /** @hidden */
  19730. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19731. /** @hidden */
  19732. _onVRDisplayPointerRestricted: () => void;
  19733. /** @hidden */
  19734. _onVRDisplayPointerUnrestricted: () => void;
  19735. /** @hidden */
  19736. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19737. /** @hidden */
  19738. _onVrDisplayDisconnect: Nullable<() => void>;
  19739. /** @hidden */
  19740. _onVrDisplayPresentChange: Nullable<() => void>;
  19741. /**
  19742. * Observable signaled when VR display mode changes
  19743. */
  19744. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19745. /**
  19746. * Observable signaled when VR request present is complete
  19747. */
  19748. onVRRequestPresentComplete: Observable<boolean>;
  19749. /**
  19750. * Observable signaled when VR request present starts
  19751. */
  19752. onVRRequestPresentStart: Observable<Engine>;
  19753. /**
  19754. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19755. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19756. */
  19757. isInVRExclusivePointerMode: boolean;
  19758. /**
  19759. * Gets a boolean indicating if a webVR device was detected
  19760. * @returns true if a webVR device was detected
  19761. */
  19762. isVRDevicePresent(): boolean;
  19763. /**
  19764. * Gets the current webVR device
  19765. * @returns the current webVR device (or null)
  19766. */
  19767. getVRDevice(): any;
  19768. /**
  19769. * Initializes a webVR display and starts listening to display change events
  19770. * The onVRDisplayChangedObservable will be notified upon these changes
  19771. * @returns A promise containing a VRDisplay and if vr is supported
  19772. */
  19773. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19774. /** @hidden */
  19775. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19776. /**
  19777. * Gets or sets the presentation attributes used to configure VR rendering
  19778. */
  19779. vrPresentationAttributes?: IVRPresentationAttributes;
  19780. /**
  19781. * Call this function to switch to webVR mode
  19782. * Will do nothing if webVR is not supported or if there is no webVR device
  19783. * @param options the webvr options provided to the camera. mainly used for multiview
  19784. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19785. */
  19786. enableVR(options: WebVROptions): void;
  19787. /** @hidden */
  19788. _onVRFullScreenTriggered(): void;
  19789. }
  19790. }
  19791. }
  19792. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19793. import { Nullable } from "babylonjs/types";
  19794. import { Observable } from "babylonjs/Misc/observable";
  19795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19796. import { Scene } from "babylonjs/scene";
  19797. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19799. import { Node } from "babylonjs/node";
  19800. import { Ray } from "babylonjs/Culling/ray";
  19801. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19802. import "babylonjs/Engines/Extensions/engine.webVR";
  19803. /**
  19804. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19805. * IMPORTANT!! The data is right-hand data.
  19806. * @export
  19807. * @interface DevicePose
  19808. */
  19809. export interface DevicePose {
  19810. /**
  19811. * The position of the device, values in array are [x,y,z].
  19812. */
  19813. readonly position: Nullable<Float32Array>;
  19814. /**
  19815. * The linearVelocity of the device, values in array are [x,y,z].
  19816. */
  19817. readonly linearVelocity: Nullable<Float32Array>;
  19818. /**
  19819. * The linearAcceleration of the device, values in array are [x,y,z].
  19820. */
  19821. readonly linearAcceleration: Nullable<Float32Array>;
  19822. /**
  19823. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19824. */
  19825. readonly orientation: Nullable<Float32Array>;
  19826. /**
  19827. * The angularVelocity of the device, values in array are [x,y,z].
  19828. */
  19829. readonly angularVelocity: Nullable<Float32Array>;
  19830. /**
  19831. * The angularAcceleration of the device, values in array are [x,y,z].
  19832. */
  19833. readonly angularAcceleration: Nullable<Float32Array>;
  19834. }
  19835. /**
  19836. * Interface representing a pose controlled object in Babylon.
  19837. * A pose controlled object has both regular pose values as well as pose values
  19838. * from an external device such as a VR head mounted display
  19839. */
  19840. export interface PoseControlled {
  19841. /**
  19842. * The position of the object in babylon space.
  19843. */
  19844. position: Vector3;
  19845. /**
  19846. * The rotation quaternion of the object in babylon space.
  19847. */
  19848. rotationQuaternion: Quaternion;
  19849. /**
  19850. * The position of the device in babylon space.
  19851. */
  19852. devicePosition?: Vector3;
  19853. /**
  19854. * The rotation quaternion of the device in babylon space.
  19855. */
  19856. deviceRotationQuaternion: Quaternion;
  19857. /**
  19858. * The raw pose coming from the device.
  19859. */
  19860. rawPose: Nullable<DevicePose>;
  19861. /**
  19862. * The scale of the device to be used when translating from device space to babylon space.
  19863. */
  19864. deviceScaleFactor: number;
  19865. /**
  19866. * Updates the poseControlled values based on the input device pose.
  19867. * @param poseData the pose data to update the object with
  19868. */
  19869. updateFromDevice(poseData: DevicePose): void;
  19870. }
  19871. /**
  19872. * Set of options to customize the webVRCamera
  19873. */
  19874. export interface WebVROptions {
  19875. /**
  19876. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19877. */
  19878. trackPosition?: boolean;
  19879. /**
  19880. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19881. */
  19882. positionScale?: number;
  19883. /**
  19884. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19885. */
  19886. displayName?: string;
  19887. /**
  19888. * Should the native controller meshes be initialized. (default: true)
  19889. */
  19890. controllerMeshes?: boolean;
  19891. /**
  19892. * Creating a default HemiLight only on controllers. (default: true)
  19893. */
  19894. defaultLightingOnControllers?: boolean;
  19895. /**
  19896. * If you don't want to use the default VR button of the helper. (default: false)
  19897. */
  19898. useCustomVRButton?: boolean;
  19899. /**
  19900. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19901. */
  19902. customVRButton?: HTMLButtonElement;
  19903. /**
  19904. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19905. */
  19906. rayLength?: number;
  19907. /**
  19908. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19909. */
  19910. defaultHeight?: number;
  19911. /**
  19912. * If multiview should be used if availible (default: false)
  19913. */
  19914. useMultiview?: boolean;
  19915. }
  19916. /**
  19917. * This represents a WebVR camera.
  19918. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19919. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19920. */
  19921. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19922. private webVROptions;
  19923. /**
  19924. * @hidden
  19925. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19926. */
  19927. _vrDevice: any;
  19928. /**
  19929. * The rawPose of the vrDevice.
  19930. */
  19931. rawPose: Nullable<DevicePose>;
  19932. private _onVREnabled;
  19933. private _specsVersion;
  19934. private _attached;
  19935. private _frameData;
  19936. protected _descendants: Array<Node>;
  19937. private _deviceRoomPosition;
  19938. /** @hidden */
  19939. _deviceRoomRotationQuaternion: Quaternion;
  19940. private _standingMatrix;
  19941. /**
  19942. * Represents device position in babylon space.
  19943. */
  19944. devicePosition: Vector3;
  19945. /**
  19946. * Represents device rotation in babylon space.
  19947. */
  19948. deviceRotationQuaternion: Quaternion;
  19949. /**
  19950. * The scale of the device to be used when translating from device space to babylon space.
  19951. */
  19952. deviceScaleFactor: number;
  19953. private _deviceToWorld;
  19954. private _worldToDevice;
  19955. /**
  19956. * References to the webVR controllers for the vrDevice.
  19957. */
  19958. controllers: Array<WebVRController>;
  19959. /**
  19960. * Emits an event when a controller is attached.
  19961. */
  19962. onControllersAttachedObservable: Observable<WebVRController[]>;
  19963. /**
  19964. * Emits an event when a controller's mesh has been loaded;
  19965. */
  19966. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19967. /**
  19968. * Emits an event when the HMD's pose has been updated.
  19969. */
  19970. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19971. private _poseSet;
  19972. /**
  19973. * If the rig cameras be used as parent instead of this camera.
  19974. */
  19975. rigParenting: boolean;
  19976. private _lightOnControllers;
  19977. private _defaultHeight?;
  19978. /**
  19979. * Instantiates a WebVRFreeCamera.
  19980. * @param name The name of the WebVRFreeCamera
  19981. * @param position The starting anchor position for the camera
  19982. * @param scene The scene the camera belongs to
  19983. * @param webVROptions a set of customizable options for the webVRCamera
  19984. */
  19985. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19986. /**
  19987. * Gets the device distance from the ground in meters.
  19988. * @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.
  19989. */
  19990. deviceDistanceToRoomGround(): number;
  19991. /**
  19992. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19993. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19994. */
  19995. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @returns A promise with a boolean set to if the standing matrix is supported.
  19999. */
  20000. useStandingMatrixAsync(): Promise<boolean>;
  20001. /**
  20002. * Disposes the camera
  20003. */
  20004. dispose(): void;
  20005. /**
  20006. * Gets a vrController by name.
  20007. * @param name The name of the controller to retreive
  20008. * @returns the controller matching the name specified or null if not found
  20009. */
  20010. getControllerByName(name: string): Nullable<WebVRController>;
  20011. private _leftController;
  20012. /**
  20013. * The controller corresponding to the users left hand.
  20014. */
  20015. get leftController(): Nullable<WebVRController>;
  20016. private _rightController;
  20017. /**
  20018. * The controller corresponding to the users right hand.
  20019. */
  20020. get rightController(): Nullable<WebVRController>;
  20021. /**
  20022. * Casts a ray forward from the vrCamera's gaze.
  20023. * @param length Length of the ray (default: 100)
  20024. * @returns the ray corresponding to the gaze
  20025. */
  20026. getForwardRay(length?: number): Ray;
  20027. /**
  20028. * @hidden
  20029. * Updates the camera based on device's frame data
  20030. */
  20031. _checkInputs(): void;
  20032. /**
  20033. * Updates the poseControlled values based on the input device pose.
  20034. * @param poseData Pose coming from the device
  20035. */
  20036. updateFromDevice(poseData: DevicePose): void;
  20037. private _htmlElementAttached;
  20038. private _detachIfAttached;
  20039. /**
  20040. * WebVR's attach control will start broadcasting frames to the device.
  20041. * Note that in certain browsers (chrome for example) this function must be called
  20042. * within a user-interaction callback. Example:
  20043. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20044. *
  20045. * @param element html element to attach the vrDevice to
  20046. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20047. */
  20048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20049. /**
  20050. * Detaches the camera from the html element and disables VR
  20051. *
  20052. * @param element html element to detach from
  20053. */
  20054. detachControl(element: HTMLElement): void;
  20055. /**
  20056. * @returns the name of this class
  20057. */
  20058. getClassName(): string;
  20059. /**
  20060. * Calls resetPose on the vrDisplay
  20061. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20062. */
  20063. resetToCurrentRotation(): void;
  20064. /**
  20065. * @hidden
  20066. * Updates the rig cameras (left and right eye)
  20067. */
  20068. _updateRigCameras(): void;
  20069. private _workingVector;
  20070. private _oneVector;
  20071. private _workingMatrix;
  20072. private updateCacheCalled;
  20073. private _correctPositionIfNotTrackPosition;
  20074. /**
  20075. * @hidden
  20076. * Updates the cached values of the camera
  20077. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20078. */
  20079. _updateCache(ignoreParentClass?: boolean): void;
  20080. /**
  20081. * @hidden
  20082. * Get current device position in babylon world
  20083. */
  20084. _computeDevicePosition(): void;
  20085. /**
  20086. * Updates the current device position and rotation in the babylon world
  20087. */
  20088. update(): void;
  20089. /**
  20090. * @hidden
  20091. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20092. * @returns an identity matrix
  20093. */
  20094. _getViewMatrix(): Matrix;
  20095. private _tmpMatrix;
  20096. /**
  20097. * This function is called by the two RIG cameras.
  20098. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20099. * @hidden
  20100. */
  20101. _getWebVRViewMatrix(): Matrix;
  20102. /** @hidden */
  20103. _getWebVRProjectionMatrix(): Matrix;
  20104. private _onGamepadConnectedObserver;
  20105. private _onGamepadDisconnectedObserver;
  20106. private _updateCacheWhenTrackingDisabledObserver;
  20107. /**
  20108. * Initializes the controllers and their meshes
  20109. */
  20110. initControllers(): void;
  20111. }
  20112. }
  20113. declare module "babylonjs/PostProcesses/postProcess" {
  20114. import { Nullable } from "babylonjs/types";
  20115. import { SmartArray } from "babylonjs/Misc/smartArray";
  20116. import { Observable } from "babylonjs/Misc/observable";
  20117. import { Vector2 } from "babylonjs/Maths/math.vector";
  20118. import { Camera } from "babylonjs/Cameras/camera";
  20119. import { Effect } from "babylonjs/Materials/effect";
  20120. import "babylonjs/Shaders/postprocess.vertex";
  20121. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20122. import { Engine } from "babylonjs/Engines/engine";
  20123. import { Color4 } from "babylonjs/Maths/math.color";
  20124. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20126. /**
  20127. * Size options for a post process
  20128. */
  20129. export type PostProcessOptions = {
  20130. width: number;
  20131. height: number;
  20132. };
  20133. /**
  20134. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20135. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20136. */
  20137. export class PostProcess {
  20138. /** Name of the PostProcess. */
  20139. name: string;
  20140. /**
  20141. * Gets or sets the unique id of the post process
  20142. */
  20143. uniqueId: number;
  20144. /**
  20145. * Width of the texture to apply the post process on
  20146. */
  20147. width: number;
  20148. /**
  20149. * Height of the texture to apply the post process on
  20150. */
  20151. height: number;
  20152. /**
  20153. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20154. * @hidden
  20155. */
  20156. _outputTexture: Nullable<InternalTexture>;
  20157. /**
  20158. * Sampling mode used by the shader
  20159. * See https://doc.babylonjs.com/classes/3.1/texture
  20160. */
  20161. renderTargetSamplingMode: number;
  20162. /**
  20163. * Clear color to use when screen clearing
  20164. */
  20165. clearColor: Color4;
  20166. /**
  20167. * If the buffer needs to be cleared before applying the post process. (default: true)
  20168. * Should be set to false if shader will overwrite all previous pixels.
  20169. */
  20170. autoClear: boolean;
  20171. /**
  20172. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20173. */
  20174. alphaMode: number;
  20175. /**
  20176. * Sets the setAlphaBlendConstants of the babylon engine
  20177. */
  20178. alphaConstants: Color4;
  20179. /**
  20180. * Animations to be used for the post processing
  20181. */
  20182. animations: import("babylonjs/Animations/animation").Animation[];
  20183. /**
  20184. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20185. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20186. */
  20187. enablePixelPerfectMode: boolean;
  20188. /**
  20189. * Force the postprocess to be applied without taking in account viewport
  20190. */
  20191. forceFullscreenViewport: boolean;
  20192. /**
  20193. * List of inspectable custom properties (used by the Inspector)
  20194. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20195. */
  20196. inspectableCustomProperties: IInspectable[];
  20197. /**
  20198. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20199. *
  20200. * | Value | Type | Description |
  20201. * | ----- | ----------------------------------- | ----------- |
  20202. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20203. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20204. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20205. *
  20206. */
  20207. scaleMode: number;
  20208. /**
  20209. * Force textures to be a power of two (default: false)
  20210. */
  20211. alwaysForcePOT: boolean;
  20212. private _samples;
  20213. /**
  20214. * Number of sample textures (default: 1)
  20215. */
  20216. get samples(): number;
  20217. set samples(n: number);
  20218. /**
  20219. * Modify the scale of the post process to be the same as the viewport (default: false)
  20220. */
  20221. adaptScaleToCurrentViewport: boolean;
  20222. private _camera;
  20223. private _scene;
  20224. private _engine;
  20225. private _options;
  20226. private _reusable;
  20227. private _textureType;
  20228. private _textureFormat;
  20229. /**
  20230. * Smart array of input and output textures for the post process.
  20231. * @hidden
  20232. */
  20233. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20234. /**
  20235. * The index in _textures that corresponds to the output texture.
  20236. * @hidden
  20237. */
  20238. _currentRenderTextureInd: number;
  20239. private _effect;
  20240. private _samplers;
  20241. private _fragmentUrl;
  20242. private _vertexUrl;
  20243. private _parameters;
  20244. private _scaleRatio;
  20245. protected _indexParameters: any;
  20246. private _shareOutputWithPostProcess;
  20247. private _texelSize;
  20248. private _forcedOutputTexture;
  20249. /**
  20250. * Returns the fragment url or shader name used in the post process.
  20251. * @returns the fragment url or name in the shader store.
  20252. */
  20253. getEffectName(): string;
  20254. /**
  20255. * An event triggered when the postprocess is activated.
  20256. */
  20257. onActivateObservable: Observable<Camera>;
  20258. private _onActivateObserver;
  20259. /**
  20260. * A function that is added to the onActivateObservable
  20261. */
  20262. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20263. /**
  20264. * An event triggered when the postprocess changes its size.
  20265. */
  20266. onSizeChangedObservable: Observable<PostProcess>;
  20267. private _onSizeChangedObserver;
  20268. /**
  20269. * A function that is added to the onSizeChangedObservable
  20270. */
  20271. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20272. /**
  20273. * An event triggered when the postprocess applies its effect.
  20274. */
  20275. onApplyObservable: Observable<Effect>;
  20276. private _onApplyObserver;
  20277. /**
  20278. * A function that is added to the onApplyObservable
  20279. */
  20280. set onApply(callback: (effect: Effect) => void);
  20281. /**
  20282. * An event triggered before rendering the postprocess
  20283. */
  20284. onBeforeRenderObservable: Observable<Effect>;
  20285. private _onBeforeRenderObserver;
  20286. /**
  20287. * A function that is added to the onBeforeRenderObservable
  20288. */
  20289. set onBeforeRender(callback: (effect: Effect) => void);
  20290. /**
  20291. * An event triggered after rendering the postprocess
  20292. */
  20293. onAfterRenderObservable: Observable<Effect>;
  20294. private _onAfterRenderObserver;
  20295. /**
  20296. * A function that is added to the onAfterRenderObservable
  20297. */
  20298. set onAfterRender(callback: (efect: Effect) => void);
  20299. /**
  20300. * 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
  20301. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20302. */
  20303. get inputTexture(): InternalTexture;
  20304. set inputTexture(value: InternalTexture);
  20305. /**
  20306. * Gets the camera which post process is applied to.
  20307. * @returns The camera the post process is applied to.
  20308. */
  20309. getCamera(): Camera;
  20310. /**
  20311. * Gets the texel size of the postprocess.
  20312. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20313. */
  20314. get texelSize(): Vector2;
  20315. /**
  20316. * Creates a new instance PostProcess
  20317. * @param name The name of the PostProcess.
  20318. * @param fragmentUrl The url of the fragment shader to be used.
  20319. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20320. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20321. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20322. * @param camera The camera to apply the render pass to.
  20323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20324. * @param engine The engine which the post process will be applied. (default: current engine)
  20325. * @param reusable If the post process can be reused on the same frame. (default: false)
  20326. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20327. * @param textureType Type of textures used when performing the post process. (default: 0)
  20328. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20329. * @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
  20330. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20331. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20332. */
  20333. constructor(
  20334. /** Name of the PostProcess. */
  20335. 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);
  20336. /**
  20337. * Gets a string idenfifying the name of the class
  20338. * @returns "PostProcess" string
  20339. */
  20340. getClassName(): string;
  20341. /**
  20342. * Gets the engine which this post process belongs to.
  20343. * @returns The engine the post process was enabled with.
  20344. */
  20345. getEngine(): Engine;
  20346. /**
  20347. * The effect that is created when initializing the post process.
  20348. * @returns The created effect corresponding the the postprocess.
  20349. */
  20350. getEffect(): Effect;
  20351. /**
  20352. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20353. * @param postProcess The post process to share the output with.
  20354. * @returns This post process.
  20355. */
  20356. shareOutputWith(postProcess: PostProcess): PostProcess;
  20357. /**
  20358. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20359. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20360. */
  20361. useOwnOutput(): void;
  20362. /**
  20363. * Updates the effect with the current post process compile time values and recompiles the shader.
  20364. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20365. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20366. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20367. * @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
  20368. * @param onCompiled Called when the shader has been compiled.
  20369. * @param onError Called if there is an error when compiling a shader.
  20370. */
  20371. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20372. /**
  20373. * The post process is reusable if it can be used multiple times within one frame.
  20374. * @returns If the post process is reusable
  20375. */
  20376. isReusable(): boolean;
  20377. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20378. markTextureDirty(): void;
  20379. /**
  20380. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20381. * 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.
  20382. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20383. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20384. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20385. * @returns The target texture that was bound to be written to.
  20386. */
  20387. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20388. /**
  20389. * If the post process is supported.
  20390. */
  20391. get isSupported(): boolean;
  20392. /**
  20393. * The aspect ratio of the output texture.
  20394. */
  20395. get aspectRatio(): number;
  20396. /**
  20397. * Get a value indicating if the post-process is ready to be used
  20398. * @returns true if the post-process is ready (shader is compiled)
  20399. */
  20400. isReady(): boolean;
  20401. /**
  20402. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20403. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20404. */
  20405. apply(): Nullable<Effect>;
  20406. private _disposeTextures;
  20407. /**
  20408. * Disposes the post process.
  20409. * @param camera The camera to dispose the post process on.
  20410. */
  20411. dispose(camera?: Camera): void;
  20412. }
  20413. }
  20414. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20415. /** @hidden */
  20416. export var kernelBlurVaryingDeclaration: {
  20417. name: string;
  20418. shader: string;
  20419. };
  20420. }
  20421. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20422. /** @hidden */
  20423. export var kernelBlurFragment: {
  20424. name: string;
  20425. shader: string;
  20426. };
  20427. }
  20428. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20429. /** @hidden */
  20430. export var kernelBlurFragment2: {
  20431. name: string;
  20432. shader: string;
  20433. };
  20434. }
  20435. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20436. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20437. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20438. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20439. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20440. /** @hidden */
  20441. export var kernelBlurPixelShader: {
  20442. name: string;
  20443. shader: string;
  20444. };
  20445. }
  20446. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20447. /** @hidden */
  20448. export var kernelBlurVertex: {
  20449. name: string;
  20450. shader: string;
  20451. };
  20452. }
  20453. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20454. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20455. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20456. /** @hidden */
  20457. export var kernelBlurVertexShader: {
  20458. name: string;
  20459. shader: string;
  20460. };
  20461. }
  20462. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20463. import { Vector2 } from "babylonjs/Maths/math.vector";
  20464. import { Nullable } from "babylonjs/types";
  20465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20466. import { Camera } from "babylonjs/Cameras/camera";
  20467. import { Effect } from "babylonjs/Materials/effect";
  20468. import { Engine } from "babylonjs/Engines/engine";
  20469. import "babylonjs/Shaders/kernelBlur.fragment";
  20470. import "babylonjs/Shaders/kernelBlur.vertex";
  20471. /**
  20472. * The Blur Post Process which blurs an image based on a kernel and direction.
  20473. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20474. */
  20475. export class BlurPostProcess extends PostProcess {
  20476. /** The direction in which to blur the image. */
  20477. direction: Vector2;
  20478. private blockCompilation;
  20479. protected _kernel: number;
  20480. protected _idealKernel: number;
  20481. protected _packedFloat: boolean;
  20482. private _staticDefines;
  20483. /**
  20484. * Sets the length in pixels of the blur sample region
  20485. */
  20486. set kernel(v: number);
  20487. /**
  20488. * Gets the length in pixels of the blur sample region
  20489. */
  20490. get kernel(): number;
  20491. /**
  20492. * Sets wether or not the blur needs to unpack/repack floats
  20493. */
  20494. set packedFloat(v: boolean);
  20495. /**
  20496. * Gets wether or not the blur is unpacking/repacking floats
  20497. */
  20498. get packedFloat(): boolean;
  20499. /**
  20500. * Creates a new instance BlurPostProcess
  20501. * @param name The name of the effect.
  20502. * @param direction The direction in which to blur the image.
  20503. * @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.
  20504. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20505. * @param camera The camera to apply the render pass to.
  20506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20507. * @param engine The engine which the post process will be applied. (default: current engine)
  20508. * @param reusable If the post process can be reused on the same frame. (default: false)
  20509. * @param textureType Type of textures used when performing the post process. (default: 0)
  20510. * @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)
  20511. */
  20512. constructor(name: string,
  20513. /** The direction in which to blur the image. */
  20514. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20515. /**
  20516. * Updates the effect with the current post process compile time values and recompiles the shader.
  20517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20520. * @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
  20521. * @param onCompiled Called when the shader has been compiled.
  20522. * @param onError Called if there is an error when compiling a shader.
  20523. */
  20524. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20525. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20526. /**
  20527. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20528. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20529. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20530. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20531. * The gaps between physical kernels are compensated for in the weighting of the samples
  20532. * @param idealKernel Ideal blur kernel.
  20533. * @return Nearest best kernel.
  20534. */
  20535. protected _nearestBestKernel(idealKernel: number): number;
  20536. /**
  20537. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20538. * @param x The point on the Gaussian distribution to sample.
  20539. * @return the value of the Gaussian function at x.
  20540. */
  20541. protected _gaussianWeight(x: number): number;
  20542. /**
  20543. * Generates a string that can be used as a floating point number in GLSL.
  20544. * @param x Value to print.
  20545. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20546. * @return GLSL float string.
  20547. */
  20548. protected _glslFloat(x: number, decimalFigures?: number): string;
  20549. }
  20550. }
  20551. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20552. import { Scene } from "babylonjs/scene";
  20553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20554. import { Plane } from "babylonjs/Maths/math.plane";
  20555. /**
  20556. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20557. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20558. * You can then easily use it as a reflectionTexture on a flat surface.
  20559. * In case the surface is not a plane, please consider relying on reflection probes.
  20560. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20561. */
  20562. export class MirrorTexture extends RenderTargetTexture {
  20563. private scene;
  20564. /**
  20565. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20566. * 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.
  20567. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20568. */
  20569. mirrorPlane: Plane;
  20570. /**
  20571. * Define the blur ratio used to blur the reflection if needed.
  20572. */
  20573. set blurRatio(value: number);
  20574. get blurRatio(): number;
  20575. /**
  20576. * Define the adaptive blur kernel used to blur the reflection if needed.
  20577. * This will autocompute the closest best match for the `blurKernel`
  20578. */
  20579. set adaptiveBlurKernel(value: number);
  20580. /**
  20581. * Define the blur kernel used to blur the reflection if needed.
  20582. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20583. */
  20584. set blurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernelX(value: number);
  20590. get blurKernelX(): number;
  20591. /**
  20592. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20594. */
  20595. set blurKernelY(value: number);
  20596. get blurKernelY(): number;
  20597. private _autoComputeBlurKernel;
  20598. protected _onRatioRescale(): void;
  20599. private _updateGammaSpace;
  20600. private _imageProcessingConfigChangeObserver;
  20601. private _transformMatrix;
  20602. private _mirrorMatrix;
  20603. private _savedViewMatrix;
  20604. private _blurX;
  20605. private _blurY;
  20606. private _adaptiveBlurKernel;
  20607. private _blurKernelX;
  20608. private _blurKernelY;
  20609. private _blurRatio;
  20610. /**
  20611. * Instantiates a Mirror Texture.
  20612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20614. * You can then easily use it as a reflectionTexture on a flat surface.
  20615. * In case the surface is not a plane, please consider relying on reflection probes.
  20616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20617. * @param name
  20618. * @param size
  20619. * @param scene
  20620. * @param generateMipMaps
  20621. * @param type
  20622. * @param samplingMode
  20623. * @param generateDepthBuffer
  20624. */
  20625. constructor(name: string, size: number | {
  20626. width: number;
  20627. height: number;
  20628. } | {
  20629. ratio: number;
  20630. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20631. private _preparePostProcesses;
  20632. /**
  20633. * Clone the mirror texture.
  20634. * @returns the cloned texture
  20635. */
  20636. clone(): MirrorTexture;
  20637. /**
  20638. * Serialize the texture to a JSON representation you could use in Parse later on
  20639. * @returns the serialized JSON representation
  20640. */
  20641. serialize(): any;
  20642. /**
  20643. * Dispose the texture and release its associated resources.
  20644. */
  20645. dispose(): void;
  20646. }
  20647. }
  20648. declare module "babylonjs/Materials/Textures/texture" {
  20649. import { Observable } from "babylonjs/Misc/observable";
  20650. import { Nullable } from "babylonjs/types";
  20651. import { Matrix } from "babylonjs/Maths/math.vector";
  20652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20653. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20654. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20655. import { Scene } from "babylonjs/scene";
  20656. /**
  20657. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20658. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20659. */
  20660. export class Texture extends BaseTexture {
  20661. /**
  20662. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20663. */
  20664. static SerializeBuffers: boolean;
  20665. /** @hidden */
  20666. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20667. /** @hidden */
  20668. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20669. /** @hidden */
  20670. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20671. /** nearest is mag = nearest and min = nearest and mip = linear */
  20672. static readonly NEAREST_SAMPLINGMODE: number;
  20673. /** nearest is mag = nearest and min = nearest and mip = linear */
  20674. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20676. static readonly BILINEAR_SAMPLINGMODE: number;
  20677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20678. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20679. /** Trilinear is mag = linear and min = linear and mip = linear */
  20680. static readonly TRILINEAR_SAMPLINGMODE: number;
  20681. /** Trilinear is mag = linear and min = linear and mip = linear */
  20682. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20683. /** mag = nearest and min = nearest and mip = nearest */
  20684. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20685. /** mag = nearest and min = linear and mip = nearest */
  20686. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20687. /** mag = nearest and min = linear and mip = linear */
  20688. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20689. /** mag = nearest and min = linear and mip = none */
  20690. static readonly NEAREST_LINEAR: number;
  20691. /** mag = nearest and min = nearest and mip = none */
  20692. static readonly NEAREST_NEAREST: number;
  20693. /** mag = linear and min = nearest and mip = nearest */
  20694. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20695. /** mag = linear and min = nearest and mip = linear */
  20696. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20697. /** mag = linear and min = linear and mip = none */
  20698. static readonly LINEAR_LINEAR: number;
  20699. /** mag = linear and min = nearest and mip = none */
  20700. static readonly LINEAR_NEAREST: number;
  20701. /** Explicit coordinates mode */
  20702. static readonly EXPLICIT_MODE: number;
  20703. /** Spherical coordinates mode */
  20704. static readonly SPHERICAL_MODE: number;
  20705. /** Planar coordinates mode */
  20706. static readonly PLANAR_MODE: number;
  20707. /** Cubic coordinates mode */
  20708. static readonly CUBIC_MODE: number;
  20709. /** Projection coordinates mode */
  20710. static readonly PROJECTION_MODE: number;
  20711. /** Inverse Cubic coordinates mode */
  20712. static readonly SKYBOX_MODE: number;
  20713. /** Inverse Cubic coordinates mode */
  20714. static readonly INVCUBIC_MODE: number;
  20715. /** Equirectangular coordinates mode */
  20716. static readonly EQUIRECTANGULAR_MODE: number;
  20717. /** Equirectangular Fixed coordinates mode */
  20718. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20719. /** Equirectangular Fixed Mirrored coordinates mode */
  20720. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20721. /** Texture is not repeating outside of 0..1 UVs */
  20722. static readonly CLAMP_ADDRESSMODE: number;
  20723. /** Texture is repeating outside of 0..1 UVs */
  20724. static readonly WRAP_ADDRESSMODE: number;
  20725. /** Texture is repeating and mirrored */
  20726. static readonly MIRROR_ADDRESSMODE: number;
  20727. /**
  20728. * 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
  20729. */
  20730. static UseSerializedUrlIfAny: boolean;
  20731. /**
  20732. * Define the url of the texture.
  20733. */
  20734. url: Nullable<string>;
  20735. /**
  20736. * Define an offset on the texture to offset the u coordinates of the UVs
  20737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20738. */
  20739. uOffset: number;
  20740. /**
  20741. * Define an offset on the texture to offset the v coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. vOffset: number;
  20745. /**
  20746. * Define an offset on the texture to scale the u coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20748. */
  20749. uScale: number;
  20750. /**
  20751. * Define an offset on the texture to scale the v coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. vScale: number;
  20755. /**
  20756. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials
  20758. */
  20759. uAng: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. vAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. wAng: number;
  20770. /**
  20771. * Defines the center of rotation (U)
  20772. */
  20773. uRotationCenter: number;
  20774. /**
  20775. * Defines the center of rotation (V)
  20776. */
  20777. vRotationCenter: number;
  20778. /**
  20779. * Defines the center of rotation (W)
  20780. */
  20781. wRotationCenter: number;
  20782. /**
  20783. * Are mip maps generated for this texture or not.
  20784. */
  20785. get noMipmap(): boolean;
  20786. /**
  20787. * List of inspectable custom properties (used by the Inspector)
  20788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20789. */
  20790. inspectableCustomProperties: Nullable<IInspectable[]>;
  20791. private _noMipmap;
  20792. /** @hidden */
  20793. _invertY: boolean;
  20794. private _rowGenerationMatrix;
  20795. private _cachedTextureMatrix;
  20796. private _projectionModeMatrix;
  20797. private _t0;
  20798. private _t1;
  20799. private _t2;
  20800. private _cachedUOffset;
  20801. private _cachedVOffset;
  20802. private _cachedUScale;
  20803. private _cachedVScale;
  20804. private _cachedUAng;
  20805. private _cachedVAng;
  20806. private _cachedWAng;
  20807. private _cachedProjectionMatrixId;
  20808. private _cachedCoordinatesMode;
  20809. /** @hidden */
  20810. protected _initialSamplingMode: number;
  20811. /** @hidden */
  20812. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20813. private _deleteBuffer;
  20814. protected _format: Nullable<number>;
  20815. private _delayedOnLoad;
  20816. private _delayedOnError;
  20817. private _mimeType?;
  20818. /**
  20819. * Observable triggered once the texture has been loaded.
  20820. */
  20821. onLoadObservable: Observable<Texture>;
  20822. protected _isBlocking: boolean;
  20823. /**
  20824. * Is the texture preventing material to render while loading.
  20825. * If false, a default texture will be used instead of the loading one during the preparation step.
  20826. */
  20827. set isBlocking(value: boolean);
  20828. get isBlocking(): boolean;
  20829. /**
  20830. * Get the current sampling mode associated with the texture.
  20831. */
  20832. get samplingMode(): number;
  20833. /**
  20834. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20835. */
  20836. get invertY(): boolean;
  20837. /**
  20838. * Instantiates a new texture.
  20839. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20840. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20841. * @param url defines the url of the picture to load as a texture
  20842. * @param scene defines the scene or engine the texture will belong to
  20843. * @param noMipmap defines if the texture will require mip maps or not
  20844. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20845. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20846. * @param onLoad defines a callback triggered when the texture has been loaded
  20847. * @param onError defines a callback triggered when an error occurred during the loading session
  20848. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20849. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20850. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20851. * @param mimeType defines an optional mime type information
  20852. */
  20853. 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);
  20854. /**
  20855. * Update the url (and optional buffer) of this texture if url was null during construction.
  20856. * @param url the url of the texture
  20857. * @param buffer the buffer of the texture (defaults to null)
  20858. * @param onLoad callback called when the texture is loaded (defaults to null)
  20859. */
  20860. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20861. /**
  20862. * Finish the loading sequence of a texture flagged as delayed load.
  20863. * @hidden
  20864. */
  20865. delayLoad(): void;
  20866. private _prepareRowForTextureGeneration;
  20867. /**
  20868. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20869. * @returns the transform matrix of the texture.
  20870. */
  20871. getTextureMatrix(uBase?: number): Matrix;
  20872. /**
  20873. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20874. * @returns The reflection texture transform
  20875. */
  20876. getReflectionTextureMatrix(): Matrix;
  20877. /**
  20878. * Clones the texture.
  20879. * @returns the cloned texture
  20880. */
  20881. clone(): Texture;
  20882. /**
  20883. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20884. * @returns The JSON representation of the texture
  20885. */
  20886. serialize(): any;
  20887. /**
  20888. * Get the current class name of the texture useful for serialization or dynamic coding.
  20889. * @returns "Texture"
  20890. */
  20891. getClassName(): string;
  20892. /**
  20893. * Dispose the texture and release its associated resources.
  20894. */
  20895. dispose(): void;
  20896. /**
  20897. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20898. * @param parsedTexture Define the JSON representation of the texture
  20899. * @param scene Define the scene the parsed texture should be instantiated in
  20900. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20901. * @returns The parsed texture if successful
  20902. */
  20903. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20904. /**
  20905. * Creates a texture from its base 64 representation.
  20906. * @param data Define the base64 payload without the data: prefix
  20907. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20908. * @param scene Define the scene the texture should belong to
  20909. * @param noMipmap Forces the texture to not create mip map information if true
  20910. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20911. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20912. * @param onLoad define a callback triggered when the texture has been loaded
  20913. * @param onError define a callback triggered when an error occurred during the loading session
  20914. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20915. * @returns the created texture
  20916. */
  20917. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20918. /**
  20919. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20920. * @param data Define the base64 payload without the data: prefix
  20921. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20922. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20923. * @param scene Define the scene the texture should belong to
  20924. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20925. * @param noMipmap Forces the texture to not create mip map information if true
  20926. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20927. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20928. * @param onLoad define a callback triggered when the texture has been loaded
  20929. * @param onError define a callback triggered when an error occurred during the loading session
  20930. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20931. * @returns the created texture
  20932. */
  20933. 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;
  20934. }
  20935. }
  20936. declare module "babylonjs/PostProcesses/postProcessManager" {
  20937. import { Nullable } from "babylonjs/types";
  20938. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20940. import { Scene } from "babylonjs/scene";
  20941. /**
  20942. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20943. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20944. */
  20945. export class PostProcessManager {
  20946. private _scene;
  20947. private _indexBuffer;
  20948. private _vertexBuffers;
  20949. /**
  20950. * Creates a new instance PostProcess
  20951. * @param scene The scene that the post process is associated with.
  20952. */
  20953. constructor(scene: Scene);
  20954. private _prepareBuffers;
  20955. private _buildIndexBuffer;
  20956. /**
  20957. * Rebuilds the vertex buffers of the manager.
  20958. * @hidden
  20959. */
  20960. _rebuild(): void;
  20961. /**
  20962. * Prepares a frame to be run through a post process.
  20963. * @param sourceTexture The input texture to the post procesess. (default: null)
  20964. * @param postProcesses An array of post processes to be run. (default: null)
  20965. * @returns True if the post processes were able to be run.
  20966. * @hidden
  20967. */
  20968. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20969. /**
  20970. * Manually render a set of post processes to a texture.
  20971. * @param postProcesses An array of post processes to be run.
  20972. * @param targetTexture The target texture to render to.
  20973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20974. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20975. * @param lodLevel defines which lod of the texture to render to
  20976. */
  20977. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20978. /**
  20979. * Finalize the result of the output of the postprocesses.
  20980. * @param doNotPresent If true the result will not be displayed to the screen.
  20981. * @param targetTexture The target texture to render to.
  20982. * @param faceIndex The index of the face to bind the target texture to.
  20983. * @param postProcesses The array of post processes to render.
  20984. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20985. * @hidden
  20986. */
  20987. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20988. /**
  20989. * Disposes of the post process manager.
  20990. */
  20991. dispose(): void;
  20992. }
  20993. }
  20994. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20995. import { Observable } from "babylonjs/Misc/observable";
  20996. import { SmartArray } from "babylonjs/Misc/smartArray";
  20997. import { Nullable, Immutable } from "babylonjs/types";
  20998. import { Camera } from "babylonjs/Cameras/camera";
  20999. import { Scene } from "babylonjs/scene";
  21000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21001. import { Color4 } from "babylonjs/Maths/math.color";
  21002. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21006. import { Texture } from "babylonjs/Materials/Textures/texture";
  21007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21008. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21009. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21010. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21011. import { Engine } from "babylonjs/Engines/engine";
  21012. /**
  21013. * This Helps creating a texture that will be created from a camera in your scene.
  21014. * It is basically a dynamic texture that could be used to create special effects for instance.
  21015. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21016. */
  21017. export class RenderTargetTexture extends Texture {
  21018. isCube: boolean;
  21019. /**
  21020. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21021. */
  21022. static readonly REFRESHRATE_RENDER_ONCE: number;
  21023. /**
  21024. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21025. */
  21026. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21027. /**
  21028. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21029. * the central point of your effect and can save a lot of performances.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21032. /**
  21033. * Use this predicate to dynamically define the list of mesh you want to render.
  21034. * If set, the renderList property will be overwritten.
  21035. */
  21036. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21037. private _renderList;
  21038. /**
  21039. * Use this list to define the list of mesh you want to render.
  21040. */
  21041. get renderList(): Nullable<Array<AbstractMesh>>;
  21042. set renderList(value: Nullable<Array<AbstractMesh>>);
  21043. /**
  21044. * Use this function to overload the renderList array at rendering time.
  21045. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21046. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21047. * the cube (if the RTT is a cube, else layerOrFace=0).
  21048. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21049. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21050. * hold dummy elements!
  21051. */
  21052. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21053. private _hookArray;
  21054. /**
  21055. * Define if particles should be rendered in your texture.
  21056. */
  21057. renderParticles: boolean;
  21058. /**
  21059. * Define if sprites should be rendered in your texture.
  21060. */
  21061. renderSprites: boolean;
  21062. /**
  21063. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21064. */
  21065. coordinatesMode: number;
  21066. /**
  21067. * Define the camera used to render the texture.
  21068. */
  21069. activeCamera: Nullable<Camera>;
  21070. /**
  21071. * Override the render function of the texture with your own one.
  21072. */
  21073. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21074. /**
  21075. * Define if camera post processes should be use while rendering the texture.
  21076. */
  21077. useCameraPostProcesses: boolean;
  21078. /**
  21079. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21080. */
  21081. ignoreCameraViewport: boolean;
  21082. private _postProcessManager;
  21083. private _postProcesses;
  21084. private _resizeObserver;
  21085. /**
  21086. * An event triggered when the texture is unbind.
  21087. */
  21088. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21089. /**
  21090. * An event triggered when the texture is unbind.
  21091. */
  21092. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21093. private _onAfterUnbindObserver;
  21094. /**
  21095. * Set a after unbind callback in the texture.
  21096. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21097. */
  21098. set onAfterUnbind(callback: () => void);
  21099. /**
  21100. * An event triggered before rendering the texture
  21101. */
  21102. onBeforeRenderObservable: Observable<number>;
  21103. private _onBeforeRenderObserver;
  21104. /**
  21105. * Set a before render callback in the texture.
  21106. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21107. */
  21108. set onBeforeRender(callback: (faceIndex: number) => void);
  21109. /**
  21110. * An event triggered after rendering the texture
  21111. */
  21112. onAfterRenderObservable: Observable<number>;
  21113. private _onAfterRenderObserver;
  21114. /**
  21115. * Set a after render callback in the texture.
  21116. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21117. */
  21118. set onAfterRender(callback: (faceIndex: number) => void);
  21119. /**
  21120. * An event triggered after the texture clear
  21121. */
  21122. onClearObservable: Observable<Engine>;
  21123. private _onClearObserver;
  21124. /**
  21125. * Set a clear callback in the texture.
  21126. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21127. */
  21128. set onClear(callback: (Engine: Engine) => void);
  21129. /**
  21130. * An event triggered when the texture is resized.
  21131. */
  21132. onResizeObservable: Observable<RenderTargetTexture>;
  21133. /**
  21134. * Define the clear color of the Render Target if it should be different from the scene.
  21135. */
  21136. clearColor: Color4;
  21137. protected _size: number | {
  21138. width: number;
  21139. height: number;
  21140. layers?: number;
  21141. };
  21142. protected _initialSizeParameter: number | {
  21143. width: number;
  21144. height: number;
  21145. } | {
  21146. ratio: number;
  21147. };
  21148. protected _sizeRatio: Nullable<number>;
  21149. /** @hidden */
  21150. _generateMipMaps: boolean;
  21151. protected _renderingManager: RenderingManager;
  21152. /** @hidden */
  21153. _waitingRenderList: string[];
  21154. protected _doNotChangeAspectRatio: boolean;
  21155. protected _currentRefreshId: number;
  21156. protected _refreshRate: number;
  21157. protected _textureMatrix: Matrix;
  21158. protected _samples: number;
  21159. protected _renderTargetOptions: RenderTargetCreationOptions;
  21160. /**
  21161. * Gets render target creation options that were used.
  21162. */
  21163. get renderTargetOptions(): RenderTargetCreationOptions;
  21164. protected _engine: Engine;
  21165. protected _onRatioRescale(): void;
  21166. /**
  21167. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21168. * It must define where the camera used to render the texture is set
  21169. */
  21170. boundingBoxPosition: Vector3;
  21171. private _boundingBoxSize;
  21172. /**
  21173. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21174. * When defined, the cubemap will switch to local mode
  21175. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21176. * @example https://www.babylonjs-playground.com/#RNASML
  21177. */
  21178. set boundingBoxSize(value: Vector3);
  21179. get boundingBoxSize(): Vector3;
  21180. /**
  21181. * In case the RTT has been created with a depth texture, get the associated
  21182. * depth texture.
  21183. * Otherwise, return null.
  21184. */
  21185. get depthStencilTexture(): Nullable<InternalTexture>;
  21186. /**
  21187. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21188. * or used a shadow, depth texture...
  21189. * @param name The friendly name of the texture
  21190. * @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)
  21191. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21192. * @param generateMipMaps True if mip maps need to be generated after render.
  21193. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21194. * @param type The type of the buffer in the RTT (int, half float, float...)
  21195. * @param isCube True if a cube texture needs to be created
  21196. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21197. * @param generateDepthBuffer True to generate a depth buffer
  21198. * @param generateStencilBuffer True to generate a stencil buffer
  21199. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21200. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21201. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21202. */
  21203. constructor(name: string, size: number | {
  21204. width: number;
  21205. height: number;
  21206. layers?: number;
  21207. } | {
  21208. ratio: number;
  21209. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21210. /**
  21211. * Creates a depth stencil texture.
  21212. * This is only available in WebGL 2 or with the depth texture extension available.
  21213. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21214. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21215. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21216. */
  21217. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21218. private _processSizeParameter;
  21219. /**
  21220. * Define the number of samples to use in case of MSAA.
  21221. * It defaults to one meaning no MSAA has been enabled.
  21222. */
  21223. get samples(): number;
  21224. set samples(value: number);
  21225. /**
  21226. * Resets the refresh counter of the texture and start bak from scratch.
  21227. * Could be useful to regenerate the texture if it is setup to render only once.
  21228. */
  21229. resetRefreshCounter(): void;
  21230. /**
  21231. * Define the refresh rate of the texture or the rendering frequency.
  21232. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21233. */
  21234. get refreshRate(): number;
  21235. set refreshRate(value: number);
  21236. /**
  21237. * Adds a post process to the render target rendering passes.
  21238. * @param postProcess define the post process to add
  21239. */
  21240. addPostProcess(postProcess: PostProcess): void;
  21241. /**
  21242. * Clear all the post processes attached to the render target
  21243. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21244. */
  21245. clearPostProcesses(dispose?: boolean): void;
  21246. /**
  21247. * Remove one of the post process from the list of attached post processes to the texture
  21248. * @param postProcess define the post process to remove from the list
  21249. */
  21250. removePostProcess(postProcess: PostProcess): void;
  21251. /** @hidden */
  21252. _shouldRender(): boolean;
  21253. /**
  21254. * Gets the actual render size of the texture.
  21255. * @returns the width of the render size
  21256. */
  21257. getRenderSize(): number;
  21258. /**
  21259. * Gets the actual render width of the texture.
  21260. * @returns the width of the render size
  21261. */
  21262. getRenderWidth(): number;
  21263. /**
  21264. * Gets the actual render height of the texture.
  21265. * @returns the height of the render size
  21266. */
  21267. getRenderHeight(): number;
  21268. /**
  21269. * Gets the actual number of layers of the texture.
  21270. * @returns the number of layers
  21271. */
  21272. getRenderLayers(): number;
  21273. /**
  21274. * Get if the texture can be rescaled or not.
  21275. */
  21276. get canRescale(): boolean;
  21277. /**
  21278. * Resize the texture using a ratio.
  21279. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21280. */
  21281. scale(ratio: number): void;
  21282. /**
  21283. * Get the texture reflection matrix used to rotate/transform the reflection.
  21284. * @returns the reflection matrix
  21285. */
  21286. getReflectionTextureMatrix(): Matrix;
  21287. /**
  21288. * Resize the texture to a new desired size.
  21289. * Be carrefull as it will recreate all the data in the new texture.
  21290. * @param size Define the new size. It can be:
  21291. * - a number for squared texture,
  21292. * - an object containing { width: number, height: number }
  21293. * - or an object containing a ratio { ratio: number }
  21294. */
  21295. resize(size: number | {
  21296. width: number;
  21297. height: number;
  21298. } | {
  21299. ratio: number;
  21300. }): void;
  21301. private _defaultRenderListPrepared;
  21302. /**
  21303. * Renders all the objects from the render list into the texture.
  21304. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21305. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21306. */
  21307. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21308. private _bestReflectionRenderTargetDimension;
  21309. private _prepareRenderingManager;
  21310. /**
  21311. * @hidden
  21312. * @param faceIndex face index to bind to if this is a cubetexture
  21313. * @param layer defines the index of the texture to bind in the array
  21314. */
  21315. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21316. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21317. private renderToTarget;
  21318. /**
  21319. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21320. * This allowed control for front to back rendering or reversly depending of the special needs.
  21321. *
  21322. * @param renderingGroupId The rendering group id corresponding to its index
  21323. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21324. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21325. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21326. */
  21327. 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;
  21328. /**
  21329. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21330. *
  21331. * @param renderingGroupId The rendering group id corresponding to its index
  21332. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21333. */
  21334. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21335. /**
  21336. * Clones the texture.
  21337. * @returns the cloned texture
  21338. */
  21339. clone(): RenderTargetTexture;
  21340. /**
  21341. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21342. * @returns The JSON representation of the texture
  21343. */
  21344. serialize(): any;
  21345. /**
  21346. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21347. */
  21348. disposeFramebufferObjects(): void;
  21349. /**
  21350. * Dispose the texture and release its associated resources.
  21351. */
  21352. dispose(): void;
  21353. /** @hidden */
  21354. _rebuild(): void;
  21355. /**
  21356. * Clear the info related to rendering groups preventing retention point in material dispose.
  21357. */
  21358. freeRenderingGroups(): void;
  21359. /**
  21360. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21361. * @returns the view count
  21362. */
  21363. getViewCount(): number;
  21364. }
  21365. }
  21366. declare module "babylonjs/Materials/material" {
  21367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21368. import { SmartArray } from "babylonjs/Misc/smartArray";
  21369. import { Observable } from "babylonjs/Misc/observable";
  21370. import { Nullable } from "babylonjs/types";
  21371. import { Scene } from "babylonjs/scene";
  21372. import { Matrix } from "babylonjs/Maths/math.vector";
  21373. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21376. import { Effect } from "babylonjs/Materials/effect";
  21377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21378. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21379. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21380. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21381. import { Mesh } from "babylonjs/Meshes/mesh";
  21382. import { Animation } from "babylonjs/Animations/animation";
  21383. /**
  21384. * Options for compiling materials.
  21385. */
  21386. export interface IMaterialCompilationOptions {
  21387. /**
  21388. * Defines whether clip planes are enabled.
  21389. */
  21390. clipPlane: boolean;
  21391. /**
  21392. * Defines whether instances are enabled.
  21393. */
  21394. useInstances: boolean;
  21395. }
  21396. /**
  21397. * Base class for the main features of a material in Babylon.js
  21398. */
  21399. export class Material implements IAnimatable {
  21400. /**
  21401. * Returns the triangle fill mode
  21402. */
  21403. static readonly TriangleFillMode: number;
  21404. /**
  21405. * Returns the wireframe mode
  21406. */
  21407. static readonly WireFrameFillMode: number;
  21408. /**
  21409. * Returns the point fill mode
  21410. */
  21411. static readonly PointFillMode: number;
  21412. /**
  21413. * Returns the point list draw mode
  21414. */
  21415. static readonly PointListDrawMode: number;
  21416. /**
  21417. * Returns the line list draw mode
  21418. */
  21419. static readonly LineListDrawMode: number;
  21420. /**
  21421. * Returns the line loop draw mode
  21422. */
  21423. static readonly LineLoopDrawMode: number;
  21424. /**
  21425. * Returns the line strip draw mode
  21426. */
  21427. static readonly LineStripDrawMode: number;
  21428. /**
  21429. * Returns the triangle strip draw mode
  21430. */
  21431. static readonly TriangleStripDrawMode: number;
  21432. /**
  21433. * Returns the triangle fan draw mode
  21434. */
  21435. static readonly TriangleFanDrawMode: number;
  21436. /**
  21437. * Stores the clock-wise side orientation
  21438. */
  21439. static readonly ClockWiseSideOrientation: number;
  21440. /**
  21441. * Stores the counter clock-wise side orientation
  21442. */
  21443. static readonly CounterClockWiseSideOrientation: number;
  21444. /**
  21445. * The dirty texture flag value
  21446. */
  21447. static readonly TextureDirtyFlag: number;
  21448. /**
  21449. * The dirty light flag value
  21450. */
  21451. static readonly LightDirtyFlag: number;
  21452. /**
  21453. * The dirty fresnel flag value
  21454. */
  21455. static readonly FresnelDirtyFlag: number;
  21456. /**
  21457. * The dirty attribute flag value
  21458. */
  21459. static readonly AttributesDirtyFlag: number;
  21460. /**
  21461. * The dirty misc flag value
  21462. */
  21463. static readonly MiscDirtyFlag: number;
  21464. /**
  21465. * The all dirty flag value
  21466. */
  21467. static readonly AllDirtyFlag: number;
  21468. /**
  21469. * The ID of the material
  21470. */
  21471. id: string;
  21472. /**
  21473. * Gets or sets the unique id of the material
  21474. */
  21475. uniqueId: number;
  21476. /**
  21477. * The name of the material
  21478. */
  21479. name: string;
  21480. /**
  21481. * Gets or sets user defined metadata
  21482. */
  21483. metadata: any;
  21484. /**
  21485. * For internal use only. Please do not use.
  21486. */
  21487. reservedDataStore: any;
  21488. /**
  21489. * Specifies if the ready state should be checked on each call
  21490. */
  21491. checkReadyOnEveryCall: boolean;
  21492. /**
  21493. * Specifies if the ready state should be checked once
  21494. */
  21495. checkReadyOnlyOnce: boolean;
  21496. /**
  21497. * The state of the material
  21498. */
  21499. state: string;
  21500. /**
  21501. * The alpha value of the material
  21502. */
  21503. protected _alpha: number;
  21504. /**
  21505. * List of inspectable custom properties (used by the Inspector)
  21506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21507. */
  21508. inspectableCustomProperties: IInspectable[];
  21509. /**
  21510. * Sets the alpha value of the material
  21511. */
  21512. set alpha(value: number);
  21513. /**
  21514. * Gets the alpha value of the material
  21515. */
  21516. get alpha(): number;
  21517. /**
  21518. * Specifies if back face culling is enabled
  21519. */
  21520. protected _backFaceCulling: boolean;
  21521. /**
  21522. * Sets the back-face culling state
  21523. */
  21524. set backFaceCulling(value: boolean);
  21525. /**
  21526. * Gets the back-face culling state
  21527. */
  21528. get backFaceCulling(): boolean;
  21529. /**
  21530. * Stores the value for side orientation
  21531. */
  21532. sideOrientation: number;
  21533. /**
  21534. * Callback triggered when the material is compiled
  21535. */
  21536. onCompiled: Nullable<(effect: Effect) => void>;
  21537. /**
  21538. * Callback triggered when an error occurs
  21539. */
  21540. onError: Nullable<(effect: Effect, errors: string) => void>;
  21541. /**
  21542. * Callback triggered to get the render target textures
  21543. */
  21544. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21545. /**
  21546. * Gets a boolean indicating that current material needs to register RTT
  21547. */
  21548. get hasRenderTargetTextures(): boolean;
  21549. /**
  21550. * Specifies if the material should be serialized
  21551. */
  21552. doNotSerialize: boolean;
  21553. /**
  21554. * @hidden
  21555. */
  21556. _storeEffectOnSubMeshes: boolean;
  21557. /**
  21558. * Stores the animations for the material
  21559. */
  21560. animations: Nullable<Array<Animation>>;
  21561. /**
  21562. * An event triggered when the material is disposed
  21563. */
  21564. onDisposeObservable: Observable<Material>;
  21565. /**
  21566. * An observer which watches for dispose events
  21567. */
  21568. private _onDisposeObserver;
  21569. private _onUnBindObservable;
  21570. /**
  21571. * Called during a dispose event
  21572. */
  21573. set onDispose(callback: () => void);
  21574. private _onBindObservable;
  21575. /**
  21576. * An event triggered when the material is bound
  21577. */
  21578. get onBindObservable(): Observable<AbstractMesh>;
  21579. /**
  21580. * An observer which watches for bind events
  21581. */
  21582. private _onBindObserver;
  21583. /**
  21584. * Called during a bind event
  21585. */
  21586. set onBind(callback: (Mesh: AbstractMesh) => void);
  21587. /**
  21588. * An event triggered when the material is unbound
  21589. */
  21590. get onUnBindObservable(): Observable<Material>;
  21591. /**
  21592. * Stores the value of the alpha mode
  21593. */
  21594. private _alphaMode;
  21595. /**
  21596. * Sets the value of the alpha mode.
  21597. *
  21598. * | Value | Type | Description |
  21599. * | --- | --- | --- |
  21600. * | 0 | ALPHA_DISABLE | |
  21601. * | 1 | ALPHA_ADD | |
  21602. * | 2 | ALPHA_COMBINE | |
  21603. * | 3 | ALPHA_SUBTRACT | |
  21604. * | 4 | ALPHA_MULTIPLY | |
  21605. * | 5 | ALPHA_MAXIMIZED | |
  21606. * | 6 | ALPHA_ONEONE | |
  21607. * | 7 | ALPHA_PREMULTIPLIED | |
  21608. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21609. * | 9 | ALPHA_INTERPOLATE | |
  21610. * | 10 | ALPHA_SCREENMODE | |
  21611. *
  21612. */
  21613. set alphaMode(value: number);
  21614. /**
  21615. * Gets the value of the alpha mode
  21616. */
  21617. get alphaMode(): number;
  21618. /**
  21619. * Stores the state of the need depth pre-pass value
  21620. */
  21621. private _needDepthPrePass;
  21622. /**
  21623. * Sets the need depth pre-pass value
  21624. */
  21625. set needDepthPrePass(value: boolean);
  21626. /**
  21627. * Gets the depth pre-pass value
  21628. */
  21629. get needDepthPrePass(): boolean;
  21630. /**
  21631. * Specifies if depth writing should be disabled
  21632. */
  21633. disableDepthWrite: boolean;
  21634. /**
  21635. * Specifies if depth writing should be forced
  21636. */
  21637. forceDepthWrite: boolean;
  21638. /**
  21639. * Specifies the depth function that should be used. 0 means the default engine function
  21640. */
  21641. depthFunction: number;
  21642. /**
  21643. * Specifies if there should be a separate pass for culling
  21644. */
  21645. separateCullingPass: boolean;
  21646. /**
  21647. * Stores the state specifing if fog should be enabled
  21648. */
  21649. private _fogEnabled;
  21650. /**
  21651. * Sets the state for enabling fog
  21652. */
  21653. set fogEnabled(value: boolean);
  21654. /**
  21655. * Gets the value of the fog enabled state
  21656. */
  21657. get fogEnabled(): boolean;
  21658. /**
  21659. * Stores the size of points
  21660. */
  21661. pointSize: number;
  21662. /**
  21663. * Stores the z offset value
  21664. */
  21665. zOffset: number;
  21666. /**
  21667. * Gets a value specifying if wireframe mode is enabled
  21668. */
  21669. get wireframe(): boolean;
  21670. /**
  21671. * Sets the state of wireframe mode
  21672. */
  21673. set wireframe(value: boolean);
  21674. /**
  21675. * Gets the value specifying if point clouds are enabled
  21676. */
  21677. get pointsCloud(): boolean;
  21678. /**
  21679. * Sets the state of point cloud mode
  21680. */
  21681. set pointsCloud(value: boolean);
  21682. /**
  21683. * Gets the material fill mode
  21684. */
  21685. get fillMode(): number;
  21686. /**
  21687. * Sets the material fill mode
  21688. */
  21689. set fillMode(value: number);
  21690. /**
  21691. * @hidden
  21692. * Stores the effects for the material
  21693. */
  21694. _effect: Nullable<Effect>;
  21695. /**
  21696. * Specifies if uniform buffers should be used
  21697. */
  21698. private _useUBO;
  21699. /**
  21700. * Stores a reference to the scene
  21701. */
  21702. private _scene;
  21703. /**
  21704. * Stores the fill mode state
  21705. */
  21706. private _fillMode;
  21707. /**
  21708. * Specifies if the depth write state should be cached
  21709. */
  21710. private _cachedDepthWriteState;
  21711. /**
  21712. * Specifies if the depth function state should be cached
  21713. */
  21714. private _cachedDepthFunctionState;
  21715. /**
  21716. * Stores the uniform buffer
  21717. */
  21718. protected _uniformBuffer: UniformBuffer;
  21719. /** @hidden */
  21720. _indexInSceneMaterialArray: number;
  21721. /** @hidden */
  21722. meshMap: Nullable<{
  21723. [id: string]: AbstractMesh | undefined;
  21724. }>;
  21725. /**
  21726. * Creates a material instance
  21727. * @param name defines the name of the material
  21728. * @param scene defines the scene to reference
  21729. * @param doNotAdd specifies if the material should be added to the scene
  21730. */
  21731. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21732. /**
  21733. * Returns a string representation of the current material
  21734. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21735. * @returns a string with material information
  21736. */
  21737. toString(fullDetails?: boolean): string;
  21738. /**
  21739. * Gets the class name of the material
  21740. * @returns a string with the class name of the material
  21741. */
  21742. getClassName(): string;
  21743. /**
  21744. * Specifies if updates for the material been locked
  21745. */
  21746. get isFrozen(): boolean;
  21747. /**
  21748. * Locks updates for the material
  21749. */
  21750. freeze(): void;
  21751. /**
  21752. * Unlocks updates for the material
  21753. */
  21754. unfreeze(): void;
  21755. /**
  21756. * Specifies if the material is ready to be used
  21757. * @param mesh defines the mesh to check
  21758. * @param useInstances specifies if instances should be used
  21759. * @returns a boolean indicating if the material is ready to be used
  21760. */
  21761. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21762. /**
  21763. * Specifies that the submesh is ready to be used
  21764. * @param mesh defines the mesh to check
  21765. * @param subMesh defines which submesh to check
  21766. * @param useInstances specifies that instances should be used
  21767. * @returns a boolean indicating that the submesh is ready or not
  21768. */
  21769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21770. /**
  21771. * Returns the material effect
  21772. * @returns the effect associated with the material
  21773. */
  21774. getEffect(): Nullable<Effect>;
  21775. /**
  21776. * Returns the current scene
  21777. * @returns a Scene
  21778. */
  21779. getScene(): Scene;
  21780. /**
  21781. * Specifies if the material will require alpha blending
  21782. * @returns a boolean specifying if alpha blending is needed
  21783. */
  21784. needAlphaBlending(): boolean;
  21785. /**
  21786. * Specifies if the mesh will require alpha blending
  21787. * @param mesh defines the mesh to check
  21788. * @returns a boolean specifying if alpha blending is needed for the mesh
  21789. */
  21790. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21791. /**
  21792. * Specifies if this material should be rendered in alpha test mode
  21793. * @returns a boolean specifying if an alpha test is needed.
  21794. */
  21795. needAlphaTesting(): boolean;
  21796. /**
  21797. * Gets the texture used for the alpha test
  21798. * @returns the texture to use for alpha testing
  21799. */
  21800. getAlphaTestTexture(): Nullable<BaseTexture>;
  21801. /**
  21802. * Marks the material to indicate that it needs to be re-calculated
  21803. */
  21804. markDirty(): void;
  21805. /** @hidden */
  21806. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21807. /**
  21808. * Binds the material to the mesh
  21809. * @param world defines the world transformation matrix
  21810. * @param mesh defines the mesh to bind the material to
  21811. */
  21812. bind(world: Matrix, mesh?: Mesh): void;
  21813. /**
  21814. * Binds the submesh to the material
  21815. * @param world defines the world transformation matrix
  21816. * @param mesh defines the mesh containing the submesh
  21817. * @param subMesh defines the submesh to bind the material to
  21818. */
  21819. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21820. /**
  21821. * Binds the world matrix to the material
  21822. * @param world defines the world transformation matrix
  21823. */
  21824. bindOnlyWorldMatrix(world: Matrix): void;
  21825. /**
  21826. * Binds the scene's uniform buffer to the effect.
  21827. * @param effect defines the effect to bind to the scene uniform buffer
  21828. * @param sceneUbo defines the uniform buffer storing scene data
  21829. */
  21830. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21831. /**
  21832. * Binds the view matrix to the effect
  21833. * @param effect defines the effect to bind the view matrix to
  21834. */
  21835. bindView(effect: Effect): void;
  21836. /**
  21837. * Binds the view projection matrix to the effect
  21838. * @param effect defines the effect to bind the view projection matrix to
  21839. */
  21840. bindViewProjection(effect: Effect): void;
  21841. /**
  21842. * Specifies if material alpha testing should be turned on for the mesh
  21843. * @param mesh defines the mesh to check
  21844. */
  21845. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21846. /**
  21847. * Processes to execute after binding the material to a mesh
  21848. * @param mesh defines the rendered mesh
  21849. */
  21850. protected _afterBind(mesh?: Mesh): void;
  21851. /**
  21852. * Unbinds the material from the mesh
  21853. */
  21854. unbind(): void;
  21855. /**
  21856. * Gets the active textures from the material
  21857. * @returns an array of textures
  21858. */
  21859. getActiveTextures(): BaseTexture[];
  21860. /**
  21861. * Specifies if the material uses a texture
  21862. * @param texture defines the texture to check against the material
  21863. * @returns a boolean specifying if the material uses the texture
  21864. */
  21865. hasTexture(texture: BaseTexture): boolean;
  21866. /**
  21867. * Makes a duplicate of the material, and gives it a new name
  21868. * @param name defines the new name for the duplicated material
  21869. * @returns the cloned material
  21870. */
  21871. clone(name: string): Nullable<Material>;
  21872. /**
  21873. * Gets the meshes bound to the material
  21874. * @returns an array of meshes bound to the material
  21875. */
  21876. getBindedMeshes(): AbstractMesh[];
  21877. /**
  21878. * Force shader compilation
  21879. * @param mesh defines the mesh associated with this material
  21880. * @param onCompiled defines a function to execute once the material is compiled
  21881. * @param options defines the options to configure the compilation
  21882. * @param onError defines a function to execute if the material fails compiling
  21883. */
  21884. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21885. /**
  21886. * Force shader compilation
  21887. * @param mesh defines the mesh that will use this material
  21888. * @param options defines additional options for compiling the shaders
  21889. * @returns a promise that resolves when the compilation completes
  21890. */
  21891. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21892. private static readonly _AllDirtyCallBack;
  21893. private static readonly _ImageProcessingDirtyCallBack;
  21894. private static readonly _TextureDirtyCallBack;
  21895. private static readonly _FresnelDirtyCallBack;
  21896. private static readonly _MiscDirtyCallBack;
  21897. private static readonly _LightsDirtyCallBack;
  21898. private static readonly _AttributeDirtyCallBack;
  21899. private static _FresnelAndMiscDirtyCallBack;
  21900. private static _TextureAndMiscDirtyCallBack;
  21901. private static readonly _DirtyCallbackArray;
  21902. private static readonly _RunDirtyCallBacks;
  21903. /**
  21904. * Marks a define in the material to indicate that it needs to be re-computed
  21905. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21906. */
  21907. markAsDirty(flag: number): void;
  21908. /**
  21909. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21910. * @param func defines a function which checks material defines against the submeshes
  21911. */
  21912. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21913. /**
  21914. * Indicates that we need to re-calculated for all submeshes
  21915. */
  21916. protected _markAllSubMeshesAsAllDirty(): void;
  21917. /**
  21918. * Indicates that image processing needs to be re-calculated for all submeshes
  21919. */
  21920. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21921. /**
  21922. * Indicates that textures need to be re-calculated for all submeshes
  21923. */
  21924. protected _markAllSubMeshesAsTexturesDirty(): void;
  21925. /**
  21926. * Indicates that fresnel needs to be re-calculated for all submeshes
  21927. */
  21928. protected _markAllSubMeshesAsFresnelDirty(): void;
  21929. /**
  21930. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21931. */
  21932. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21933. /**
  21934. * Indicates that lights need to be re-calculated for all submeshes
  21935. */
  21936. protected _markAllSubMeshesAsLightsDirty(): void;
  21937. /**
  21938. * Indicates that attributes need to be re-calculated for all submeshes
  21939. */
  21940. protected _markAllSubMeshesAsAttributesDirty(): void;
  21941. /**
  21942. * Indicates that misc needs to be re-calculated for all submeshes
  21943. */
  21944. protected _markAllSubMeshesAsMiscDirty(): void;
  21945. /**
  21946. * Indicates that textures and misc need to be re-calculated for all submeshes
  21947. */
  21948. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21949. /**
  21950. * Disposes the material
  21951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21953. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21954. */
  21955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21956. /** @hidden */
  21957. private releaseVertexArrayObject;
  21958. /**
  21959. * Serializes this material
  21960. * @returns the serialized material object
  21961. */
  21962. serialize(): any;
  21963. /**
  21964. * Creates a material from parsed material data
  21965. * @param parsedMaterial defines parsed material data
  21966. * @param scene defines the hosting scene
  21967. * @param rootUrl defines the root URL to use to load textures
  21968. * @returns a new material
  21969. */
  21970. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21971. }
  21972. }
  21973. declare module "babylonjs/Materials/multiMaterial" {
  21974. import { Nullable } from "babylonjs/types";
  21975. import { Scene } from "babylonjs/scene";
  21976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21977. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21979. import { Material } from "babylonjs/Materials/material";
  21980. /**
  21981. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21982. * separate meshes. This can be use to improve performances.
  21983. * @see http://doc.babylonjs.com/how_to/multi_materials
  21984. */
  21985. export class MultiMaterial extends Material {
  21986. private _subMaterials;
  21987. /**
  21988. * Gets or Sets the list of Materials used within the multi material.
  21989. * They need to be ordered according to the submeshes order in the associated mesh
  21990. */
  21991. get subMaterials(): Nullable<Material>[];
  21992. set subMaterials(value: Nullable<Material>[]);
  21993. /**
  21994. * Function used to align with Node.getChildren()
  21995. * @returns the list of Materials used within the multi material
  21996. */
  21997. getChildren(): Nullable<Material>[];
  21998. /**
  21999. * Instantiates a new Multi Material
  22000. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22001. * separate meshes. This can be use to improve performances.
  22002. * @see http://doc.babylonjs.com/how_to/multi_materials
  22003. * @param name Define the name in the scene
  22004. * @param scene Define the scene the material belongs to
  22005. */
  22006. constructor(name: string, scene: Scene);
  22007. private _hookArray;
  22008. /**
  22009. * Get one of the submaterial by its index in the submaterials array
  22010. * @param index The index to look the sub material at
  22011. * @returns The Material if the index has been defined
  22012. */
  22013. getSubMaterial(index: number): Nullable<Material>;
  22014. /**
  22015. * Get the list of active textures for the whole sub materials list.
  22016. * @returns All the textures that will be used during the rendering
  22017. */
  22018. getActiveTextures(): BaseTexture[];
  22019. /**
  22020. * Gets the current class name of the material e.g. "MultiMaterial"
  22021. * Mainly use in serialization.
  22022. * @returns the class name
  22023. */
  22024. getClassName(): string;
  22025. /**
  22026. * Checks if the material is ready to render the requested sub mesh
  22027. * @param mesh Define the mesh the submesh belongs to
  22028. * @param subMesh Define the sub mesh to look readyness for
  22029. * @param useInstances Define whether or not the material is used with instances
  22030. * @returns true if ready, otherwise false
  22031. */
  22032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22033. /**
  22034. * Clones the current material and its related sub materials
  22035. * @param name Define the name of the newly cloned material
  22036. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22037. * @returns the cloned material
  22038. */
  22039. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22040. /**
  22041. * Serializes the materials into a JSON representation.
  22042. * @returns the JSON representation
  22043. */
  22044. serialize(): any;
  22045. /**
  22046. * Dispose the material and release its associated resources
  22047. * @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)
  22048. * @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)
  22049. * @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)
  22050. */
  22051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22052. /**
  22053. * Creates a MultiMaterial from parsed MultiMaterial data.
  22054. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22055. * @param scene defines the hosting scene
  22056. * @returns a new MultiMaterial
  22057. */
  22058. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22059. }
  22060. }
  22061. declare module "babylonjs/Meshes/subMesh" {
  22062. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22063. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22064. import { Engine } from "babylonjs/Engines/engine";
  22065. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22066. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22067. import { Effect } from "babylonjs/Materials/effect";
  22068. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22069. import { Plane } from "babylonjs/Maths/math.plane";
  22070. import { Collider } from "babylonjs/Collisions/collider";
  22071. import { Material } from "babylonjs/Materials/material";
  22072. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22074. import { Mesh } from "babylonjs/Meshes/mesh";
  22075. import { Ray } from "babylonjs/Culling/ray";
  22076. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22077. /**
  22078. * Base class for submeshes
  22079. */
  22080. export class BaseSubMesh {
  22081. /** @hidden */
  22082. _materialDefines: Nullable<MaterialDefines>;
  22083. /** @hidden */
  22084. _materialEffect: Nullable<Effect>;
  22085. /**
  22086. * Gets material defines used by the effect associated to the sub mesh
  22087. */
  22088. get materialDefines(): Nullable<MaterialDefines>;
  22089. /**
  22090. * Sets material defines used by the effect associated to the sub mesh
  22091. */
  22092. set materialDefines(defines: Nullable<MaterialDefines>);
  22093. /**
  22094. * Gets associated effect
  22095. */
  22096. get effect(): Nullable<Effect>;
  22097. /**
  22098. * Sets associated effect (effect used to render this submesh)
  22099. * @param effect defines the effect to associate with
  22100. * @param defines defines the set of defines used to compile this effect
  22101. */
  22102. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22103. }
  22104. /**
  22105. * Defines a subdivision inside a mesh
  22106. */
  22107. export class SubMesh extends BaseSubMesh implements ICullable {
  22108. /** the material index to use */
  22109. materialIndex: number;
  22110. /** vertex index start */
  22111. verticesStart: number;
  22112. /** vertices count */
  22113. verticesCount: number;
  22114. /** index start */
  22115. indexStart: number;
  22116. /** indices count */
  22117. indexCount: number;
  22118. /** @hidden */
  22119. _linesIndexCount: number;
  22120. private _mesh;
  22121. private _renderingMesh;
  22122. private _boundingInfo;
  22123. private _linesIndexBuffer;
  22124. /** @hidden */
  22125. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22126. /** @hidden */
  22127. _trianglePlanes: Plane[];
  22128. /** @hidden */
  22129. _lastColliderTransformMatrix: Nullable<Matrix>;
  22130. /** @hidden */
  22131. _renderId: number;
  22132. /** @hidden */
  22133. _alphaIndex: number;
  22134. /** @hidden */
  22135. _distanceToCamera: number;
  22136. /** @hidden */
  22137. _id: number;
  22138. private _currentMaterial;
  22139. /**
  22140. * Add a new submesh to a mesh
  22141. * @param materialIndex defines the material index to use
  22142. * @param verticesStart defines vertex index start
  22143. * @param verticesCount defines vertices count
  22144. * @param indexStart defines index start
  22145. * @param indexCount defines indices count
  22146. * @param mesh defines the parent mesh
  22147. * @param renderingMesh defines an optional rendering mesh
  22148. * @param createBoundingBox defines if bounding box should be created for this submesh
  22149. * @returns the new submesh
  22150. */
  22151. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22152. /**
  22153. * Creates a new submesh
  22154. * @param materialIndex defines the material index to use
  22155. * @param verticesStart defines vertex index start
  22156. * @param verticesCount defines vertices count
  22157. * @param indexStart defines index start
  22158. * @param indexCount defines indices count
  22159. * @param mesh defines the parent mesh
  22160. * @param renderingMesh defines an optional rendering mesh
  22161. * @param createBoundingBox defines if bounding box should be created for this submesh
  22162. */
  22163. constructor(
  22164. /** the material index to use */
  22165. materialIndex: number,
  22166. /** vertex index start */
  22167. verticesStart: number,
  22168. /** vertices count */
  22169. verticesCount: number,
  22170. /** index start */
  22171. indexStart: number,
  22172. /** indices count */
  22173. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22174. /**
  22175. * Returns true if this submesh covers the entire parent mesh
  22176. * @ignorenaming
  22177. */
  22178. get IsGlobal(): boolean;
  22179. /**
  22180. * Returns the submesh BoudingInfo object
  22181. * @returns current bounding info (or mesh's one if the submesh is global)
  22182. */
  22183. getBoundingInfo(): BoundingInfo;
  22184. /**
  22185. * Sets the submesh BoundingInfo
  22186. * @param boundingInfo defines the new bounding info to use
  22187. * @returns the SubMesh
  22188. */
  22189. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22190. /**
  22191. * Returns the mesh of the current submesh
  22192. * @return the parent mesh
  22193. */
  22194. getMesh(): AbstractMesh;
  22195. /**
  22196. * Returns the rendering mesh of the submesh
  22197. * @returns the rendering mesh (could be different from parent mesh)
  22198. */
  22199. getRenderingMesh(): Mesh;
  22200. /**
  22201. * Returns the submesh material
  22202. * @returns null or the current material
  22203. */
  22204. getMaterial(): Nullable<Material>;
  22205. /**
  22206. * Sets a new updated BoundingInfo object to the submesh
  22207. * @param data defines an optional position array to use to determine the bounding info
  22208. * @returns the SubMesh
  22209. */
  22210. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22211. /** @hidden */
  22212. _checkCollision(collider: Collider): boolean;
  22213. /**
  22214. * Updates the submesh BoundingInfo
  22215. * @param world defines the world matrix to use to update the bounding info
  22216. * @returns the submesh
  22217. */
  22218. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22219. /**
  22220. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22221. * @param frustumPlanes defines the frustum planes
  22222. * @returns true if the submesh is intersecting with the frustum
  22223. */
  22224. isInFrustum(frustumPlanes: Plane[]): boolean;
  22225. /**
  22226. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22227. * @param frustumPlanes defines the frustum planes
  22228. * @returns true if the submesh is inside the frustum
  22229. */
  22230. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22231. /**
  22232. * Renders the submesh
  22233. * @param enableAlphaMode defines if alpha needs to be used
  22234. * @returns the submesh
  22235. */
  22236. render(enableAlphaMode: boolean): SubMesh;
  22237. /**
  22238. * @hidden
  22239. */
  22240. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22241. /**
  22242. * Checks if the submesh intersects with a ray
  22243. * @param ray defines the ray to test
  22244. * @returns true is the passed ray intersects the submesh bounding box
  22245. */
  22246. canIntersects(ray: Ray): boolean;
  22247. /**
  22248. * Intersects current submesh with a ray
  22249. * @param ray defines the ray to test
  22250. * @param positions defines mesh's positions array
  22251. * @param indices defines mesh's indices array
  22252. * @param fastCheck defines if only bounding info should be used
  22253. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22254. * @returns intersection info or null if no intersection
  22255. */
  22256. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22257. /** @hidden */
  22258. private _intersectLines;
  22259. /** @hidden */
  22260. private _intersectUnIndexedLines;
  22261. /** @hidden */
  22262. private _intersectTriangles;
  22263. /** @hidden */
  22264. private _intersectUnIndexedTriangles;
  22265. /** @hidden */
  22266. _rebuild(): void;
  22267. /**
  22268. * Creates a new submesh from the passed mesh
  22269. * @param newMesh defines the new hosting mesh
  22270. * @param newRenderingMesh defines an optional rendering mesh
  22271. * @returns the new submesh
  22272. */
  22273. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22274. /**
  22275. * Release associated resources
  22276. */
  22277. dispose(): void;
  22278. /**
  22279. * Gets the class name
  22280. * @returns the string "SubMesh".
  22281. */
  22282. getClassName(): string;
  22283. /**
  22284. * Creates a new submesh from indices data
  22285. * @param materialIndex the index of the main mesh material
  22286. * @param startIndex the index where to start the copy in the mesh indices array
  22287. * @param indexCount the number of indices to copy then from the startIndex
  22288. * @param mesh the main mesh to create the submesh from
  22289. * @param renderingMesh the optional rendering mesh
  22290. * @returns a new submesh
  22291. */
  22292. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22293. }
  22294. }
  22295. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22296. /**
  22297. * Class used to represent data loading progression
  22298. */
  22299. export class SceneLoaderFlags {
  22300. private static _ForceFullSceneLoadingForIncremental;
  22301. private static _ShowLoadingScreen;
  22302. private static _CleanBoneMatrixWeights;
  22303. private static _loggingLevel;
  22304. /**
  22305. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22306. */
  22307. static get ForceFullSceneLoadingForIncremental(): boolean;
  22308. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22309. /**
  22310. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22311. */
  22312. static get ShowLoadingScreen(): boolean;
  22313. static set ShowLoadingScreen(value: boolean);
  22314. /**
  22315. * Defines the current logging level (while loading the scene)
  22316. * @ignorenaming
  22317. */
  22318. static get loggingLevel(): number;
  22319. static set loggingLevel(value: number);
  22320. /**
  22321. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22322. */
  22323. static get CleanBoneMatrixWeights(): boolean;
  22324. static set CleanBoneMatrixWeights(value: boolean);
  22325. }
  22326. }
  22327. declare module "babylonjs/Meshes/geometry" {
  22328. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22329. import { Scene } from "babylonjs/scene";
  22330. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22331. import { Engine } from "babylonjs/Engines/engine";
  22332. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22333. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22334. import { Effect } from "babylonjs/Materials/effect";
  22335. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22336. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22337. import { Mesh } from "babylonjs/Meshes/mesh";
  22338. /**
  22339. * Class used to store geometry data (vertex buffers + index buffer)
  22340. */
  22341. export class Geometry implements IGetSetVerticesData {
  22342. /**
  22343. * Gets or sets the ID of the geometry
  22344. */
  22345. id: string;
  22346. /**
  22347. * Gets or sets the unique ID of the geometry
  22348. */
  22349. uniqueId: number;
  22350. /**
  22351. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22352. */
  22353. delayLoadState: number;
  22354. /**
  22355. * Gets the file containing the data to load when running in delay load state
  22356. */
  22357. delayLoadingFile: Nullable<string>;
  22358. /**
  22359. * Callback called when the geometry is updated
  22360. */
  22361. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22362. private _scene;
  22363. private _engine;
  22364. private _meshes;
  22365. private _totalVertices;
  22366. /** @hidden */
  22367. _indices: IndicesArray;
  22368. /** @hidden */
  22369. _vertexBuffers: {
  22370. [key: string]: VertexBuffer;
  22371. };
  22372. private _isDisposed;
  22373. private _extend;
  22374. private _boundingBias;
  22375. /** @hidden */
  22376. _delayInfo: Array<string>;
  22377. private _indexBuffer;
  22378. private _indexBufferIsUpdatable;
  22379. /** @hidden */
  22380. _boundingInfo: Nullable<BoundingInfo>;
  22381. /** @hidden */
  22382. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22383. /** @hidden */
  22384. _softwareSkinningFrameId: number;
  22385. private _vertexArrayObjects;
  22386. private _updatable;
  22387. /** @hidden */
  22388. _positions: Nullable<Vector3[]>;
  22389. /**
  22390. * 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
  22391. */
  22392. get boundingBias(): Vector2;
  22393. /**
  22394. * 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
  22395. */
  22396. set boundingBias(value: Vector2);
  22397. /**
  22398. * Static function used to attach a new empty geometry to a mesh
  22399. * @param mesh defines the mesh to attach the geometry to
  22400. * @returns the new Geometry
  22401. */
  22402. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22403. /**
  22404. * Creates a new geometry
  22405. * @param id defines the unique ID
  22406. * @param scene defines the hosting scene
  22407. * @param vertexData defines the VertexData used to get geometry data
  22408. * @param updatable defines if geometry must be updatable (false by default)
  22409. * @param mesh defines the mesh that will be associated with the geometry
  22410. */
  22411. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22412. /**
  22413. * Gets the current extend of the geometry
  22414. */
  22415. get extend(): {
  22416. minimum: Vector3;
  22417. maximum: Vector3;
  22418. };
  22419. /**
  22420. * Gets the hosting scene
  22421. * @returns the hosting Scene
  22422. */
  22423. getScene(): Scene;
  22424. /**
  22425. * Gets the hosting engine
  22426. * @returns the hosting Engine
  22427. */
  22428. getEngine(): Engine;
  22429. /**
  22430. * Defines if the geometry is ready to use
  22431. * @returns true if the geometry is ready to be used
  22432. */
  22433. isReady(): boolean;
  22434. /**
  22435. * Gets a value indicating that the geometry should not be serialized
  22436. */
  22437. get doNotSerialize(): boolean;
  22438. /** @hidden */
  22439. _rebuild(): void;
  22440. /**
  22441. * Affects all geometry data in one call
  22442. * @param vertexData defines the geometry data
  22443. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22444. */
  22445. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22446. /**
  22447. * Set specific vertex data
  22448. * @param kind defines the data kind (Position, normal, etc...)
  22449. * @param data defines the vertex data to use
  22450. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22451. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22452. */
  22453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22454. /**
  22455. * Removes a specific vertex data
  22456. * @param kind defines the data kind (Position, normal, etc...)
  22457. */
  22458. removeVerticesData(kind: string): void;
  22459. /**
  22460. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22461. * @param buffer defines the vertex buffer to use
  22462. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22463. */
  22464. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22465. /**
  22466. * Update a specific vertex buffer
  22467. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22468. * It will do nothing if the buffer is not updatable
  22469. * @param kind defines the data kind (Position, normal, etc...)
  22470. * @param data defines the data to use
  22471. * @param offset defines the offset in the target buffer where to store the data
  22472. * @param useBytes set to true if the offset is in bytes
  22473. */
  22474. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22475. /**
  22476. * Update a specific vertex buffer
  22477. * This function will create a new buffer if the current one is not updatable
  22478. * @param kind defines the data kind (Position, normal, etc...)
  22479. * @param data defines the data to use
  22480. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22481. */
  22482. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22483. private _updateBoundingInfo;
  22484. /** @hidden */
  22485. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22486. /**
  22487. * Gets total number of vertices
  22488. * @returns the total number of vertices
  22489. */
  22490. getTotalVertices(): number;
  22491. /**
  22492. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22493. * @param kind defines the data kind (Position, normal, etc...)
  22494. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22495. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22496. * @returns a float array containing vertex data
  22497. */
  22498. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22499. /**
  22500. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22501. * @param kind defines the data kind (Position, normal, etc...)
  22502. * @returns true if the vertex buffer with the specified kind is updatable
  22503. */
  22504. isVertexBufferUpdatable(kind: string): boolean;
  22505. /**
  22506. * Gets a specific vertex buffer
  22507. * @param kind defines the data kind (Position, normal, etc...)
  22508. * @returns a VertexBuffer
  22509. */
  22510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22511. /**
  22512. * Returns all vertex buffers
  22513. * @return an object holding all vertex buffers indexed by kind
  22514. */
  22515. getVertexBuffers(): Nullable<{
  22516. [key: string]: VertexBuffer;
  22517. }>;
  22518. /**
  22519. * Gets a boolean indicating if specific vertex buffer is present
  22520. * @param kind defines the data kind (Position, normal, etc...)
  22521. * @returns true if data is present
  22522. */
  22523. isVerticesDataPresent(kind: string): boolean;
  22524. /**
  22525. * Gets a list of all attached data kinds (Position, normal, etc...)
  22526. * @returns a list of string containing all kinds
  22527. */
  22528. getVerticesDataKinds(): string[];
  22529. /**
  22530. * Update index buffer
  22531. * @param indices defines the indices to store in the index buffer
  22532. * @param offset defines the offset in the target buffer where to store the data
  22533. * @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)
  22534. */
  22535. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22536. /**
  22537. * Creates a new index buffer
  22538. * @param indices defines the indices to store in the index buffer
  22539. * @param totalVertices defines the total number of vertices (could be null)
  22540. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22541. */
  22542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22543. /**
  22544. * Return the total number of indices
  22545. * @returns the total number of indices
  22546. */
  22547. getTotalIndices(): number;
  22548. /**
  22549. * Gets the index buffer array
  22550. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22552. * @returns the index buffer array
  22553. */
  22554. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22555. /**
  22556. * Gets the index buffer
  22557. * @return the index buffer
  22558. */
  22559. getIndexBuffer(): Nullable<DataBuffer>;
  22560. /** @hidden */
  22561. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22562. /**
  22563. * Release the associated resources for a specific mesh
  22564. * @param mesh defines the source mesh
  22565. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22566. */
  22567. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22568. /**
  22569. * Apply current geometry to a given mesh
  22570. * @param mesh defines the mesh to apply geometry to
  22571. */
  22572. applyToMesh(mesh: Mesh): void;
  22573. private _updateExtend;
  22574. private _applyToMesh;
  22575. private notifyUpdate;
  22576. /**
  22577. * Load the geometry if it was flagged as delay loaded
  22578. * @param scene defines the hosting scene
  22579. * @param onLoaded defines a callback called when the geometry is loaded
  22580. */
  22581. load(scene: Scene, onLoaded?: () => void): void;
  22582. private _queueLoad;
  22583. /**
  22584. * Invert the geometry to move from a right handed system to a left handed one.
  22585. */
  22586. toLeftHanded(): void;
  22587. /** @hidden */
  22588. _resetPointsArrayCache(): void;
  22589. /** @hidden */
  22590. _generatePointsArray(): boolean;
  22591. /**
  22592. * Gets a value indicating if the geometry is disposed
  22593. * @returns true if the geometry was disposed
  22594. */
  22595. isDisposed(): boolean;
  22596. private _disposeVertexArrayObjects;
  22597. /**
  22598. * Free all associated resources
  22599. */
  22600. dispose(): void;
  22601. /**
  22602. * Clone the current geometry into a new geometry
  22603. * @param id defines the unique ID of the new geometry
  22604. * @returns a new geometry object
  22605. */
  22606. copy(id: string): Geometry;
  22607. /**
  22608. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22609. * @return a JSON representation of the current geometry data (without the vertices data)
  22610. */
  22611. serialize(): any;
  22612. private toNumberArray;
  22613. /**
  22614. * Serialize all vertices data into a JSON oject
  22615. * @returns a JSON representation of the current geometry data
  22616. */
  22617. serializeVerticeData(): any;
  22618. /**
  22619. * Extracts a clone of a mesh geometry
  22620. * @param mesh defines the source mesh
  22621. * @param id defines the unique ID of the new geometry object
  22622. * @returns the new geometry object
  22623. */
  22624. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22625. /**
  22626. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22627. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22628. * Be aware Math.random() could cause collisions, but:
  22629. * "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"
  22630. * @returns a string containing a new GUID
  22631. */
  22632. static RandomId(): string;
  22633. /** @hidden */
  22634. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22635. private static _CleanMatricesWeights;
  22636. /**
  22637. * Create a new geometry from persisted data (Using .babylon file format)
  22638. * @param parsedVertexData defines the persisted data
  22639. * @param scene defines the hosting scene
  22640. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22641. * @returns the new geometry object
  22642. */
  22643. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22644. }
  22645. }
  22646. declare module "babylonjs/Meshes/mesh.vertexData" {
  22647. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22648. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22649. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22650. import { Geometry } from "babylonjs/Meshes/geometry";
  22651. import { Mesh } from "babylonjs/Meshes/mesh";
  22652. /**
  22653. * Define an interface for all classes that will get and set the data on vertices
  22654. */
  22655. export interface IGetSetVerticesData {
  22656. /**
  22657. * Gets a boolean indicating if specific vertex data is present
  22658. * @param kind defines the vertex data kind to use
  22659. * @returns true is data kind is present
  22660. */
  22661. isVerticesDataPresent(kind: string): boolean;
  22662. /**
  22663. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22664. * @param kind defines the data kind (Position, normal, etc...)
  22665. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22666. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22667. * @returns a float array containing vertex data
  22668. */
  22669. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22670. /**
  22671. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22672. * @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.
  22673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22674. * @returns the indices array or an empty array if the mesh has no geometry
  22675. */
  22676. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22677. /**
  22678. * Set specific vertex data
  22679. * @param kind defines the data kind (Position, normal, etc...)
  22680. * @param data defines the vertex data to use
  22681. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22682. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22683. */
  22684. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22685. /**
  22686. * Update a specific associated vertex buffer
  22687. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22688. * - VertexBuffer.PositionKind
  22689. * - VertexBuffer.UVKind
  22690. * - VertexBuffer.UV2Kind
  22691. * - VertexBuffer.UV3Kind
  22692. * - VertexBuffer.UV4Kind
  22693. * - VertexBuffer.UV5Kind
  22694. * - VertexBuffer.UV6Kind
  22695. * - VertexBuffer.ColorKind
  22696. * - VertexBuffer.MatricesIndicesKind
  22697. * - VertexBuffer.MatricesIndicesExtraKind
  22698. * - VertexBuffer.MatricesWeightsKind
  22699. * - VertexBuffer.MatricesWeightsExtraKind
  22700. * @param data defines the data source
  22701. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22702. * @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)
  22703. */
  22704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22705. /**
  22706. * Creates a new index buffer
  22707. * @param indices defines the indices to store in the index buffer
  22708. * @param totalVertices defines the total number of vertices (could be null)
  22709. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22710. */
  22711. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22712. }
  22713. /**
  22714. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22715. */
  22716. export class VertexData {
  22717. /**
  22718. * Mesh side orientation : usually the external or front surface
  22719. */
  22720. static readonly FRONTSIDE: number;
  22721. /**
  22722. * Mesh side orientation : usually the internal or back surface
  22723. */
  22724. static readonly BACKSIDE: number;
  22725. /**
  22726. * Mesh side orientation : both internal and external or front and back surfaces
  22727. */
  22728. static readonly DOUBLESIDE: number;
  22729. /**
  22730. * Mesh side orientation : by default, `FRONTSIDE`
  22731. */
  22732. static readonly DEFAULTSIDE: number;
  22733. /**
  22734. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22735. */
  22736. positions: Nullable<FloatArray>;
  22737. /**
  22738. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22739. */
  22740. normals: Nullable<FloatArray>;
  22741. /**
  22742. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22743. */
  22744. tangents: Nullable<FloatArray>;
  22745. /**
  22746. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22747. */
  22748. uvs: Nullable<FloatArray>;
  22749. /**
  22750. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22751. */
  22752. uvs2: Nullable<FloatArray>;
  22753. /**
  22754. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22755. */
  22756. uvs3: Nullable<FloatArray>;
  22757. /**
  22758. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22759. */
  22760. uvs4: Nullable<FloatArray>;
  22761. /**
  22762. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22763. */
  22764. uvs5: Nullable<FloatArray>;
  22765. /**
  22766. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22767. */
  22768. uvs6: Nullable<FloatArray>;
  22769. /**
  22770. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22771. */
  22772. colors: Nullable<FloatArray>;
  22773. /**
  22774. * 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).
  22775. */
  22776. matricesIndices: Nullable<FloatArray>;
  22777. /**
  22778. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22779. */
  22780. matricesWeights: Nullable<FloatArray>;
  22781. /**
  22782. * An array extending the number of possible indices
  22783. */
  22784. matricesIndicesExtra: Nullable<FloatArray>;
  22785. /**
  22786. * An array extending the number of possible weights when the number of indices is extended
  22787. */
  22788. matricesWeightsExtra: Nullable<FloatArray>;
  22789. /**
  22790. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22791. */
  22792. indices: Nullable<IndicesArray>;
  22793. /**
  22794. * Uses the passed data array to set the set the values for the specified kind of data
  22795. * @param data a linear array of floating numbers
  22796. * @param kind the type of data that is being set, eg positions, colors etc
  22797. */
  22798. set(data: FloatArray, kind: string): void;
  22799. /**
  22800. * Associates the vertexData to the passed Mesh.
  22801. * Sets it as updatable or not (default `false`)
  22802. * @param mesh the mesh the vertexData is applied to
  22803. * @param updatable when used and having the value true allows new data to update the vertexData
  22804. * @returns the VertexData
  22805. */
  22806. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22807. /**
  22808. * Associates the vertexData to the passed Geometry.
  22809. * Sets it as updatable or not (default `false`)
  22810. * @param geometry the geometry the vertexData is applied to
  22811. * @param updatable when used and having the value true allows new data to update the vertexData
  22812. * @returns VertexData
  22813. */
  22814. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22815. /**
  22816. * Updates the associated mesh
  22817. * @param mesh the mesh to be updated
  22818. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22819. * @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
  22820. * @returns VertexData
  22821. */
  22822. updateMesh(mesh: Mesh): VertexData;
  22823. /**
  22824. * Updates the associated geometry
  22825. * @param geometry the geometry to be updated
  22826. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22827. * @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
  22828. * @returns VertexData.
  22829. */
  22830. updateGeometry(geometry: Geometry): VertexData;
  22831. private _applyTo;
  22832. private _update;
  22833. /**
  22834. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22835. * @param matrix the transforming matrix
  22836. * @returns the VertexData
  22837. */
  22838. transform(matrix: Matrix): VertexData;
  22839. /**
  22840. * Merges the passed VertexData into the current one
  22841. * @param other the VertexData to be merged into the current one
  22842. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22843. * @returns the modified VertexData
  22844. */
  22845. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22846. private _mergeElement;
  22847. private _validate;
  22848. /**
  22849. * Serializes the VertexData
  22850. * @returns a serialized object
  22851. */
  22852. serialize(): any;
  22853. /**
  22854. * Extracts the vertexData from a mesh
  22855. * @param mesh the mesh from which to extract the VertexData
  22856. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22857. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22858. * @returns the object VertexData associated to the passed mesh
  22859. */
  22860. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22861. /**
  22862. * Extracts the vertexData from the geometry
  22863. * @param geometry the geometry from which to extract the VertexData
  22864. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22866. * @returns the object VertexData associated to the passed mesh
  22867. */
  22868. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22869. private static _ExtractFrom;
  22870. /**
  22871. * Creates the VertexData for a Ribbon
  22872. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22873. * * pathArray array of paths, each of which an array of successive Vector3
  22874. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22875. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22876. * * 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
  22877. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22878. * * 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)
  22879. * * 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)
  22880. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22881. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22882. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22883. * @returns the VertexData of the ribbon
  22884. */
  22885. static CreateRibbon(options: {
  22886. pathArray: Vector3[][];
  22887. closeArray?: boolean;
  22888. closePath?: boolean;
  22889. offset?: number;
  22890. sideOrientation?: number;
  22891. frontUVs?: Vector4;
  22892. backUVs?: Vector4;
  22893. invertUV?: boolean;
  22894. uvs?: Vector2[];
  22895. colors?: Color4[];
  22896. }): VertexData;
  22897. /**
  22898. * Creates the VertexData for a box
  22899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22900. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22901. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22902. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22903. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22904. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22905. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22907. * * 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)
  22908. * * 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)
  22909. * @returns the VertexData of the box
  22910. */
  22911. static CreateBox(options: {
  22912. size?: number;
  22913. width?: number;
  22914. height?: number;
  22915. depth?: number;
  22916. faceUV?: Vector4[];
  22917. faceColors?: Color4[];
  22918. sideOrientation?: number;
  22919. frontUVs?: Vector4;
  22920. backUVs?: Vector4;
  22921. }): VertexData;
  22922. /**
  22923. * Creates the VertexData for a tiled box
  22924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22925. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22926. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22927. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22929. * @returns the VertexData of the box
  22930. */
  22931. static CreateTiledBox(options: {
  22932. pattern?: number;
  22933. width?: number;
  22934. height?: number;
  22935. depth?: number;
  22936. tileSize?: number;
  22937. tileWidth?: number;
  22938. tileHeight?: number;
  22939. alignHorizontal?: number;
  22940. alignVertical?: number;
  22941. faceUV?: Vector4[];
  22942. faceColors?: Color4[];
  22943. sideOrientation?: number;
  22944. }): VertexData;
  22945. /**
  22946. * Creates the VertexData for a tiled plane
  22947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22948. * * pattern a limited pattern arrangement depending on the number
  22949. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22950. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22951. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22952. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22953. * * 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)
  22954. * * 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)
  22955. * @returns the VertexData of the tiled plane
  22956. */
  22957. static CreateTiledPlane(options: {
  22958. pattern?: number;
  22959. tileSize?: number;
  22960. tileWidth?: number;
  22961. tileHeight?: number;
  22962. size?: number;
  22963. width?: number;
  22964. height?: number;
  22965. alignHorizontal?: number;
  22966. alignVertical?: number;
  22967. sideOrientation?: number;
  22968. frontUVs?: Vector4;
  22969. backUVs?: Vector4;
  22970. }): VertexData;
  22971. /**
  22972. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22974. * * segments sets the number of horizontal strips optional, default 32
  22975. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22976. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22977. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22978. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22979. * * 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
  22980. * * 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
  22981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22982. * * 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)
  22983. * * 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)
  22984. * @returns the VertexData of the ellipsoid
  22985. */
  22986. static CreateSphere(options: {
  22987. segments?: number;
  22988. diameter?: number;
  22989. diameterX?: number;
  22990. diameterY?: number;
  22991. diameterZ?: number;
  22992. arc?: number;
  22993. slice?: number;
  22994. sideOrientation?: number;
  22995. frontUVs?: Vector4;
  22996. backUVs?: Vector4;
  22997. }): VertexData;
  22998. /**
  22999. * Creates the VertexData for a cylinder, cone or prism
  23000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23001. * * height sets the height (y direction) of the cylinder, optional, default 2
  23002. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23003. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23004. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23005. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23006. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23007. * * 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
  23008. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23009. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23010. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23011. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23013. * * 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)
  23014. * * 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)
  23015. * @returns the VertexData of the cylinder, cone or prism
  23016. */
  23017. static CreateCylinder(options: {
  23018. height?: number;
  23019. diameterTop?: number;
  23020. diameterBottom?: number;
  23021. diameter?: number;
  23022. tessellation?: number;
  23023. subdivisions?: number;
  23024. arc?: number;
  23025. faceColors?: Color4[];
  23026. faceUV?: Vector4[];
  23027. hasRings?: boolean;
  23028. enclose?: boolean;
  23029. sideOrientation?: number;
  23030. frontUVs?: Vector4;
  23031. backUVs?: Vector4;
  23032. }): VertexData;
  23033. /**
  23034. * Creates the VertexData for a torus
  23035. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23036. * * diameter the diameter of the torus, optional default 1
  23037. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23038. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23040. * * 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)
  23041. * * 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)
  23042. * @returns the VertexData of the torus
  23043. */
  23044. static CreateTorus(options: {
  23045. diameter?: number;
  23046. thickness?: number;
  23047. tessellation?: number;
  23048. sideOrientation?: number;
  23049. frontUVs?: Vector4;
  23050. backUVs?: Vector4;
  23051. }): VertexData;
  23052. /**
  23053. * Creates the VertexData of the LineSystem
  23054. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23055. * - lines an array of lines, each line being an array of successive Vector3
  23056. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23057. * @returns the VertexData of the LineSystem
  23058. */
  23059. static CreateLineSystem(options: {
  23060. lines: Vector3[][];
  23061. colors?: Nullable<Color4[][]>;
  23062. }): VertexData;
  23063. /**
  23064. * Create the VertexData for a DashedLines
  23065. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23066. * - points an array successive Vector3
  23067. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23068. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23069. * - dashNb the intended total number of dashes, optional, default 200
  23070. * @returns the VertexData for the DashedLines
  23071. */
  23072. static CreateDashedLines(options: {
  23073. points: Vector3[];
  23074. dashSize?: number;
  23075. gapSize?: number;
  23076. dashNb?: number;
  23077. }): VertexData;
  23078. /**
  23079. * Creates the VertexData for a Ground
  23080. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23081. * - width the width (x direction) of the ground, optional, default 1
  23082. * - height the height (z direction) of the ground, optional, default 1
  23083. * - subdivisions the number of subdivisions per side, optional, default 1
  23084. * @returns the VertexData of the Ground
  23085. */
  23086. static CreateGround(options: {
  23087. width?: number;
  23088. height?: number;
  23089. subdivisions?: number;
  23090. subdivisionsX?: number;
  23091. subdivisionsY?: number;
  23092. }): VertexData;
  23093. /**
  23094. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23095. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23096. * * xmin the ground minimum X coordinate, optional, default -1
  23097. * * zmin the ground minimum Z coordinate, optional, default -1
  23098. * * xmax the ground maximum X coordinate, optional, default 1
  23099. * * zmax the ground maximum Z coordinate, optional, default 1
  23100. * * 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}
  23101. * * 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}
  23102. * @returns the VertexData of the TiledGround
  23103. */
  23104. static CreateTiledGround(options: {
  23105. xmin: number;
  23106. zmin: number;
  23107. xmax: number;
  23108. zmax: number;
  23109. subdivisions?: {
  23110. w: number;
  23111. h: number;
  23112. };
  23113. precision?: {
  23114. w: number;
  23115. h: number;
  23116. };
  23117. }): VertexData;
  23118. /**
  23119. * Creates the VertexData of the Ground designed from a heightmap
  23120. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23121. * * width the width (x direction) of the ground
  23122. * * height the height (z direction) of the ground
  23123. * * subdivisions the number of subdivisions per side
  23124. * * minHeight the minimum altitude on the ground, optional, default 0
  23125. * * maxHeight the maximum altitude on the ground, optional default 1
  23126. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23127. * * buffer the array holding the image color data
  23128. * * bufferWidth the width of image
  23129. * * bufferHeight the height of image
  23130. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23131. * @returns the VertexData of the Ground designed from a heightmap
  23132. */
  23133. static CreateGroundFromHeightMap(options: {
  23134. width: number;
  23135. height: number;
  23136. subdivisions: number;
  23137. minHeight: number;
  23138. maxHeight: number;
  23139. colorFilter: Color3;
  23140. buffer: Uint8Array;
  23141. bufferWidth: number;
  23142. bufferHeight: number;
  23143. alphaFilter: number;
  23144. }): VertexData;
  23145. /**
  23146. * Creates the VertexData for a Plane
  23147. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23148. * * size sets the width and height of the plane to the value of size, optional default 1
  23149. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23150. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23152. * * 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)
  23153. * * 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)
  23154. * @returns the VertexData of the box
  23155. */
  23156. static CreatePlane(options: {
  23157. size?: number;
  23158. width?: number;
  23159. height?: number;
  23160. sideOrientation?: number;
  23161. frontUVs?: Vector4;
  23162. backUVs?: Vector4;
  23163. }): VertexData;
  23164. /**
  23165. * Creates the VertexData of the Disc or regular Polygon
  23166. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23167. * * radius the radius of the disc, optional default 0.5
  23168. * * tessellation the number of polygon sides, optional, default 64
  23169. * * 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
  23170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23171. * * 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)
  23172. * * 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)
  23173. * @returns the VertexData of the box
  23174. */
  23175. static CreateDisc(options: {
  23176. radius?: number;
  23177. tessellation?: number;
  23178. arc?: number;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }): VertexData;
  23183. /**
  23184. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23185. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23186. * @param polygon a mesh built from polygonTriangulation.build()
  23187. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23188. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23189. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23190. * @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)
  23191. * @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)
  23192. * @returns the VertexData of the Polygon
  23193. */
  23194. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23195. /**
  23196. * Creates the VertexData of the IcoSphere
  23197. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23198. * * radius the radius of the IcoSphere, optional default 1
  23199. * * radiusX allows stretching in the x direction, optional, default radius
  23200. * * radiusY allows stretching in the y direction, optional, default radius
  23201. * * radiusZ allows stretching in the z direction, optional, default radius
  23202. * * flat when true creates a flat shaded mesh, optional, default true
  23203. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23205. * * 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)
  23206. * * 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)
  23207. * @returns the VertexData of the IcoSphere
  23208. */
  23209. static CreateIcoSphere(options: {
  23210. radius?: number;
  23211. radiusX?: number;
  23212. radiusY?: number;
  23213. radiusZ?: number;
  23214. flat?: boolean;
  23215. subdivisions?: number;
  23216. sideOrientation?: number;
  23217. frontUVs?: Vector4;
  23218. backUVs?: Vector4;
  23219. }): VertexData;
  23220. /**
  23221. * Creates the VertexData for a Polyhedron
  23222. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23223. * * type provided types are:
  23224. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23225. * * 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)
  23226. * * size the size of the IcoSphere, optional default 1
  23227. * * sizeX allows stretching in the x direction, optional, default size
  23228. * * sizeY allows stretching in the y direction, optional, default size
  23229. * * sizeZ allows stretching in the z direction, optional, default size
  23230. * * 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
  23231. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23232. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23233. * * flat when true creates a flat shaded mesh, optional, default true
  23234. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23235. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23236. * * 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)
  23237. * * 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)
  23238. * @returns the VertexData of the Polyhedron
  23239. */
  23240. static CreatePolyhedron(options: {
  23241. type?: number;
  23242. size?: number;
  23243. sizeX?: number;
  23244. sizeY?: number;
  23245. sizeZ?: number;
  23246. custom?: any;
  23247. faceUV?: Vector4[];
  23248. faceColors?: Color4[];
  23249. flat?: boolean;
  23250. sideOrientation?: number;
  23251. frontUVs?: Vector4;
  23252. backUVs?: Vector4;
  23253. }): VertexData;
  23254. /**
  23255. * Creates the VertexData for a TorusKnot
  23256. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23257. * * radius the radius of the torus knot, optional, default 2
  23258. * * tube the thickness of the tube, optional, default 0.5
  23259. * * radialSegments the number of sides on each tube segments, optional, default 32
  23260. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23261. * * p the number of windings around the z axis, optional, default 2
  23262. * * q the number of windings around the x axis, optional, default 3
  23263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23264. * * 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)
  23265. * * 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)
  23266. * @returns the VertexData of the Torus Knot
  23267. */
  23268. static CreateTorusKnot(options: {
  23269. radius?: number;
  23270. tube?: number;
  23271. radialSegments?: number;
  23272. tubularSegments?: number;
  23273. p?: number;
  23274. q?: number;
  23275. sideOrientation?: number;
  23276. frontUVs?: Vector4;
  23277. backUVs?: Vector4;
  23278. }): VertexData;
  23279. /**
  23280. * Compute normals for given positions and indices
  23281. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23282. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23283. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23284. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23285. * * facetNormals : optional array of facet normals (vector3)
  23286. * * facetPositions : optional array of facet positions (vector3)
  23287. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23288. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23289. * * bInfo : optional bounding info, required for facetPartitioning computation
  23290. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23291. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23292. * * useRightHandedSystem: optional boolean to for right handed system computation
  23293. * * depthSort : optional boolean to enable the facet depth sort computation
  23294. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23295. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23296. */
  23297. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23298. facetNormals?: any;
  23299. facetPositions?: any;
  23300. facetPartitioning?: any;
  23301. ratio?: number;
  23302. bInfo?: any;
  23303. bbSize?: Vector3;
  23304. subDiv?: any;
  23305. useRightHandedSystem?: boolean;
  23306. depthSort?: boolean;
  23307. distanceTo?: Vector3;
  23308. depthSortedFacets?: any;
  23309. }): void;
  23310. /** @hidden */
  23311. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23312. /**
  23313. * Applies VertexData created from the imported parameters to the geometry
  23314. * @param parsedVertexData the parsed data from an imported file
  23315. * @param geometry the geometry to apply the VertexData to
  23316. */
  23317. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23318. }
  23319. }
  23320. declare module "babylonjs/Morph/morphTarget" {
  23321. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23322. import { Observable } from "babylonjs/Misc/observable";
  23323. import { Nullable, FloatArray } from "babylonjs/types";
  23324. import { Scene } from "babylonjs/scene";
  23325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23326. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23327. /**
  23328. * Defines a target to use with MorphTargetManager
  23329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23330. */
  23331. export class MorphTarget implements IAnimatable {
  23332. /** defines the name of the target */
  23333. name: string;
  23334. /**
  23335. * Gets or sets the list of animations
  23336. */
  23337. animations: import("babylonjs/Animations/animation").Animation[];
  23338. private _scene;
  23339. private _positions;
  23340. private _normals;
  23341. private _tangents;
  23342. private _uvs;
  23343. private _influence;
  23344. private _uniqueId;
  23345. /**
  23346. * Observable raised when the influence changes
  23347. */
  23348. onInfluenceChanged: Observable<boolean>;
  23349. /** @hidden */
  23350. _onDataLayoutChanged: Observable<void>;
  23351. /**
  23352. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23353. */
  23354. get influence(): number;
  23355. set influence(influence: number);
  23356. /**
  23357. * Gets or sets the id of the morph Target
  23358. */
  23359. id: string;
  23360. private _animationPropertiesOverride;
  23361. /**
  23362. * Gets or sets the animation properties override
  23363. */
  23364. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23365. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23366. /**
  23367. * Creates a new MorphTarget
  23368. * @param name defines the name of the target
  23369. * @param influence defines the influence to use
  23370. * @param scene defines the scene the morphtarget belongs to
  23371. */
  23372. constructor(
  23373. /** defines the name of the target */
  23374. name: string, influence?: number, scene?: Nullable<Scene>);
  23375. /**
  23376. * Gets the unique ID of this manager
  23377. */
  23378. get uniqueId(): number;
  23379. /**
  23380. * Gets a boolean defining if the target contains position data
  23381. */
  23382. get hasPositions(): boolean;
  23383. /**
  23384. * Gets a boolean defining if the target contains normal data
  23385. */
  23386. get hasNormals(): boolean;
  23387. /**
  23388. * Gets a boolean defining if the target contains tangent data
  23389. */
  23390. get hasTangents(): boolean;
  23391. /**
  23392. * Gets a boolean defining if the target contains texture coordinates data
  23393. */
  23394. get hasUVs(): boolean;
  23395. /**
  23396. * Affects position data to this target
  23397. * @param data defines the position data to use
  23398. */
  23399. setPositions(data: Nullable<FloatArray>): void;
  23400. /**
  23401. * Gets the position data stored in this target
  23402. * @returns a FloatArray containing the position data (or null if not present)
  23403. */
  23404. getPositions(): Nullable<FloatArray>;
  23405. /**
  23406. * Affects normal data to this target
  23407. * @param data defines the normal data to use
  23408. */
  23409. setNormals(data: Nullable<FloatArray>): void;
  23410. /**
  23411. * Gets the normal data stored in this target
  23412. * @returns a FloatArray containing the normal data (or null if not present)
  23413. */
  23414. getNormals(): Nullable<FloatArray>;
  23415. /**
  23416. * Affects tangent data to this target
  23417. * @param data defines the tangent data to use
  23418. */
  23419. setTangents(data: Nullable<FloatArray>): void;
  23420. /**
  23421. * Gets the tangent data stored in this target
  23422. * @returns a FloatArray containing the tangent data (or null if not present)
  23423. */
  23424. getTangents(): Nullable<FloatArray>;
  23425. /**
  23426. * Affects texture coordinates data to this target
  23427. * @param data defines the texture coordinates data to use
  23428. */
  23429. setUVs(data: Nullable<FloatArray>): void;
  23430. /**
  23431. * Gets the texture coordinates data stored in this target
  23432. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23433. */
  23434. getUVs(): Nullable<FloatArray>;
  23435. /**
  23436. * Clone the current target
  23437. * @returns a new MorphTarget
  23438. */
  23439. clone(): MorphTarget;
  23440. /**
  23441. * Serializes the current target into a Serialization object
  23442. * @returns the serialized object
  23443. */
  23444. serialize(): any;
  23445. /**
  23446. * Returns the string "MorphTarget"
  23447. * @returns "MorphTarget"
  23448. */
  23449. getClassName(): string;
  23450. /**
  23451. * Creates a new target from serialized data
  23452. * @param serializationObject defines the serialized data to use
  23453. * @returns a new MorphTarget
  23454. */
  23455. static Parse(serializationObject: any): MorphTarget;
  23456. /**
  23457. * Creates a MorphTarget from mesh data
  23458. * @param mesh defines the source mesh
  23459. * @param name defines the name to use for the new target
  23460. * @param influence defines the influence to attach to the target
  23461. * @returns a new MorphTarget
  23462. */
  23463. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23464. }
  23465. }
  23466. declare module "babylonjs/Morph/morphTargetManager" {
  23467. import { Nullable } from "babylonjs/types";
  23468. import { Scene } from "babylonjs/scene";
  23469. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23470. /**
  23471. * This class is used to deform meshes using morphing between different targets
  23472. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23473. */
  23474. export class MorphTargetManager {
  23475. private _targets;
  23476. private _targetInfluenceChangedObservers;
  23477. private _targetDataLayoutChangedObservers;
  23478. private _activeTargets;
  23479. private _scene;
  23480. private _influences;
  23481. private _supportsNormals;
  23482. private _supportsTangents;
  23483. private _supportsUVs;
  23484. private _vertexCount;
  23485. private _uniqueId;
  23486. private _tempInfluences;
  23487. /**
  23488. * Gets or sets a boolean indicating if normals must be morphed
  23489. */
  23490. enableNormalMorphing: boolean;
  23491. /**
  23492. * Gets or sets a boolean indicating if tangents must be morphed
  23493. */
  23494. enableTangentMorphing: boolean;
  23495. /**
  23496. * Gets or sets a boolean indicating if UV must be morphed
  23497. */
  23498. enableUVMorphing: boolean;
  23499. /**
  23500. * Creates a new MorphTargetManager
  23501. * @param scene defines the current scene
  23502. */
  23503. constructor(scene?: Nullable<Scene>);
  23504. /**
  23505. * Gets the unique ID of this manager
  23506. */
  23507. get uniqueId(): number;
  23508. /**
  23509. * Gets the number of vertices handled by this manager
  23510. */
  23511. get vertexCount(): number;
  23512. /**
  23513. * Gets a boolean indicating if this manager supports morphing of normals
  23514. */
  23515. get supportsNormals(): boolean;
  23516. /**
  23517. * Gets a boolean indicating if this manager supports morphing of tangents
  23518. */
  23519. get supportsTangents(): boolean;
  23520. /**
  23521. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23522. */
  23523. get supportsUVs(): boolean;
  23524. /**
  23525. * Gets the number of targets stored in this manager
  23526. */
  23527. get numTargets(): number;
  23528. /**
  23529. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23530. */
  23531. get numInfluencers(): number;
  23532. /**
  23533. * Gets the list of influences (one per target)
  23534. */
  23535. get influences(): Float32Array;
  23536. /**
  23537. * Gets the active target at specified index. An active target is a target with an influence > 0
  23538. * @param index defines the index to check
  23539. * @returns the requested target
  23540. */
  23541. getActiveTarget(index: number): MorphTarget;
  23542. /**
  23543. * Gets the target at specified index
  23544. * @param index defines the index to check
  23545. * @returns the requested target
  23546. */
  23547. getTarget(index: number): MorphTarget;
  23548. /**
  23549. * Add a new target to this manager
  23550. * @param target defines the target to add
  23551. */
  23552. addTarget(target: MorphTarget): void;
  23553. /**
  23554. * Removes a target from the manager
  23555. * @param target defines the target to remove
  23556. */
  23557. removeTarget(target: MorphTarget): void;
  23558. /**
  23559. * Clone the current manager
  23560. * @returns a new MorphTargetManager
  23561. */
  23562. clone(): MorphTargetManager;
  23563. /**
  23564. * Serializes the current manager into a Serialization object
  23565. * @returns the serialized object
  23566. */
  23567. serialize(): any;
  23568. private _syncActiveTargets;
  23569. /**
  23570. * Syncrhonize the targets with all the meshes using this morph target manager
  23571. */
  23572. synchronize(): void;
  23573. /**
  23574. * Creates a new MorphTargetManager from serialized data
  23575. * @param serializationObject defines the serialized data
  23576. * @param scene defines the hosting scene
  23577. * @returns the new MorphTargetManager
  23578. */
  23579. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23580. }
  23581. }
  23582. declare module "babylonjs/Meshes/meshLODLevel" {
  23583. import { Mesh } from "babylonjs/Meshes/mesh";
  23584. import { Nullable } from "babylonjs/types";
  23585. /**
  23586. * Class used to represent a specific level of detail of a mesh
  23587. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23588. */
  23589. export class MeshLODLevel {
  23590. /** Defines the distance where this level should start being displayed */
  23591. distance: number;
  23592. /** Defines the mesh to use to render this level */
  23593. mesh: Nullable<Mesh>;
  23594. /**
  23595. * Creates a new LOD level
  23596. * @param distance defines the distance where this level should star being displayed
  23597. * @param mesh defines the mesh to use to render this level
  23598. */
  23599. constructor(
  23600. /** Defines the distance where this level should start being displayed */
  23601. distance: number,
  23602. /** Defines the mesh to use to render this level */
  23603. mesh: Nullable<Mesh>);
  23604. }
  23605. }
  23606. declare module "babylonjs/Meshes/groundMesh" {
  23607. import { Scene } from "babylonjs/scene";
  23608. import { Vector3 } from "babylonjs/Maths/math.vector";
  23609. import { Mesh } from "babylonjs/Meshes/mesh";
  23610. /**
  23611. * Mesh representing the gorund
  23612. */
  23613. export class GroundMesh extends Mesh {
  23614. /** If octree should be generated */
  23615. generateOctree: boolean;
  23616. private _heightQuads;
  23617. /** @hidden */
  23618. _subdivisionsX: number;
  23619. /** @hidden */
  23620. _subdivisionsY: number;
  23621. /** @hidden */
  23622. _width: number;
  23623. /** @hidden */
  23624. _height: number;
  23625. /** @hidden */
  23626. _minX: number;
  23627. /** @hidden */
  23628. _maxX: number;
  23629. /** @hidden */
  23630. _minZ: number;
  23631. /** @hidden */
  23632. _maxZ: number;
  23633. constructor(name: string, scene: Scene);
  23634. /**
  23635. * "GroundMesh"
  23636. * @returns "GroundMesh"
  23637. */
  23638. getClassName(): string;
  23639. /**
  23640. * The minimum of x and y subdivisions
  23641. */
  23642. get subdivisions(): number;
  23643. /**
  23644. * X subdivisions
  23645. */
  23646. get subdivisionsX(): number;
  23647. /**
  23648. * Y subdivisions
  23649. */
  23650. get subdivisionsY(): number;
  23651. /**
  23652. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23653. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23654. * @param chunksCount the number of subdivisions for x and y
  23655. * @param octreeBlocksSize (Default: 32)
  23656. */
  23657. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23658. /**
  23659. * Returns a height (y) value in the Worl system :
  23660. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23661. * @param x x coordinate
  23662. * @param z z coordinate
  23663. * @returns the ground y position if (x, z) are outside the ground surface.
  23664. */
  23665. getHeightAtCoordinates(x: number, z: number): number;
  23666. /**
  23667. * Returns a normalized vector (Vector3) orthogonal to the ground
  23668. * at the ground coordinates (x, z) expressed in the World system.
  23669. * @param x x coordinate
  23670. * @param z z coordinate
  23671. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23672. */
  23673. getNormalAtCoordinates(x: number, z: number): Vector3;
  23674. /**
  23675. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23676. * at the ground coordinates (x, z) expressed in the World system.
  23677. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23678. * @param x x coordinate
  23679. * @param z z coordinate
  23680. * @param ref vector to store the result
  23681. * @returns the GroundMesh.
  23682. */
  23683. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23684. /**
  23685. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23686. * if the ground has been updated.
  23687. * This can be used in the render loop.
  23688. * @returns the GroundMesh.
  23689. */
  23690. updateCoordinateHeights(): GroundMesh;
  23691. private _getFacetAt;
  23692. private _initHeightQuads;
  23693. private _computeHeightQuads;
  23694. /**
  23695. * Serializes this ground mesh
  23696. * @param serializationObject object to write serialization to
  23697. */
  23698. serialize(serializationObject: any): void;
  23699. /**
  23700. * Parses a serialized ground mesh
  23701. * @param parsedMesh the serialized mesh
  23702. * @param scene the scene to create the ground mesh in
  23703. * @returns the created ground mesh
  23704. */
  23705. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23706. }
  23707. }
  23708. declare module "babylonjs/Physics/physicsJoint" {
  23709. import { Vector3 } from "babylonjs/Maths/math.vector";
  23710. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23711. /**
  23712. * Interface for Physics-Joint data
  23713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23714. */
  23715. export interface PhysicsJointData {
  23716. /**
  23717. * The main pivot of the joint
  23718. */
  23719. mainPivot?: Vector3;
  23720. /**
  23721. * The connected pivot of the joint
  23722. */
  23723. connectedPivot?: Vector3;
  23724. /**
  23725. * The main axis of the joint
  23726. */
  23727. mainAxis?: Vector3;
  23728. /**
  23729. * The connected axis of the joint
  23730. */
  23731. connectedAxis?: Vector3;
  23732. /**
  23733. * The collision of the joint
  23734. */
  23735. collision?: boolean;
  23736. /**
  23737. * Native Oimo/Cannon/Energy data
  23738. */
  23739. nativeParams?: any;
  23740. }
  23741. /**
  23742. * This is a holder class for the physics joint created by the physics plugin
  23743. * It holds a set of functions to control the underlying joint
  23744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23745. */
  23746. export class PhysicsJoint {
  23747. /**
  23748. * The type of the physics joint
  23749. */
  23750. type: number;
  23751. /**
  23752. * The data for the physics joint
  23753. */
  23754. jointData: PhysicsJointData;
  23755. private _physicsJoint;
  23756. protected _physicsPlugin: IPhysicsEnginePlugin;
  23757. /**
  23758. * Initializes the physics joint
  23759. * @param type The type of the physics joint
  23760. * @param jointData The data for the physics joint
  23761. */
  23762. constructor(
  23763. /**
  23764. * The type of the physics joint
  23765. */
  23766. type: number,
  23767. /**
  23768. * The data for the physics joint
  23769. */
  23770. jointData: PhysicsJointData);
  23771. /**
  23772. * Gets the physics joint
  23773. */
  23774. get physicsJoint(): any;
  23775. /**
  23776. * Sets the physics joint
  23777. */
  23778. set physicsJoint(newJoint: any);
  23779. /**
  23780. * Sets the physics plugin
  23781. */
  23782. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23783. /**
  23784. * Execute a function that is physics-plugin specific.
  23785. * @param {Function} func the function that will be executed.
  23786. * It accepts two parameters: the physics world and the physics joint
  23787. */
  23788. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23789. /**
  23790. * Distance-Joint type
  23791. */
  23792. static DistanceJoint: number;
  23793. /**
  23794. * Hinge-Joint type
  23795. */
  23796. static HingeJoint: number;
  23797. /**
  23798. * Ball-and-Socket joint type
  23799. */
  23800. static BallAndSocketJoint: number;
  23801. /**
  23802. * Wheel-Joint type
  23803. */
  23804. static WheelJoint: number;
  23805. /**
  23806. * Slider-Joint type
  23807. */
  23808. static SliderJoint: number;
  23809. /**
  23810. * Prismatic-Joint type
  23811. */
  23812. static PrismaticJoint: number;
  23813. /**
  23814. * Universal-Joint type
  23815. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23816. */
  23817. static UniversalJoint: number;
  23818. /**
  23819. * Hinge-Joint 2 type
  23820. */
  23821. static Hinge2Joint: number;
  23822. /**
  23823. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23824. */
  23825. static PointToPointJoint: number;
  23826. /**
  23827. * Spring-Joint type
  23828. */
  23829. static SpringJoint: number;
  23830. /**
  23831. * Lock-Joint type
  23832. */
  23833. static LockJoint: number;
  23834. }
  23835. /**
  23836. * A class representing a physics distance joint
  23837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23838. */
  23839. export class DistanceJoint extends PhysicsJoint {
  23840. /**
  23841. *
  23842. * @param jointData The data for the Distance-Joint
  23843. */
  23844. constructor(jointData: DistanceJointData);
  23845. /**
  23846. * Update the predefined distance.
  23847. * @param maxDistance The maximum preferred distance
  23848. * @param minDistance The minimum preferred distance
  23849. */
  23850. updateDistance(maxDistance: number, minDistance?: number): void;
  23851. }
  23852. /**
  23853. * Represents a Motor-Enabled Joint
  23854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23855. */
  23856. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23857. /**
  23858. * Initializes the Motor-Enabled Joint
  23859. * @param type The type of the joint
  23860. * @param jointData The physica joint data for the joint
  23861. */
  23862. constructor(type: number, jointData: PhysicsJointData);
  23863. /**
  23864. * Set the motor values.
  23865. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23866. * @param force the force to apply
  23867. * @param maxForce max force for this motor.
  23868. */
  23869. setMotor(force?: number, maxForce?: number): void;
  23870. /**
  23871. * Set the motor's limits.
  23872. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23873. * @param upperLimit The upper limit of the motor
  23874. * @param lowerLimit The lower limit of the motor
  23875. */
  23876. setLimit(upperLimit: number, lowerLimit?: number): void;
  23877. }
  23878. /**
  23879. * This class represents a single physics Hinge-Joint
  23880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23881. */
  23882. export class HingeJoint extends MotorEnabledJoint {
  23883. /**
  23884. * Initializes the Hinge-Joint
  23885. * @param jointData The joint data for the Hinge-Joint
  23886. */
  23887. constructor(jointData: PhysicsJointData);
  23888. /**
  23889. * Set the motor values.
  23890. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23891. * @param {number} force the force to apply
  23892. * @param {number} maxForce max force for this motor.
  23893. */
  23894. setMotor(force?: number, maxForce?: number): void;
  23895. /**
  23896. * Set the motor's limits.
  23897. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23898. * @param upperLimit The upper limit of the motor
  23899. * @param lowerLimit The lower limit of the motor
  23900. */
  23901. setLimit(upperLimit: number, lowerLimit?: number): void;
  23902. }
  23903. /**
  23904. * This class represents a dual hinge physics joint (same as wheel joint)
  23905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23906. */
  23907. export class Hinge2Joint extends MotorEnabledJoint {
  23908. /**
  23909. * Initializes the Hinge2-Joint
  23910. * @param jointData The joint data for the Hinge2-Joint
  23911. */
  23912. constructor(jointData: PhysicsJointData);
  23913. /**
  23914. * Set the motor values.
  23915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23916. * @param {number} targetSpeed the speed the motor is to reach
  23917. * @param {number} maxForce max force for this motor.
  23918. * @param {motorIndex} the motor's index, 0 or 1.
  23919. */
  23920. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23921. /**
  23922. * Set the motor limits.
  23923. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23924. * @param {number} upperLimit the upper limit
  23925. * @param {number} lowerLimit lower limit
  23926. * @param {motorIndex} the motor's index, 0 or 1.
  23927. */
  23928. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23929. }
  23930. /**
  23931. * Interface for a motor enabled joint
  23932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23933. */
  23934. export interface IMotorEnabledJoint {
  23935. /**
  23936. * Physics joint
  23937. */
  23938. physicsJoint: any;
  23939. /**
  23940. * Sets the motor of the motor-enabled joint
  23941. * @param force The force of the motor
  23942. * @param maxForce The maximum force of the motor
  23943. * @param motorIndex The index of the motor
  23944. */
  23945. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23946. /**
  23947. * Sets the limit of the motor
  23948. * @param upperLimit The upper limit of the motor
  23949. * @param lowerLimit The lower limit of the motor
  23950. * @param motorIndex The index of the motor
  23951. */
  23952. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23953. }
  23954. /**
  23955. * Joint data for a Distance-Joint
  23956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23957. */
  23958. export interface DistanceJointData extends PhysicsJointData {
  23959. /**
  23960. * Max distance the 2 joint objects can be apart
  23961. */
  23962. maxDistance: number;
  23963. }
  23964. /**
  23965. * Joint data from a spring joint
  23966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23967. */
  23968. export interface SpringJointData extends PhysicsJointData {
  23969. /**
  23970. * Length of the spring
  23971. */
  23972. length: number;
  23973. /**
  23974. * Stiffness of the spring
  23975. */
  23976. stiffness: number;
  23977. /**
  23978. * Damping of the spring
  23979. */
  23980. damping: number;
  23981. /** this callback will be called when applying the force to the impostors. */
  23982. forceApplicationCallback: () => void;
  23983. }
  23984. }
  23985. declare module "babylonjs/Physics/physicsRaycastResult" {
  23986. import { Vector3 } from "babylonjs/Maths/math.vector";
  23987. /**
  23988. * Holds the data for the raycast result
  23989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23990. */
  23991. export class PhysicsRaycastResult {
  23992. private _hasHit;
  23993. private _hitDistance;
  23994. private _hitNormalWorld;
  23995. private _hitPointWorld;
  23996. private _rayFromWorld;
  23997. private _rayToWorld;
  23998. /**
  23999. * Gets if there was a hit
  24000. */
  24001. get hasHit(): boolean;
  24002. /**
  24003. * Gets the distance from the hit
  24004. */
  24005. get hitDistance(): number;
  24006. /**
  24007. * Gets the hit normal/direction in the world
  24008. */
  24009. get hitNormalWorld(): Vector3;
  24010. /**
  24011. * Gets the hit point in the world
  24012. */
  24013. get hitPointWorld(): Vector3;
  24014. /**
  24015. * Gets the ray "start point" of the ray in the world
  24016. */
  24017. get rayFromWorld(): Vector3;
  24018. /**
  24019. * Gets the ray "end point" of the ray in the world
  24020. */
  24021. get rayToWorld(): Vector3;
  24022. /**
  24023. * Sets the hit data (normal & point in world space)
  24024. * @param hitNormalWorld defines the normal in world space
  24025. * @param hitPointWorld defines the point in world space
  24026. */
  24027. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24028. /**
  24029. * Sets the distance from the start point to the hit point
  24030. * @param distance
  24031. */
  24032. setHitDistance(distance: number): void;
  24033. /**
  24034. * Calculates the distance manually
  24035. */
  24036. calculateHitDistance(): void;
  24037. /**
  24038. * Resets all the values to default
  24039. * @param from The from point on world space
  24040. * @param to The to point on world space
  24041. */
  24042. reset(from?: Vector3, to?: Vector3): void;
  24043. }
  24044. /**
  24045. * Interface for the size containing width and height
  24046. */
  24047. interface IXYZ {
  24048. /**
  24049. * X
  24050. */
  24051. x: number;
  24052. /**
  24053. * Y
  24054. */
  24055. y: number;
  24056. /**
  24057. * Z
  24058. */
  24059. z: number;
  24060. }
  24061. }
  24062. declare module "babylonjs/Physics/IPhysicsEngine" {
  24063. import { Nullable } from "babylonjs/types";
  24064. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24066. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24067. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24068. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24069. /**
  24070. * Interface used to describe a physics joint
  24071. */
  24072. export interface PhysicsImpostorJoint {
  24073. /** Defines the main impostor to which the joint is linked */
  24074. mainImpostor: PhysicsImpostor;
  24075. /** Defines the impostor that is connected to the main impostor using this joint */
  24076. connectedImpostor: PhysicsImpostor;
  24077. /** Defines the joint itself */
  24078. joint: PhysicsJoint;
  24079. }
  24080. /** @hidden */
  24081. export interface IPhysicsEnginePlugin {
  24082. world: any;
  24083. name: string;
  24084. setGravity(gravity: Vector3): void;
  24085. setTimeStep(timeStep: number): void;
  24086. getTimeStep(): number;
  24087. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24088. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24089. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24090. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24091. removePhysicsBody(impostor: PhysicsImpostor): void;
  24092. generateJoint(joint: PhysicsImpostorJoint): void;
  24093. removeJoint(joint: PhysicsImpostorJoint): void;
  24094. isSupported(): boolean;
  24095. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24096. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24102. getBodyMass(impostor: PhysicsImpostor): number;
  24103. getBodyFriction(impostor: PhysicsImpostor): number;
  24104. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24105. getBodyRestitution(impostor: PhysicsImpostor): number;
  24106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24107. getBodyPressure?(impostor: PhysicsImpostor): number;
  24108. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24109. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24110. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24111. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24112. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24113. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24114. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24115. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24116. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24117. sleepBody(impostor: PhysicsImpostor): void;
  24118. wakeUpBody(impostor: PhysicsImpostor): void;
  24119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24120. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24121. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24122. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24123. getRadius(impostor: PhysicsImpostor): number;
  24124. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24125. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24126. dispose(): void;
  24127. }
  24128. /**
  24129. * Interface used to define a physics engine
  24130. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24131. */
  24132. export interface IPhysicsEngine {
  24133. /**
  24134. * Gets the gravity vector used by the simulation
  24135. */
  24136. gravity: Vector3;
  24137. /**
  24138. * Sets the gravity vector used by the simulation
  24139. * @param gravity defines the gravity vector to use
  24140. */
  24141. setGravity(gravity: Vector3): void;
  24142. /**
  24143. * Set the time step of the physics engine.
  24144. * Default is 1/60.
  24145. * To slow it down, enter 1/600 for example.
  24146. * To speed it up, 1/30
  24147. * @param newTimeStep the new timestep to apply to this world.
  24148. */
  24149. setTimeStep(newTimeStep: number): void;
  24150. /**
  24151. * Get the time step of the physics engine.
  24152. * @returns the current time step
  24153. */
  24154. getTimeStep(): number;
  24155. /**
  24156. * Set the sub time step of the physics engine.
  24157. * Default is 0 meaning there is no sub steps
  24158. * To increase physics resolution precision, set a small value (like 1 ms)
  24159. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24160. */
  24161. setSubTimeStep(subTimeStep: number): void;
  24162. /**
  24163. * Get the sub time step of the physics engine.
  24164. * @returns the current sub time step
  24165. */
  24166. getSubTimeStep(): number;
  24167. /**
  24168. * Release all resources
  24169. */
  24170. dispose(): void;
  24171. /**
  24172. * Gets the name of the current physics plugin
  24173. * @returns the name of the plugin
  24174. */
  24175. getPhysicsPluginName(): string;
  24176. /**
  24177. * Adding a new impostor for the impostor tracking.
  24178. * This will be done by the impostor itself.
  24179. * @param impostor the impostor to add
  24180. */
  24181. addImpostor(impostor: PhysicsImpostor): void;
  24182. /**
  24183. * Remove an impostor from the engine.
  24184. * This impostor and its mesh will not longer be updated by the physics engine.
  24185. * @param impostor the impostor to remove
  24186. */
  24187. removeImpostor(impostor: PhysicsImpostor): void;
  24188. /**
  24189. * Add a joint to the physics engine
  24190. * @param mainImpostor defines the main impostor to which the joint is added.
  24191. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24192. * @param joint defines the joint that will connect both impostors.
  24193. */
  24194. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24195. /**
  24196. * Removes a joint from the simulation
  24197. * @param mainImpostor defines the impostor used with the joint
  24198. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24199. * @param joint defines the joint to remove
  24200. */
  24201. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24202. /**
  24203. * Gets the current plugin used to run the simulation
  24204. * @returns current plugin
  24205. */
  24206. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24207. /**
  24208. * Gets the list of physic impostors
  24209. * @returns an array of PhysicsImpostor
  24210. */
  24211. getImpostors(): Array<PhysicsImpostor>;
  24212. /**
  24213. * Gets the impostor for a physics enabled object
  24214. * @param object defines the object impersonated by the impostor
  24215. * @returns the PhysicsImpostor or null if not found
  24216. */
  24217. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24218. /**
  24219. * Gets the impostor for a physics body object
  24220. * @param body defines physics body used by the impostor
  24221. * @returns the PhysicsImpostor or null if not found
  24222. */
  24223. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24224. /**
  24225. * Does a raycast in the physics world
  24226. * @param from when should the ray start?
  24227. * @param to when should the ray end?
  24228. * @returns PhysicsRaycastResult
  24229. */
  24230. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24231. /**
  24232. * Called by the scene. No need to call it.
  24233. * @param delta defines the timespam between frames
  24234. */
  24235. _step(delta: number): void;
  24236. }
  24237. }
  24238. declare module "babylonjs/Physics/physicsImpostor" {
  24239. import { Nullable, IndicesArray } from "babylonjs/types";
  24240. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24243. import { Scene } from "babylonjs/scene";
  24244. import { Bone } from "babylonjs/Bones/bone";
  24245. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24246. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24247. import { Space } from "babylonjs/Maths/math.axis";
  24248. /**
  24249. * The interface for the physics imposter parameters
  24250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24251. */
  24252. export interface PhysicsImpostorParameters {
  24253. /**
  24254. * The mass of the physics imposter
  24255. */
  24256. mass: number;
  24257. /**
  24258. * The friction of the physics imposter
  24259. */
  24260. friction?: number;
  24261. /**
  24262. * The coefficient of restitution of the physics imposter
  24263. */
  24264. restitution?: number;
  24265. /**
  24266. * The native options of the physics imposter
  24267. */
  24268. nativeOptions?: any;
  24269. /**
  24270. * Specifies if the parent should be ignored
  24271. */
  24272. ignoreParent?: boolean;
  24273. /**
  24274. * Specifies if bi-directional transformations should be disabled
  24275. */
  24276. disableBidirectionalTransformation?: boolean;
  24277. /**
  24278. * The pressure inside the physics imposter, soft object only
  24279. */
  24280. pressure?: number;
  24281. /**
  24282. * The stiffness the physics imposter, soft object only
  24283. */
  24284. stiffness?: number;
  24285. /**
  24286. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24287. */
  24288. velocityIterations?: number;
  24289. /**
  24290. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24291. */
  24292. positionIterations?: number;
  24293. /**
  24294. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24295. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24296. * Add to fix multiple points
  24297. */
  24298. fixedPoints?: number;
  24299. /**
  24300. * The collision margin around a soft object
  24301. */
  24302. margin?: number;
  24303. /**
  24304. * The collision margin around a soft object
  24305. */
  24306. damping?: number;
  24307. /**
  24308. * The path for a rope based on an extrusion
  24309. */
  24310. path?: any;
  24311. /**
  24312. * The shape of an extrusion used for a rope based on an extrusion
  24313. */
  24314. shape?: any;
  24315. }
  24316. /**
  24317. * Interface for a physics-enabled object
  24318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24319. */
  24320. export interface IPhysicsEnabledObject {
  24321. /**
  24322. * The position of the physics-enabled object
  24323. */
  24324. position: Vector3;
  24325. /**
  24326. * The rotation of the physics-enabled object
  24327. */
  24328. rotationQuaternion: Nullable<Quaternion>;
  24329. /**
  24330. * The scale of the physics-enabled object
  24331. */
  24332. scaling: Vector3;
  24333. /**
  24334. * The rotation of the physics-enabled object
  24335. */
  24336. rotation?: Vector3;
  24337. /**
  24338. * The parent of the physics-enabled object
  24339. */
  24340. parent?: any;
  24341. /**
  24342. * The bounding info of the physics-enabled object
  24343. * @returns The bounding info of the physics-enabled object
  24344. */
  24345. getBoundingInfo(): BoundingInfo;
  24346. /**
  24347. * Computes the world matrix
  24348. * @param force Specifies if the world matrix should be computed by force
  24349. * @returns A world matrix
  24350. */
  24351. computeWorldMatrix(force: boolean): Matrix;
  24352. /**
  24353. * Gets the world matrix
  24354. * @returns A world matrix
  24355. */
  24356. getWorldMatrix?(): Matrix;
  24357. /**
  24358. * Gets the child meshes
  24359. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24360. * @returns An array of abstract meshes
  24361. */
  24362. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24363. /**
  24364. * Gets the vertex data
  24365. * @param kind The type of vertex data
  24366. * @returns A nullable array of numbers, or a float32 array
  24367. */
  24368. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24369. /**
  24370. * Gets the indices from the mesh
  24371. * @returns A nullable array of index arrays
  24372. */
  24373. getIndices?(): Nullable<IndicesArray>;
  24374. /**
  24375. * Gets the scene from the mesh
  24376. * @returns the indices array or null
  24377. */
  24378. getScene?(): Scene;
  24379. /**
  24380. * Gets the absolute position from the mesh
  24381. * @returns the absolute position
  24382. */
  24383. getAbsolutePosition(): Vector3;
  24384. /**
  24385. * Gets the absolute pivot point from the mesh
  24386. * @returns the absolute pivot point
  24387. */
  24388. getAbsolutePivotPoint(): Vector3;
  24389. /**
  24390. * Rotates the mesh
  24391. * @param axis The axis of rotation
  24392. * @param amount The amount of rotation
  24393. * @param space The space of the rotation
  24394. * @returns The rotation transform node
  24395. */
  24396. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24397. /**
  24398. * Translates the mesh
  24399. * @param axis The axis of translation
  24400. * @param distance The distance of translation
  24401. * @param space The space of the translation
  24402. * @returns The transform node
  24403. */
  24404. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24405. /**
  24406. * Sets the absolute position of the mesh
  24407. * @param absolutePosition The absolute position of the mesh
  24408. * @returns The transform node
  24409. */
  24410. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24411. /**
  24412. * Gets the class name of the mesh
  24413. * @returns The class name
  24414. */
  24415. getClassName(): string;
  24416. }
  24417. /**
  24418. * Represents a physics imposter
  24419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24420. */
  24421. export class PhysicsImpostor {
  24422. /**
  24423. * The physics-enabled object used as the physics imposter
  24424. */
  24425. object: IPhysicsEnabledObject;
  24426. /**
  24427. * The type of the physics imposter
  24428. */
  24429. type: number;
  24430. private _options;
  24431. private _scene?;
  24432. /**
  24433. * The default object size of the imposter
  24434. */
  24435. static DEFAULT_OBJECT_SIZE: Vector3;
  24436. /**
  24437. * The identity quaternion of the imposter
  24438. */
  24439. static IDENTITY_QUATERNION: Quaternion;
  24440. /** @hidden */
  24441. _pluginData: any;
  24442. private _physicsEngine;
  24443. private _physicsBody;
  24444. private _bodyUpdateRequired;
  24445. private _onBeforePhysicsStepCallbacks;
  24446. private _onAfterPhysicsStepCallbacks;
  24447. /** @hidden */
  24448. _onPhysicsCollideCallbacks: Array<{
  24449. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24450. otherImpostors: Array<PhysicsImpostor>;
  24451. }>;
  24452. private _deltaPosition;
  24453. private _deltaRotation;
  24454. private _deltaRotationConjugated;
  24455. /** @hidden */
  24456. _isFromLine: boolean;
  24457. private _parent;
  24458. private _isDisposed;
  24459. private static _tmpVecs;
  24460. private static _tmpQuat;
  24461. /**
  24462. * Specifies if the physics imposter is disposed
  24463. */
  24464. get isDisposed(): boolean;
  24465. /**
  24466. * Gets the mass of the physics imposter
  24467. */
  24468. get mass(): number;
  24469. set mass(value: number);
  24470. /**
  24471. * Gets the coefficient of friction
  24472. */
  24473. get friction(): number;
  24474. /**
  24475. * Sets the coefficient of friction
  24476. */
  24477. set friction(value: number);
  24478. /**
  24479. * Gets the coefficient of restitution
  24480. */
  24481. get restitution(): number;
  24482. /**
  24483. * Sets the coefficient of restitution
  24484. */
  24485. set restitution(value: number);
  24486. /**
  24487. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24488. */
  24489. get pressure(): number;
  24490. /**
  24491. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24492. */
  24493. set pressure(value: number);
  24494. /**
  24495. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24496. */
  24497. get stiffness(): number;
  24498. /**
  24499. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24500. */
  24501. set stiffness(value: number);
  24502. /**
  24503. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24504. */
  24505. get velocityIterations(): number;
  24506. /**
  24507. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24508. */
  24509. set velocityIterations(value: number);
  24510. /**
  24511. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24512. */
  24513. get positionIterations(): number;
  24514. /**
  24515. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24516. */
  24517. set positionIterations(value: number);
  24518. /**
  24519. * The unique id of the physics imposter
  24520. * set by the physics engine when adding this impostor to the array
  24521. */
  24522. uniqueId: number;
  24523. /**
  24524. * @hidden
  24525. */
  24526. soft: boolean;
  24527. /**
  24528. * @hidden
  24529. */
  24530. segments: number;
  24531. private _joints;
  24532. /**
  24533. * Initializes the physics imposter
  24534. * @param object The physics-enabled object used as the physics imposter
  24535. * @param type The type of the physics imposter
  24536. * @param _options The options for the physics imposter
  24537. * @param _scene The Babylon scene
  24538. */
  24539. constructor(
  24540. /**
  24541. * The physics-enabled object used as the physics imposter
  24542. */
  24543. object: IPhysicsEnabledObject,
  24544. /**
  24545. * The type of the physics imposter
  24546. */
  24547. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24548. /**
  24549. * This function will completly initialize this impostor.
  24550. * It will create a new body - but only if this mesh has no parent.
  24551. * If it has, this impostor will not be used other than to define the impostor
  24552. * of the child mesh.
  24553. * @hidden
  24554. */
  24555. _init(): void;
  24556. private _getPhysicsParent;
  24557. /**
  24558. * Should a new body be generated.
  24559. * @returns boolean specifying if body initialization is required
  24560. */
  24561. isBodyInitRequired(): boolean;
  24562. /**
  24563. * Sets the updated scaling
  24564. * @param updated Specifies if the scaling is updated
  24565. */
  24566. setScalingUpdated(): void;
  24567. /**
  24568. * Force a regeneration of this or the parent's impostor's body.
  24569. * Use under cautious - This will remove all joints already implemented.
  24570. */
  24571. forceUpdate(): void;
  24572. /**
  24573. * Gets the body that holds this impostor. Either its own, or its parent.
  24574. */
  24575. get physicsBody(): any;
  24576. /**
  24577. * Get the parent of the physics imposter
  24578. * @returns Physics imposter or null
  24579. */
  24580. get parent(): Nullable<PhysicsImpostor>;
  24581. /**
  24582. * Sets the parent of the physics imposter
  24583. */
  24584. set parent(value: Nullable<PhysicsImpostor>);
  24585. /**
  24586. * Set the physics body. Used mainly by the physics engine/plugin
  24587. */
  24588. set physicsBody(physicsBody: any);
  24589. /**
  24590. * Resets the update flags
  24591. */
  24592. resetUpdateFlags(): void;
  24593. /**
  24594. * Gets the object extend size
  24595. * @returns the object extend size
  24596. */
  24597. getObjectExtendSize(): Vector3;
  24598. /**
  24599. * Gets the object center
  24600. * @returns The object center
  24601. */
  24602. getObjectCenter(): Vector3;
  24603. /**
  24604. * Get a specific parameter from the options parameters
  24605. * @param paramName The object parameter name
  24606. * @returns The object parameter
  24607. */
  24608. getParam(paramName: string): any;
  24609. /**
  24610. * Sets a specific parameter in the options given to the physics plugin
  24611. * @param paramName The parameter name
  24612. * @param value The value of the parameter
  24613. */
  24614. setParam(paramName: string, value: number): void;
  24615. /**
  24616. * Specifically change the body's mass option. Won't recreate the physics body object
  24617. * @param mass The mass of the physics imposter
  24618. */
  24619. setMass(mass: number): void;
  24620. /**
  24621. * Gets the linear velocity
  24622. * @returns linear velocity or null
  24623. */
  24624. getLinearVelocity(): Nullable<Vector3>;
  24625. /**
  24626. * Sets the linear velocity
  24627. * @param velocity linear velocity or null
  24628. */
  24629. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24630. /**
  24631. * Gets the angular velocity
  24632. * @returns angular velocity or null
  24633. */
  24634. getAngularVelocity(): Nullable<Vector3>;
  24635. /**
  24636. * Sets the angular velocity
  24637. * @param velocity The velocity or null
  24638. */
  24639. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24640. /**
  24641. * Execute a function with the physics plugin native code
  24642. * Provide a function the will have two variables - the world object and the physics body object
  24643. * @param func The function to execute with the physics plugin native code
  24644. */
  24645. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24646. /**
  24647. * Register a function that will be executed before the physics world is stepping forward
  24648. * @param func The function to execute before the physics world is stepped forward
  24649. */
  24650. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24651. /**
  24652. * Unregister a function that will be executed before the physics world is stepping forward
  24653. * @param func The function to execute before the physics world is stepped forward
  24654. */
  24655. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24656. /**
  24657. * Register a function that will be executed after the physics step
  24658. * @param func The function to execute after physics step
  24659. */
  24660. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24661. /**
  24662. * Unregisters a function that will be executed after the physics step
  24663. * @param func The function to execute after physics step
  24664. */
  24665. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24666. /**
  24667. * register a function that will be executed when this impostor collides against a different body
  24668. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24669. * @param func Callback that is executed on collision
  24670. */
  24671. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24672. /**
  24673. * Unregisters the physics imposter on contact
  24674. * @param collideAgainst The physics object to collide against
  24675. * @param func Callback to execute on collision
  24676. */
  24677. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24678. private _tmpQuat;
  24679. private _tmpQuat2;
  24680. /**
  24681. * Get the parent rotation
  24682. * @returns The parent rotation
  24683. */
  24684. getParentsRotation(): Quaternion;
  24685. /**
  24686. * this function is executed by the physics engine.
  24687. */
  24688. beforeStep: () => void;
  24689. /**
  24690. * this function is executed by the physics engine
  24691. */
  24692. afterStep: () => void;
  24693. /**
  24694. * Legacy collision detection event support
  24695. */
  24696. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24697. /**
  24698. * event and body object due to cannon's event-based architecture.
  24699. */
  24700. onCollide: (e: {
  24701. body: any;
  24702. }) => void;
  24703. /**
  24704. * Apply a force
  24705. * @param force The force to apply
  24706. * @param contactPoint The contact point for the force
  24707. * @returns The physics imposter
  24708. */
  24709. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24710. /**
  24711. * Apply an impulse
  24712. * @param force The impulse force
  24713. * @param contactPoint The contact point for the impulse force
  24714. * @returns The physics imposter
  24715. */
  24716. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24717. /**
  24718. * A help function to create a joint
  24719. * @param otherImpostor A physics imposter used to create a joint
  24720. * @param jointType The type of joint
  24721. * @param jointData The data for the joint
  24722. * @returns The physics imposter
  24723. */
  24724. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24725. /**
  24726. * Add a joint to this impostor with a different impostor
  24727. * @param otherImpostor A physics imposter used to add a joint
  24728. * @param joint The joint to add
  24729. * @returns The physics imposter
  24730. */
  24731. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24732. /**
  24733. * Add an anchor to a cloth impostor
  24734. * @param otherImpostor rigid impostor to anchor to
  24735. * @param width ratio across width from 0 to 1
  24736. * @param height ratio up height from 0 to 1
  24737. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24738. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24739. * @returns impostor the soft imposter
  24740. */
  24741. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24742. /**
  24743. * Add a hook to a rope impostor
  24744. * @param otherImpostor rigid impostor to anchor to
  24745. * @param length ratio across rope from 0 to 1
  24746. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24748. * @returns impostor the rope imposter
  24749. */
  24750. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24751. /**
  24752. * Will keep this body still, in a sleep mode.
  24753. * @returns the physics imposter
  24754. */
  24755. sleep(): PhysicsImpostor;
  24756. /**
  24757. * Wake the body up.
  24758. * @returns The physics imposter
  24759. */
  24760. wakeUp(): PhysicsImpostor;
  24761. /**
  24762. * Clones the physics imposter
  24763. * @param newObject The physics imposter clones to this physics-enabled object
  24764. * @returns A nullable physics imposter
  24765. */
  24766. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24767. /**
  24768. * Disposes the physics imposter
  24769. */
  24770. dispose(): void;
  24771. /**
  24772. * Sets the delta position
  24773. * @param position The delta position amount
  24774. */
  24775. setDeltaPosition(position: Vector3): void;
  24776. /**
  24777. * Sets the delta rotation
  24778. * @param rotation The delta rotation amount
  24779. */
  24780. setDeltaRotation(rotation: Quaternion): void;
  24781. /**
  24782. * Gets the box size of the physics imposter and stores the result in the input parameter
  24783. * @param result Stores the box size
  24784. * @returns The physics imposter
  24785. */
  24786. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24787. /**
  24788. * Gets the radius of the physics imposter
  24789. * @returns Radius of the physics imposter
  24790. */
  24791. getRadius(): number;
  24792. /**
  24793. * Sync a bone with this impostor
  24794. * @param bone The bone to sync to the impostor.
  24795. * @param boneMesh The mesh that the bone is influencing.
  24796. * @param jointPivot The pivot of the joint / bone in local space.
  24797. * @param distToJoint Optional distance from the impostor to the joint.
  24798. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24799. */
  24800. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24801. /**
  24802. * Sync impostor to a bone
  24803. * @param bone The bone that the impostor will be synced to.
  24804. * @param boneMesh The mesh that the bone is influencing.
  24805. * @param jointPivot The pivot of the joint / bone in local space.
  24806. * @param distToJoint Optional distance from the impostor to the joint.
  24807. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24808. * @param boneAxis Optional vector3 axis the bone is aligned with
  24809. */
  24810. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24811. /**
  24812. * No-Imposter type
  24813. */
  24814. static NoImpostor: number;
  24815. /**
  24816. * Sphere-Imposter type
  24817. */
  24818. static SphereImpostor: number;
  24819. /**
  24820. * Box-Imposter type
  24821. */
  24822. static BoxImpostor: number;
  24823. /**
  24824. * Plane-Imposter type
  24825. */
  24826. static PlaneImpostor: number;
  24827. /**
  24828. * Mesh-imposter type
  24829. */
  24830. static MeshImpostor: number;
  24831. /**
  24832. * Capsule-Impostor type (Ammo.js plugin only)
  24833. */
  24834. static CapsuleImpostor: number;
  24835. /**
  24836. * Cylinder-Imposter type
  24837. */
  24838. static CylinderImpostor: number;
  24839. /**
  24840. * Particle-Imposter type
  24841. */
  24842. static ParticleImpostor: number;
  24843. /**
  24844. * Heightmap-Imposter type
  24845. */
  24846. static HeightmapImpostor: number;
  24847. /**
  24848. * ConvexHull-Impostor type (Ammo.js plugin only)
  24849. */
  24850. static ConvexHullImpostor: number;
  24851. /**
  24852. * Custom-Imposter type (Ammo.js plugin only)
  24853. */
  24854. static CustomImpostor: number;
  24855. /**
  24856. * Rope-Imposter type
  24857. */
  24858. static RopeImpostor: number;
  24859. /**
  24860. * Cloth-Imposter type
  24861. */
  24862. static ClothImpostor: number;
  24863. /**
  24864. * Softbody-Imposter type
  24865. */
  24866. static SoftbodyImpostor: number;
  24867. }
  24868. }
  24869. declare module "babylonjs/Meshes/mesh" {
  24870. import { Observable } from "babylonjs/Misc/observable";
  24871. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24872. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24873. import { Camera } from "babylonjs/Cameras/camera";
  24874. import { Scene } from "babylonjs/scene";
  24875. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24876. import { Color4 } from "babylonjs/Maths/math.color";
  24877. import { Engine } from "babylonjs/Engines/engine";
  24878. import { Node } from "babylonjs/node";
  24879. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24880. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24881. import { Buffer } from "babylonjs/Meshes/buffer";
  24882. import { Geometry } from "babylonjs/Meshes/geometry";
  24883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24885. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24886. import { Effect } from "babylonjs/Materials/effect";
  24887. import { Material } from "babylonjs/Materials/material";
  24888. import { Skeleton } from "babylonjs/Bones/skeleton";
  24889. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24890. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24891. import { Path3D } from "babylonjs/Maths/math.path";
  24892. import { Plane } from "babylonjs/Maths/math.plane";
  24893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24894. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24895. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24896. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24897. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24898. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24899. /**
  24900. * @hidden
  24901. **/
  24902. export class _CreationDataStorage {
  24903. closePath?: boolean;
  24904. closeArray?: boolean;
  24905. idx: number[];
  24906. dashSize: number;
  24907. gapSize: number;
  24908. path3D: Path3D;
  24909. pathArray: Vector3[][];
  24910. arc: number;
  24911. radius: number;
  24912. cap: number;
  24913. tessellation: number;
  24914. }
  24915. /**
  24916. * @hidden
  24917. **/
  24918. class _InstanceDataStorage {
  24919. visibleInstances: any;
  24920. batchCache: _InstancesBatch;
  24921. instancesBufferSize: number;
  24922. instancesBuffer: Nullable<Buffer>;
  24923. instancesData: Float32Array;
  24924. overridenInstanceCount: number;
  24925. isFrozen: boolean;
  24926. previousBatch: Nullable<_InstancesBatch>;
  24927. hardwareInstancedRendering: boolean;
  24928. sideOrientation: number;
  24929. manualUpdate: boolean;
  24930. }
  24931. /**
  24932. * @hidden
  24933. **/
  24934. export class _InstancesBatch {
  24935. mustReturn: boolean;
  24936. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24937. renderSelf: boolean[];
  24938. hardwareInstancedRendering: boolean[];
  24939. }
  24940. /**
  24941. * Class used to represent renderable models
  24942. */
  24943. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24944. /**
  24945. * Mesh side orientation : usually the external or front surface
  24946. */
  24947. static readonly FRONTSIDE: number;
  24948. /**
  24949. * Mesh side orientation : usually the internal or back surface
  24950. */
  24951. static readonly BACKSIDE: number;
  24952. /**
  24953. * Mesh side orientation : both internal and external or front and back surfaces
  24954. */
  24955. static readonly DOUBLESIDE: number;
  24956. /**
  24957. * Mesh side orientation : by default, `FRONTSIDE`
  24958. */
  24959. static readonly DEFAULTSIDE: number;
  24960. /**
  24961. * Mesh cap setting : no cap
  24962. */
  24963. static readonly NO_CAP: number;
  24964. /**
  24965. * Mesh cap setting : one cap at the beginning of the mesh
  24966. */
  24967. static readonly CAP_START: number;
  24968. /**
  24969. * Mesh cap setting : one cap at the end of the mesh
  24970. */
  24971. static readonly CAP_END: number;
  24972. /**
  24973. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24974. */
  24975. static readonly CAP_ALL: number;
  24976. /**
  24977. * Mesh pattern setting : no flip or rotate
  24978. */
  24979. static readonly NO_FLIP: number;
  24980. /**
  24981. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24982. */
  24983. static readonly FLIP_TILE: number;
  24984. /**
  24985. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24986. */
  24987. static readonly ROTATE_TILE: number;
  24988. /**
  24989. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24990. */
  24991. static readonly FLIP_ROW: number;
  24992. /**
  24993. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24994. */
  24995. static readonly ROTATE_ROW: number;
  24996. /**
  24997. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24998. */
  24999. static readonly FLIP_N_ROTATE_TILE: number;
  25000. /**
  25001. * Mesh pattern setting : rotate pattern and rotate
  25002. */
  25003. static readonly FLIP_N_ROTATE_ROW: number;
  25004. /**
  25005. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25006. */
  25007. static readonly CENTER: number;
  25008. /**
  25009. * Mesh tile positioning : part tiles on left
  25010. */
  25011. static readonly LEFT: number;
  25012. /**
  25013. * Mesh tile positioning : part tiles on right
  25014. */
  25015. static readonly RIGHT: number;
  25016. /**
  25017. * Mesh tile positioning : part tiles on top
  25018. */
  25019. static readonly TOP: number;
  25020. /**
  25021. * Mesh tile positioning : part tiles on bottom
  25022. */
  25023. static readonly BOTTOM: number;
  25024. /**
  25025. * Gets the default side orientation.
  25026. * @param orientation the orientation to value to attempt to get
  25027. * @returns the default orientation
  25028. * @hidden
  25029. */
  25030. static _GetDefaultSideOrientation(orientation?: number): number;
  25031. private _internalMeshDataInfo;
  25032. /**
  25033. * An event triggered before rendering the mesh
  25034. */
  25035. get onBeforeRenderObservable(): Observable<Mesh>;
  25036. /**
  25037. * An event triggered before binding the mesh
  25038. */
  25039. get onBeforeBindObservable(): Observable<Mesh>;
  25040. /**
  25041. * An event triggered after rendering the mesh
  25042. */
  25043. get onAfterRenderObservable(): Observable<Mesh>;
  25044. /**
  25045. * An event triggered before drawing the mesh
  25046. */
  25047. get onBeforeDrawObservable(): Observable<Mesh>;
  25048. private _onBeforeDrawObserver;
  25049. /**
  25050. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25051. */
  25052. set onBeforeDraw(callback: () => void);
  25053. get hasInstances(): boolean;
  25054. /**
  25055. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25056. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25057. */
  25058. delayLoadState: number;
  25059. /**
  25060. * Gets the list of instances created from this mesh
  25061. * it is not supposed to be modified manually.
  25062. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25063. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25064. */
  25065. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25066. /**
  25067. * Gets the file containing delay loading data for this mesh
  25068. */
  25069. delayLoadingFile: string;
  25070. /** @hidden */
  25071. _binaryInfo: any;
  25072. /**
  25073. * User defined function used to change how LOD level selection is done
  25074. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25075. */
  25076. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25077. /**
  25078. * Gets or sets the morph target manager
  25079. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25080. */
  25081. get morphTargetManager(): Nullable<MorphTargetManager>;
  25082. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25083. /** @hidden */
  25084. _creationDataStorage: Nullable<_CreationDataStorage>;
  25085. /** @hidden */
  25086. _geometry: Nullable<Geometry>;
  25087. /** @hidden */
  25088. _delayInfo: Array<string>;
  25089. /** @hidden */
  25090. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25091. /** @hidden */
  25092. _instanceDataStorage: _InstanceDataStorage;
  25093. private _effectiveMaterial;
  25094. /** @hidden */
  25095. _shouldGenerateFlatShading: boolean;
  25096. /** @hidden */
  25097. _originalBuilderSideOrientation: number;
  25098. /**
  25099. * Use this property to change the original side orientation defined at construction time
  25100. */
  25101. overrideMaterialSideOrientation: Nullable<number>;
  25102. /**
  25103. * Gets the source mesh (the one used to clone this one from)
  25104. */
  25105. get source(): Nullable<Mesh>;
  25106. /**
  25107. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25108. */
  25109. get isUnIndexed(): boolean;
  25110. set isUnIndexed(value: boolean);
  25111. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25112. get worldMatrixInstancedBuffer(): Float32Array;
  25113. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25114. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25115. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25116. /**
  25117. * @constructor
  25118. * @param name The value used by scene.getMeshByName() to do a lookup.
  25119. * @param scene The scene to add this mesh to.
  25120. * @param parent The parent of this mesh, if it has one
  25121. * @param source An optional Mesh from which geometry is shared, cloned.
  25122. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25123. * When false, achieved by calling a clone(), also passing False.
  25124. * This will make creation of children, recursive.
  25125. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25126. */
  25127. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25128. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25129. doNotInstantiate: boolean;
  25130. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25131. /**
  25132. * Gets the class name
  25133. * @returns the string "Mesh".
  25134. */
  25135. getClassName(): string;
  25136. /** @hidden */
  25137. get _isMesh(): boolean;
  25138. /**
  25139. * Returns a description of this mesh
  25140. * @param fullDetails define if full details about this mesh must be used
  25141. * @returns a descriptive string representing this mesh
  25142. */
  25143. toString(fullDetails?: boolean): string;
  25144. /** @hidden */
  25145. _unBindEffect(): void;
  25146. /**
  25147. * Gets a boolean indicating if this mesh has LOD
  25148. */
  25149. get hasLODLevels(): boolean;
  25150. /**
  25151. * Gets the list of MeshLODLevel associated with the current mesh
  25152. * @returns an array of MeshLODLevel
  25153. */
  25154. getLODLevels(): MeshLODLevel[];
  25155. private _sortLODLevels;
  25156. /**
  25157. * Add a mesh as LOD level triggered at the given distance.
  25158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25159. * @param distance The distance from the center of the object to show this level
  25160. * @param mesh The mesh to be added as LOD level (can be null)
  25161. * @return This mesh (for chaining)
  25162. */
  25163. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25164. /**
  25165. * Returns the LOD level mesh at the passed distance or null if not found.
  25166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25167. * @param distance The distance from the center of the object to show this level
  25168. * @returns a Mesh or `null`
  25169. */
  25170. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25171. /**
  25172. * Remove a mesh from the LOD array
  25173. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25174. * @param mesh defines the mesh to be removed
  25175. * @return This mesh (for chaining)
  25176. */
  25177. removeLODLevel(mesh: Mesh): Mesh;
  25178. /**
  25179. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25180. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25181. * @param camera defines the camera to use to compute distance
  25182. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25183. * @return This mesh (for chaining)
  25184. */
  25185. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25186. /**
  25187. * Gets the mesh internal Geometry object
  25188. */
  25189. get geometry(): Nullable<Geometry>;
  25190. /**
  25191. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25192. * @returns the total number of vertices
  25193. */
  25194. getTotalVertices(): number;
  25195. /**
  25196. * Returns the content of an associated vertex buffer
  25197. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25198. * - VertexBuffer.PositionKind
  25199. * - VertexBuffer.UVKind
  25200. * - VertexBuffer.UV2Kind
  25201. * - VertexBuffer.UV3Kind
  25202. * - VertexBuffer.UV4Kind
  25203. * - VertexBuffer.UV5Kind
  25204. * - VertexBuffer.UV6Kind
  25205. * - VertexBuffer.ColorKind
  25206. * - VertexBuffer.MatricesIndicesKind
  25207. * - VertexBuffer.MatricesIndicesExtraKind
  25208. * - VertexBuffer.MatricesWeightsKind
  25209. * - VertexBuffer.MatricesWeightsExtraKind
  25210. * @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
  25211. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25212. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25213. */
  25214. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25215. /**
  25216. * Returns the mesh VertexBuffer object from the requested `kind`
  25217. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25218. * - VertexBuffer.PositionKind
  25219. * - VertexBuffer.NormalKind
  25220. * - VertexBuffer.UVKind
  25221. * - VertexBuffer.UV2Kind
  25222. * - VertexBuffer.UV3Kind
  25223. * - VertexBuffer.UV4Kind
  25224. * - VertexBuffer.UV5Kind
  25225. * - VertexBuffer.UV6Kind
  25226. * - VertexBuffer.ColorKind
  25227. * - VertexBuffer.MatricesIndicesKind
  25228. * - VertexBuffer.MatricesIndicesExtraKind
  25229. * - VertexBuffer.MatricesWeightsKind
  25230. * - VertexBuffer.MatricesWeightsExtraKind
  25231. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25232. */
  25233. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25234. /**
  25235. * Tests if a specific vertex buffer is associated with this mesh
  25236. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25237. * - VertexBuffer.PositionKind
  25238. * - VertexBuffer.NormalKind
  25239. * - VertexBuffer.UVKind
  25240. * - VertexBuffer.UV2Kind
  25241. * - VertexBuffer.UV3Kind
  25242. * - VertexBuffer.UV4Kind
  25243. * - VertexBuffer.UV5Kind
  25244. * - VertexBuffer.UV6Kind
  25245. * - VertexBuffer.ColorKind
  25246. * - VertexBuffer.MatricesIndicesKind
  25247. * - VertexBuffer.MatricesIndicesExtraKind
  25248. * - VertexBuffer.MatricesWeightsKind
  25249. * - VertexBuffer.MatricesWeightsExtraKind
  25250. * @returns a boolean
  25251. */
  25252. isVerticesDataPresent(kind: string): boolean;
  25253. /**
  25254. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25255. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25256. * - VertexBuffer.PositionKind
  25257. * - VertexBuffer.UVKind
  25258. * - VertexBuffer.UV2Kind
  25259. * - VertexBuffer.UV3Kind
  25260. * - VertexBuffer.UV4Kind
  25261. * - VertexBuffer.UV5Kind
  25262. * - VertexBuffer.UV6Kind
  25263. * - VertexBuffer.ColorKind
  25264. * - VertexBuffer.MatricesIndicesKind
  25265. * - VertexBuffer.MatricesIndicesExtraKind
  25266. * - VertexBuffer.MatricesWeightsKind
  25267. * - VertexBuffer.MatricesWeightsExtraKind
  25268. * @returns a boolean
  25269. */
  25270. isVertexBufferUpdatable(kind: string): boolean;
  25271. /**
  25272. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25273. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25274. * - VertexBuffer.PositionKind
  25275. * - VertexBuffer.NormalKind
  25276. * - VertexBuffer.UVKind
  25277. * - VertexBuffer.UV2Kind
  25278. * - VertexBuffer.UV3Kind
  25279. * - VertexBuffer.UV4Kind
  25280. * - VertexBuffer.UV5Kind
  25281. * - VertexBuffer.UV6Kind
  25282. * - VertexBuffer.ColorKind
  25283. * - VertexBuffer.MatricesIndicesKind
  25284. * - VertexBuffer.MatricesIndicesExtraKind
  25285. * - VertexBuffer.MatricesWeightsKind
  25286. * - VertexBuffer.MatricesWeightsExtraKind
  25287. * @returns an array of strings
  25288. */
  25289. getVerticesDataKinds(): string[];
  25290. /**
  25291. * Returns a positive integer : the total number of indices in this mesh geometry.
  25292. * @returns the numner of indices or zero if the mesh has no geometry.
  25293. */
  25294. getTotalIndices(): number;
  25295. /**
  25296. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25297. * @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.
  25298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25299. * @returns the indices array or an empty array if the mesh has no geometry
  25300. */
  25301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25302. get isBlocked(): boolean;
  25303. /**
  25304. * Determine if the current mesh is ready to be rendered
  25305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25306. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25307. * @returns true if all associated assets are ready (material, textures, shaders)
  25308. */
  25309. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25310. /**
  25311. * 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.
  25312. */
  25313. get areNormalsFrozen(): boolean;
  25314. /**
  25315. * 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.
  25316. * @returns the current mesh
  25317. */
  25318. freezeNormals(): Mesh;
  25319. /**
  25320. * 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
  25321. * @returns the current mesh
  25322. */
  25323. unfreezeNormals(): Mesh;
  25324. /**
  25325. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25326. */
  25327. set overridenInstanceCount(count: number);
  25328. /** @hidden */
  25329. _preActivate(): Mesh;
  25330. /** @hidden */
  25331. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25332. /** @hidden */
  25333. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25334. /**
  25335. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25336. * This means the mesh underlying bounding box and sphere are recomputed.
  25337. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25338. * @returns the current mesh
  25339. */
  25340. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25341. /** @hidden */
  25342. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25343. /**
  25344. * This function will subdivide the mesh into multiple submeshes
  25345. * @param count defines the expected number of submeshes
  25346. */
  25347. subdivide(count: number): void;
  25348. /**
  25349. * Copy a FloatArray into a specific associated vertex buffer
  25350. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25351. * - VertexBuffer.PositionKind
  25352. * - VertexBuffer.UVKind
  25353. * - VertexBuffer.UV2Kind
  25354. * - VertexBuffer.UV3Kind
  25355. * - VertexBuffer.UV4Kind
  25356. * - VertexBuffer.UV5Kind
  25357. * - VertexBuffer.UV6Kind
  25358. * - VertexBuffer.ColorKind
  25359. * - VertexBuffer.MatricesIndicesKind
  25360. * - VertexBuffer.MatricesIndicesExtraKind
  25361. * - VertexBuffer.MatricesWeightsKind
  25362. * - VertexBuffer.MatricesWeightsExtraKind
  25363. * @param data defines the data source
  25364. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25365. * @param stride defines the data stride size (can be null)
  25366. * @returns the current mesh
  25367. */
  25368. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25369. /**
  25370. * Delete a vertex buffer associated with this mesh
  25371. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25372. * - VertexBuffer.PositionKind
  25373. * - VertexBuffer.UVKind
  25374. * - VertexBuffer.UV2Kind
  25375. * - VertexBuffer.UV3Kind
  25376. * - VertexBuffer.UV4Kind
  25377. * - VertexBuffer.UV5Kind
  25378. * - VertexBuffer.UV6Kind
  25379. * - VertexBuffer.ColorKind
  25380. * - VertexBuffer.MatricesIndicesKind
  25381. * - VertexBuffer.MatricesIndicesExtraKind
  25382. * - VertexBuffer.MatricesWeightsKind
  25383. * - VertexBuffer.MatricesWeightsExtraKind
  25384. */
  25385. removeVerticesData(kind: string): void;
  25386. /**
  25387. * Flags an associated vertex buffer as updatable
  25388. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25389. * - VertexBuffer.PositionKind
  25390. * - VertexBuffer.UVKind
  25391. * - VertexBuffer.UV2Kind
  25392. * - VertexBuffer.UV3Kind
  25393. * - VertexBuffer.UV4Kind
  25394. * - VertexBuffer.UV5Kind
  25395. * - VertexBuffer.UV6Kind
  25396. * - VertexBuffer.ColorKind
  25397. * - VertexBuffer.MatricesIndicesKind
  25398. * - VertexBuffer.MatricesIndicesExtraKind
  25399. * - VertexBuffer.MatricesWeightsKind
  25400. * - VertexBuffer.MatricesWeightsExtraKind
  25401. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25402. */
  25403. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25404. /**
  25405. * Sets the mesh global Vertex Buffer
  25406. * @param buffer defines the buffer to use
  25407. * @returns the current mesh
  25408. */
  25409. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25410. /**
  25411. * Update a specific associated vertex buffer
  25412. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25413. * - VertexBuffer.PositionKind
  25414. * - VertexBuffer.UVKind
  25415. * - VertexBuffer.UV2Kind
  25416. * - VertexBuffer.UV3Kind
  25417. * - VertexBuffer.UV4Kind
  25418. * - VertexBuffer.UV5Kind
  25419. * - VertexBuffer.UV6Kind
  25420. * - VertexBuffer.ColorKind
  25421. * - VertexBuffer.MatricesIndicesKind
  25422. * - VertexBuffer.MatricesIndicesExtraKind
  25423. * - VertexBuffer.MatricesWeightsKind
  25424. * - VertexBuffer.MatricesWeightsExtraKind
  25425. * @param data defines the data source
  25426. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25427. * @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)
  25428. * @returns the current mesh
  25429. */
  25430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25431. /**
  25432. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25433. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25434. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25435. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25436. * @returns the current mesh
  25437. */
  25438. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25439. /**
  25440. * Creates a un-shared specific occurence of the geometry for the mesh.
  25441. * @returns the current mesh
  25442. */
  25443. makeGeometryUnique(): Mesh;
  25444. /**
  25445. * Set the index buffer of this mesh
  25446. * @param indices defines the source data
  25447. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25448. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25449. * @returns the current mesh
  25450. */
  25451. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25452. /**
  25453. * Update the current index buffer
  25454. * @param indices defines the source data
  25455. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25456. * @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)
  25457. * @returns the current mesh
  25458. */
  25459. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25460. /**
  25461. * Invert the geometry to move from a right handed system to a left handed one.
  25462. * @returns the current mesh
  25463. */
  25464. toLeftHanded(): Mesh;
  25465. /** @hidden */
  25466. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25467. /** @hidden */
  25468. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25469. /**
  25470. * Registers for this mesh a javascript function called just before the rendering process
  25471. * @param func defines the function to call before rendering this mesh
  25472. * @returns the current mesh
  25473. */
  25474. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25475. /**
  25476. * Disposes a previously registered javascript function called before the rendering
  25477. * @param func defines the function to remove
  25478. * @returns the current mesh
  25479. */
  25480. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25481. /**
  25482. * Registers for this mesh a javascript function called just after the rendering is complete
  25483. * @param func defines the function to call after rendering this mesh
  25484. * @returns the current mesh
  25485. */
  25486. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25487. /**
  25488. * Disposes a previously registered javascript function called after the rendering.
  25489. * @param func defines the function to remove
  25490. * @returns the current mesh
  25491. */
  25492. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25493. /** @hidden */
  25494. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25495. /** @hidden */
  25496. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25497. /** @hidden */
  25498. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25499. /** @hidden */
  25500. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25501. /** @hidden */
  25502. _rebuild(): void;
  25503. /** @hidden */
  25504. _freeze(): void;
  25505. /** @hidden */
  25506. _unFreeze(): void;
  25507. /**
  25508. * 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
  25509. * @param subMesh defines the subMesh to render
  25510. * @param enableAlphaMode defines if alpha mode can be changed
  25511. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25512. * @returns the current mesh
  25513. */
  25514. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25515. private _onBeforeDraw;
  25516. /**
  25517. * Renormalize the mesh and patch it up if there are no weights
  25518. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25519. * However in the case of zero weights then we set just a single influence to 1.
  25520. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25521. */
  25522. cleanMatrixWeights(): void;
  25523. private normalizeSkinFourWeights;
  25524. private normalizeSkinWeightsAndExtra;
  25525. /**
  25526. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25527. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25528. * the user know there was an issue with importing the mesh
  25529. * @returns a validation object with skinned, valid and report string
  25530. */
  25531. validateSkinning(): {
  25532. skinned: boolean;
  25533. valid: boolean;
  25534. report: string;
  25535. };
  25536. /** @hidden */
  25537. _checkDelayState(): Mesh;
  25538. private _queueLoad;
  25539. /**
  25540. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25541. * A mesh is in the frustum if its bounding box intersects the frustum
  25542. * @param frustumPlanes defines the frustum to test
  25543. * @returns true if the mesh is in the frustum planes
  25544. */
  25545. isInFrustum(frustumPlanes: Plane[]): boolean;
  25546. /**
  25547. * Sets the mesh material by the material or multiMaterial `id` property
  25548. * @param id is a string identifying the material or the multiMaterial
  25549. * @returns the current mesh
  25550. */
  25551. setMaterialByID(id: string): Mesh;
  25552. /**
  25553. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25554. * @returns an array of IAnimatable
  25555. */
  25556. getAnimatables(): IAnimatable[];
  25557. /**
  25558. * Modifies the mesh geometry according to the passed transformation matrix.
  25559. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25560. * The mesh normals are modified using the same transformation.
  25561. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25562. * @param transform defines the transform matrix to use
  25563. * @see http://doc.babylonjs.com/resources/baking_transformations
  25564. * @returns the current mesh
  25565. */
  25566. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25567. /**
  25568. * Modifies the mesh geometry according to its own current World Matrix.
  25569. * The mesh World Matrix is then reset.
  25570. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25571. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25572. * @see http://doc.babylonjs.com/resources/baking_transformations
  25573. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25574. * @returns the current mesh
  25575. */
  25576. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25577. /** @hidden */
  25578. get _positions(): Nullable<Vector3[]>;
  25579. /** @hidden */
  25580. _resetPointsArrayCache(): Mesh;
  25581. /** @hidden */
  25582. _generatePointsArray(): boolean;
  25583. /**
  25584. * Returns a new Mesh object generated from the current mesh properties.
  25585. * This method must not get confused with createInstance()
  25586. * @param name is a string, the name given to the new mesh
  25587. * @param newParent can be any Node object (default `null`)
  25588. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25589. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25590. * @returns a new mesh
  25591. */
  25592. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25593. /**
  25594. * Releases resources associated with this mesh.
  25595. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25596. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25597. */
  25598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25599. /** @hidden */
  25600. _disposeInstanceSpecificData(): void;
  25601. /**
  25602. * Modifies the mesh geometry according to a displacement map.
  25603. * 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.
  25604. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25605. * @param url is a string, the URL from the image file is to be downloaded.
  25606. * @param minHeight is the lower limit of the displacement.
  25607. * @param maxHeight is the upper limit of the displacement.
  25608. * @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.
  25609. * @param uvOffset is an optional vector2 used to offset UV.
  25610. * @param uvScale is an optional vector2 used to scale UV.
  25611. * @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.
  25612. * @returns the Mesh.
  25613. */
  25614. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25615. /**
  25616. * Modifies the mesh geometry according to a displacementMap buffer.
  25617. * 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.
  25618. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25619. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25620. * @param heightMapWidth is the width of the buffer image.
  25621. * @param heightMapHeight is the height of the buffer image.
  25622. * @param minHeight is the lower limit of the displacement.
  25623. * @param maxHeight is the upper limit of the displacement.
  25624. * @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.
  25625. * @param uvOffset is an optional vector2 used to offset UV.
  25626. * @param uvScale is an optional vector2 used to scale UV.
  25627. * @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.
  25628. * @returns the Mesh.
  25629. */
  25630. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25631. /**
  25632. * Modify the mesh to get a flat shading rendering.
  25633. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25634. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25635. * @returns current mesh
  25636. */
  25637. convertToFlatShadedMesh(): Mesh;
  25638. /**
  25639. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25640. * In other words, more vertices, no more indices and a single bigger VBO.
  25641. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25642. * @returns current mesh
  25643. */
  25644. convertToUnIndexedMesh(): Mesh;
  25645. /**
  25646. * Inverses facet orientations.
  25647. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25648. * @param flipNormals will also inverts the normals
  25649. * @returns current mesh
  25650. */
  25651. flipFaces(flipNormals?: boolean): Mesh;
  25652. /**
  25653. * Increase the number of facets and hence vertices in a mesh
  25654. * Vertex normals are interpolated from existing vertex normals
  25655. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25656. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25657. */
  25658. increaseVertices(numberPerEdge: number): void;
  25659. /**
  25660. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25661. * This will undo any application of covertToFlatShadedMesh
  25662. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25663. */
  25664. forceSharedVertices(): void;
  25665. /** @hidden */
  25666. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25667. /** @hidden */
  25668. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25669. /**
  25670. * Creates a new InstancedMesh object from the mesh model.
  25671. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25672. * @param name defines the name of the new instance
  25673. * @returns a new InstancedMesh
  25674. */
  25675. createInstance(name: string): InstancedMesh;
  25676. /**
  25677. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25678. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25679. * @returns the current mesh
  25680. */
  25681. synchronizeInstances(): Mesh;
  25682. /**
  25683. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25684. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25685. * This should be used together with the simplification to avoid disappearing triangles.
  25686. * @param successCallback an optional success callback to be called after the optimization finished.
  25687. * @returns the current mesh
  25688. */
  25689. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25690. /**
  25691. * Serialize current mesh
  25692. * @param serializationObject defines the object which will receive the serialization data
  25693. */
  25694. serialize(serializationObject: any): void;
  25695. /** @hidden */
  25696. _syncGeometryWithMorphTargetManager(): void;
  25697. /** @hidden */
  25698. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25699. /**
  25700. * Returns a new Mesh object parsed from the source provided.
  25701. * @param parsedMesh is the source
  25702. * @param scene defines the hosting scene
  25703. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25704. * @returns a new Mesh
  25705. */
  25706. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25707. /**
  25708. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25709. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25710. * @param name defines the name of the mesh to create
  25711. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25712. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25713. * @param closePath creates a seam between the first and the last points of each path of the path array
  25714. * @param offset is taken in account only if the `pathArray` is containing a single path
  25715. * @param scene defines the hosting scene
  25716. * @param updatable defines if the mesh must be flagged as updatable
  25717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25718. * @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)
  25719. * @returns a new Mesh
  25720. */
  25721. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25722. /**
  25723. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25724. * @param name defines the name of the mesh to create
  25725. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25726. * @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
  25727. * @param scene defines the hosting scene
  25728. * @param updatable defines if the mesh must be flagged as updatable
  25729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25730. * @returns a new Mesh
  25731. */
  25732. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25733. /**
  25734. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25735. * @param name defines the name of the mesh to create
  25736. * @param size sets the size (float) of each box side (default 1)
  25737. * @param scene defines the hosting scene
  25738. * @param updatable defines if the mesh must be flagged as updatable
  25739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25740. * @returns a new Mesh
  25741. */
  25742. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25743. /**
  25744. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25745. * @param name defines the name of the mesh to create
  25746. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25747. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25754. /**
  25755. * Creates a hemisphere 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. * @returns a new Mesh
  25761. */
  25762. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25763. /**
  25764. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25765. * @param name defines the name of the mesh to create
  25766. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25767. * @param diameterTop set the top cap diameter (floats, default 1)
  25768. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25769. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25770. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25771. * @param scene defines the hosting scene
  25772. * @param updatable defines if the mesh must be flagged as updatable
  25773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25774. * @returns a new Mesh
  25775. */
  25776. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25777. /**
  25778. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25779. * @param name defines the name of the mesh to create
  25780. * @param diameter sets the diameter size (float) of the torus (default 1)
  25781. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25782. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25783. * @param scene defines the hosting scene
  25784. * @param updatable defines if the mesh must be flagged as updatable
  25785. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25786. * @returns a new Mesh
  25787. */
  25788. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25789. /**
  25790. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25791. * @param name defines the name of the mesh to create
  25792. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25793. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25794. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25795. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25796. * @param p the number of windings on X axis (positive integers, default 2)
  25797. * @param q the number of windings on Y axis (positive integers, default 3)
  25798. * @param scene defines the hosting scene
  25799. * @param updatable defines if the mesh must be flagged as updatable
  25800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25801. * @returns a new Mesh
  25802. */
  25803. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25804. /**
  25805. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25806. * @param name defines the name of the mesh to create
  25807. * @param points is an array successive Vector3
  25808. * @param scene defines the hosting scene
  25809. * @param updatable defines if the mesh must be flagged as updatable
  25810. * @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).
  25811. * @returns a new Mesh
  25812. */
  25813. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25814. /**
  25815. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25816. * @param name defines the name of the mesh to create
  25817. * @param points is an array successive Vector3
  25818. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25819. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25820. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25821. * @param scene defines the hosting scene
  25822. * @param updatable defines if the mesh must be flagged as updatable
  25823. * @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)
  25824. * @returns a new Mesh
  25825. */
  25826. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25827. /**
  25828. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25829. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25830. * 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.
  25831. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25832. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25833. * Remember you can only change the shape positions, not their number when updating a polygon.
  25834. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25835. * @param name defines the name of the mesh to create
  25836. * @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
  25837. * @param scene defines the hosting scene
  25838. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25839. * @param updatable defines if the mesh must be flagged as updatable
  25840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25841. * @param earcutInjection can be used to inject your own earcut reference
  25842. * @returns a new Mesh
  25843. */
  25844. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25845. /**
  25846. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25847. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25848. * @param name defines the name of the mesh to create
  25849. * @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
  25850. * @param depth defines the height of extrusion
  25851. * @param scene defines the hosting scene
  25852. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25853. * @param updatable defines if the mesh must be flagged as updatable
  25854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25855. * @param earcutInjection can be used to inject your own earcut reference
  25856. * @returns a new Mesh
  25857. */
  25858. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25859. /**
  25860. * Creates an extruded shape mesh.
  25861. * 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
  25862. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25863. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25864. * @param name defines the name of the mesh to create
  25865. * @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
  25866. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25867. * @param scale is the value to scale the shape
  25868. * @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
  25869. * @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
  25870. * @param scene defines the hosting scene
  25871. * @param updatable defines if the mesh must be flagged as updatable
  25872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25873. * @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)
  25874. * @returns a new Mesh
  25875. */
  25876. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25877. /**
  25878. * Creates an custom extruded shape mesh.
  25879. * The custom extrusion is a parametric shape.
  25880. * It has no predefined shape. Its final shape will depend on the input parameters.
  25881. * Please consider using the same method from the MeshBuilder class instead
  25882. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25883. * @param name defines the name of the mesh to create
  25884. * @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
  25885. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25886. * @param scaleFunction is a custom Javascript function called on each path point
  25887. * @param rotationFunction is a custom Javascript function called on each path point
  25888. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25889. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25890. * @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
  25891. * @param scene defines the hosting scene
  25892. * @param updatable defines if the mesh must be flagged as updatable
  25893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25894. * @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)
  25895. * @returns a new Mesh
  25896. */
  25897. 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;
  25898. /**
  25899. * Creates lathe mesh.
  25900. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25901. * Please consider using the same method from the MeshBuilder class instead
  25902. * @param name defines the name of the mesh to create
  25903. * @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
  25904. * @param radius is the radius value of the lathe
  25905. * @param tessellation is the side number of the lathe.
  25906. * @param scene defines the hosting scene
  25907. * @param updatable defines if the mesh must be flagged as updatable
  25908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25909. * @returns a new Mesh
  25910. */
  25911. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25912. /**
  25913. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25914. * @param name defines the name of the mesh to create
  25915. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25916. * @param scene defines the hosting scene
  25917. * @param updatable defines if the mesh must be flagged as updatable
  25918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25919. * @returns a new Mesh
  25920. */
  25921. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25922. /**
  25923. * Creates a ground mesh.
  25924. * Please consider using the same method from the MeshBuilder class instead
  25925. * @param name defines the name of the mesh to create
  25926. * @param width set the width of the ground
  25927. * @param height set the height of the ground
  25928. * @param subdivisions sets the number of subdivisions per side
  25929. * @param scene defines the hosting scene
  25930. * @param updatable defines if the mesh must be flagged as updatable
  25931. * @returns a new Mesh
  25932. */
  25933. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25934. /**
  25935. * Creates a tiled ground mesh.
  25936. * Please consider using the same method from the MeshBuilder class instead
  25937. * @param name defines the name of the mesh to create
  25938. * @param xmin set the ground minimum X coordinate
  25939. * @param zmin set the ground minimum Y coordinate
  25940. * @param xmax set the ground maximum X coordinate
  25941. * @param zmax set the ground maximum Z coordinate
  25942. * @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
  25943. * @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
  25944. * @param scene defines the hosting scene
  25945. * @param updatable defines if the mesh must be flagged as updatable
  25946. * @returns a new Mesh
  25947. */
  25948. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25949. w: number;
  25950. h: number;
  25951. }, precision: {
  25952. w: number;
  25953. h: number;
  25954. }, scene: Scene, updatable?: boolean): Mesh;
  25955. /**
  25956. * Creates a ground mesh from a height map.
  25957. * Please consider using the same method from the MeshBuilder class instead
  25958. * @see http://doc.babylonjs.com/babylon101/height_map
  25959. * @param name defines the name of the mesh to create
  25960. * @param url sets the URL of the height map image resource
  25961. * @param width set the ground width size
  25962. * @param height set the ground height size
  25963. * @param subdivisions sets the number of subdivision per side
  25964. * @param minHeight is the minimum altitude on the ground
  25965. * @param maxHeight is the maximum altitude on the ground
  25966. * @param scene defines the hosting scene
  25967. * @param updatable defines if the mesh must be flagged as updatable
  25968. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25969. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25970. * @returns a new Mesh
  25971. */
  25972. 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;
  25973. /**
  25974. * Creates a tube mesh.
  25975. * The tube is a parametric shape.
  25976. * It has no predefined shape. Its final shape will depend on the input parameters.
  25977. * Please consider using the same method from the MeshBuilder class instead
  25978. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25979. * @param name defines the name of the mesh to create
  25980. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25981. * @param radius sets the tube radius size
  25982. * @param tessellation is the number of sides on the tubular surface
  25983. * @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
  25984. * @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
  25985. * @param scene defines the hosting scene
  25986. * @param updatable defines if the mesh must be flagged as updatable
  25987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25988. * @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)
  25989. * @returns a new Mesh
  25990. */
  25991. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25992. (i: number, distance: number): number;
  25993. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25994. /**
  25995. * Creates a polyhedron mesh.
  25996. * Please consider using the same method from the MeshBuilder class instead.
  25997. * * 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
  25998. * * The parameter `size` (positive float, default 1) sets the polygon size
  25999. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26000. * * 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`
  26001. * * 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
  26002. * * 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)`)
  26003. * * 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
  26004. * * 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
  26005. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26006. * * If you create a double-sided mesh, you can choose what parts of 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
  26007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26008. * @param name defines the name of the mesh to create
  26009. * @param options defines the options used to create the mesh
  26010. * @param scene defines the hosting scene
  26011. * @returns a new Mesh
  26012. */
  26013. static CreatePolyhedron(name: string, options: {
  26014. type?: number;
  26015. size?: number;
  26016. sizeX?: number;
  26017. sizeY?: number;
  26018. sizeZ?: number;
  26019. custom?: any;
  26020. faceUV?: Vector4[];
  26021. faceColors?: Color4[];
  26022. updatable?: boolean;
  26023. sideOrientation?: number;
  26024. }, scene: Scene): Mesh;
  26025. /**
  26026. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26027. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26028. * * 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`)
  26029. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26030. * * 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
  26031. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26032. * * If you create a double-sided mesh, you can choose what parts of 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
  26033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26034. * @param name defines the name of the mesh
  26035. * @param options defines the options used to create the mesh
  26036. * @param scene defines the hosting scene
  26037. * @returns a new Mesh
  26038. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26039. */
  26040. static CreateIcoSphere(name: string, options: {
  26041. radius?: number;
  26042. flat?: boolean;
  26043. subdivisions?: number;
  26044. sideOrientation?: number;
  26045. updatable?: boolean;
  26046. }, scene: Scene): Mesh;
  26047. /**
  26048. * Creates a decal mesh.
  26049. * Please consider using the same method from the MeshBuilder class instead.
  26050. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26051. * @param name defines the name of the mesh
  26052. * @param sourceMesh defines the mesh receiving the decal
  26053. * @param position sets the position of the decal in world coordinates
  26054. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26055. * @param size sets the decal scaling
  26056. * @param angle sets the angle to rotate the decal
  26057. * @returns a new Mesh
  26058. */
  26059. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26060. /**
  26061. * Prepare internal position array for software CPU skinning
  26062. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26063. */
  26064. setPositionsForCPUSkinning(): Float32Array;
  26065. /**
  26066. * Prepare internal normal array for software CPU skinning
  26067. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26068. */
  26069. setNormalsForCPUSkinning(): Float32Array;
  26070. /**
  26071. * Updates the vertex buffer by applying transformation from the bones
  26072. * @param skeleton defines the skeleton to apply to current mesh
  26073. * @returns the current mesh
  26074. */
  26075. applySkeleton(skeleton: Skeleton): Mesh;
  26076. /**
  26077. * 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
  26078. * @param meshes defines the list of meshes to scan
  26079. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26080. */
  26081. static MinMax(meshes: AbstractMesh[]): {
  26082. min: Vector3;
  26083. max: Vector3;
  26084. };
  26085. /**
  26086. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26087. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26088. * @returns a vector3
  26089. */
  26090. static Center(meshesOrMinMaxVector: {
  26091. min: Vector3;
  26092. max: Vector3;
  26093. } | AbstractMesh[]): Vector3;
  26094. /**
  26095. * Merge the array of meshes into a single mesh for performance reasons.
  26096. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26097. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26098. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26099. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26100. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26101. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26102. * @returns a new mesh
  26103. */
  26104. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26105. /** @hidden */
  26106. addInstance(instance: InstancedMesh): void;
  26107. /** @hidden */
  26108. removeInstance(instance: InstancedMesh): void;
  26109. }
  26110. }
  26111. declare module "babylonjs/Cameras/camera" {
  26112. import { SmartArray } from "babylonjs/Misc/smartArray";
  26113. import { Observable } from "babylonjs/Misc/observable";
  26114. import { Nullable } from "babylonjs/types";
  26115. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26116. import { Scene } from "babylonjs/scene";
  26117. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26118. import { Node } from "babylonjs/node";
  26119. import { Mesh } from "babylonjs/Meshes/mesh";
  26120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26121. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26122. import { Viewport } from "babylonjs/Maths/math.viewport";
  26123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26124. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26126. import { Ray } from "babylonjs/Culling/ray";
  26127. /**
  26128. * This is the base class of all the camera used in the application.
  26129. * @see http://doc.babylonjs.com/features/cameras
  26130. */
  26131. export class Camera extends Node {
  26132. /** @hidden */
  26133. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26134. /**
  26135. * This is the default projection mode used by the cameras.
  26136. * It helps recreating a feeling of perspective and better appreciate depth.
  26137. * This is the best way to simulate real life cameras.
  26138. */
  26139. static readonly PERSPECTIVE_CAMERA: number;
  26140. /**
  26141. * This helps creating camera with an orthographic mode.
  26142. * 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.
  26143. */
  26144. static readonly ORTHOGRAPHIC_CAMERA: number;
  26145. /**
  26146. * This is the default FOV mode for perspective cameras.
  26147. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26148. */
  26149. static readonly FOVMODE_VERTICAL_FIXED: number;
  26150. /**
  26151. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26152. */
  26153. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26154. /**
  26155. * This specifies ther is no need for a camera rig.
  26156. * Basically only one eye is rendered corresponding to the camera.
  26157. */
  26158. static readonly RIG_MODE_NONE: number;
  26159. /**
  26160. * Simulates a camera Rig with one blue eye and one red eye.
  26161. * This can be use with 3d blue and red glasses.
  26162. */
  26163. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26164. /**
  26165. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26166. */
  26167. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26168. /**
  26169. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26170. */
  26171. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26172. /**
  26173. * Defines that both eyes of the camera will be rendered over under each other.
  26174. */
  26175. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26176. /**
  26177. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26178. */
  26179. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26180. /**
  26181. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26182. */
  26183. static readonly RIG_MODE_VR: number;
  26184. /**
  26185. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26186. */
  26187. static readonly RIG_MODE_WEBVR: number;
  26188. /**
  26189. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26190. */
  26191. static readonly RIG_MODE_CUSTOM: number;
  26192. /**
  26193. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26194. */
  26195. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26196. /**
  26197. * Define the input manager associated with the camera.
  26198. */
  26199. inputs: CameraInputsManager<Camera>;
  26200. /** @hidden */
  26201. _position: Vector3;
  26202. /**
  26203. * Define the current local position of the camera in the scene
  26204. */
  26205. get position(): Vector3;
  26206. set position(newPosition: Vector3);
  26207. /**
  26208. * The vector the camera should consider as up.
  26209. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26210. */
  26211. upVector: Vector3;
  26212. /**
  26213. * Define the current limit on the left side for an orthographic camera
  26214. * In scene unit
  26215. */
  26216. orthoLeft: Nullable<number>;
  26217. /**
  26218. * Define the current limit on the right side for an orthographic camera
  26219. * In scene unit
  26220. */
  26221. orthoRight: Nullable<number>;
  26222. /**
  26223. * Define the current limit on the bottom side for an orthographic camera
  26224. * In scene unit
  26225. */
  26226. orthoBottom: Nullable<number>;
  26227. /**
  26228. * Define the current limit on the top side for an orthographic camera
  26229. * In scene unit
  26230. */
  26231. orthoTop: Nullable<number>;
  26232. /**
  26233. * Field Of View is set in Radians. (default is 0.8)
  26234. */
  26235. fov: number;
  26236. /**
  26237. * Define the minimum distance the camera can see from.
  26238. * This is important to note that the depth buffer are not infinite and the closer it starts
  26239. * the more your scene might encounter depth fighting issue.
  26240. */
  26241. minZ: number;
  26242. /**
  26243. * Define the maximum distance the camera can see to.
  26244. * This is important to note that the depth buffer are not infinite and the further it end
  26245. * the more your scene might encounter depth fighting issue.
  26246. */
  26247. maxZ: number;
  26248. /**
  26249. * Define the default inertia of the camera.
  26250. * This helps giving a smooth feeling to the camera movement.
  26251. */
  26252. inertia: number;
  26253. /**
  26254. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26255. */
  26256. mode: number;
  26257. /**
  26258. * Define whether the camera is intermediate.
  26259. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26260. */
  26261. isIntermediate: boolean;
  26262. /**
  26263. * Define the viewport of the camera.
  26264. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26265. */
  26266. viewport: Viewport;
  26267. /**
  26268. * Restricts the camera to viewing objects with the same layerMask.
  26269. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26270. */
  26271. layerMask: number;
  26272. /**
  26273. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26274. */
  26275. fovMode: number;
  26276. /**
  26277. * Rig mode of the camera.
  26278. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26279. * This is normally controlled byt the camera themselves as internal use.
  26280. */
  26281. cameraRigMode: number;
  26282. /**
  26283. * Defines the distance between both "eyes" in case of a RIG
  26284. */
  26285. interaxialDistance: number;
  26286. /**
  26287. * Defines if stereoscopic rendering is done side by side or over under.
  26288. */
  26289. isStereoscopicSideBySide: boolean;
  26290. /**
  26291. * 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
  26292. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26293. * else in the scene. (Eg. security camera)
  26294. *
  26295. * 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)
  26296. */
  26297. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26298. /**
  26299. * When set, the camera will render to this render target instead of the default canvas
  26300. *
  26301. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26302. */
  26303. outputRenderTarget: Nullable<RenderTargetTexture>;
  26304. /**
  26305. * Observable triggered when the camera view matrix has changed.
  26306. */
  26307. onViewMatrixChangedObservable: Observable<Camera>;
  26308. /**
  26309. * Observable triggered when the camera Projection matrix has changed.
  26310. */
  26311. onProjectionMatrixChangedObservable: Observable<Camera>;
  26312. /**
  26313. * Observable triggered when the inputs have been processed.
  26314. */
  26315. onAfterCheckInputsObservable: Observable<Camera>;
  26316. /**
  26317. * Observable triggered when reset has been called and applied to the camera.
  26318. */
  26319. onRestoreStateObservable: Observable<Camera>;
  26320. /**
  26321. * Is this camera a part of a rig system?
  26322. */
  26323. isRigCamera: boolean;
  26324. /**
  26325. * If isRigCamera set to true this will be set with the parent camera.
  26326. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26327. */
  26328. rigParent?: Camera;
  26329. /** @hidden */
  26330. _cameraRigParams: any;
  26331. /** @hidden */
  26332. _rigCameras: Camera[];
  26333. /** @hidden */
  26334. _rigPostProcess: Nullable<PostProcess>;
  26335. protected _webvrViewMatrix: Matrix;
  26336. /** @hidden */
  26337. _skipRendering: boolean;
  26338. /** @hidden */
  26339. _projectionMatrix: Matrix;
  26340. /** @hidden */
  26341. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26342. /** @hidden */
  26343. _activeMeshes: SmartArray<AbstractMesh>;
  26344. protected _globalPosition: Vector3;
  26345. /** @hidden */
  26346. _computedViewMatrix: Matrix;
  26347. private _doNotComputeProjectionMatrix;
  26348. private _transformMatrix;
  26349. private _frustumPlanes;
  26350. private _refreshFrustumPlanes;
  26351. private _storedFov;
  26352. private _stateStored;
  26353. /**
  26354. * Instantiates a new camera object.
  26355. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26356. * @see http://doc.babylonjs.com/features/cameras
  26357. * @param name Defines the name of the camera in the scene
  26358. * @param position Defines the position of the camera
  26359. * @param scene Defines the scene the camera belongs too
  26360. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26361. */
  26362. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26363. /**
  26364. * Store current camera state (fov, position, etc..)
  26365. * @returns the camera
  26366. */
  26367. storeState(): Camera;
  26368. /**
  26369. * Restores the camera state values if it has been stored. You must call storeState() first
  26370. */
  26371. protected _restoreStateValues(): boolean;
  26372. /**
  26373. * Restored camera state. You must call storeState() first.
  26374. * @returns true if restored and false otherwise
  26375. */
  26376. restoreState(): boolean;
  26377. /**
  26378. * Gets the class name of the camera.
  26379. * @returns the class name
  26380. */
  26381. getClassName(): string;
  26382. /** @hidden */
  26383. readonly _isCamera: boolean;
  26384. /**
  26385. * Gets a string representation of the camera useful for debug purpose.
  26386. * @param fullDetails Defines that a more verboe level of logging is required
  26387. * @returns the string representation
  26388. */
  26389. toString(fullDetails?: boolean): string;
  26390. /**
  26391. * Gets the current world space position of the camera.
  26392. */
  26393. get globalPosition(): Vector3;
  26394. /**
  26395. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26396. * @returns the active meshe list
  26397. */
  26398. getActiveMeshes(): SmartArray<AbstractMesh>;
  26399. /**
  26400. * Check whether a mesh is part of the current active mesh list of the camera
  26401. * @param mesh Defines the mesh to check
  26402. * @returns true if active, false otherwise
  26403. */
  26404. isActiveMesh(mesh: Mesh): boolean;
  26405. /**
  26406. * Is this camera ready to be used/rendered
  26407. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26408. * @return true if the camera is ready
  26409. */
  26410. isReady(completeCheck?: boolean): boolean;
  26411. /** @hidden */
  26412. _initCache(): void;
  26413. /** @hidden */
  26414. _updateCache(ignoreParentClass?: boolean): void;
  26415. /** @hidden */
  26416. _isSynchronized(): boolean;
  26417. /** @hidden */
  26418. _isSynchronizedViewMatrix(): boolean;
  26419. /** @hidden */
  26420. _isSynchronizedProjectionMatrix(): boolean;
  26421. /**
  26422. * Attach the input controls to a specific dom element to get the input from.
  26423. * @param element Defines the element the controls should be listened from
  26424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26425. */
  26426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26427. /**
  26428. * Detach the current controls from the specified dom element.
  26429. * @param element Defines the element to stop listening the inputs from
  26430. */
  26431. detachControl(element: HTMLElement): void;
  26432. /**
  26433. * Update the camera state according to the different inputs gathered during the frame.
  26434. */
  26435. update(): void;
  26436. /** @hidden */
  26437. _checkInputs(): void;
  26438. /** @hidden */
  26439. get rigCameras(): Camera[];
  26440. /**
  26441. * Gets the post process used by the rig cameras
  26442. */
  26443. get rigPostProcess(): Nullable<PostProcess>;
  26444. /**
  26445. * Internal, gets the first post proces.
  26446. * @returns the first post process to be run on this camera.
  26447. */
  26448. _getFirstPostProcess(): Nullable<PostProcess>;
  26449. private _cascadePostProcessesToRigCams;
  26450. /**
  26451. * Attach a post process to the camera.
  26452. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26453. * @param postProcess The post process to attach to the camera
  26454. * @param insertAt The position of the post process in case several of them are in use in the scene
  26455. * @returns the position the post process has been inserted at
  26456. */
  26457. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26458. /**
  26459. * Detach a post process to the camera.
  26460. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26461. * @param postProcess The post process to detach from the camera
  26462. */
  26463. detachPostProcess(postProcess: PostProcess): void;
  26464. /**
  26465. * Gets the current world matrix of the camera
  26466. */
  26467. getWorldMatrix(): Matrix;
  26468. /** @hidden */
  26469. _getViewMatrix(): Matrix;
  26470. /**
  26471. * Gets the current view matrix of the camera.
  26472. * @param force forces the camera to recompute the matrix without looking at the cached state
  26473. * @returns the view matrix
  26474. */
  26475. getViewMatrix(force?: boolean): Matrix;
  26476. /**
  26477. * Freeze the projection matrix.
  26478. * It will prevent the cache check of the camera projection compute and can speed up perf
  26479. * if no parameter of the camera are meant to change
  26480. * @param projection Defines manually a projection if necessary
  26481. */
  26482. freezeProjectionMatrix(projection?: Matrix): void;
  26483. /**
  26484. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26485. */
  26486. unfreezeProjectionMatrix(): void;
  26487. /**
  26488. * Gets the current projection matrix of the camera.
  26489. * @param force forces the camera to recompute the matrix without looking at the cached state
  26490. * @returns the projection matrix
  26491. */
  26492. getProjectionMatrix(force?: boolean): Matrix;
  26493. /**
  26494. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26495. * @returns a Matrix
  26496. */
  26497. getTransformationMatrix(): Matrix;
  26498. private _updateFrustumPlanes;
  26499. /**
  26500. * Checks if a cullable object (mesh...) is in the camera frustum
  26501. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26502. * @param target The object to check
  26503. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26504. * @returns true if the object is in frustum otherwise false
  26505. */
  26506. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26507. /**
  26508. * Checks if a cullable object (mesh...) is in the camera frustum
  26509. * Unlike isInFrustum this cheks the full bounding box
  26510. * @param target The object to check
  26511. * @returns true if the object is in frustum otherwise false
  26512. */
  26513. isCompletelyInFrustum(target: ICullable): boolean;
  26514. /**
  26515. * Gets a ray in the forward direction from the camera.
  26516. * @param length Defines the length of the ray to create
  26517. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26518. * @param origin Defines the start point of the ray which defaults to the camera position
  26519. * @returns the forward ray
  26520. */
  26521. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26522. /**
  26523. * Releases resources associated with this node.
  26524. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26525. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26526. */
  26527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26528. /** @hidden */
  26529. _isLeftCamera: boolean;
  26530. /**
  26531. * Gets the left camera of a rig setup in case of Rigged Camera
  26532. */
  26533. get isLeftCamera(): boolean;
  26534. /** @hidden */
  26535. _isRightCamera: boolean;
  26536. /**
  26537. * Gets the right camera of a rig setup in case of Rigged Camera
  26538. */
  26539. get isRightCamera(): boolean;
  26540. /**
  26541. * Gets the left camera of a rig setup in case of Rigged Camera
  26542. */
  26543. get leftCamera(): Nullable<FreeCamera>;
  26544. /**
  26545. * Gets the right camera of a rig setup in case of Rigged Camera
  26546. */
  26547. get rightCamera(): Nullable<FreeCamera>;
  26548. /**
  26549. * Gets the left camera target of a rig setup in case of Rigged Camera
  26550. * @returns the target position
  26551. */
  26552. getLeftTarget(): Nullable<Vector3>;
  26553. /**
  26554. * Gets the right camera target of a rig setup in case of Rigged Camera
  26555. * @returns the target position
  26556. */
  26557. getRightTarget(): Nullable<Vector3>;
  26558. /**
  26559. * @hidden
  26560. */
  26561. setCameraRigMode(mode: number, rigParams: any): void;
  26562. /** @hidden */
  26563. static _setStereoscopicRigMode(camera: Camera): void;
  26564. /** @hidden */
  26565. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26566. /** @hidden */
  26567. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26568. /** @hidden */
  26569. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26570. /** @hidden */
  26571. _getVRProjectionMatrix(): Matrix;
  26572. protected _updateCameraRotationMatrix(): void;
  26573. protected _updateWebVRCameraRotationMatrix(): void;
  26574. /**
  26575. * This function MUST be overwritten by the different WebVR cameras available.
  26576. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26577. * @hidden
  26578. */
  26579. _getWebVRProjectionMatrix(): Matrix;
  26580. /**
  26581. * This function MUST be overwritten by the different WebVR cameras available.
  26582. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26583. * @hidden
  26584. */
  26585. _getWebVRViewMatrix(): Matrix;
  26586. /** @hidden */
  26587. setCameraRigParameter(name: string, value: any): void;
  26588. /**
  26589. * needs to be overridden by children so sub has required properties to be copied
  26590. * @hidden
  26591. */
  26592. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26593. /**
  26594. * May need to be overridden by children
  26595. * @hidden
  26596. */
  26597. _updateRigCameras(): void;
  26598. /** @hidden */
  26599. _setupInputs(): void;
  26600. /**
  26601. * Serialiaze the camera setup to a json represention
  26602. * @returns the JSON representation
  26603. */
  26604. serialize(): any;
  26605. /**
  26606. * Clones the current camera.
  26607. * @param name The cloned camera name
  26608. * @returns the cloned camera
  26609. */
  26610. clone(name: string): Camera;
  26611. /**
  26612. * Gets the direction of the camera relative to a given local axis.
  26613. * @param localAxis Defines the reference axis to provide a relative direction.
  26614. * @return the direction
  26615. */
  26616. getDirection(localAxis: Vector3): Vector3;
  26617. /**
  26618. * Returns the current camera absolute rotation
  26619. */
  26620. get absoluteRotation(): Quaternion;
  26621. /**
  26622. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26623. * @param localAxis Defines the reference axis to provide a relative direction.
  26624. * @param result Defines the vector to store the result in
  26625. */
  26626. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26627. /**
  26628. * Gets a camera constructor for a given camera type
  26629. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26630. * @param name The name of the camera the result will be able to instantiate
  26631. * @param scene The scene the result will construct the camera in
  26632. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26633. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26634. * @returns a factory method to construc the camera
  26635. */
  26636. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26637. /**
  26638. * Compute the world matrix of the camera.
  26639. * @returns the camera world matrix
  26640. */
  26641. computeWorldMatrix(): Matrix;
  26642. /**
  26643. * Parse a JSON and creates the camera from the parsed information
  26644. * @param parsedCamera The JSON to parse
  26645. * @param scene The scene to instantiate the camera in
  26646. * @returns the newly constructed camera
  26647. */
  26648. static Parse(parsedCamera: any, scene: Scene): Camera;
  26649. }
  26650. }
  26651. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26652. import { Nullable } from "babylonjs/types";
  26653. import { Scene } from "babylonjs/scene";
  26654. import { Vector4 } from "babylonjs/Maths/math.vector";
  26655. import { Mesh } from "babylonjs/Meshes/mesh";
  26656. /**
  26657. * Class containing static functions to help procedurally build meshes
  26658. */
  26659. export class DiscBuilder {
  26660. /**
  26661. * Creates a plane polygonal mesh. By default, this is a disc
  26662. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26663. * * 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
  26664. * * 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
  26665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26668. * @param name defines the name of the mesh
  26669. * @param options defines the options used to create the mesh
  26670. * @param scene defines the hosting scene
  26671. * @returns the plane polygonal mesh
  26672. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26673. */
  26674. static CreateDisc(name: string, options: {
  26675. radius?: number;
  26676. tessellation?: number;
  26677. arc?: number;
  26678. updatable?: boolean;
  26679. sideOrientation?: number;
  26680. frontUVs?: Vector4;
  26681. backUVs?: Vector4;
  26682. }, scene?: Nullable<Scene>): Mesh;
  26683. }
  26684. }
  26685. declare module "babylonjs/Materials/fresnelParameters" {
  26686. import { Color3 } from "babylonjs/Maths/math.color";
  26687. /**
  26688. * This represents all the required information to add a fresnel effect on a material:
  26689. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26690. */
  26691. export class FresnelParameters {
  26692. private _isEnabled;
  26693. /**
  26694. * Define if the fresnel effect is enable or not.
  26695. */
  26696. get isEnabled(): boolean;
  26697. set isEnabled(value: boolean);
  26698. /**
  26699. * Define the color used on edges (grazing angle)
  26700. */
  26701. leftColor: Color3;
  26702. /**
  26703. * Define the color used on center
  26704. */
  26705. rightColor: Color3;
  26706. /**
  26707. * Define bias applied to computed fresnel term
  26708. */
  26709. bias: number;
  26710. /**
  26711. * Defined the power exponent applied to fresnel term
  26712. */
  26713. power: number;
  26714. /**
  26715. * Clones the current fresnel and its valuues
  26716. * @returns a clone fresnel configuration
  26717. */
  26718. clone(): FresnelParameters;
  26719. /**
  26720. * Serializes the current fresnel parameters to a JSON representation.
  26721. * @return the JSON serialization
  26722. */
  26723. serialize(): any;
  26724. /**
  26725. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26726. * @param parsedFresnelParameters Define the JSON representation
  26727. * @returns the parsed parameters
  26728. */
  26729. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26730. }
  26731. }
  26732. declare module "babylonjs/Materials/pushMaterial" {
  26733. import { Nullable } from "babylonjs/types";
  26734. import { Scene } from "babylonjs/scene";
  26735. import { Matrix } from "babylonjs/Maths/math.vector";
  26736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26737. import { Mesh } from "babylonjs/Meshes/mesh";
  26738. import { Material } from "babylonjs/Materials/material";
  26739. import { Effect } from "babylonjs/Materials/effect";
  26740. /**
  26741. * Base class of materials working in push mode in babylon JS
  26742. * @hidden
  26743. */
  26744. export class PushMaterial extends Material {
  26745. protected _activeEffect: Effect;
  26746. protected _normalMatrix: Matrix;
  26747. /**
  26748. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26749. * This means that the material can keep using a previous shader while a new one is being compiled.
  26750. * This is mostly used when shader parallel compilation is supported (true by default)
  26751. */
  26752. allowShaderHotSwapping: boolean;
  26753. constructor(name: string, scene: Scene);
  26754. getEffect(): Effect;
  26755. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26756. /**
  26757. * Binds the given world matrix to the active effect
  26758. *
  26759. * @param world the matrix to bind
  26760. */
  26761. bindOnlyWorldMatrix(world: Matrix): void;
  26762. /**
  26763. * Binds the given normal matrix to the active effect
  26764. *
  26765. * @param normalMatrix the matrix to bind
  26766. */
  26767. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26768. bind(world: Matrix, mesh?: Mesh): void;
  26769. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26770. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26771. }
  26772. }
  26773. declare module "babylonjs/Materials/materialFlags" {
  26774. /**
  26775. * This groups all the flags used to control the materials channel.
  26776. */
  26777. export class MaterialFlags {
  26778. private static _DiffuseTextureEnabled;
  26779. /**
  26780. * Are diffuse textures enabled in the application.
  26781. */
  26782. static get DiffuseTextureEnabled(): boolean;
  26783. static set DiffuseTextureEnabled(value: boolean);
  26784. private static _AmbientTextureEnabled;
  26785. /**
  26786. * Are ambient textures enabled in the application.
  26787. */
  26788. static get AmbientTextureEnabled(): boolean;
  26789. static set AmbientTextureEnabled(value: boolean);
  26790. private static _OpacityTextureEnabled;
  26791. /**
  26792. * Are opacity textures enabled in the application.
  26793. */
  26794. static get OpacityTextureEnabled(): boolean;
  26795. static set OpacityTextureEnabled(value: boolean);
  26796. private static _ReflectionTextureEnabled;
  26797. /**
  26798. * Are reflection textures enabled in the application.
  26799. */
  26800. static get ReflectionTextureEnabled(): boolean;
  26801. static set ReflectionTextureEnabled(value: boolean);
  26802. private static _EmissiveTextureEnabled;
  26803. /**
  26804. * Are emissive textures enabled in the application.
  26805. */
  26806. static get EmissiveTextureEnabled(): boolean;
  26807. static set EmissiveTextureEnabled(value: boolean);
  26808. private static _SpecularTextureEnabled;
  26809. /**
  26810. * Are specular textures enabled in the application.
  26811. */
  26812. static get SpecularTextureEnabled(): boolean;
  26813. static set SpecularTextureEnabled(value: boolean);
  26814. private static _BumpTextureEnabled;
  26815. /**
  26816. * Are bump textures enabled in the application.
  26817. */
  26818. static get BumpTextureEnabled(): boolean;
  26819. static set BumpTextureEnabled(value: boolean);
  26820. private static _LightmapTextureEnabled;
  26821. /**
  26822. * Are lightmap textures enabled in the application.
  26823. */
  26824. static get LightmapTextureEnabled(): boolean;
  26825. static set LightmapTextureEnabled(value: boolean);
  26826. private static _RefractionTextureEnabled;
  26827. /**
  26828. * Are refraction textures enabled in the application.
  26829. */
  26830. static get RefractionTextureEnabled(): boolean;
  26831. static set RefractionTextureEnabled(value: boolean);
  26832. private static _ColorGradingTextureEnabled;
  26833. /**
  26834. * Are color grading textures enabled in the application.
  26835. */
  26836. static get ColorGradingTextureEnabled(): boolean;
  26837. static set ColorGradingTextureEnabled(value: boolean);
  26838. private static _FresnelEnabled;
  26839. /**
  26840. * Are fresnels enabled in the application.
  26841. */
  26842. static get FresnelEnabled(): boolean;
  26843. static set FresnelEnabled(value: boolean);
  26844. private static _ClearCoatTextureEnabled;
  26845. /**
  26846. * Are clear coat textures enabled in the application.
  26847. */
  26848. static get ClearCoatTextureEnabled(): boolean;
  26849. static set ClearCoatTextureEnabled(value: boolean);
  26850. private static _ClearCoatBumpTextureEnabled;
  26851. /**
  26852. * Are clear coat bump textures enabled in the application.
  26853. */
  26854. static get ClearCoatBumpTextureEnabled(): boolean;
  26855. static set ClearCoatBumpTextureEnabled(value: boolean);
  26856. private static _ClearCoatTintTextureEnabled;
  26857. /**
  26858. * Are clear coat tint textures enabled in the application.
  26859. */
  26860. static get ClearCoatTintTextureEnabled(): boolean;
  26861. static set ClearCoatTintTextureEnabled(value: boolean);
  26862. private static _SheenTextureEnabled;
  26863. /**
  26864. * Are sheen textures enabled in the application.
  26865. */
  26866. static get SheenTextureEnabled(): boolean;
  26867. static set SheenTextureEnabled(value: boolean);
  26868. private static _AnisotropicTextureEnabled;
  26869. /**
  26870. * Are anisotropic textures enabled in the application.
  26871. */
  26872. static get AnisotropicTextureEnabled(): boolean;
  26873. static set AnisotropicTextureEnabled(value: boolean);
  26874. private static _ThicknessTextureEnabled;
  26875. /**
  26876. * Are thickness textures enabled in the application.
  26877. */
  26878. static get ThicknessTextureEnabled(): boolean;
  26879. static set ThicknessTextureEnabled(value: boolean);
  26880. }
  26881. }
  26882. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26883. /** @hidden */
  26884. export var defaultFragmentDeclaration: {
  26885. name: string;
  26886. shader: string;
  26887. };
  26888. }
  26889. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26890. /** @hidden */
  26891. export var defaultUboDeclaration: {
  26892. name: string;
  26893. shader: string;
  26894. };
  26895. }
  26896. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26897. /** @hidden */
  26898. export var lightFragmentDeclaration: {
  26899. name: string;
  26900. shader: string;
  26901. };
  26902. }
  26903. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26904. /** @hidden */
  26905. export var lightUboDeclaration: {
  26906. name: string;
  26907. shader: string;
  26908. };
  26909. }
  26910. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26911. /** @hidden */
  26912. export var lightsFragmentFunctions: {
  26913. name: string;
  26914. shader: string;
  26915. };
  26916. }
  26917. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26918. /** @hidden */
  26919. export var shadowsFragmentFunctions: {
  26920. name: string;
  26921. shader: string;
  26922. };
  26923. }
  26924. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26925. /** @hidden */
  26926. export var fresnelFunction: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26932. /** @hidden */
  26933. export var reflectionFunction: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26939. /** @hidden */
  26940. export var bumpFragmentFunctions: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26946. /** @hidden */
  26947. export var logDepthDeclaration: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26953. /** @hidden */
  26954. export var bumpFragment: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26960. /** @hidden */
  26961. export var depthPrePass: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26967. /** @hidden */
  26968. export var lightFragment: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26974. /** @hidden */
  26975. export var logDepthFragment: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/default.fragment" {
  26981. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26982. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26984. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26987. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26988. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26989. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26991. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26992. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26995. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26997. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26998. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26999. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27000. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27001. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27002. /** @hidden */
  27003. export var defaultPixelShader: {
  27004. name: string;
  27005. shader: string;
  27006. };
  27007. }
  27008. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27009. /** @hidden */
  27010. export var defaultVertexDeclaration: {
  27011. name: string;
  27012. shader: string;
  27013. };
  27014. }
  27015. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27016. /** @hidden */
  27017. export var bumpVertexDeclaration: {
  27018. name: string;
  27019. shader: string;
  27020. };
  27021. }
  27022. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27023. /** @hidden */
  27024. export var bumpVertex: {
  27025. name: string;
  27026. shader: string;
  27027. };
  27028. }
  27029. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27030. /** @hidden */
  27031. export var fogVertex: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27037. /** @hidden */
  27038. export var shadowsVertex: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27044. /** @hidden */
  27045. export var pointCloudVertex: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27051. /** @hidden */
  27052. export var logDepthVertex: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/default.vertex" {
  27058. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27059. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27060. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27061. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27072. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27073. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27074. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27078. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27079. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27080. /** @hidden */
  27081. export var defaultVertexShader: {
  27082. name: string;
  27083. shader: string;
  27084. };
  27085. }
  27086. declare module "babylonjs/Materials/standardMaterial" {
  27087. import { SmartArray } from "babylonjs/Misc/smartArray";
  27088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27089. import { Nullable } from "babylonjs/types";
  27090. import { Scene } from "babylonjs/scene";
  27091. import { Matrix } from "babylonjs/Maths/math.vector";
  27092. import { Color3 } from "babylonjs/Maths/math.color";
  27093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27095. import { Mesh } from "babylonjs/Meshes/mesh";
  27096. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27097. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27098. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27099. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27100. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27103. import "babylonjs/Shaders/default.fragment";
  27104. import "babylonjs/Shaders/default.vertex";
  27105. /** @hidden */
  27106. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27107. MAINUV1: boolean;
  27108. MAINUV2: boolean;
  27109. DIFFUSE: boolean;
  27110. DIFFUSEDIRECTUV: number;
  27111. AMBIENT: boolean;
  27112. AMBIENTDIRECTUV: number;
  27113. OPACITY: boolean;
  27114. OPACITYDIRECTUV: number;
  27115. OPACITYRGB: boolean;
  27116. REFLECTION: boolean;
  27117. EMISSIVE: boolean;
  27118. EMISSIVEDIRECTUV: number;
  27119. SPECULAR: boolean;
  27120. SPECULARDIRECTUV: number;
  27121. BUMP: boolean;
  27122. BUMPDIRECTUV: number;
  27123. PARALLAX: boolean;
  27124. PARALLAXOCCLUSION: boolean;
  27125. SPECULAROVERALPHA: boolean;
  27126. CLIPPLANE: boolean;
  27127. CLIPPLANE2: boolean;
  27128. CLIPPLANE3: boolean;
  27129. CLIPPLANE4: boolean;
  27130. CLIPPLANE5: boolean;
  27131. CLIPPLANE6: boolean;
  27132. ALPHATEST: boolean;
  27133. DEPTHPREPASS: boolean;
  27134. ALPHAFROMDIFFUSE: boolean;
  27135. POINTSIZE: boolean;
  27136. FOG: boolean;
  27137. SPECULARTERM: boolean;
  27138. DIFFUSEFRESNEL: boolean;
  27139. OPACITYFRESNEL: boolean;
  27140. REFLECTIONFRESNEL: boolean;
  27141. REFRACTIONFRESNEL: boolean;
  27142. EMISSIVEFRESNEL: boolean;
  27143. FRESNEL: boolean;
  27144. NORMAL: boolean;
  27145. UV1: boolean;
  27146. UV2: boolean;
  27147. VERTEXCOLOR: boolean;
  27148. VERTEXALPHA: boolean;
  27149. NUM_BONE_INFLUENCERS: number;
  27150. BonesPerMesh: number;
  27151. BONETEXTURE: boolean;
  27152. INSTANCES: boolean;
  27153. GLOSSINESS: boolean;
  27154. ROUGHNESS: boolean;
  27155. EMISSIVEASILLUMINATION: boolean;
  27156. LINKEMISSIVEWITHDIFFUSE: boolean;
  27157. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27158. LIGHTMAP: boolean;
  27159. LIGHTMAPDIRECTUV: number;
  27160. OBJECTSPACE_NORMALMAP: boolean;
  27161. USELIGHTMAPASSHADOWMAP: boolean;
  27162. REFLECTIONMAP_3D: boolean;
  27163. REFLECTIONMAP_SPHERICAL: boolean;
  27164. REFLECTIONMAP_PLANAR: boolean;
  27165. REFLECTIONMAP_CUBIC: boolean;
  27166. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27167. REFLECTIONMAP_PROJECTION: boolean;
  27168. REFLECTIONMAP_SKYBOX: boolean;
  27169. REFLECTIONMAP_EXPLICIT: boolean;
  27170. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27171. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27172. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27173. INVERTCUBICMAP: boolean;
  27174. LOGARITHMICDEPTH: boolean;
  27175. REFRACTION: boolean;
  27176. REFRACTIONMAP_3D: boolean;
  27177. REFLECTIONOVERALPHA: boolean;
  27178. TWOSIDEDLIGHTING: boolean;
  27179. SHADOWFLOAT: boolean;
  27180. MORPHTARGETS: boolean;
  27181. MORPHTARGETS_NORMAL: boolean;
  27182. MORPHTARGETS_TANGENT: boolean;
  27183. MORPHTARGETS_UV: boolean;
  27184. NUM_MORPH_INFLUENCERS: number;
  27185. NONUNIFORMSCALING: boolean;
  27186. PREMULTIPLYALPHA: boolean;
  27187. IMAGEPROCESSING: boolean;
  27188. VIGNETTE: boolean;
  27189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27190. VIGNETTEBLENDMODEOPAQUE: boolean;
  27191. TONEMAPPING: boolean;
  27192. TONEMAPPING_ACES: boolean;
  27193. CONTRAST: boolean;
  27194. COLORCURVES: boolean;
  27195. COLORGRADING: boolean;
  27196. COLORGRADING3D: boolean;
  27197. SAMPLER3DGREENDEPTH: boolean;
  27198. SAMPLER3DBGRMAP: boolean;
  27199. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27200. MULTIVIEW: boolean;
  27201. /**
  27202. * If the reflection texture on this material is in linear color space
  27203. * @hidden
  27204. */
  27205. IS_REFLECTION_LINEAR: boolean;
  27206. /**
  27207. * If the refraction texture on this material is in linear color space
  27208. * @hidden
  27209. */
  27210. IS_REFRACTION_LINEAR: boolean;
  27211. EXPOSURE: boolean;
  27212. constructor();
  27213. setReflectionMode(modeToEnable: string): void;
  27214. }
  27215. /**
  27216. * This is the default material used in Babylon. It is the best trade off between quality
  27217. * and performances.
  27218. * @see http://doc.babylonjs.com/babylon101/materials
  27219. */
  27220. export class StandardMaterial extends PushMaterial {
  27221. private _diffuseTexture;
  27222. /**
  27223. * The basic texture of the material as viewed under a light.
  27224. */
  27225. diffuseTexture: Nullable<BaseTexture>;
  27226. private _ambientTexture;
  27227. /**
  27228. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27229. */
  27230. ambientTexture: Nullable<BaseTexture>;
  27231. private _opacityTexture;
  27232. /**
  27233. * Define the transparency of the material from a texture.
  27234. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27235. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27236. */
  27237. opacityTexture: Nullable<BaseTexture>;
  27238. private _reflectionTexture;
  27239. /**
  27240. * Define the texture used to display the reflection.
  27241. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27242. */
  27243. reflectionTexture: Nullable<BaseTexture>;
  27244. private _emissiveTexture;
  27245. /**
  27246. * Define texture of the material as if self lit.
  27247. * This will be mixed in the final result even in the absence of light.
  27248. */
  27249. emissiveTexture: Nullable<BaseTexture>;
  27250. private _specularTexture;
  27251. /**
  27252. * Define how the color and intensity of the highlight given by the light in the material.
  27253. */
  27254. specularTexture: Nullable<BaseTexture>;
  27255. private _bumpTexture;
  27256. /**
  27257. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27258. * 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.
  27259. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27260. */
  27261. bumpTexture: Nullable<BaseTexture>;
  27262. private _lightmapTexture;
  27263. /**
  27264. * Complex lighting can be computationally expensive to compute at runtime.
  27265. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27266. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27267. */
  27268. lightmapTexture: Nullable<BaseTexture>;
  27269. private _refractionTexture;
  27270. /**
  27271. * Define the texture used to display the refraction.
  27272. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27273. */
  27274. refractionTexture: Nullable<BaseTexture>;
  27275. /**
  27276. * The color of the material lit by the environmental background lighting.
  27277. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27278. */
  27279. ambientColor: Color3;
  27280. /**
  27281. * The basic color of the material as viewed under a light.
  27282. */
  27283. diffuseColor: Color3;
  27284. /**
  27285. * Define how the color and intensity of the highlight given by the light in the material.
  27286. */
  27287. specularColor: Color3;
  27288. /**
  27289. * Define the color of the material as if self lit.
  27290. * This will be mixed in the final result even in the absence of light.
  27291. */
  27292. emissiveColor: Color3;
  27293. /**
  27294. * Defines how sharp are the highlights in the material.
  27295. * The bigger the value the sharper giving a more glossy feeling to the result.
  27296. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27297. */
  27298. specularPower: number;
  27299. private _useAlphaFromDiffuseTexture;
  27300. /**
  27301. * Does the transparency come from the diffuse texture alpha channel.
  27302. */
  27303. useAlphaFromDiffuseTexture: boolean;
  27304. private _useEmissiveAsIllumination;
  27305. /**
  27306. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27307. */
  27308. useEmissiveAsIllumination: boolean;
  27309. private _linkEmissiveWithDiffuse;
  27310. /**
  27311. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27312. * the emissive level when the final color is close to one.
  27313. */
  27314. linkEmissiveWithDiffuse: boolean;
  27315. private _useSpecularOverAlpha;
  27316. /**
  27317. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27318. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27319. */
  27320. useSpecularOverAlpha: boolean;
  27321. private _useReflectionOverAlpha;
  27322. /**
  27323. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27324. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27325. */
  27326. useReflectionOverAlpha: boolean;
  27327. private _disableLighting;
  27328. /**
  27329. * Does lights from the scene impacts this material.
  27330. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27331. */
  27332. disableLighting: boolean;
  27333. private _useObjectSpaceNormalMap;
  27334. /**
  27335. * Allows using an object space normal map (instead of tangent space).
  27336. */
  27337. useObjectSpaceNormalMap: boolean;
  27338. private _useParallax;
  27339. /**
  27340. * Is parallax enabled or not.
  27341. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27342. */
  27343. useParallax: boolean;
  27344. private _useParallaxOcclusion;
  27345. /**
  27346. * Is parallax occlusion enabled or not.
  27347. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27348. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27349. */
  27350. useParallaxOcclusion: boolean;
  27351. /**
  27352. * 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.
  27353. */
  27354. parallaxScaleBias: number;
  27355. private _roughness;
  27356. /**
  27357. * Helps to define how blurry the reflections should appears in the material.
  27358. */
  27359. roughness: number;
  27360. /**
  27361. * In case of refraction, define the value of the index of refraction.
  27362. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27363. */
  27364. indexOfRefraction: number;
  27365. /**
  27366. * Invert the refraction texture alongside the y axis.
  27367. * It can be useful with procedural textures or probe for instance.
  27368. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27369. */
  27370. invertRefractionY: boolean;
  27371. /**
  27372. * Defines the alpha limits in alpha test mode.
  27373. */
  27374. alphaCutOff: number;
  27375. private _useLightmapAsShadowmap;
  27376. /**
  27377. * In case of light mapping, define whether the map contains light or shadow informations.
  27378. */
  27379. useLightmapAsShadowmap: boolean;
  27380. private _diffuseFresnelParameters;
  27381. /**
  27382. * Define the diffuse fresnel parameters of the material.
  27383. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27384. */
  27385. diffuseFresnelParameters: FresnelParameters;
  27386. private _opacityFresnelParameters;
  27387. /**
  27388. * Define the opacity fresnel parameters of the material.
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27390. */
  27391. opacityFresnelParameters: FresnelParameters;
  27392. private _reflectionFresnelParameters;
  27393. /**
  27394. * Define the reflection fresnel parameters of the material.
  27395. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27396. */
  27397. reflectionFresnelParameters: FresnelParameters;
  27398. private _refractionFresnelParameters;
  27399. /**
  27400. * Define the refraction fresnel parameters of the material.
  27401. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27402. */
  27403. refractionFresnelParameters: FresnelParameters;
  27404. private _emissiveFresnelParameters;
  27405. /**
  27406. * Define the emissive fresnel parameters of the material.
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27408. */
  27409. emissiveFresnelParameters: FresnelParameters;
  27410. private _useReflectionFresnelFromSpecular;
  27411. /**
  27412. * If true automatically deducts the fresnels values from the material specularity.
  27413. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27414. */
  27415. useReflectionFresnelFromSpecular: boolean;
  27416. private _useGlossinessFromSpecularMapAlpha;
  27417. /**
  27418. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27419. */
  27420. useGlossinessFromSpecularMapAlpha: boolean;
  27421. private _maxSimultaneousLights;
  27422. /**
  27423. * Defines the maximum number of lights that can be used in the material
  27424. */
  27425. maxSimultaneousLights: number;
  27426. private _invertNormalMapX;
  27427. /**
  27428. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27429. */
  27430. invertNormalMapX: boolean;
  27431. private _invertNormalMapY;
  27432. /**
  27433. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27434. */
  27435. invertNormalMapY: boolean;
  27436. private _twoSidedLighting;
  27437. /**
  27438. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27439. */
  27440. twoSidedLighting: boolean;
  27441. /**
  27442. * Default configuration related to image processing available in the standard Material.
  27443. */
  27444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27445. /**
  27446. * Gets the image processing configuration used either in this material.
  27447. */
  27448. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27449. /**
  27450. * Sets the Default image processing configuration used either in the this material.
  27451. *
  27452. * If sets to null, the scene one is in use.
  27453. */
  27454. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27455. /**
  27456. * Keep track of the image processing observer to allow dispose and replace.
  27457. */
  27458. private _imageProcessingObserver;
  27459. /**
  27460. * Attaches a new image processing configuration to the Standard Material.
  27461. * @param configuration
  27462. */
  27463. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27464. /**
  27465. * Gets wether the color curves effect is enabled.
  27466. */
  27467. get cameraColorCurvesEnabled(): boolean;
  27468. /**
  27469. * Sets wether the color curves effect is enabled.
  27470. */
  27471. set cameraColorCurvesEnabled(value: boolean);
  27472. /**
  27473. * Gets wether the color grading effect is enabled.
  27474. */
  27475. get cameraColorGradingEnabled(): boolean;
  27476. /**
  27477. * Gets wether the color grading effect is enabled.
  27478. */
  27479. set cameraColorGradingEnabled(value: boolean);
  27480. /**
  27481. * Gets wether tonemapping is enabled or not.
  27482. */
  27483. get cameraToneMappingEnabled(): boolean;
  27484. /**
  27485. * Sets wether tonemapping is enabled or not
  27486. */
  27487. set cameraToneMappingEnabled(value: boolean);
  27488. /**
  27489. * The camera exposure used on this material.
  27490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27491. * This corresponds to a photographic exposure.
  27492. */
  27493. get cameraExposure(): number;
  27494. /**
  27495. * The camera exposure used on this material.
  27496. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27497. * This corresponds to a photographic exposure.
  27498. */
  27499. set cameraExposure(value: number);
  27500. /**
  27501. * Gets The camera contrast used on this material.
  27502. */
  27503. get cameraContrast(): number;
  27504. /**
  27505. * Sets The camera contrast used on this material.
  27506. */
  27507. set cameraContrast(value: number);
  27508. /**
  27509. * Gets the Color Grading 2D Lookup Texture.
  27510. */
  27511. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27512. /**
  27513. * Sets the Color Grading 2D Lookup Texture.
  27514. */
  27515. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27516. /**
  27517. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27518. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27519. * 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;
  27520. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27521. */
  27522. get cameraColorCurves(): Nullable<ColorCurves>;
  27523. /**
  27524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27526. * 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;
  27527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27528. */
  27529. set cameraColorCurves(value: Nullable<ColorCurves>);
  27530. /**
  27531. * Custom callback helping to override the default shader used in the material.
  27532. */
  27533. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27534. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27535. protected _worldViewProjectionMatrix: Matrix;
  27536. protected _globalAmbientColor: Color3;
  27537. protected _useLogarithmicDepth: boolean;
  27538. protected _rebuildInParallel: boolean;
  27539. /**
  27540. * Instantiates a new standard material.
  27541. * This is the default material used in Babylon. It is the best trade off between quality
  27542. * and performances.
  27543. * @see http://doc.babylonjs.com/babylon101/materials
  27544. * @param name Define the name of the material in the scene
  27545. * @param scene Define the scene the material belong to
  27546. */
  27547. constructor(name: string, scene: Scene);
  27548. /**
  27549. * Gets a boolean indicating that current material needs to register RTT
  27550. */
  27551. get hasRenderTargetTextures(): boolean;
  27552. /**
  27553. * Gets the current class name of the material e.g. "StandardMaterial"
  27554. * Mainly use in serialization.
  27555. * @returns the class name
  27556. */
  27557. getClassName(): string;
  27558. /**
  27559. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27560. * You can try switching to logarithmic depth.
  27561. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27562. */
  27563. get useLogarithmicDepth(): boolean;
  27564. set useLogarithmicDepth(value: boolean);
  27565. /**
  27566. * Specifies if the material will require alpha blending
  27567. * @returns a boolean specifying if alpha blending is needed
  27568. */
  27569. needAlphaBlending(): boolean;
  27570. /**
  27571. * Specifies if this material should be rendered in alpha test mode
  27572. * @returns a boolean specifying if an alpha test is needed.
  27573. */
  27574. needAlphaTesting(): boolean;
  27575. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27576. /**
  27577. * Get the texture used for alpha test purpose.
  27578. * @returns the diffuse texture in case of the standard material.
  27579. */
  27580. getAlphaTestTexture(): Nullable<BaseTexture>;
  27581. /**
  27582. * Get if the submesh is ready to be used and all its information available.
  27583. * Child classes can use it to update shaders
  27584. * @param mesh defines the mesh to check
  27585. * @param subMesh defines which submesh to check
  27586. * @param useInstances specifies that instances should be used
  27587. * @returns a boolean indicating that the submesh is ready or not
  27588. */
  27589. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27590. /**
  27591. * Builds the material UBO layouts.
  27592. * Used internally during the effect preparation.
  27593. */
  27594. buildUniformLayout(): void;
  27595. /**
  27596. * Unbinds the material from the mesh
  27597. */
  27598. unbind(): void;
  27599. /**
  27600. * Binds the submesh to this material by preparing the effect and shader to draw
  27601. * @param world defines the world transformation matrix
  27602. * @param mesh defines the mesh containing the submesh
  27603. * @param subMesh defines the submesh to bind the material to
  27604. */
  27605. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27606. /**
  27607. * Get the list of animatables in the material.
  27608. * @returns the list of animatables object used in the material
  27609. */
  27610. getAnimatables(): IAnimatable[];
  27611. /**
  27612. * Gets the active textures from the material
  27613. * @returns an array of textures
  27614. */
  27615. getActiveTextures(): BaseTexture[];
  27616. /**
  27617. * Specifies if the material uses a texture
  27618. * @param texture defines the texture to check against the material
  27619. * @returns a boolean specifying if the material uses the texture
  27620. */
  27621. hasTexture(texture: BaseTexture): boolean;
  27622. /**
  27623. * Disposes the material
  27624. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27625. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27626. */
  27627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27628. /**
  27629. * Makes a duplicate of the material, and gives it a new name
  27630. * @param name defines the new name for the duplicated material
  27631. * @returns the cloned material
  27632. */
  27633. clone(name: string): StandardMaterial;
  27634. /**
  27635. * Serializes this material in a JSON representation
  27636. * @returns the serialized material object
  27637. */
  27638. serialize(): any;
  27639. /**
  27640. * Creates a standard material from parsed material data
  27641. * @param source defines the JSON representation of the material
  27642. * @param scene defines the hosting scene
  27643. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27644. * @returns a new standard material
  27645. */
  27646. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27647. /**
  27648. * Are diffuse textures enabled in the application.
  27649. */
  27650. static get DiffuseTextureEnabled(): boolean;
  27651. static set DiffuseTextureEnabled(value: boolean);
  27652. /**
  27653. * Are ambient textures enabled in the application.
  27654. */
  27655. static get AmbientTextureEnabled(): boolean;
  27656. static set AmbientTextureEnabled(value: boolean);
  27657. /**
  27658. * Are opacity textures enabled in the application.
  27659. */
  27660. static get OpacityTextureEnabled(): boolean;
  27661. static set OpacityTextureEnabled(value: boolean);
  27662. /**
  27663. * Are reflection textures enabled in the application.
  27664. */
  27665. static get ReflectionTextureEnabled(): boolean;
  27666. static set ReflectionTextureEnabled(value: boolean);
  27667. /**
  27668. * Are emissive textures enabled in the application.
  27669. */
  27670. static get EmissiveTextureEnabled(): boolean;
  27671. static set EmissiveTextureEnabled(value: boolean);
  27672. /**
  27673. * Are specular textures enabled in the application.
  27674. */
  27675. static get SpecularTextureEnabled(): boolean;
  27676. static set SpecularTextureEnabled(value: boolean);
  27677. /**
  27678. * Are bump textures enabled in the application.
  27679. */
  27680. static get BumpTextureEnabled(): boolean;
  27681. static set BumpTextureEnabled(value: boolean);
  27682. /**
  27683. * Are lightmap textures enabled in the application.
  27684. */
  27685. static get LightmapTextureEnabled(): boolean;
  27686. static set LightmapTextureEnabled(value: boolean);
  27687. /**
  27688. * Are refraction textures enabled in the application.
  27689. */
  27690. static get RefractionTextureEnabled(): boolean;
  27691. static set RefractionTextureEnabled(value: boolean);
  27692. /**
  27693. * Are color grading textures enabled in the application.
  27694. */
  27695. static get ColorGradingTextureEnabled(): boolean;
  27696. static set ColorGradingTextureEnabled(value: boolean);
  27697. /**
  27698. * Are fresnels enabled in the application.
  27699. */
  27700. static get FresnelEnabled(): boolean;
  27701. static set FresnelEnabled(value: boolean);
  27702. }
  27703. }
  27704. declare module "babylonjs/Particles/solidParticleSystem" {
  27705. import { Nullable } from "babylonjs/types";
  27706. import { Vector3 } from "babylonjs/Maths/math.vector";
  27707. import { Mesh } from "babylonjs/Meshes/mesh";
  27708. import { Scene, IDisposable } from "babylonjs/scene";
  27709. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27710. import { Material } from "babylonjs/Materials/material";
  27711. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27712. /**
  27713. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27714. *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.
  27715. * The SPS is also a particle system. It provides some methods to manage the particles.
  27716. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27717. *
  27718. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27719. */
  27720. export class SolidParticleSystem implements IDisposable {
  27721. /**
  27722. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27723. * Example : var p = SPS.particles[i];
  27724. */
  27725. particles: SolidParticle[];
  27726. /**
  27727. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27728. */
  27729. nbParticles: number;
  27730. /**
  27731. * If the particles must ever face the camera (default false). Useful for planar particles.
  27732. */
  27733. billboard: boolean;
  27734. /**
  27735. * Recompute normals when adding a shape
  27736. */
  27737. recomputeNormals: boolean;
  27738. /**
  27739. * This a counter ofr your own usage. It's not set by any SPS functions.
  27740. */
  27741. counter: number;
  27742. /**
  27743. * The SPS name. This name is also given to the underlying mesh.
  27744. */
  27745. name: string;
  27746. /**
  27747. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27748. */
  27749. mesh: Mesh;
  27750. /**
  27751. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27752. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27753. */
  27754. vars: any;
  27755. /**
  27756. * This array is populated when the SPS is set as 'pickable'.
  27757. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27758. * Each element of this array is an object `{idx: int, faceId: int}`.
  27759. * `idx` is the picked particle index in the `SPS.particles` array
  27760. * `faceId` is the picked face index counted within this particle.
  27761. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27762. */
  27763. pickedParticles: {
  27764. idx: number;
  27765. faceId: number;
  27766. }[];
  27767. /**
  27768. * This array is populated when `enableDepthSort` is set to true.
  27769. * Each element of this array is an instance of the class DepthSortedParticle.
  27770. */
  27771. depthSortedParticles: DepthSortedParticle[];
  27772. /**
  27773. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27774. * @hidden
  27775. */
  27776. _bSphereOnly: boolean;
  27777. /**
  27778. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27779. * @hidden
  27780. */
  27781. _bSphereRadiusFactor: number;
  27782. private _scene;
  27783. private _positions;
  27784. private _indices;
  27785. private _normals;
  27786. private _colors;
  27787. private _uvs;
  27788. private _indices32;
  27789. private _positions32;
  27790. private _normals32;
  27791. private _fixedNormal32;
  27792. private _colors32;
  27793. private _uvs32;
  27794. private _index;
  27795. private _updatable;
  27796. private _pickable;
  27797. private _isVisibilityBoxLocked;
  27798. private _alwaysVisible;
  27799. private _depthSort;
  27800. private _expandable;
  27801. private _shapeCounter;
  27802. private _copy;
  27803. private _color;
  27804. private _computeParticleColor;
  27805. private _computeParticleTexture;
  27806. private _computeParticleRotation;
  27807. private _computeParticleVertex;
  27808. private _computeBoundingBox;
  27809. private _depthSortParticles;
  27810. private _camera;
  27811. private _mustUnrotateFixedNormals;
  27812. private _particlesIntersect;
  27813. private _needs32Bits;
  27814. private _isNotBuilt;
  27815. private _lastParticleId;
  27816. private _idxOfId;
  27817. private _multimaterialEnabled;
  27818. private _useModelMaterial;
  27819. private _indicesByMaterial;
  27820. private _materialIndexes;
  27821. private _depthSortFunction;
  27822. private _materialSortFunction;
  27823. private _materials;
  27824. private _multimaterial;
  27825. private _materialIndexesById;
  27826. private _defaultMaterial;
  27827. private _autoUpdateSubMeshes;
  27828. /**
  27829. * Creates a SPS (Solid Particle System) object.
  27830. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27831. * @param scene (Scene) is the scene in which the SPS is added.
  27832. * @param options defines the options of the sps e.g.
  27833. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27834. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27835. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27836. * * 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.
  27837. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27838. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27839. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27840. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27841. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27842. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27843. */
  27844. constructor(name: string, scene: Scene, options?: {
  27845. updatable?: boolean;
  27846. isPickable?: boolean;
  27847. enableDepthSort?: boolean;
  27848. particleIntersection?: boolean;
  27849. boundingSphereOnly?: boolean;
  27850. bSphereRadiusFactor?: number;
  27851. expandable?: boolean;
  27852. useModelMaterial?: boolean;
  27853. enableMultiMaterial?: boolean;
  27854. });
  27855. /**
  27856. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27857. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27858. * @returns the created mesh
  27859. */
  27860. buildMesh(): Mesh;
  27861. /**
  27862. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27863. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27864. * Thus the particles generated from `digest()` have their property `position` set yet.
  27865. * @param mesh ( Mesh ) is the mesh to be digested
  27866. * @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
  27867. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27868. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27869. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27870. * @returns the current SPS
  27871. */
  27872. digest(mesh: Mesh, options?: {
  27873. facetNb?: number;
  27874. number?: number;
  27875. delta?: number;
  27876. storage?: [];
  27877. }): SolidParticleSystem;
  27878. /**
  27879. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27880. * @hidden
  27881. */
  27882. private _unrotateFixedNormals;
  27883. /**
  27884. * Resets the temporary working copy particle
  27885. * @hidden
  27886. */
  27887. private _resetCopy;
  27888. /**
  27889. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27890. * @param p the current index in the positions array to be updated
  27891. * @param ind the current index in the indices array
  27892. * @param shape a Vector3 array, the shape geometry
  27893. * @param positions the positions array to be updated
  27894. * @param meshInd the shape indices array
  27895. * @param indices the indices array to be updated
  27896. * @param meshUV the shape uv array
  27897. * @param uvs the uv array to be updated
  27898. * @param meshCol the shape color array
  27899. * @param colors the color array to be updated
  27900. * @param meshNor the shape normals array
  27901. * @param normals the normals array to be updated
  27902. * @param idx the particle index
  27903. * @param idxInShape the particle index in its shape
  27904. * @param options the addShape() method passed options
  27905. * @model the particle model
  27906. * @hidden
  27907. */
  27908. private _meshBuilder;
  27909. /**
  27910. * Returns a shape Vector3 array from positions float array
  27911. * @param positions float array
  27912. * @returns a vector3 array
  27913. * @hidden
  27914. */
  27915. private _posToShape;
  27916. /**
  27917. * Returns a shapeUV array from a float uvs (array deep copy)
  27918. * @param uvs as a float array
  27919. * @returns a shapeUV array
  27920. * @hidden
  27921. */
  27922. private _uvsToShapeUV;
  27923. /**
  27924. * Adds a new particle object in the particles array
  27925. * @param idx particle index in particles array
  27926. * @param id particle id
  27927. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27928. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27929. * @param model particle ModelShape object
  27930. * @param shapeId model shape identifier
  27931. * @param idxInShape index of the particle in the current model
  27932. * @param bInfo model bounding info object
  27933. * @param storage target storage array, if any
  27934. * @hidden
  27935. */
  27936. private _addParticle;
  27937. /**
  27938. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27939. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27940. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27941. * @param nb (positive integer) the number of particles to be created from this model
  27942. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27943. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27944. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27945. * @returns the number of shapes in the system
  27946. */
  27947. addShape(mesh: Mesh, nb: number, options?: {
  27948. positionFunction?: any;
  27949. vertexFunction?: any;
  27950. storage?: [];
  27951. }): number;
  27952. /**
  27953. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27954. * @hidden
  27955. */
  27956. private _rebuildParticle;
  27957. /**
  27958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27959. * @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.
  27960. * @returns the SPS.
  27961. */
  27962. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27963. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27964. * Returns an array with the removed particles.
  27965. * 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.
  27966. * The SPS can't be empty so at least one particle needs to remain in place.
  27967. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27968. * @param start index of the first particle to remove
  27969. * @param end index of the last particle to remove (included)
  27970. * @returns an array populated with the removed particles
  27971. */
  27972. removeParticles(start: number, end: number): SolidParticle[];
  27973. /**
  27974. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27975. * @param solidParticleArray an array populated with Solid Particles objects
  27976. * @returns the SPS
  27977. */
  27978. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27979. /**
  27980. * Creates a new particle and modifies the SPS mesh geometry :
  27981. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27982. * - calls _addParticle() to populate the particle array
  27983. * factorized code from addShape() and insertParticlesFromArray()
  27984. * @param idx particle index in the particles array
  27985. * @param i particle index in its shape
  27986. * @param modelShape particle ModelShape object
  27987. * @param shape shape vertex array
  27988. * @param meshInd shape indices array
  27989. * @param meshUV shape uv array
  27990. * @param meshCol shape color array
  27991. * @param meshNor shape normals array
  27992. * @param bbInfo shape bounding info
  27993. * @param storage target particle storage
  27994. * @options addShape() passed options
  27995. * @hidden
  27996. */
  27997. private _insertNewParticle;
  27998. /**
  27999. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28000. * This method calls `updateParticle()` for each particle of the SPS.
  28001. * For an animated SPS, it is usually called within the render loop.
  28002. * 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.
  28003. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28004. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28005. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28006. * @returns the SPS.
  28007. */
  28008. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28009. /**
  28010. * Disposes the SPS.
  28011. */
  28012. dispose(): void;
  28013. /**
  28014. * Returns a SolidParticle object from its identifier : particle.id
  28015. * @param id (integer) the particle Id
  28016. * @returns the searched particle or null if not found in the SPS.
  28017. */
  28018. getParticleById(id: number): Nullable<SolidParticle>;
  28019. /**
  28020. * Returns a new array populated with the particles having the passed shapeId.
  28021. * @param shapeId (integer) the shape identifier
  28022. * @returns a new solid particle array
  28023. */
  28024. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28025. /**
  28026. * Populates the passed array "ref" with the particles having the passed shapeId.
  28027. * @param shapeId the shape identifier
  28028. * @returns the SPS
  28029. * @param ref
  28030. */
  28031. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28032. /**
  28033. * Computes the required SubMeshes according the materials assigned to the particles.
  28034. * @returns the solid particle system.
  28035. * Does nothing if called before the SPS mesh is built.
  28036. */
  28037. computeSubMeshes(): SolidParticleSystem;
  28038. /**
  28039. * Sorts the solid particles by material when MultiMaterial is enabled.
  28040. * Updates the indices32 array.
  28041. * Updates the indicesByMaterial array.
  28042. * Updates the mesh indices array.
  28043. * @returns the SPS
  28044. * @hidden
  28045. */
  28046. private _sortParticlesByMaterial;
  28047. /**
  28048. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28049. * @hidden
  28050. */
  28051. private _setMaterialIndexesById;
  28052. /**
  28053. * Returns an array with unique values of Materials from the passed array
  28054. * @param array the material array to be checked and filtered
  28055. * @hidden
  28056. */
  28057. private _filterUniqueMaterialId;
  28058. /**
  28059. * Sets a new Standard Material as _defaultMaterial if not already set.
  28060. * @hidden
  28061. */
  28062. private _setDefaultMaterial;
  28063. /**
  28064. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28065. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28066. * @returns the SPS.
  28067. */
  28068. refreshVisibleSize(): SolidParticleSystem;
  28069. /**
  28070. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28071. * @param size the size (float) of the visibility box
  28072. * note : this doesn't lock the SPS mesh bounding box.
  28073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28074. */
  28075. setVisibilityBox(size: number): void;
  28076. /**
  28077. * Gets whether the SPS as always visible or not
  28078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28079. */
  28080. get isAlwaysVisible(): boolean;
  28081. /**
  28082. * Sets the SPS as always visible or not
  28083. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28084. */
  28085. set isAlwaysVisible(val: boolean);
  28086. /**
  28087. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28088. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28089. */
  28090. set isVisibilityBoxLocked(val: boolean);
  28091. /**
  28092. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28094. */
  28095. get isVisibilityBoxLocked(): boolean;
  28096. /**
  28097. * Tells to `setParticles()` to compute the particle rotations or not.
  28098. * Default value : true. The SPS is faster when it's set to false.
  28099. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28100. */
  28101. set computeParticleRotation(val: boolean);
  28102. /**
  28103. * Tells to `setParticles()` to compute the particle colors or not.
  28104. * Default value : true. The SPS is faster when it's set to false.
  28105. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28106. */
  28107. set computeParticleColor(val: boolean);
  28108. set computeParticleTexture(val: boolean);
  28109. /**
  28110. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28111. * Default value : false. The SPS is faster when it's set to false.
  28112. * Note : the particle custom vertex positions aren't stored values.
  28113. */
  28114. set computeParticleVertex(val: boolean);
  28115. /**
  28116. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28117. */
  28118. set computeBoundingBox(val: boolean);
  28119. /**
  28120. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28121. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28122. * Default : `true`
  28123. */
  28124. set depthSortParticles(val: boolean);
  28125. /**
  28126. * Gets if `setParticles()` computes the particle rotations or not.
  28127. * Default value : true. The SPS is faster when it's set to false.
  28128. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28129. */
  28130. get computeParticleRotation(): boolean;
  28131. /**
  28132. * Gets if `setParticles()` computes the particle colors or not.
  28133. * Default value : true. The SPS is faster when it's set to false.
  28134. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28135. */
  28136. get computeParticleColor(): boolean;
  28137. /**
  28138. * Gets if `setParticles()` computes the particle textures or not.
  28139. * Default value : true. The SPS is faster when it's set to false.
  28140. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28141. */
  28142. get computeParticleTexture(): boolean;
  28143. /**
  28144. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28145. * Default value : false. The SPS is faster when it's set to false.
  28146. * Note : the particle custom vertex positions aren't stored values.
  28147. */
  28148. get computeParticleVertex(): boolean;
  28149. /**
  28150. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28151. */
  28152. get computeBoundingBox(): boolean;
  28153. /**
  28154. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28155. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28156. * Default : `true`
  28157. */
  28158. get depthSortParticles(): boolean;
  28159. /**
  28160. * Gets if the SPS is created as expandable at construction time.
  28161. * Default : `false`
  28162. */
  28163. get expandable(): boolean;
  28164. /**
  28165. * Gets if the SPS supports the Multi Materials
  28166. */
  28167. get multimaterialEnabled(): boolean;
  28168. /**
  28169. * Gets if the SPS uses the model materials for its own multimaterial.
  28170. */
  28171. get useModelMaterial(): boolean;
  28172. /**
  28173. * The SPS used material array.
  28174. */
  28175. get materials(): Material[];
  28176. /**
  28177. * Sets the SPS MultiMaterial from the passed materials.
  28178. * Note : the passed array is internally copied and not used then by reference.
  28179. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28180. */
  28181. setMultiMaterial(materials: Material[]): void;
  28182. /**
  28183. * The SPS computed multimaterial object
  28184. */
  28185. get multimaterial(): MultiMaterial;
  28186. set multimaterial(mm: MultiMaterial);
  28187. /**
  28188. * If the subMeshes must be updated on the next call to setParticles()
  28189. */
  28190. get autoUpdateSubMeshes(): boolean;
  28191. set autoUpdateSubMeshes(val: boolean);
  28192. /**
  28193. * This function does nothing. It may be overwritten to set all the particle first values.
  28194. * The SPS doesn't call this function, you may have to call it by your own.
  28195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28196. */
  28197. initParticles(): void;
  28198. /**
  28199. * This function does nothing. It may be overwritten to recycle a particle.
  28200. * The SPS doesn't call this function, you may have to call it by your own.
  28201. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28202. * @param particle The particle to recycle
  28203. * @returns the recycled particle
  28204. */
  28205. recycleParticle(particle: SolidParticle): SolidParticle;
  28206. /**
  28207. * Updates a particle : this function should be overwritten by the user.
  28208. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28210. * @example : just set a particle position or velocity and recycle conditions
  28211. * @param particle The particle to update
  28212. * @returns the updated particle
  28213. */
  28214. updateParticle(particle: SolidParticle): SolidParticle;
  28215. /**
  28216. * Updates a vertex of a particle : it can be overwritten by the user.
  28217. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28218. * @param particle the current particle
  28219. * @param vertex the current index of the current particle
  28220. * @param pt the index of the current vertex in the particle shape
  28221. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28222. * @example : just set a vertex particle position
  28223. * @returns the updated vertex
  28224. */
  28225. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28226. /**
  28227. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28228. * This does nothing and may be overwritten by the user.
  28229. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28230. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28231. * @param update the boolean update value actually passed to setParticles()
  28232. */
  28233. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28234. /**
  28235. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28236. * This will be passed three parameters.
  28237. * This does nothing and may be overwritten by the user.
  28238. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28240. * @param update the boolean update value actually passed to setParticles()
  28241. */
  28242. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28243. }
  28244. }
  28245. declare module "babylonjs/Particles/solidParticle" {
  28246. import { Nullable } from "babylonjs/types";
  28247. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28248. import { Color4 } from "babylonjs/Maths/math.color";
  28249. import { Mesh } from "babylonjs/Meshes/mesh";
  28250. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28251. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28252. import { Plane } from "babylonjs/Maths/math.plane";
  28253. import { Material } from "babylonjs/Materials/material";
  28254. /**
  28255. * Represents one particle of a solid particle system.
  28256. */
  28257. export class SolidParticle {
  28258. /**
  28259. * particle global index
  28260. */
  28261. idx: number;
  28262. /**
  28263. * particle identifier
  28264. */
  28265. id: number;
  28266. /**
  28267. * The color of the particle
  28268. */
  28269. color: Nullable<Color4>;
  28270. /**
  28271. * The world space position of the particle.
  28272. */
  28273. position: Vector3;
  28274. /**
  28275. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28276. */
  28277. rotation: Vector3;
  28278. /**
  28279. * The world space rotation quaternion of the particle.
  28280. */
  28281. rotationQuaternion: Nullable<Quaternion>;
  28282. /**
  28283. * The scaling of the particle.
  28284. */
  28285. scaling: Vector3;
  28286. /**
  28287. * The uvs of the particle.
  28288. */
  28289. uvs: Vector4;
  28290. /**
  28291. * The current speed of the particle.
  28292. */
  28293. velocity: Vector3;
  28294. /**
  28295. * The pivot point in the particle local space.
  28296. */
  28297. pivot: Vector3;
  28298. /**
  28299. * Must the particle be translated from its pivot point in its local space ?
  28300. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28301. * Default : false
  28302. */
  28303. translateFromPivot: boolean;
  28304. /**
  28305. * Is the particle active or not ?
  28306. */
  28307. alive: boolean;
  28308. /**
  28309. * Is the particle visible or not ?
  28310. */
  28311. isVisible: boolean;
  28312. /**
  28313. * Index of this particle in the global "positions" array (Internal use)
  28314. * @hidden
  28315. */
  28316. _pos: number;
  28317. /**
  28318. * @hidden Index of this particle in the global "indices" array (Internal use)
  28319. */
  28320. _ind: number;
  28321. /**
  28322. * @hidden ModelShape of this particle (Internal use)
  28323. */
  28324. _model: ModelShape;
  28325. /**
  28326. * ModelShape id of this particle
  28327. */
  28328. shapeId: number;
  28329. /**
  28330. * Index of the particle in its shape id
  28331. */
  28332. idxInShape: number;
  28333. /**
  28334. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28335. */
  28336. _modelBoundingInfo: BoundingInfo;
  28337. /**
  28338. * @hidden Particle BoundingInfo object (Internal use)
  28339. */
  28340. _boundingInfo: BoundingInfo;
  28341. /**
  28342. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28343. */
  28344. _sps: SolidParticleSystem;
  28345. /**
  28346. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28347. */
  28348. _stillInvisible: boolean;
  28349. /**
  28350. * @hidden Last computed particle rotation matrix
  28351. */
  28352. _rotationMatrix: number[];
  28353. /**
  28354. * Parent particle Id, if any.
  28355. * Default null.
  28356. */
  28357. parentId: Nullable<number>;
  28358. /**
  28359. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28360. */
  28361. materialIndex: Nullable<number>;
  28362. /**
  28363. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28364. * The possible values are :
  28365. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28366. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28367. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28368. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28369. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28370. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28371. * */
  28372. cullingStrategy: number;
  28373. /**
  28374. * @hidden Internal global position in the SPS.
  28375. */
  28376. _globalPosition: Vector3;
  28377. /**
  28378. * Creates a Solid Particle object.
  28379. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28380. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28381. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28382. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28383. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28384. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28385. * @param shapeId (integer) is the model shape identifier in the SPS.
  28386. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28387. * @param sps defines the sps it is associated to
  28388. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28389. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28390. */
  28391. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28392. /**
  28393. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28394. * @param target the particle target
  28395. * @returns the current particle
  28396. */
  28397. copyToRef(target: SolidParticle): SolidParticle;
  28398. /**
  28399. * Legacy support, changed scale to scaling
  28400. */
  28401. get scale(): Vector3;
  28402. /**
  28403. * Legacy support, changed scale to scaling
  28404. */
  28405. set scale(scale: Vector3);
  28406. /**
  28407. * Legacy support, changed quaternion to rotationQuaternion
  28408. */
  28409. get quaternion(): Nullable<Quaternion>;
  28410. /**
  28411. * Legacy support, changed quaternion to rotationQuaternion
  28412. */
  28413. set quaternion(q: Nullable<Quaternion>);
  28414. /**
  28415. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28416. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28417. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28418. * @returns true if it intersects
  28419. */
  28420. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28421. /**
  28422. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28423. * A particle is in the frustum if its bounding box intersects the frustum
  28424. * @param frustumPlanes defines the frustum to test
  28425. * @returns true if the particle is in the frustum planes
  28426. */
  28427. isInFrustum(frustumPlanes: Plane[]): boolean;
  28428. /**
  28429. * get the rotation matrix of the particle
  28430. * @hidden
  28431. */
  28432. getRotationMatrix(m: Matrix): void;
  28433. }
  28434. /**
  28435. * Represents the shape of the model used by one particle of a solid particle system.
  28436. * SPS internal tool, don't use it manually.
  28437. */
  28438. export class ModelShape {
  28439. /**
  28440. * The shape id
  28441. * @hidden
  28442. */
  28443. shapeID: number;
  28444. /**
  28445. * flat array of model positions (internal use)
  28446. * @hidden
  28447. */
  28448. _shape: Vector3[];
  28449. /**
  28450. * flat array of model UVs (internal use)
  28451. * @hidden
  28452. */
  28453. _shapeUV: number[];
  28454. /**
  28455. * color array of the model
  28456. * @hidden
  28457. */
  28458. _shapeColors: number[];
  28459. /**
  28460. * indices array of the model
  28461. * @hidden
  28462. */
  28463. _indices: number[];
  28464. /**
  28465. * normals array of the model
  28466. * @hidden
  28467. */
  28468. _normals: number[];
  28469. /**
  28470. * length of the shape in the model indices array (internal use)
  28471. * @hidden
  28472. */
  28473. _indicesLength: number;
  28474. /**
  28475. * Custom position function (internal use)
  28476. * @hidden
  28477. */
  28478. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28479. /**
  28480. * Custom vertex function (internal use)
  28481. * @hidden
  28482. */
  28483. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28484. /**
  28485. * Model material (internal use)
  28486. * @hidden
  28487. */
  28488. _material: Nullable<Material>;
  28489. /**
  28490. * 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.
  28491. * SPS internal tool, don't use it manually.
  28492. * @hidden
  28493. */
  28494. 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>);
  28495. }
  28496. /**
  28497. * Represents a Depth Sorted Particle in the solid particle system.
  28498. * @hidden
  28499. */
  28500. export class DepthSortedParticle {
  28501. /**
  28502. * Index of the particle in the "indices" array
  28503. */
  28504. ind: number;
  28505. /**
  28506. * Length of the particle shape in the "indices" array
  28507. */
  28508. indicesLength: number;
  28509. /**
  28510. * Squared distance from the particle to the camera
  28511. */
  28512. sqDistance: number;
  28513. /**
  28514. * Material index when used with MultiMaterials
  28515. */
  28516. materialIndex: number;
  28517. /**
  28518. * Creates a new sorted particle
  28519. * @param materialIndex
  28520. */
  28521. constructor(ind: number, indLength: number, materialIndex: number);
  28522. }
  28523. }
  28524. declare module "babylonjs/Collisions/meshCollisionData" {
  28525. import { Collider } from "babylonjs/Collisions/collider";
  28526. import { Vector3 } from "babylonjs/Maths/math.vector";
  28527. import { Nullable } from "babylonjs/types";
  28528. import { Observer } from "babylonjs/Misc/observable";
  28529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28530. /**
  28531. * @hidden
  28532. */
  28533. export class _MeshCollisionData {
  28534. _checkCollisions: boolean;
  28535. _collisionMask: number;
  28536. _collisionGroup: number;
  28537. _collider: Nullable<Collider>;
  28538. _oldPositionForCollisions: Vector3;
  28539. _diffPositionForCollisions: Vector3;
  28540. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28541. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28542. }
  28543. }
  28544. declare module "babylonjs/Meshes/abstractMesh" {
  28545. import { Observable } from "babylonjs/Misc/observable";
  28546. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28547. import { Camera } from "babylonjs/Cameras/camera";
  28548. import { Scene, IDisposable } from "babylonjs/scene";
  28549. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28550. import { Node } from "babylonjs/node";
  28551. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28554. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28555. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28556. import { Material } from "babylonjs/Materials/material";
  28557. import { Light } from "babylonjs/Lights/light";
  28558. import { Skeleton } from "babylonjs/Bones/skeleton";
  28559. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28560. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28561. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28562. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28563. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28564. import { Plane } from "babylonjs/Maths/math.plane";
  28565. import { Ray } from "babylonjs/Culling/ray";
  28566. import { Collider } from "babylonjs/Collisions/collider";
  28567. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28568. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28569. /** @hidden */
  28570. class _FacetDataStorage {
  28571. facetPositions: Vector3[];
  28572. facetNormals: Vector3[];
  28573. facetPartitioning: number[][];
  28574. facetNb: number;
  28575. partitioningSubdivisions: number;
  28576. partitioningBBoxRatio: number;
  28577. facetDataEnabled: boolean;
  28578. facetParameters: any;
  28579. bbSize: Vector3;
  28580. subDiv: {
  28581. max: number;
  28582. X: number;
  28583. Y: number;
  28584. Z: number;
  28585. };
  28586. facetDepthSort: boolean;
  28587. facetDepthSortEnabled: boolean;
  28588. depthSortedIndices: IndicesArray;
  28589. depthSortedFacets: {
  28590. ind: number;
  28591. sqDistance: number;
  28592. }[];
  28593. facetDepthSortFunction: (f1: {
  28594. ind: number;
  28595. sqDistance: number;
  28596. }, f2: {
  28597. ind: number;
  28598. sqDistance: number;
  28599. }) => number;
  28600. facetDepthSortFrom: Vector3;
  28601. facetDepthSortOrigin: Vector3;
  28602. invertedMatrix: Matrix;
  28603. }
  28604. /**
  28605. * @hidden
  28606. **/
  28607. class _InternalAbstractMeshDataInfo {
  28608. _hasVertexAlpha: boolean;
  28609. _useVertexColors: boolean;
  28610. _numBoneInfluencers: number;
  28611. _applyFog: boolean;
  28612. _receiveShadows: boolean;
  28613. _facetData: _FacetDataStorage;
  28614. _visibility: number;
  28615. _skeleton: Nullable<Skeleton>;
  28616. _layerMask: number;
  28617. _computeBonesUsingShaders: boolean;
  28618. _isActive: boolean;
  28619. _onlyForInstances: boolean;
  28620. _isActiveIntermediate: boolean;
  28621. _onlyForInstancesIntermediate: boolean;
  28622. _actAsRegularMesh: boolean;
  28623. }
  28624. /**
  28625. * Class used to store all common mesh properties
  28626. */
  28627. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28628. /** No occlusion */
  28629. static OCCLUSION_TYPE_NONE: number;
  28630. /** Occlusion set to optimisitic */
  28631. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28632. /** Occlusion set to strict */
  28633. static OCCLUSION_TYPE_STRICT: number;
  28634. /** Use an accurante occlusion algorithm */
  28635. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28636. /** Use a conservative occlusion algorithm */
  28637. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28638. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28639. * Test order :
  28640. * Is the bounding sphere outside the frustum ?
  28641. * If not, are the bounding box vertices outside the frustum ?
  28642. * It not, then the cullable object is in the frustum.
  28643. */
  28644. static readonly CULLINGSTRATEGY_STANDARD: number;
  28645. /** Culling strategy : Bounding Sphere Only.
  28646. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28647. * It's also less accurate than the standard because some not visible objects can still be selected.
  28648. * Test : is the bounding sphere outside the frustum ?
  28649. * If not, then the cullable object is in the frustum.
  28650. */
  28651. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28652. /** Culling strategy : Optimistic Inclusion.
  28653. * This in an inclusion test first, then the standard exclusion test.
  28654. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28655. * 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.
  28656. * Anyway, it's as accurate as the standard strategy.
  28657. * Test :
  28658. * Is the cullable object bounding sphere center in the frustum ?
  28659. * If not, apply the default culling strategy.
  28660. */
  28661. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28662. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28663. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28664. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28665. * 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.
  28666. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28667. * Test :
  28668. * Is the cullable object bounding sphere center in the frustum ?
  28669. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28670. */
  28671. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28672. /**
  28673. * No billboard
  28674. */
  28675. static get BILLBOARDMODE_NONE(): number;
  28676. /** Billboard on X axis */
  28677. static get BILLBOARDMODE_X(): number;
  28678. /** Billboard on Y axis */
  28679. static get BILLBOARDMODE_Y(): number;
  28680. /** Billboard on Z axis */
  28681. static get BILLBOARDMODE_Z(): number;
  28682. /** Billboard on all axes */
  28683. static get BILLBOARDMODE_ALL(): number;
  28684. /** Billboard on using position instead of orientation */
  28685. static get BILLBOARDMODE_USE_POSITION(): number;
  28686. /** @hidden */
  28687. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28688. /**
  28689. * The culling strategy to use to check whether the mesh must be rendered or not.
  28690. * This value can be changed at any time and will be used on the next render mesh selection.
  28691. * The possible values are :
  28692. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28693. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28694. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28695. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28696. * Please read each static variable documentation to get details about the culling process.
  28697. * */
  28698. cullingStrategy: number;
  28699. /**
  28700. * Gets the number of facets in the mesh
  28701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28702. */
  28703. get facetNb(): number;
  28704. /**
  28705. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28707. */
  28708. get partitioningSubdivisions(): number;
  28709. set partitioningSubdivisions(nb: number);
  28710. /**
  28711. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28712. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28714. */
  28715. get partitioningBBoxRatio(): number;
  28716. set partitioningBBoxRatio(ratio: number);
  28717. /**
  28718. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28719. * Works only for updatable meshes.
  28720. * Doesn't work with multi-materials
  28721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28722. */
  28723. get mustDepthSortFacets(): boolean;
  28724. set mustDepthSortFacets(sort: boolean);
  28725. /**
  28726. * The location (Vector3) where the facet depth sort must be computed from.
  28727. * By default, the active camera position.
  28728. * Used only when facet depth sort is enabled
  28729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28730. */
  28731. get facetDepthSortFrom(): Vector3;
  28732. set facetDepthSortFrom(location: Vector3);
  28733. /**
  28734. * gets a boolean indicating if facetData is enabled
  28735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28736. */
  28737. get isFacetDataEnabled(): boolean;
  28738. /** @hidden */
  28739. _updateNonUniformScalingState(value: boolean): boolean;
  28740. /**
  28741. * An event triggered when this mesh collides with another one
  28742. */
  28743. onCollideObservable: Observable<AbstractMesh>;
  28744. /** Set a function to call when this mesh collides with another one */
  28745. set onCollide(callback: () => void);
  28746. /**
  28747. * An event triggered when the collision's position changes
  28748. */
  28749. onCollisionPositionChangeObservable: Observable<Vector3>;
  28750. /** Set a function to call when the collision's position changes */
  28751. set onCollisionPositionChange(callback: () => void);
  28752. /**
  28753. * An event triggered when material is changed
  28754. */
  28755. onMaterialChangedObservable: Observable<AbstractMesh>;
  28756. /**
  28757. * Gets or sets the orientation for POV movement & rotation
  28758. */
  28759. definedFacingForward: boolean;
  28760. /** @hidden */
  28761. _occlusionQuery: Nullable<WebGLQuery>;
  28762. /** @hidden */
  28763. _renderingGroup: Nullable<RenderingGroup>;
  28764. /**
  28765. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28766. */
  28767. get visibility(): number;
  28768. /**
  28769. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28770. */
  28771. set visibility(value: number);
  28772. /** Gets or sets the alpha index used to sort transparent meshes
  28773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28774. */
  28775. alphaIndex: number;
  28776. /**
  28777. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28778. */
  28779. isVisible: boolean;
  28780. /**
  28781. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28782. */
  28783. isPickable: boolean;
  28784. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28785. showSubMeshesBoundingBox: boolean;
  28786. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28787. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28788. */
  28789. isBlocker: boolean;
  28790. /**
  28791. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28792. */
  28793. enablePointerMoveEvents: boolean;
  28794. /**
  28795. * Specifies the rendering group id for this mesh (0 by default)
  28796. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28797. */
  28798. renderingGroupId: number;
  28799. private _material;
  28800. /** Gets or sets current material */
  28801. get material(): Nullable<Material>;
  28802. set material(value: Nullable<Material>);
  28803. /**
  28804. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28805. * @see http://doc.babylonjs.com/babylon101/shadows
  28806. */
  28807. get receiveShadows(): boolean;
  28808. set receiveShadows(value: boolean);
  28809. /** Defines color to use when rendering outline */
  28810. outlineColor: Color3;
  28811. /** Define width to use when rendering outline */
  28812. outlineWidth: number;
  28813. /** Defines color to use when rendering overlay */
  28814. overlayColor: Color3;
  28815. /** Defines alpha to use when rendering overlay */
  28816. overlayAlpha: number;
  28817. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28818. get hasVertexAlpha(): boolean;
  28819. set hasVertexAlpha(value: boolean);
  28820. /** 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) */
  28821. get useVertexColors(): boolean;
  28822. set useVertexColors(value: boolean);
  28823. /**
  28824. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28825. */
  28826. get computeBonesUsingShaders(): boolean;
  28827. set computeBonesUsingShaders(value: boolean);
  28828. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28829. get numBoneInfluencers(): number;
  28830. set numBoneInfluencers(value: number);
  28831. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28832. get applyFog(): boolean;
  28833. set applyFog(value: boolean);
  28834. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28835. useOctreeForRenderingSelection: boolean;
  28836. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28837. useOctreeForPicking: boolean;
  28838. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28839. useOctreeForCollisions: boolean;
  28840. /**
  28841. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28842. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28843. */
  28844. get layerMask(): number;
  28845. set layerMask(value: number);
  28846. /**
  28847. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28848. */
  28849. alwaysSelectAsActiveMesh: boolean;
  28850. /**
  28851. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28852. */
  28853. doNotSyncBoundingInfo: boolean;
  28854. /**
  28855. * Gets or sets the current action manager
  28856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28857. */
  28858. actionManager: Nullable<AbstractActionManager>;
  28859. private _meshCollisionData;
  28860. /**
  28861. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28863. */
  28864. ellipsoid: Vector3;
  28865. /**
  28866. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28868. */
  28869. ellipsoidOffset: Vector3;
  28870. /**
  28871. * Gets or sets a collision mask used to mask collisions (default is -1).
  28872. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28873. */
  28874. get collisionMask(): number;
  28875. set collisionMask(mask: number);
  28876. /**
  28877. * Gets or sets the current collision group mask (-1 by default).
  28878. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28879. */
  28880. get collisionGroup(): number;
  28881. set collisionGroup(mask: number);
  28882. /**
  28883. * Defines edge width used when edgesRenderer is enabled
  28884. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28885. */
  28886. edgesWidth: number;
  28887. /**
  28888. * Defines edge color used when edgesRenderer is enabled
  28889. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28890. */
  28891. edgesColor: Color4;
  28892. /** @hidden */
  28893. _edgesRenderer: Nullable<IEdgesRenderer>;
  28894. /** @hidden */
  28895. _masterMesh: Nullable<AbstractMesh>;
  28896. /** @hidden */
  28897. _boundingInfo: Nullable<BoundingInfo>;
  28898. /** @hidden */
  28899. _renderId: number;
  28900. /**
  28901. * Gets or sets the list of subMeshes
  28902. * @see http://doc.babylonjs.com/how_to/multi_materials
  28903. */
  28904. subMeshes: SubMesh[];
  28905. /** @hidden */
  28906. _intersectionsInProgress: AbstractMesh[];
  28907. /** @hidden */
  28908. _unIndexed: boolean;
  28909. /** @hidden */
  28910. _lightSources: Light[];
  28911. /** Gets the list of lights affecting that mesh */
  28912. get lightSources(): Light[];
  28913. /** @hidden */
  28914. get _positions(): Nullable<Vector3[]>;
  28915. /** @hidden */
  28916. _waitingData: {
  28917. lods: Nullable<any>;
  28918. actions: Nullable<any>;
  28919. freezeWorldMatrix: Nullable<boolean>;
  28920. };
  28921. /** @hidden */
  28922. _bonesTransformMatrices: Nullable<Float32Array>;
  28923. /** @hidden */
  28924. _transformMatrixTexture: Nullable<RawTexture>;
  28925. /**
  28926. * Gets or sets a skeleton to apply skining transformations
  28927. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28928. */
  28929. set skeleton(value: Nullable<Skeleton>);
  28930. get skeleton(): Nullable<Skeleton>;
  28931. /**
  28932. * An event triggered when the mesh is rebuilt.
  28933. */
  28934. onRebuildObservable: Observable<AbstractMesh>;
  28935. /**
  28936. * Creates a new AbstractMesh
  28937. * @param name defines the name of the mesh
  28938. * @param scene defines the hosting scene
  28939. */
  28940. constructor(name: string, scene?: Nullable<Scene>);
  28941. /**
  28942. * Returns the string "AbstractMesh"
  28943. * @returns "AbstractMesh"
  28944. */
  28945. getClassName(): string;
  28946. /**
  28947. * Gets a string representation of the current mesh
  28948. * @param fullDetails defines a boolean indicating if full details must be included
  28949. * @returns a string representation of the current mesh
  28950. */
  28951. toString(fullDetails?: boolean): string;
  28952. /**
  28953. * @hidden
  28954. */
  28955. protected _getEffectiveParent(): Nullable<Node>;
  28956. /** @hidden */
  28957. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28958. /** @hidden */
  28959. _rebuild(): void;
  28960. /** @hidden */
  28961. _resyncLightSources(): void;
  28962. /** @hidden */
  28963. _resyncLightSource(light: Light): void;
  28964. /** @hidden */
  28965. _unBindEffect(): void;
  28966. /** @hidden */
  28967. _removeLightSource(light: Light, dispose: boolean): void;
  28968. private _markSubMeshesAsDirty;
  28969. /** @hidden */
  28970. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28971. /** @hidden */
  28972. _markSubMeshesAsAttributesDirty(): void;
  28973. /** @hidden */
  28974. _markSubMeshesAsMiscDirty(): void;
  28975. /**
  28976. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28977. */
  28978. get scaling(): Vector3;
  28979. set scaling(newScaling: Vector3);
  28980. /**
  28981. * Returns true if the mesh is blocked. Implemented by child classes
  28982. */
  28983. get isBlocked(): boolean;
  28984. /**
  28985. * Returns the mesh itself by default. Implemented by child classes
  28986. * @param camera defines the camera to use to pick the right LOD level
  28987. * @returns the currentAbstractMesh
  28988. */
  28989. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28990. /**
  28991. * Returns 0 by default. Implemented by child classes
  28992. * @returns an integer
  28993. */
  28994. getTotalVertices(): number;
  28995. /**
  28996. * Returns a positive integer : the total number of indices in this mesh geometry.
  28997. * @returns the numner of indices or zero if the mesh has no geometry.
  28998. */
  28999. getTotalIndices(): number;
  29000. /**
  29001. * Returns null by default. Implemented by child classes
  29002. * @returns null
  29003. */
  29004. getIndices(): Nullable<IndicesArray>;
  29005. /**
  29006. * Returns the array of the requested vertex data kind. Implemented by child classes
  29007. * @param kind defines the vertex data kind to use
  29008. * @returns null
  29009. */
  29010. getVerticesData(kind: string): Nullable<FloatArray>;
  29011. /**
  29012. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29013. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29014. * Note that a new underlying VertexBuffer object is created each call.
  29015. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29016. * @param kind defines vertex data kind:
  29017. * * VertexBuffer.PositionKind
  29018. * * VertexBuffer.UVKind
  29019. * * VertexBuffer.UV2Kind
  29020. * * VertexBuffer.UV3Kind
  29021. * * VertexBuffer.UV4Kind
  29022. * * VertexBuffer.UV5Kind
  29023. * * VertexBuffer.UV6Kind
  29024. * * VertexBuffer.ColorKind
  29025. * * VertexBuffer.MatricesIndicesKind
  29026. * * VertexBuffer.MatricesIndicesExtraKind
  29027. * * VertexBuffer.MatricesWeightsKind
  29028. * * VertexBuffer.MatricesWeightsExtraKind
  29029. * @param data defines the data source
  29030. * @param updatable defines if the data must be flagged as updatable (or static)
  29031. * @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
  29032. * @returns the current mesh
  29033. */
  29034. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29035. /**
  29036. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29037. * If the mesh has no geometry, it is simply returned as it is.
  29038. * @param kind defines vertex data kind:
  29039. * * VertexBuffer.PositionKind
  29040. * * VertexBuffer.UVKind
  29041. * * VertexBuffer.UV2Kind
  29042. * * VertexBuffer.UV3Kind
  29043. * * VertexBuffer.UV4Kind
  29044. * * VertexBuffer.UV5Kind
  29045. * * VertexBuffer.UV6Kind
  29046. * * VertexBuffer.ColorKind
  29047. * * VertexBuffer.MatricesIndicesKind
  29048. * * VertexBuffer.MatricesIndicesExtraKind
  29049. * * VertexBuffer.MatricesWeightsKind
  29050. * * VertexBuffer.MatricesWeightsExtraKind
  29051. * @param data defines the data source
  29052. * @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
  29053. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29054. * @returns the current mesh
  29055. */
  29056. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29057. /**
  29058. * Sets the mesh indices,
  29059. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29060. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29061. * @param totalVertices Defines the total number of vertices
  29062. * @returns the current mesh
  29063. */
  29064. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29065. /**
  29066. * Gets a boolean indicating if specific vertex data is present
  29067. * @param kind defines the vertex data kind to use
  29068. * @returns true is data kind is present
  29069. */
  29070. isVerticesDataPresent(kind: string): boolean;
  29071. /**
  29072. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29073. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29074. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29075. * @returns a BoundingInfo
  29076. */
  29077. getBoundingInfo(): BoundingInfo;
  29078. /**
  29079. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29080. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29081. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29082. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29083. * @returns the current mesh
  29084. */
  29085. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29086. /**
  29087. * Overwrite the current bounding info
  29088. * @param boundingInfo defines the new bounding info
  29089. * @returns the current mesh
  29090. */
  29091. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29092. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29093. get useBones(): boolean;
  29094. /** @hidden */
  29095. _preActivate(): void;
  29096. /** @hidden */
  29097. _preActivateForIntermediateRendering(renderId: number): void;
  29098. /** @hidden */
  29099. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29100. /** @hidden */
  29101. _postActivate(): void;
  29102. /** @hidden */
  29103. _freeze(): void;
  29104. /** @hidden */
  29105. _unFreeze(): void;
  29106. /**
  29107. * Gets the current world matrix
  29108. * @returns a Matrix
  29109. */
  29110. getWorldMatrix(): Matrix;
  29111. /** @hidden */
  29112. _getWorldMatrixDeterminant(): number;
  29113. /**
  29114. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29115. */
  29116. get isAnInstance(): boolean;
  29117. /**
  29118. * Gets a boolean indicating if this mesh has instances
  29119. */
  29120. get hasInstances(): boolean;
  29121. /**
  29122. * Perform relative position change from the point of view of behind the front of the mesh.
  29123. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29124. * Supports definition of mesh facing forward or backward
  29125. * @param amountRight defines the distance on the right axis
  29126. * @param amountUp defines the distance on the up axis
  29127. * @param amountForward defines the distance on the forward axis
  29128. * @returns the current mesh
  29129. */
  29130. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29131. /**
  29132. * Calculate relative position change from the point of view of behind the front of the mesh.
  29133. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29134. * Supports definition of mesh facing forward or backward
  29135. * @param amountRight defines the distance on the right axis
  29136. * @param amountUp defines the distance on the up axis
  29137. * @param amountForward defines the distance on the forward axis
  29138. * @returns the new displacement vector
  29139. */
  29140. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29141. /**
  29142. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29143. * Supports definition of mesh facing forward or backward
  29144. * @param flipBack defines the flip
  29145. * @param twirlClockwise defines the twirl
  29146. * @param tiltRight defines the tilt
  29147. * @returns the current mesh
  29148. */
  29149. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29150. /**
  29151. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29152. * Supports definition of mesh facing forward or backward.
  29153. * @param flipBack defines the flip
  29154. * @param twirlClockwise defines the twirl
  29155. * @param tiltRight defines the tilt
  29156. * @returns the new rotation vector
  29157. */
  29158. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29159. /**
  29160. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29161. * This means the mesh underlying bounding box and sphere are recomputed.
  29162. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29163. * @returns the current mesh
  29164. */
  29165. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29166. /** @hidden */
  29167. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29168. /** @hidden */
  29169. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29170. /** @hidden */
  29171. _updateBoundingInfo(): AbstractMesh;
  29172. /** @hidden */
  29173. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29174. /** @hidden */
  29175. protected _afterComputeWorldMatrix(): void;
  29176. /** @hidden */
  29177. get _effectiveMesh(): AbstractMesh;
  29178. /**
  29179. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29180. * A mesh is in the frustum if its bounding box intersects the frustum
  29181. * @param frustumPlanes defines the frustum to test
  29182. * @returns true if the mesh is in the frustum planes
  29183. */
  29184. isInFrustum(frustumPlanes: Plane[]): boolean;
  29185. /**
  29186. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29187. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29188. * @param frustumPlanes defines the frustum to test
  29189. * @returns true if the mesh is completely in the frustum planes
  29190. */
  29191. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29192. /**
  29193. * True if the mesh intersects another mesh or a SolidParticle object
  29194. * @param mesh defines a target mesh or SolidParticle to test
  29195. * @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)
  29196. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29197. * @returns true if there is an intersection
  29198. */
  29199. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29200. /**
  29201. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29202. * @param point defines the point to test
  29203. * @returns true if there is an intersection
  29204. */
  29205. intersectsPoint(point: Vector3): boolean;
  29206. /**
  29207. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29209. */
  29210. get checkCollisions(): boolean;
  29211. set checkCollisions(collisionEnabled: boolean);
  29212. /**
  29213. * Gets Collider object used to compute collisions (not physics)
  29214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29215. */
  29216. get collider(): Nullable<Collider>;
  29217. /**
  29218. * Move the mesh using collision engine
  29219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29220. * @param displacement defines the requested displacement vector
  29221. * @returns the current mesh
  29222. */
  29223. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29224. private _onCollisionPositionChange;
  29225. /** @hidden */
  29226. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29227. /** @hidden */
  29228. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29229. /** @hidden */
  29230. _checkCollision(collider: Collider): AbstractMesh;
  29231. /** @hidden */
  29232. _generatePointsArray(): boolean;
  29233. /**
  29234. * Checks if the passed Ray intersects with the mesh
  29235. * @param ray defines the ray to use
  29236. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29238. * @returns the picking info
  29239. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29240. */
  29241. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29242. /**
  29243. * Clones the current mesh
  29244. * @param name defines the mesh name
  29245. * @param newParent defines the new mesh parent
  29246. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29247. * @returns the new mesh
  29248. */
  29249. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29250. /**
  29251. * Disposes all the submeshes of the current meshnp
  29252. * @returns the current mesh
  29253. */
  29254. releaseSubMeshes(): AbstractMesh;
  29255. /**
  29256. * Releases resources associated with this abstract mesh.
  29257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29259. */
  29260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29261. /**
  29262. * Adds the passed mesh as a child to the current mesh
  29263. * @param mesh defines the child mesh
  29264. * @returns the current mesh
  29265. */
  29266. addChild(mesh: AbstractMesh): AbstractMesh;
  29267. /**
  29268. * Removes the passed mesh from the current mesh children list
  29269. * @param mesh defines the child mesh
  29270. * @returns the current mesh
  29271. */
  29272. removeChild(mesh: AbstractMesh): AbstractMesh;
  29273. /** @hidden */
  29274. private _initFacetData;
  29275. /**
  29276. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29277. * This method can be called within the render loop.
  29278. * 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
  29279. * @returns the current mesh
  29280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29281. */
  29282. updateFacetData(): AbstractMesh;
  29283. /**
  29284. * Returns the facetLocalNormals array.
  29285. * The normals are expressed in the mesh local spac
  29286. * @returns an array of Vector3
  29287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29288. */
  29289. getFacetLocalNormals(): Vector3[];
  29290. /**
  29291. * Returns the facetLocalPositions array.
  29292. * The facet positions are expressed in the mesh local space
  29293. * @returns an array of Vector3
  29294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29295. */
  29296. getFacetLocalPositions(): Vector3[];
  29297. /**
  29298. * Returns the facetLocalPartioning array
  29299. * @returns an array of array of numbers
  29300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29301. */
  29302. getFacetLocalPartitioning(): number[][];
  29303. /**
  29304. * Returns the i-th facet position in the world system.
  29305. * This method allocates a new Vector3 per call
  29306. * @param i defines the facet index
  29307. * @returns a new Vector3
  29308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29309. */
  29310. getFacetPosition(i: number): Vector3;
  29311. /**
  29312. * Sets the reference Vector3 with the i-th facet position in the world system
  29313. * @param i defines the facet index
  29314. * @param ref defines the target vector
  29315. * @returns the current mesh
  29316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29317. */
  29318. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29319. /**
  29320. * Returns the i-th facet normal in the world system.
  29321. * This method allocates a new Vector3 per call
  29322. * @param i defines the facet index
  29323. * @returns a new Vector3
  29324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29325. */
  29326. getFacetNormal(i: number): Vector3;
  29327. /**
  29328. * Sets the reference Vector3 with the i-th facet normal in the world system
  29329. * @param i defines the facet index
  29330. * @param ref defines the target vector
  29331. * @returns the current mesh
  29332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29333. */
  29334. getFacetNormalToRef(i: number, ref: Vector3): this;
  29335. /**
  29336. * 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)
  29337. * @param x defines x coordinate
  29338. * @param y defines y coordinate
  29339. * @param z defines z coordinate
  29340. * @returns the array of facet indexes
  29341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29342. */
  29343. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29344. /**
  29345. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29346. * @param projected sets as the (x,y,z) world projection on the facet
  29347. * @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
  29348. * @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
  29349. * @param x defines x coordinate
  29350. * @param y defines y coordinate
  29351. * @param z defines z coordinate
  29352. * @returns the face index if found (or null instead)
  29353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29354. */
  29355. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29356. /**
  29357. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29358. * @param projected sets as the (x,y,z) local projection on the facet
  29359. * @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
  29360. * @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
  29361. * @param x defines x coordinate
  29362. * @param y defines y coordinate
  29363. * @param z defines z coordinate
  29364. * @returns the face index if found (or null instead)
  29365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29366. */
  29367. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29368. /**
  29369. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29370. * @returns the parameters
  29371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29372. */
  29373. getFacetDataParameters(): any;
  29374. /**
  29375. * Disables the feature FacetData and frees the related memory
  29376. * @returns the current mesh
  29377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29378. */
  29379. disableFacetData(): AbstractMesh;
  29380. /**
  29381. * Updates the AbstractMesh indices array
  29382. * @param indices defines the data source
  29383. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29384. * @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)
  29385. * @returns the current mesh
  29386. */
  29387. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29388. /**
  29389. * Creates new normals data for the mesh
  29390. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29391. * @returns the current mesh
  29392. */
  29393. createNormals(updatable: boolean): AbstractMesh;
  29394. /**
  29395. * Align the mesh with a normal
  29396. * @param normal defines the normal to use
  29397. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29398. * @returns the current mesh
  29399. */
  29400. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29401. /** @hidden */
  29402. _checkOcclusionQuery(): boolean;
  29403. /**
  29404. * Disables the mesh edge rendering mode
  29405. * @returns the currentAbstractMesh
  29406. */
  29407. disableEdgesRendering(): AbstractMesh;
  29408. /**
  29409. * Enables the edge rendering mode on the mesh.
  29410. * This mode makes the mesh edges visible
  29411. * @param epsilon defines the maximal distance between two angles to detect a face
  29412. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29413. * @returns the currentAbstractMesh
  29414. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29415. */
  29416. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29417. }
  29418. }
  29419. declare module "babylonjs/Actions/actionEvent" {
  29420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29421. import { Nullable } from "babylonjs/types";
  29422. import { Sprite } from "babylonjs/Sprites/sprite";
  29423. import { Scene } from "babylonjs/scene";
  29424. import { Vector2 } from "babylonjs/Maths/math.vector";
  29425. /**
  29426. * Interface used to define ActionEvent
  29427. */
  29428. export interface IActionEvent {
  29429. /** The mesh or sprite that triggered the action */
  29430. source: any;
  29431. /** The X mouse cursor position at the time of the event */
  29432. pointerX: number;
  29433. /** The Y mouse cursor position at the time of the event */
  29434. pointerY: number;
  29435. /** The mesh that is currently pointed at (can be null) */
  29436. meshUnderPointer: Nullable<AbstractMesh>;
  29437. /** the original (browser) event that triggered the ActionEvent */
  29438. sourceEvent?: any;
  29439. /** additional data for the event */
  29440. additionalData?: any;
  29441. }
  29442. /**
  29443. * ActionEvent is the event being sent when an action is triggered.
  29444. */
  29445. export class ActionEvent implements IActionEvent {
  29446. /** The mesh or sprite that triggered the action */
  29447. source: any;
  29448. /** The X mouse cursor position at the time of the event */
  29449. pointerX: number;
  29450. /** The Y mouse cursor position at the time of the event */
  29451. pointerY: number;
  29452. /** The mesh that is currently pointed at (can be null) */
  29453. meshUnderPointer: Nullable<AbstractMesh>;
  29454. /** the original (browser) event that triggered the ActionEvent */
  29455. sourceEvent?: any;
  29456. /** additional data for the event */
  29457. additionalData?: any;
  29458. /**
  29459. * Creates a new ActionEvent
  29460. * @param source The mesh or sprite that triggered the action
  29461. * @param pointerX The X mouse cursor position at the time of the event
  29462. * @param pointerY The Y mouse cursor position at the time of the event
  29463. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29464. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29465. * @param additionalData additional data for the event
  29466. */
  29467. constructor(
  29468. /** The mesh or sprite that triggered the action */
  29469. source: any,
  29470. /** The X mouse cursor position at the time of the event */
  29471. pointerX: number,
  29472. /** The Y mouse cursor position at the time of the event */
  29473. pointerY: number,
  29474. /** The mesh that is currently pointed at (can be null) */
  29475. meshUnderPointer: Nullable<AbstractMesh>,
  29476. /** the original (browser) event that triggered the ActionEvent */
  29477. sourceEvent?: any,
  29478. /** additional data for the event */
  29479. additionalData?: any);
  29480. /**
  29481. * Helper function to auto-create an ActionEvent from a source mesh.
  29482. * @param source The source mesh that triggered the event
  29483. * @param evt The original (browser) event
  29484. * @param additionalData additional data for the event
  29485. * @returns the new ActionEvent
  29486. */
  29487. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29488. /**
  29489. * Helper function to auto-create an ActionEvent from a source sprite
  29490. * @param source The source sprite that triggered the event
  29491. * @param scene Scene associated with the sprite
  29492. * @param evt The original (browser) event
  29493. * @param additionalData additional data for the event
  29494. * @returns the new ActionEvent
  29495. */
  29496. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29497. /**
  29498. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29499. * @param scene the scene where the event occurred
  29500. * @param evt The original (browser) event
  29501. * @returns the new ActionEvent
  29502. */
  29503. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29504. /**
  29505. * Helper function to auto-create an ActionEvent from a primitive
  29506. * @param prim defines the target primitive
  29507. * @param pointerPos defines the pointer position
  29508. * @param evt The original (browser) event
  29509. * @param additionalData additional data for the event
  29510. * @returns the new ActionEvent
  29511. */
  29512. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29513. }
  29514. }
  29515. declare module "babylonjs/Actions/abstractActionManager" {
  29516. import { IDisposable } from "babylonjs/scene";
  29517. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29518. import { IAction } from "babylonjs/Actions/action";
  29519. import { Nullable } from "babylonjs/types";
  29520. /**
  29521. * Abstract class used to decouple action Manager from scene and meshes.
  29522. * Do not instantiate.
  29523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29524. */
  29525. export abstract class AbstractActionManager implements IDisposable {
  29526. /** Gets the list of active triggers */
  29527. static Triggers: {
  29528. [key: string]: number;
  29529. };
  29530. /** Gets the cursor to use when hovering items */
  29531. hoverCursor: string;
  29532. /** Gets the list of actions */
  29533. actions: IAction[];
  29534. /**
  29535. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29536. */
  29537. isRecursive: boolean;
  29538. /**
  29539. * Releases all associated resources
  29540. */
  29541. abstract dispose(): void;
  29542. /**
  29543. * Does this action manager has pointer triggers
  29544. */
  29545. abstract get hasPointerTriggers(): boolean;
  29546. /**
  29547. * Does this action manager has pick triggers
  29548. */
  29549. abstract get hasPickTriggers(): boolean;
  29550. /**
  29551. * Process a specific trigger
  29552. * @param trigger defines the trigger to process
  29553. * @param evt defines the event details to be processed
  29554. */
  29555. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29556. /**
  29557. * Does this action manager handles actions of any of the given triggers
  29558. * @param triggers defines the triggers to be tested
  29559. * @return a boolean indicating whether one (or more) of the triggers is handled
  29560. */
  29561. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29562. /**
  29563. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29564. * speed.
  29565. * @param triggerA defines the trigger to be tested
  29566. * @param triggerB defines the trigger to be tested
  29567. * @return a boolean indicating whether one (or more) of the triggers is handled
  29568. */
  29569. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29570. /**
  29571. * Does this action manager handles actions of a given trigger
  29572. * @param trigger defines the trigger to be tested
  29573. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29574. * @return whether the trigger is handled
  29575. */
  29576. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29577. /**
  29578. * Serialize this manager to a JSON object
  29579. * @param name defines the property name to store this manager
  29580. * @returns a JSON representation of this manager
  29581. */
  29582. abstract serialize(name: string): any;
  29583. /**
  29584. * Registers an action to this action manager
  29585. * @param action defines the action to be registered
  29586. * @return the action amended (prepared) after registration
  29587. */
  29588. abstract registerAction(action: IAction): Nullable<IAction>;
  29589. /**
  29590. * Unregisters an action to this action manager
  29591. * @param action defines the action to be unregistered
  29592. * @return a boolean indicating whether the action has been unregistered
  29593. */
  29594. abstract unregisterAction(action: IAction): Boolean;
  29595. /**
  29596. * Does exist one action manager with at least one trigger
  29597. **/
  29598. static get HasTriggers(): boolean;
  29599. /**
  29600. * Does exist one action manager with at least one pick trigger
  29601. **/
  29602. static get HasPickTriggers(): boolean;
  29603. /**
  29604. * Does exist one action manager that handles actions of a given trigger
  29605. * @param trigger defines the trigger to be tested
  29606. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29607. **/
  29608. static HasSpecificTrigger(trigger: number): boolean;
  29609. }
  29610. }
  29611. declare module "babylonjs/node" {
  29612. import { Scene } from "babylonjs/scene";
  29613. import { Nullable } from "babylonjs/types";
  29614. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29615. import { Engine } from "babylonjs/Engines/engine";
  29616. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29617. import { Observable } from "babylonjs/Misc/observable";
  29618. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29619. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29620. import { Animatable } from "babylonjs/Animations/animatable";
  29621. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29622. import { Animation } from "babylonjs/Animations/animation";
  29623. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29625. /**
  29626. * Defines how a node can be built from a string name.
  29627. */
  29628. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29629. /**
  29630. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29631. */
  29632. export class Node implements IBehaviorAware<Node> {
  29633. /** @hidden */
  29634. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29635. private static _NodeConstructors;
  29636. /**
  29637. * Add a new node constructor
  29638. * @param type defines the type name of the node to construct
  29639. * @param constructorFunc defines the constructor function
  29640. */
  29641. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29642. /**
  29643. * Returns a node constructor based on type name
  29644. * @param type defines the type name
  29645. * @param name defines the new node name
  29646. * @param scene defines the hosting scene
  29647. * @param options defines optional options to transmit to constructors
  29648. * @returns the new constructor or null
  29649. */
  29650. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29651. /**
  29652. * Gets or sets the name of the node
  29653. */
  29654. name: string;
  29655. /**
  29656. * Gets or sets the id of the node
  29657. */
  29658. id: string;
  29659. /**
  29660. * Gets or sets the unique id of the node
  29661. */
  29662. uniqueId: number;
  29663. /**
  29664. * Gets or sets a string used to store user defined state for the node
  29665. */
  29666. state: string;
  29667. /**
  29668. * Gets or sets an object used to store user defined information for the node
  29669. */
  29670. metadata: any;
  29671. /**
  29672. * For internal use only. Please do not use.
  29673. */
  29674. reservedDataStore: any;
  29675. /**
  29676. * List of inspectable custom properties (used by the Inspector)
  29677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29678. */
  29679. inspectableCustomProperties: IInspectable[];
  29680. private _doNotSerialize;
  29681. /**
  29682. * Gets or sets a boolean used to define if the node must be serialized
  29683. */
  29684. get doNotSerialize(): boolean;
  29685. set doNotSerialize(value: boolean);
  29686. /** @hidden */
  29687. _isDisposed: boolean;
  29688. /**
  29689. * Gets a list of Animations associated with the node
  29690. */
  29691. animations: import("babylonjs/Animations/animation").Animation[];
  29692. protected _ranges: {
  29693. [name: string]: Nullable<AnimationRange>;
  29694. };
  29695. /**
  29696. * Callback raised when the node is ready to be used
  29697. */
  29698. onReady: Nullable<(node: Node) => void>;
  29699. private _isEnabled;
  29700. private _isParentEnabled;
  29701. private _isReady;
  29702. /** @hidden */
  29703. _currentRenderId: number;
  29704. private _parentUpdateId;
  29705. /** @hidden */
  29706. _childUpdateId: number;
  29707. /** @hidden */
  29708. _waitingParentId: Nullable<string>;
  29709. /** @hidden */
  29710. _scene: Scene;
  29711. /** @hidden */
  29712. _cache: any;
  29713. private _parentNode;
  29714. private _children;
  29715. /** @hidden */
  29716. _worldMatrix: Matrix;
  29717. /** @hidden */
  29718. _worldMatrixDeterminant: number;
  29719. /** @hidden */
  29720. _worldMatrixDeterminantIsDirty: boolean;
  29721. /** @hidden */
  29722. private _sceneRootNodesIndex;
  29723. /**
  29724. * Gets a boolean indicating if the node has been disposed
  29725. * @returns true if the node was disposed
  29726. */
  29727. isDisposed(): boolean;
  29728. /**
  29729. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29730. * @see https://doc.babylonjs.com/how_to/parenting
  29731. */
  29732. set parent(parent: Nullable<Node>);
  29733. get parent(): Nullable<Node>;
  29734. /** @hidden */
  29735. _addToSceneRootNodes(): void;
  29736. /** @hidden */
  29737. _removeFromSceneRootNodes(): void;
  29738. private _animationPropertiesOverride;
  29739. /**
  29740. * Gets or sets the animation properties override
  29741. */
  29742. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29743. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29744. /**
  29745. * Gets a string idenfifying the name of the class
  29746. * @returns "Node" string
  29747. */
  29748. getClassName(): string;
  29749. /** @hidden */
  29750. readonly _isNode: boolean;
  29751. /**
  29752. * An event triggered when the mesh is disposed
  29753. */
  29754. onDisposeObservable: Observable<Node>;
  29755. private _onDisposeObserver;
  29756. /**
  29757. * Sets a callback that will be raised when the node will be disposed
  29758. */
  29759. set onDispose(callback: () => void);
  29760. /**
  29761. * Creates a new Node
  29762. * @param name the name and id to be given to this node
  29763. * @param scene the scene this node will be added to
  29764. */
  29765. constructor(name: string, scene?: Nullable<Scene>);
  29766. /**
  29767. * Gets the scene of the node
  29768. * @returns a scene
  29769. */
  29770. getScene(): Scene;
  29771. /**
  29772. * Gets the engine of the node
  29773. * @returns a Engine
  29774. */
  29775. getEngine(): Engine;
  29776. private _behaviors;
  29777. /**
  29778. * Attach a behavior to the node
  29779. * @see http://doc.babylonjs.com/features/behaviour
  29780. * @param behavior defines the behavior to attach
  29781. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29782. * @returns the current Node
  29783. */
  29784. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29785. /**
  29786. * Remove an attached behavior
  29787. * @see http://doc.babylonjs.com/features/behaviour
  29788. * @param behavior defines the behavior to attach
  29789. * @returns the current Node
  29790. */
  29791. removeBehavior(behavior: Behavior<Node>): Node;
  29792. /**
  29793. * Gets the list of attached behaviors
  29794. * @see http://doc.babylonjs.com/features/behaviour
  29795. */
  29796. get behaviors(): Behavior<Node>[];
  29797. /**
  29798. * Gets an attached behavior by name
  29799. * @param name defines the name of the behavior to look for
  29800. * @see http://doc.babylonjs.com/features/behaviour
  29801. * @returns null if behavior was not found else the requested behavior
  29802. */
  29803. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29804. /**
  29805. * Returns the latest update of the World matrix
  29806. * @returns a Matrix
  29807. */
  29808. getWorldMatrix(): Matrix;
  29809. /** @hidden */
  29810. _getWorldMatrixDeterminant(): number;
  29811. /**
  29812. * Returns directly the latest state of the mesh World matrix.
  29813. * A Matrix is returned.
  29814. */
  29815. get worldMatrixFromCache(): Matrix;
  29816. /** @hidden */
  29817. _initCache(): void;
  29818. /** @hidden */
  29819. updateCache(force?: boolean): void;
  29820. /** @hidden */
  29821. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29822. /** @hidden */
  29823. _updateCache(ignoreParentClass?: boolean): void;
  29824. /** @hidden */
  29825. _isSynchronized(): boolean;
  29826. /** @hidden */
  29827. _markSyncedWithParent(): void;
  29828. /** @hidden */
  29829. isSynchronizedWithParent(): boolean;
  29830. /** @hidden */
  29831. isSynchronized(): boolean;
  29832. /**
  29833. * Is this node ready to be used/rendered
  29834. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29835. * @return true if the node is ready
  29836. */
  29837. isReady(completeCheck?: boolean): boolean;
  29838. /**
  29839. * Is this node enabled?
  29840. * 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
  29841. * @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
  29842. * @return whether this node (and its parent) is enabled
  29843. */
  29844. isEnabled(checkAncestors?: boolean): boolean;
  29845. /** @hidden */
  29846. protected _syncParentEnabledState(): void;
  29847. /**
  29848. * Set the enabled state of this node
  29849. * @param value defines the new enabled state
  29850. */
  29851. setEnabled(value: boolean): void;
  29852. /**
  29853. * Is this node a descendant of the given node?
  29854. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29855. * @param ancestor defines the parent node to inspect
  29856. * @returns a boolean indicating if this node is a descendant of the given node
  29857. */
  29858. isDescendantOf(ancestor: Node): boolean;
  29859. /** @hidden */
  29860. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29861. /**
  29862. * Will return all nodes that have this node as ascendant
  29863. * @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
  29864. * @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
  29865. * @return all children nodes of all types
  29866. */
  29867. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29868. /**
  29869. * Get all child-meshes of this node
  29870. * @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)
  29871. * @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
  29872. * @returns an array of AbstractMesh
  29873. */
  29874. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29875. /**
  29876. * Get all direct children of this node
  29877. * @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
  29878. * @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)
  29879. * @returns an array of Node
  29880. */
  29881. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29882. /** @hidden */
  29883. _setReady(state: boolean): void;
  29884. /**
  29885. * Get an animation by name
  29886. * @param name defines the name of the animation to look for
  29887. * @returns null if not found else the requested animation
  29888. */
  29889. getAnimationByName(name: string): Nullable<Animation>;
  29890. /**
  29891. * Creates an animation range for this node
  29892. * @param name defines the name of the range
  29893. * @param from defines the starting key
  29894. * @param to defines the end key
  29895. */
  29896. createAnimationRange(name: string, from: number, to: number): void;
  29897. /**
  29898. * Delete a specific animation range
  29899. * @param name defines the name of the range to delete
  29900. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29901. */
  29902. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29903. /**
  29904. * Get an animation range by name
  29905. * @param name defines the name of the animation range to look for
  29906. * @returns null if not found else the requested animation range
  29907. */
  29908. getAnimationRange(name: string): Nullable<AnimationRange>;
  29909. /**
  29910. * Gets the list of all animation ranges defined on this node
  29911. * @returns an array
  29912. */
  29913. getAnimationRanges(): Nullable<AnimationRange>[];
  29914. /**
  29915. * Will start the animation sequence
  29916. * @param name defines the range frames for animation sequence
  29917. * @param loop defines if the animation should loop (false by default)
  29918. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29919. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29920. * @returns the object created for this animation. If range does not exist, it will return null
  29921. */
  29922. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29923. /**
  29924. * Serialize animation ranges into a JSON compatible object
  29925. * @returns serialization object
  29926. */
  29927. serializeAnimationRanges(): any;
  29928. /**
  29929. * Computes the world matrix of the node
  29930. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29931. * @returns the world matrix
  29932. */
  29933. computeWorldMatrix(force?: boolean): Matrix;
  29934. /**
  29935. * Releases resources associated with this node.
  29936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29938. */
  29939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29940. /**
  29941. * Parse animation range data from a serialization object and store them into a given node
  29942. * @param node defines where to store the animation ranges
  29943. * @param parsedNode defines the serialization object to read data from
  29944. * @param scene defines the hosting scene
  29945. */
  29946. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29947. /**
  29948. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29949. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29950. * @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
  29951. * @returns the new bounding vectors
  29952. */
  29953. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29954. min: Vector3;
  29955. max: Vector3;
  29956. };
  29957. }
  29958. }
  29959. declare module "babylonjs/Animations/animation" {
  29960. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29961. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29962. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29963. import { Nullable } from "babylonjs/types";
  29964. import { Scene } from "babylonjs/scene";
  29965. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29966. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29967. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29968. import { Node } from "babylonjs/node";
  29969. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29970. import { Size } from "babylonjs/Maths/math.size";
  29971. import { Animatable } from "babylonjs/Animations/animatable";
  29972. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29973. /**
  29974. * @hidden
  29975. */
  29976. export class _IAnimationState {
  29977. key: number;
  29978. repeatCount: number;
  29979. workValue?: any;
  29980. loopMode?: number;
  29981. offsetValue?: any;
  29982. highLimitValue?: any;
  29983. }
  29984. /**
  29985. * Class used to store any kind of animation
  29986. */
  29987. export class Animation {
  29988. /**Name of the animation */
  29989. name: string;
  29990. /**Property to animate */
  29991. targetProperty: string;
  29992. /**The frames per second of the animation */
  29993. framePerSecond: number;
  29994. /**The data type of the animation */
  29995. dataType: number;
  29996. /**The loop mode of the animation */
  29997. loopMode?: number | undefined;
  29998. /**Specifies if blending should be enabled */
  29999. enableBlending?: boolean | undefined;
  30000. /**
  30001. * Use matrix interpolation instead of using direct key value when animating matrices
  30002. */
  30003. static AllowMatricesInterpolation: boolean;
  30004. /**
  30005. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30006. */
  30007. static AllowMatrixDecomposeForInterpolation: boolean;
  30008. /**
  30009. * Stores the key frames of the animation
  30010. */
  30011. private _keys;
  30012. /**
  30013. * Stores the easing function of the animation
  30014. */
  30015. private _easingFunction;
  30016. /**
  30017. * @hidden Internal use only
  30018. */
  30019. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30020. /**
  30021. * The set of event that will be linked to this animation
  30022. */
  30023. private _events;
  30024. /**
  30025. * Stores an array of target property paths
  30026. */
  30027. targetPropertyPath: string[];
  30028. /**
  30029. * Stores the blending speed of the animation
  30030. */
  30031. blendingSpeed: number;
  30032. /**
  30033. * Stores the animation ranges for the animation
  30034. */
  30035. private _ranges;
  30036. /**
  30037. * @hidden Internal use
  30038. */
  30039. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30040. /**
  30041. * Sets up an animation
  30042. * @param property The property to animate
  30043. * @param animationType The animation type to apply
  30044. * @param framePerSecond The frames per second of the animation
  30045. * @param easingFunction The easing function used in the animation
  30046. * @returns The created animation
  30047. */
  30048. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30049. /**
  30050. * Create and start an animation on a node
  30051. * @param name defines the name of the global animation that will be run on all nodes
  30052. * @param node defines the root node where the animation will take place
  30053. * @param targetProperty defines property to animate
  30054. * @param framePerSecond defines the number of frame per second yo use
  30055. * @param totalFrame defines the number of frames in total
  30056. * @param from defines the initial value
  30057. * @param to defines the final value
  30058. * @param loopMode defines which loop mode you want to use (off by default)
  30059. * @param easingFunction defines the easing function to use (linear by default)
  30060. * @param onAnimationEnd defines the callback to call when animation end
  30061. * @returns the animatable created for this animation
  30062. */
  30063. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30064. /**
  30065. * Create and start an animation on a node and its descendants
  30066. * @param name defines the name of the global animation that will be run on all nodes
  30067. * @param node defines the root node where the animation will take place
  30068. * @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
  30069. * @param targetProperty defines property to animate
  30070. * @param framePerSecond defines the number of frame per second to use
  30071. * @param totalFrame defines the number of frames in total
  30072. * @param from defines the initial value
  30073. * @param to defines the final value
  30074. * @param loopMode defines which loop mode you want to use (off by default)
  30075. * @param easingFunction defines the easing function to use (linear by default)
  30076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30077. * @returns the list of animatables created for all nodes
  30078. * @example https://www.babylonjs-playground.com/#MH0VLI
  30079. */
  30080. 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[]>;
  30081. /**
  30082. * Creates a new animation, merges it with the existing animations and starts it
  30083. * @param name Name of the animation
  30084. * @param node Node which contains the scene that begins the animations
  30085. * @param targetProperty Specifies which property to animate
  30086. * @param framePerSecond The frames per second of the animation
  30087. * @param totalFrame The total number of frames
  30088. * @param from The frame at the beginning of the animation
  30089. * @param to The frame at the end of the animation
  30090. * @param loopMode Specifies the loop mode of the animation
  30091. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30092. * @param onAnimationEnd Callback to run once the animation is complete
  30093. * @returns Nullable animation
  30094. */
  30095. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30096. /**
  30097. * Transition property of an host to the target Value
  30098. * @param property The property to transition
  30099. * @param targetValue The target Value of the property
  30100. * @param host The object where the property to animate belongs
  30101. * @param scene Scene used to run the animation
  30102. * @param frameRate Framerate (in frame/s) to use
  30103. * @param transition The transition type we want to use
  30104. * @param duration The duration of the animation, in milliseconds
  30105. * @param onAnimationEnd Callback trigger at the end of the animation
  30106. * @returns Nullable animation
  30107. */
  30108. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30109. /**
  30110. * Return the array of runtime animations currently using this animation
  30111. */
  30112. get runtimeAnimations(): RuntimeAnimation[];
  30113. /**
  30114. * Specifies if any of the runtime animations are currently running
  30115. */
  30116. get hasRunningRuntimeAnimations(): boolean;
  30117. /**
  30118. * Initializes the animation
  30119. * @param name Name of the animation
  30120. * @param targetProperty Property to animate
  30121. * @param framePerSecond The frames per second of the animation
  30122. * @param dataType The data type of the animation
  30123. * @param loopMode The loop mode of the animation
  30124. * @param enableBlending Specifies if blending should be enabled
  30125. */
  30126. constructor(
  30127. /**Name of the animation */
  30128. name: string,
  30129. /**Property to animate */
  30130. targetProperty: string,
  30131. /**The frames per second of the animation */
  30132. framePerSecond: number,
  30133. /**The data type of the animation */
  30134. dataType: number,
  30135. /**The loop mode of the animation */
  30136. loopMode?: number | undefined,
  30137. /**Specifies if blending should be enabled */
  30138. enableBlending?: boolean | undefined);
  30139. /**
  30140. * Converts the animation to a string
  30141. * @param fullDetails support for multiple levels of logging within scene loading
  30142. * @returns String form of the animation
  30143. */
  30144. toString(fullDetails?: boolean): string;
  30145. /**
  30146. * Add an event to this animation
  30147. * @param event Event to add
  30148. */
  30149. addEvent(event: AnimationEvent): void;
  30150. /**
  30151. * Remove all events found at the given frame
  30152. * @param frame The frame to remove events from
  30153. */
  30154. removeEvents(frame: number): void;
  30155. /**
  30156. * Retrieves all the events from the animation
  30157. * @returns Events from the animation
  30158. */
  30159. getEvents(): AnimationEvent[];
  30160. /**
  30161. * Creates an animation range
  30162. * @param name Name of the animation range
  30163. * @param from Starting frame of the animation range
  30164. * @param to Ending frame of the animation
  30165. */
  30166. createRange(name: string, from: number, to: number): void;
  30167. /**
  30168. * Deletes an animation range by name
  30169. * @param name Name of the animation range to delete
  30170. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30171. */
  30172. deleteRange(name: string, deleteFrames?: boolean): void;
  30173. /**
  30174. * Gets the animation range by name, or null if not defined
  30175. * @param name Name of the animation range
  30176. * @returns Nullable animation range
  30177. */
  30178. getRange(name: string): Nullable<AnimationRange>;
  30179. /**
  30180. * Gets the key frames from the animation
  30181. * @returns The key frames of the animation
  30182. */
  30183. getKeys(): Array<IAnimationKey>;
  30184. /**
  30185. * Gets the highest frame rate of the animation
  30186. * @returns Highest frame rate of the animation
  30187. */
  30188. getHighestFrame(): number;
  30189. /**
  30190. * Gets the easing function of the animation
  30191. * @returns Easing function of the animation
  30192. */
  30193. getEasingFunction(): IEasingFunction;
  30194. /**
  30195. * Sets the easing function of the animation
  30196. * @param easingFunction A custom mathematical formula for animation
  30197. */
  30198. setEasingFunction(easingFunction: EasingFunction): void;
  30199. /**
  30200. * Interpolates a scalar linearly
  30201. * @param startValue Start value of the animation curve
  30202. * @param endValue End value of the animation curve
  30203. * @param gradient Scalar amount to interpolate
  30204. * @returns Interpolated scalar value
  30205. */
  30206. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30207. /**
  30208. * Interpolates a scalar cubically
  30209. * @param startValue Start value of the animation curve
  30210. * @param outTangent End tangent of the animation
  30211. * @param endValue End value of the animation curve
  30212. * @param inTangent Start tangent of the animation curve
  30213. * @param gradient Scalar amount to interpolate
  30214. * @returns Interpolated scalar value
  30215. */
  30216. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30217. /**
  30218. * Interpolates a quaternion using a spherical linear interpolation
  30219. * @param startValue Start value of the animation curve
  30220. * @param endValue End value of the animation curve
  30221. * @param gradient Scalar amount to interpolate
  30222. * @returns Interpolated quaternion value
  30223. */
  30224. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30225. /**
  30226. * Interpolates a quaternion cubically
  30227. * @param startValue Start value of the animation curve
  30228. * @param outTangent End tangent of the animation curve
  30229. * @param endValue End value of the animation curve
  30230. * @param inTangent Start tangent of the animation curve
  30231. * @param gradient Scalar amount to interpolate
  30232. * @returns Interpolated quaternion value
  30233. */
  30234. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30235. /**
  30236. * Interpolates a Vector3 linearl
  30237. * @param startValue Start value of the animation curve
  30238. * @param endValue End value of the animation curve
  30239. * @param gradient Scalar amount to interpolate
  30240. * @returns Interpolated scalar value
  30241. */
  30242. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30243. /**
  30244. * Interpolates a Vector3 cubically
  30245. * @param startValue Start value of the animation curve
  30246. * @param outTangent End tangent of the animation
  30247. * @param endValue End value of the animation curve
  30248. * @param inTangent Start tangent of the animation curve
  30249. * @param gradient Scalar amount to interpolate
  30250. * @returns InterpolatedVector3 value
  30251. */
  30252. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30253. /**
  30254. * Interpolates a Vector2 linearly
  30255. * @param startValue Start value of the animation curve
  30256. * @param endValue End value of the animation curve
  30257. * @param gradient Scalar amount to interpolate
  30258. * @returns Interpolated Vector2 value
  30259. */
  30260. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30261. /**
  30262. * Interpolates a Vector2 cubically
  30263. * @param startValue Start value of the animation curve
  30264. * @param outTangent End tangent of the animation
  30265. * @param endValue End value of the animation curve
  30266. * @param inTangent Start tangent of the animation curve
  30267. * @param gradient Scalar amount to interpolate
  30268. * @returns Interpolated Vector2 value
  30269. */
  30270. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30271. /**
  30272. * Interpolates a size linearly
  30273. * @param startValue Start value of the animation curve
  30274. * @param endValue End value of the animation curve
  30275. * @param gradient Scalar amount to interpolate
  30276. * @returns Interpolated Size value
  30277. */
  30278. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30279. /**
  30280. * Interpolates a Color3 linearly
  30281. * @param startValue Start value of the animation curve
  30282. * @param endValue End value of the animation curve
  30283. * @param gradient Scalar amount to interpolate
  30284. * @returns Interpolated Color3 value
  30285. */
  30286. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30287. /**
  30288. * Interpolates a Color4 linearly
  30289. * @param startValue Start value of the animation curve
  30290. * @param endValue End value of the animation curve
  30291. * @param gradient Scalar amount to interpolate
  30292. * @returns Interpolated Color3 value
  30293. */
  30294. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30295. /**
  30296. * @hidden Internal use only
  30297. */
  30298. _getKeyValue(value: any): any;
  30299. /**
  30300. * @hidden Internal use only
  30301. */
  30302. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30303. /**
  30304. * Defines the function to use to interpolate matrices
  30305. * @param startValue defines the start matrix
  30306. * @param endValue defines the end matrix
  30307. * @param gradient defines the gradient between both matrices
  30308. * @param result defines an optional target matrix where to store the interpolation
  30309. * @returns the interpolated matrix
  30310. */
  30311. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30312. /**
  30313. * Makes a copy of the animation
  30314. * @returns Cloned animation
  30315. */
  30316. clone(): Animation;
  30317. /**
  30318. * Sets the key frames of the animation
  30319. * @param values The animation key frames to set
  30320. */
  30321. setKeys(values: Array<IAnimationKey>): void;
  30322. /**
  30323. * Serializes the animation to an object
  30324. * @returns Serialized object
  30325. */
  30326. serialize(): any;
  30327. /**
  30328. * Float animation type
  30329. */
  30330. static readonly ANIMATIONTYPE_FLOAT: number;
  30331. /**
  30332. * Vector3 animation type
  30333. */
  30334. static readonly ANIMATIONTYPE_VECTOR3: number;
  30335. /**
  30336. * Quaternion animation type
  30337. */
  30338. static readonly ANIMATIONTYPE_QUATERNION: number;
  30339. /**
  30340. * Matrix animation type
  30341. */
  30342. static readonly ANIMATIONTYPE_MATRIX: number;
  30343. /**
  30344. * Color3 animation type
  30345. */
  30346. static readonly ANIMATIONTYPE_COLOR3: number;
  30347. /**
  30348. * Color3 animation type
  30349. */
  30350. static readonly ANIMATIONTYPE_COLOR4: number;
  30351. /**
  30352. * Vector2 animation type
  30353. */
  30354. static readonly ANIMATIONTYPE_VECTOR2: number;
  30355. /**
  30356. * Size animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_SIZE: number;
  30359. /**
  30360. * Relative Loop Mode
  30361. */
  30362. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30363. /**
  30364. * Cycle Loop Mode
  30365. */
  30366. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30367. /**
  30368. * Constant Loop Mode
  30369. */
  30370. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30371. /** @hidden */
  30372. static _UniversalLerp(left: any, right: any, amount: number): any;
  30373. /**
  30374. * Parses an animation object and creates an animation
  30375. * @param parsedAnimation Parsed animation object
  30376. * @returns Animation object
  30377. */
  30378. static Parse(parsedAnimation: any): Animation;
  30379. /**
  30380. * Appends the serialized animations from the source animations
  30381. * @param source Source containing the animations
  30382. * @param destination Target to store the animations
  30383. */
  30384. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30385. }
  30386. }
  30387. declare module "babylonjs/Animations/animatable.interface" {
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Animation } from "babylonjs/Animations/animation";
  30390. /**
  30391. * Interface containing an array of animations
  30392. */
  30393. export interface IAnimatable {
  30394. /**
  30395. * Array of animations
  30396. */
  30397. animations: Nullable<Array<Animation>>;
  30398. }
  30399. }
  30400. declare module "babylonjs/Misc/decorators" {
  30401. import { Nullable } from "babylonjs/types";
  30402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30403. import { Scene } from "babylonjs/scene";
  30404. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30405. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30406. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30407. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30408. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. /**
  30418. * Decorator used to define property that can be serialized as reference to a camera
  30419. * @param sourceName defines the name of the property to decorate
  30420. */
  30421. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30422. /**
  30423. * Class used to help serialization objects
  30424. */
  30425. export class SerializationHelper {
  30426. /** @hidden */
  30427. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30428. /** @hidden */
  30429. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30430. /** @hidden */
  30431. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30432. /** @hidden */
  30433. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30434. /**
  30435. * Appends the serialized animations from the source animations
  30436. * @param source Source containing the animations
  30437. * @param destination Target to store the animations
  30438. */
  30439. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30440. /**
  30441. * Static function used to serialized a specific entity
  30442. * @param entity defines the entity to serialize
  30443. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30444. * @returns a JSON compatible object representing the serialization of the entity
  30445. */
  30446. static Serialize<T>(entity: T, serializationObject?: any): any;
  30447. /**
  30448. * Creates a new entity from a serialization data object
  30449. * @param creationFunction defines a function used to instanciated the new entity
  30450. * @param source defines the source serialization data
  30451. * @param scene defines the hosting scene
  30452. * @param rootUrl defines the root url for resources
  30453. * @returns a new entity
  30454. */
  30455. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30456. /**
  30457. * Clones an object
  30458. * @param creationFunction defines the function used to instanciate the new object
  30459. * @param source defines the source object
  30460. * @returns the cloned object
  30461. */
  30462. static Clone<T>(creationFunction: () => T, source: T): T;
  30463. /**
  30464. * Instanciates a new object based on a source one (some data will be shared between both object)
  30465. * @param creationFunction defines the function used to instanciate the new object
  30466. * @param source defines the source object
  30467. * @returns the new object
  30468. */
  30469. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30470. }
  30471. }
  30472. declare module "babylonjs/Misc/guid" {
  30473. /**
  30474. * Class used to manipulate GUIDs
  30475. */
  30476. export class GUID {
  30477. /**
  30478. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30479. * Be aware Math.random() could cause collisions, but:
  30480. * "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"
  30481. * @returns a pseudo random id
  30482. */
  30483. static RandomId(): string;
  30484. }
  30485. }
  30486. declare module "babylonjs/Materials/Textures/baseTexture" {
  30487. import { Observable } from "babylonjs/Misc/observable";
  30488. import { Nullable } from "babylonjs/types";
  30489. import { Scene } from "babylonjs/scene";
  30490. import { Matrix } from "babylonjs/Maths/math.vector";
  30491. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30492. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30493. import { ISize } from "babylonjs/Maths/math.size";
  30494. import "babylonjs/Misc/fileTools";
  30495. /**
  30496. * Base class of all the textures in babylon.
  30497. * It groups all the common properties the materials, post process, lights... might need
  30498. * in order to make a correct use of the texture.
  30499. */
  30500. export class BaseTexture implements IAnimatable {
  30501. /**
  30502. * Default anisotropic filtering level for the application.
  30503. * It is set to 4 as a good tradeoff between perf and quality.
  30504. */
  30505. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30506. /**
  30507. * Gets or sets the unique id of the texture
  30508. */
  30509. uniqueId: number;
  30510. /**
  30511. * Define the name of the texture.
  30512. */
  30513. name: string;
  30514. /**
  30515. * Gets or sets an object used to store user defined information.
  30516. */
  30517. metadata: any;
  30518. /**
  30519. * For internal use only. Please do not use.
  30520. */
  30521. reservedDataStore: any;
  30522. private _hasAlpha;
  30523. /**
  30524. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30525. */
  30526. set hasAlpha(value: boolean);
  30527. get hasAlpha(): boolean;
  30528. /**
  30529. * Defines if the alpha value should be determined via the rgb values.
  30530. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30531. */
  30532. getAlphaFromRGB: boolean;
  30533. /**
  30534. * Intensity or strength of the texture.
  30535. * It is commonly used by materials to fine tune the intensity of the texture
  30536. */
  30537. level: number;
  30538. /**
  30539. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30540. * This is part of the texture as textures usually maps to one uv set.
  30541. */
  30542. coordinatesIndex: number;
  30543. private _coordinatesMode;
  30544. /**
  30545. * How a texture is mapped.
  30546. *
  30547. * | Value | Type | Description |
  30548. * | ----- | ----------------------------------- | ----------- |
  30549. * | 0 | EXPLICIT_MODE | |
  30550. * | 1 | SPHERICAL_MODE | |
  30551. * | 2 | PLANAR_MODE | |
  30552. * | 3 | CUBIC_MODE | |
  30553. * | 4 | PROJECTION_MODE | |
  30554. * | 5 | SKYBOX_MODE | |
  30555. * | 6 | INVCUBIC_MODE | |
  30556. * | 7 | EQUIRECTANGULAR_MODE | |
  30557. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30558. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30559. */
  30560. set coordinatesMode(value: number);
  30561. get coordinatesMode(): number;
  30562. /**
  30563. * | Value | Type | Description |
  30564. * | ----- | ------------------ | ----------- |
  30565. * | 0 | CLAMP_ADDRESSMODE | |
  30566. * | 1 | WRAP_ADDRESSMODE | |
  30567. * | 2 | MIRROR_ADDRESSMODE | |
  30568. */
  30569. wrapU: number;
  30570. /**
  30571. * | Value | Type | Description |
  30572. * | ----- | ------------------ | ----------- |
  30573. * | 0 | CLAMP_ADDRESSMODE | |
  30574. * | 1 | WRAP_ADDRESSMODE | |
  30575. * | 2 | MIRROR_ADDRESSMODE | |
  30576. */
  30577. wrapV: number;
  30578. /**
  30579. * | Value | Type | Description |
  30580. * | ----- | ------------------ | ----------- |
  30581. * | 0 | CLAMP_ADDRESSMODE | |
  30582. * | 1 | WRAP_ADDRESSMODE | |
  30583. * | 2 | MIRROR_ADDRESSMODE | |
  30584. */
  30585. wrapR: number;
  30586. /**
  30587. * With compliant hardware and browser (supporting anisotropic filtering)
  30588. * this defines the level of anisotropic filtering in the texture.
  30589. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30590. */
  30591. anisotropicFilteringLevel: number;
  30592. /**
  30593. * Define if the texture is a cube texture or if false a 2d texture.
  30594. */
  30595. get isCube(): boolean;
  30596. set isCube(value: boolean);
  30597. /**
  30598. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30599. */
  30600. get is3D(): boolean;
  30601. set is3D(value: boolean);
  30602. /**
  30603. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30604. */
  30605. get is2DArray(): boolean;
  30606. set is2DArray(value: boolean);
  30607. /**
  30608. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30609. * HDR texture are usually stored in linear space.
  30610. * This only impacts the PBR and Background materials
  30611. */
  30612. gammaSpace: boolean;
  30613. /**
  30614. * Gets or sets whether or not the texture contains RGBD data.
  30615. */
  30616. get isRGBD(): boolean;
  30617. set isRGBD(value: boolean);
  30618. /**
  30619. * Is Z inverted in the texture (useful in a cube texture).
  30620. */
  30621. invertZ: boolean;
  30622. /**
  30623. * Are mip maps generated for this texture or not.
  30624. */
  30625. get noMipmap(): boolean;
  30626. /**
  30627. * @hidden
  30628. */
  30629. lodLevelInAlpha: boolean;
  30630. /**
  30631. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30632. */
  30633. get lodGenerationOffset(): number;
  30634. set lodGenerationOffset(value: number);
  30635. /**
  30636. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30637. */
  30638. get lodGenerationScale(): number;
  30639. set lodGenerationScale(value: number);
  30640. /**
  30641. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30642. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30643. * average roughness values.
  30644. */
  30645. get linearSpecularLOD(): boolean;
  30646. set linearSpecularLOD(value: boolean);
  30647. /**
  30648. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30649. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30650. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30651. */
  30652. get irradianceTexture(): Nullable<BaseTexture>;
  30653. set irradianceTexture(value: Nullable<BaseTexture>);
  30654. /**
  30655. * Define if the texture is a render target.
  30656. */
  30657. isRenderTarget: boolean;
  30658. /**
  30659. * Define the unique id of the texture in the scene.
  30660. */
  30661. get uid(): string;
  30662. /**
  30663. * Return a string representation of the texture.
  30664. * @returns the texture as a string
  30665. */
  30666. toString(): string;
  30667. /**
  30668. * Get the class name of the texture.
  30669. * @returns "BaseTexture"
  30670. */
  30671. getClassName(): string;
  30672. /**
  30673. * Define the list of animation attached to the texture.
  30674. */
  30675. animations: import("babylonjs/Animations/animation").Animation[];
  30676. /**
  30677. * An event triggered when the texture is disposed.
  30678. */
  30679. onDisposeObservable: Observable<BaseTexture>;
  30680. private _onDisposeObserver;
  30681. /**
  30682. * Callback triggered when the texture has been disposed.
  30683. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30684. */
  30685. set onDispose(callback: () => void);
  30686. /**
  30687. * Define the current state of the loading sequence when in delayed load mode.
  30688. */
  30689. delayLoadState: number;
  30690. private _scene;
  30691. /** @hidden */
  30692. _texture: Nullable<InternalTexture>;
  30693. private _uid;
  30694. /**
  30695. * Define if the texture is preventinga material to render or not.
  30696. * If not and the texture is not ready, the engine will use a default black texture instead.
  30697. */
  30698. get isBlocking(): boolean;
  30699. /**
  30700. * Instantiates a new BaseTexture.
  30701. * Base class of all the textures in babylon.
  30702. * It groups all the common properties the materials, post process, lights... might need
  30703. * in order to make a correct use of the texture.
  30704. * @param scene Define the scene the texture blongs to
  30705. */
  30706. constructor(scene: Nullable<Scene>);
  30707. /**
  30708. * Get the scene the texture belongs to.
  30709. * @returns the scene or null if undefined
  30710. */
  30711. getScene(): Nullable<Scene>;
  30712. /**
  30713. * Get the texture transform matrix used to offset tile the texture for istance.
  30714. * @returns the transformation matrix
  30715. */
  30716. getTextureMatrix(): Matrix;
  30717. /**
  30718. * Get the texture reflection matrix used to rotate/transform the reflection.
  30719. * @returns the reflection matrix
  30720. */
  30721. getReflectionTextureMatrix(): Matrix;
  30722. /**
  30723. * Get the underlying lower level texture from Babylon.
  30724. * @returns the insternal texture
  30725. */
  30726. getInternalTexture(): Nullable<InternalTexture>;
  30727. /**
  30728. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30729. * @returns true if ready or not blocking
  30730. */
  30731. isReadyOrNotBlocking(): boolean;
  30732. /**
  30733. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30734. * @returns true if fully ready
  30735. */
  30736. isReady(): boolean;
  30737. private _cachedSize;
  30738. /**
  30739. * Get the size of the texture.
  30740. * @returns the texture size.
  30741. */
  30742. getSize(): ISize;
  30743. /**
  30744. * Get the base size of the texture.
  30745. * It can be different from the size if the texture has been resized for POT for instance
  30746. * @returns the base size
  30747. */
  30748. getBaseSize(): ISize;
  30749. /**
  30750. * Update the sampling mode of the texture.
  30751. * Default is Trilinear mode.
  30752. *
  30753. * | Value | Type | Description |
  30754. * | ----- | ------------------ | ----------- |
  30755. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30756. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30757. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30758. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30759. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30760. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30761. * | 7 | NEAREST_LINEAR | |
  30762. * | 8 | NEAREST_NEAREST | |
  30763. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30764. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30765. * | 11 | LINEAR_LINEAR | |
  30766. * | 12 | LINEAR_NEAREST | |
  30767. *
  30768. * > _mag_: magnification filter (close to the viewer)
  30769. * > _min_: minification filter (far from the viewer)
  30770. * > _mip_: filter used between mip map levels
  30771. *@param samplingMode Define the new sampling mode of the texture
  30772. */
  30773. updateSamplingMode(samplingMode: number): void;
  30774. /**
  30775. * Scales the texture if is `canRescale()`
  30776. * @param ratio the resize factor we want to use to rescale
  30777. */
  30778. scale(ratio: number): void;
  30779. /**
  30780. * Get if the texture can rescale.
  30781. */
  30782. get canRescale(): boolean;
  30783. /** @hidden */
  30784. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30785. /** @hidden */
  30786. _rebuild(): void;
  30787. /**
  30788. * Triggers the load sequence in delayed load mode.
  30789. */
  30790. delayLoad(): void;
  30791. /**
  30792. * Clones the texture.
  30793. * @returns the cloned texture
  30794. */
  30795. clone(): Nullable<BaseTexture>;
  30796. /**
  30797. * Get the texture underlying type (INT, FLOAT...)
  30798. */
  30799. get textureType(): number;
  30800. /**
  30801. * Get the texture underlying format (RGB, RGBA...)
  30802. */
  30803. get textureFormat(): number;
  30804. /**
  30805. * Indicates that textures need to be re-calculated for all materials
  30806. */
  30807. protected _markAllSubMeshesAsTexturesDirty(): void;
  30808. /**
  30809. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30810. * This will returns an RGBA array buffer containing either in values (0-255) or
  30811. * float values (0-1) depending of the underlying buffer type.
  30812. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30813. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30814. * @param buffer defines a user defined buffer to fill with data (can be null)
  30815. * @returns The Array buffer containing the pixels data.
  30816. */
  30817. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30818. /**
  30819. * Release and destroy the underlying lower level texture aka internalTexture.
  30820. */
  30821. releaseInternalTexture(): void;
  30822. /** @hidden */
  30823. get _lodTextureHigh(): Nullable<BaseTexture>;
  30824. /** @hidden */
  30825. get _lodTextureMid(): Nullable<BaseTexture>;
  30826. /** @hidden */
  30827. get _lodTextureLow(): Nullable<BaseTexture>;
  30828. /**
  30829. * Dispose the texture and release its associated resources.
  30830. */
  30831. dispose(): void;
  30832. /**
  30833. * Serialize the texture into a JSON representation that can be parsed later on.
  30834. * @returns the JSON representation of the texture
  30835. */
  30836. serialize(): any;
  30837. /**
  30838. * Helper function to be called back once a list of texture contains only ready textures.
  30839. * @param textures Define the list of textures to wait for
  30840. * @param callback Define the callback triggered once the entire list will be ready
  30841. */
  30842. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30843. }
  30844. }
  30845. declare module "babylonjs/Materials/effect" {
  30846. import { Observable } from "babylonjs/Misc/observable";
  30847. import { Nullable } from "babylonjs/types";
  30848. import { IDisposable } from "babylonjs/scene";
  30849. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30850. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30851. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30852. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30853. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30854. import { Engine } from "babylonjs/Engines/engine";
  30855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30858. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30859. /**
  30860. * Options to be used when creating an effect.
  30861. */
  30862. export interface IEffectCreationOptions {
  30863. /**
  30864. * Atrributes that will be used in the shader.
  30865. */
  30866. attributes: string[];
  30867. /**
  30868. * Uniform varible names that will be set in the shader.
  30869. */
  30870. uniformsNames: string[];
  30871. /**
  30872. * Uniform buffer variable names that will be set in the shader.
  30873. */
  30874. uniformBuffersNames: string[];
  30875. /**
  30876. * Sampler texture variable names that will be set in the shader.
  30877. */
  30878. samplers: string[];
  30879. /**
  30880. * Define statements that will be set in the shader.
  30881. */
  30882. defines: any;
  30883. /**
  30884. * Possible fallbacks for this effect to improve performance when needed.
  30885. */
  30886. fallbacks: Nullable<IEffectFallbacks>;
  30887. /**
  30888. * Callback that will be called when the shader is compiled.
  30889. */
  30890. onCompiled: Nullable<(effect: Effect) => void>;
  30891. /**
  30892. * Callback that will be called if an error occurs during shader compilation.
  30893. */
  30894. onError: Nullable<(effect: Effect, errors: string) => void>;
  30895. /**
  30896. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30897. */
  30898. indexParameters?: any;
  30899. /**
  30900. * Max number of lights that can be used in the shader.
  30901. */
  30902. maxSimultaneousLights?: number;
  30903. /**
  30904. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30905. */
  30906. transformFeedbackVaryings?: Nullable<string[]>;
  30907. }
  30908. /**
  30909. * Effect containing vertex and fragment shader that can be executed on an object.
  30910. */
  30911. export class Effect implements IDisposable {
  30912. /**
  30913. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30914. */
  30915. static ShadersRepository: string;
  30916. /**
  30917. * Name of the effect.
  30918. */
  30919. name: any;
  30920. /**
  30921. * String container all the define statements that should be set on the shader.
  30922. */
  30923. defines: string;
  30924. /**
  30925. * Callback that will be called when the shader is compiled.
  30926. */
  30927. onCompiled: Nullable<(effect: Effect) => void>;
  30928. /**
  30929. * Callback that will be called if an error occurs during shader compilation.
  30930. */
  30931. onError: Nullable<(effect: Effect, errors: string) => void>;
  30932. /**
  30933. * Callback that will be called when effect is bound.
  30934. */
  30935. onBind: Nullable<(effect: Effect) => void>;
  30936. /**
  30937. * Unique ID of the effect.
  30938. */
  30939. uniqueId: number;
  30940. /**
  30941. * Observable that will be called when the shader is compiled.
  30942. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30943. */
  30944. onCompileObservable: Observable<Effect>;
  30945. /**
  30946. * Observable that will be called if an error occurs during shader compilation.
  30947. */
  30948. onErrorObservable: Observable<Effect>;
  30949. /** @hidden */
  30950. _onBindObservable: Nullable<Observable<Effect>>;
  30951. /**
  30952. * @hidden
  30953. * Specifies if the effect was previously ready
  30954. */
  30955. _wasPreviouslyReady: boolean;
  30956. /**
  30957. * Observable that will be called when effect is bound.
  30958. */
  30959. get onBindObservable(): Observable<Effect>;
  30960. /** @hidden */
  30961. _bonesComputationForcedToCPU: boolean;
  30962. private static _uniqueIdSeed;
  30963. private _engine;
  30964. private _uniformBuffersNames;
  30965. private _uniformsNames;
  30966. private _samplerList;
  30967. private _samplers;
  30968. private _isReady;
  30969. private _compilationError;
  30970. private _allFallbacksProcessed;
  30971. private _attributesNames;
  30972. private _attributes;
  30973. private _attributeLocationByName;
  30974. private _uniforms;
  30975. /**
  30976. * Key for the effect.
  30977. * @hidden
  30978. */
  30979. _key: string;
  30980. private _indexParameters;
  30981. private _fallbacks;
  30982. private _vertexSourceCode;
  30983. private _fragmentSourceCode;
  30984. private _vertexSourceCodeOverride;
  30985. private _fragmentSourceCodeOverride;
  30986. private _transformFeedbackVaryings;
  30987. /**
  30988. * Compiled shader to webGL program.
  30989. * @hidden
  30990. */
  30991. _pipelineContext: Nullable<IPipelineContext>;
  30992. private _valueCache;
  30993. private static _baseCache;
  30994. /**
  30995. * Instantiates an effect.
  30996. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30997. * @param baseName Name of the effect.
  30998. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30999. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31000. * @param samplers List of sampler variables that will be passed to the shader.
  31001. * @param engine Engine to be used to render the effect
  31002. * @param defines Define statements to be added to the shader.
  31003. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31004. * @param onCompiled Callback that will be called when the shader is compiled.
  31005. * @param onError Callback that will be called if an error occurs during shader compilation.
  31006. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31007. */
  31008. 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);
  31009. private _useFinalCode;
  31010. /**
  31011. * Unique key for this effect
  31012. */
  31013. get key(): string;
  31014. /**
  31015. * If the effect has been compiled and prepared.
  31016. * @returns if the effect is compiled and prepared.
  31017. */
  31018. isReady(): boolean;
  31019. private _isReadyInternal;
  31020. /**
  31021. * The engine the effect was initialized with.
  31022. * @returns the engine.
  31023. */
  31024. getEngine(): Engine;
  31025. /**
  31026. * The pipeline context for this effect
  31027. * @returns the associated pipeline context
  31028. */
  31029. getPipelineContext(): Nullable<IPipelineContext>;
  31030. /**
  31031. * The set of names of attribute variables for the shader.
  31032. * @returns An array of attribute names.
  31033. */
  31034. getAttributesNames(): string[];
  31035. /**
  31036. * Returns the attribute at the given index.
  31037. * @param index The index of the attribute.
  31038. * @returns The location of the attribute.
  31039. */
  31040. getAttributeLocation(index: number): number;
  31041. /**
  31042. * Returns the attribute based on the name of the variable.
  31043. * @param name of the attribute to look up.
  31044. * @returns the attribute location.
  31045. */
  31046. getAttributeLocationByName(name: string): number;
  31047. /**
  31048. * The number of attributes.
  31049. * @returns the numnber of attributes.
  31050. */
  31051. getAttributesCount(): number;
  31052. /**
  31053. * Gets the index of a uniform variable.
  31054. * @param uniformName of the uniform to look up.
  31055. * @returns the index.
  31056. */
  31057. getUniformIndex(uniformName: string): number;
  31058. /**
  31059. * Returns the attribute based on the name of the variable.
  31060. * @param uniformName of the uniform to look up.
  31061. * @returns the location of the uniform.
  31062. */
  31063. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31064. /**
  31065. * Returns an array of sampler variable names
  31066. * @returns The array of sampler variable neames.
  31067. */
  31068. getSamplers(): string[];
  31069. /**
  31070. * The error from the last compilation.
  31071. * @returns the error string.
  31072. */
  31073. getCompilationError(): string;
  31074. /**
  31075. * Gets a boolean indicating that all fallbacks were used during compilation
  31076. * @returns true if all fallbacks were used
  31077. */
  31078. allFallbacksProcessed(): boolean;
  31079. /**
  31080. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31081. * @param func The callback to be used.
  31082. */
  31083. executeWhenCompiled(func: (effect: Effect) => void): void;
  31084. private _checkIsReady;
  31085. private _loadShader;
  31086. /**
  31087. * Recompiles the webGL program
  31088. * @param vertexSourceCode The source code for the vertex shader.
  31089. * @param fragmentSourceCode The source code for the fragment shader.
  31090. * @param onCompiled Callback called when completed.
  31091. * @param onError Callback called on error.
  31092. * @hidden
  31093. */
  31094. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31095. /**
  31096. * Prepares the effect
  31097. * @hidden
  31098. */
  31099. _prepareEffect(): void;
  31100. private _processCompilationErrors;
  31101. /**
  31102. * Checks if the effect is supported. (Must be called after compilation)
  31103. */
  31104. get isSupported(): boolean;
  31105. /**
  31106. * Binds a texture to the engine to be used as output of the shader.
  31107. * @param channel Name of the output variable.
  31108. * @param texture Texture to bind.
  31109. * @hidden
  31110. */
  31111. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31112. /**
  31113. * Sets a texture on the engine to be used in the shader.
  31114. * @param channel Name of the sampler variable.
  31115. * @param texture Texture to set.
  31116. */
  31117. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31118. /**
  31119. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31120. * @param channel Name of the sampler variable.
  31121. * @param texture Texture to set.
  31122. */
  31123. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31124. /**
  31125. * Sets an array of textures on the engine to be used in the shader.
  31126. * @param channel Name of the variable.
  31127. * @param textures Textures to set.
  31128. */
  31129. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31130. /**
  31131. * 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)
  31132. * @param channel Name of the sampler variable.
  31133. * @param postProcess Post process to get the input texture from.
  31134. */
  31135. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31136. /**
  31137. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31138. * 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)
  31139. * @param channel Name of the sampler variable.
  31140. * @param postProcess Post process to get the output texture from.
  31141. */
  31142. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31143. /** @hidden */
  31144. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31145. /** @hidden */
  31146. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31147. /** @hidden */
  31148. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31149. /** @hidden */
  31150. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31151. /**
  31152. * Binds a buffer to a uniform.
  31153. * @param buffer Buffer to bind.
  31154. * @param name Name of the uniform variable to bind to.
  31155. */
  31156. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31157. /**
  31158. * Binds block to a uniform.
  31159. * @param blockName Name of the block to bind.
  31160. * @param index Index to bind.
  31161. */
  31162. bindUniformBlock(blockName: string, index: number): void;
  31163. /**
  31164. * Sets an interger value on a uniform variable.
  31165. * @param uniformName Name of the variable.
  31166. * @param value Value to be set.
  31167. * @returns this effect.
  31168. */
  31169. setInt(uniformName: string, value: number): Effect;
  31170. /**
  31171. * Sets an int array on a uniform variable.
  31172. * @param uniformName Name of the variable.
  31173. * @param array array to be set.
  31174. * @returns this effect.
  31175. */
  31176. setIntArray(uniformName: string, array: Int32Array): Effect;
  31177. /**
  31178. * 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)
  31179. * @param uniformName Name of the variable.
  31180. * @param array array to be set.
  31181. * @returns this effect.
  31182. */
  31183. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31184. /**
  31185. * 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)
  31186. * @param uniformName Name of the variable.
  31187. * @param array array to be set.
  31188. * @returns this effect.
  31189. */
  31190. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31191. /**
  31192. * 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)
  31193. * @param uniformName Name of the variable.
  31194. * @param array array to be set.
  31195. * @returns this effect.
  31196. */
  31197. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31198. /**
  31199. * Sets an float array on a uniform variable.
  31200. * @param uniformName Name of the variable.
  31201. * @param array array to be set.
  31202. * @returns this effect.
  31203. */
  31204. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31205. /**
  31206. * 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)
  31207. * @param uniformName Name of the variable.
  31208. * @param array array to be set.
  31209. * @returns this effect.
  31210. */
  31211. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31212. /**
  31213. * 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)
  31214. * @param uniformName Name of the variable.
  31215. * @param array array to be set.
  31216. * @returns this effect.
  31217. */
  31218. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31219. /**
  31220. * 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)
  31221. * @param uniformName Name of the variable.
  31222. * @param array array to be set.
  31223. * @returns this effect.
  31224. */
  31225. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31226. /**
  31227. * Sets an array on a uniform variable.
  31228. * @param uniformName Name of the variable.
  31229. * @param array array to be set.
  31230. * @returns this effect.
  31231. */
  31232. setArray(uniformName: string, array: number[]): Effect;
  31233. /**
  31234. * 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)
  31235. * @param uniformName Name of the variable.
  31236. * @param array array to be set.
  31237. * @returns this effect.
  31238. */
  31239. setArray2(uniformName: string, array: number[]): Effect;
  31240. /**
  31241. * 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)
  31242. * @param uniformName Name of the variable.
  31243. * @param array array to be set.
  31244. * @returns this effect.
  31245. */
  31246. setArray3(uniformName: string, array: number[]): Effect;
  31247. /**
  31248. * 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)
  31249. * @param uniformName Name of the variable.
  31250. * @param array array to be set.
  31251. * @returns this effect.
  31252. */
  31253. setArray4(uniformName: string, array: number[]): Effect;
  31254. /**
  31255. * Sets matrices on a uniform variable.
  31256. * @param uniformName Name of the variable.
  31257. * @param matrices matrices to be set.
  31258. * @returns this effect.
  31259. */
  31260. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31261. /**
  31262. * Sets matrix on a uniform variable.
  31263. * @param uniformName Name of the variable.
  31264. * @param matrix matrix to be set.
  31265. * @returns this effect.
  31266. */
  31267. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31268. /**
  31269. * 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)
  31270. * @param uniformName Name of the variable.
  31271. * @param matrix matrix to be set.
  31272. * @returns this effect.
  31273. */
  31274. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31275. /**
  31276. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31277. * @param uniformName Name of the variable.
  31278. * @param matrix matrix to be set.
  31279. * @returns this effect.
  31280. */
  31281. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31282. /**
  31283. * Sets a float on a uniform variable.
  31284. * @param uniformName Name of the variable.
  31285. * @param value value to be set.
  31286. * @returns this effect.
  31287. */
  31288. setFloat(uniformName: string, value: number): Effect;
  31289. /**
  31290. * Sets a boolean on a uniform variable.
  31291. * @param uniformName Name of the variable.
  31292. * @param bool value to be set.
  31293. * @returns this effect.
  31294. */
  31295. setBool(uniformName: string, bool: boolean): Effect;
  31296. /**
  31297. * Sets a Vector2 on a uniform variable.
  31298. * @param uniformName Name of the variable.
  31299. * @param vector2 vector2 to be set.
  31300. * @returns this effect.
  31301. */
  31302. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31303. /**
  31304. * Sets a float2 on a uniform variable.
  31305. * @param uniformName Name of the variable.
  31306. * @param x First float in float2.
  31307. * @param y Second float in float2.
  31308. * @returns this effect.
  31309. */
  31310. setFloat2(uniformName: string, x: number, y: number): Effect;
  31311. /**
  31312. * Sets a Vector3 on a uniform variable.
  31313. * @param uniformName Name of the variable.
  31314. * @param vector3 Value to be set.
  31315. * @returns this effect.
  31316. */
  31317. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31318. /**
  31319. * Sets a float3 on a uniform variable.
  31320. * @param uniformName Name of the variable.
  31321. * @param x First float in float3.
  31322. * @param y Second float in float3.
  31323. * @param z Third float in float3.
  31324. * @returns this effect.
  31325. */
  31326. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31327. /**
  31328. * Sets a Vector4 on a uniform variable.
  31329. * @param uniformName Name of the variable.
  31330. * @param vector4 Value to be set.
  31331. * @returns this effect.
  31332. */
  31333. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31334. /**
  31335. * Sets a float4 on a uniform variable.
  31336. * @param uniformName Name of the variable.
  31337. * @param x First float in float4.
  31338. * @param y Second float in float4.
  31339. * @param z Third float in float4.
  31340. * @param w Fourth float in float4.
  31341. * @returns this effect.
  31342. */
  31343. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31344. /**
  31345. * Sets a Color3 on a uniform variable.
  31346. * @param uniformName Name of the variable.
  31347. * @param color3 Value to be set.
  31348. * @returns this effect.
  31349. */
  31350. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31351. /**
  31352. * Sets a Color4 on a uniform variable.
  31353. * @param uniformName Name of the variable.
  31354. * @param color3 Value to be set.
  31355. * @param alpha Alpha value to be set.
  31356. * @returns this effect.
  31357. */
  31358. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31359. /**
  31360. * Sets a Color4 on a uniform variable
  31361. * @param uniformName defines the name of the variable
  31362. * @param color4 defines the value to be set
  31363. * @returns this effect.
  31364. */
  31365. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31366. /** Release all associated resources */
  31367. dispose(): void;
  31368. /**
  31369. * This function will add a new shader to the shader store
  31370. * @param name the name of the shader
  31371. * @param pixelShader optional pixel shader content
  31372. * @param vertexShader optional vertex shader content
  31373. */
  31374. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31375. /**
  31376. * Store of each shader (The can be looked up using effect.key)
  31377. */
  31378. static ShadersStore: {
  31379. [key: string]: string;
  31380. };
  31381. /**
  31382. * Store of each included file for a shader (The can be looked up using effect.key)
  31383. */
  31384. static IncludesShadersStore: {
  31385. [key: string]: string;
  31386. };
  31387. /**
  31388. * Resets the cache of effects.
  31389. */
  31390. static ResetCache(): void;
  31391. }
  31392. }
  31393. declare module "babylonjs/Engines/engineCapabilities" {
  31394. /**
  31395. * Interface used to describe the capabilities of the engine relatively to the current browser
  31396. */
  31397. export interface EngineCapabilities {
  31398. /** Maximum textures units per fragment shader */
  31399. maxTexturesImageUnits: number;
  31400. /** Maximum texture units per vertex shader */
  31401. maxVertexTextureImageUnits: number;
  31402. /** Maximum textures units in the entire pipeline */
  31403. maxCombinedTexturesImageUnits: number;
  31404. /** Maximum texture size */
  31405. maxTextureSize: number;
  31406. /** Maximum texture samples */
  31407. maxSamples?: number;
  31408. /** Maximum cube texture size */
  31409. maxCubemapTextureSize: number;
  31410. /** Maximum render texture size */
  31411. maxRenderTextureSize: number;
  31412. /** Maximum number of vertex attributes */
  31413. maxVertexAttribs: number;
  31414. /** Maximum number of varyings */
  31415. maxVaryingVectors: number;
  31416. /** Maximum number of uniforms per vertex shader */
  31417. maxVertexUniformVectors: number;
  31418. /** Maximum number of uniforms per fragment shader */
  31419. maxFragmentUniformVectors: number;
  31420. /** Defines if standard derivates (dx/dy) are supported */
  31421. standardDerivatives: boolean;
  31422. /** Defines if s3tc texture compression is supported */
  31423. s3tc?: WEBGL_compressed_texture_s3tc;
  31424. /** Defines if pvrtc texture compression is supported */
  31425. pvrtc: any;
  31426. /** Defines if etc1 texture compression is supported */
  31427. etc1: any;
  31428. /** Defines if etc2 texture compression is supported */
  31429. etc2: any;
  31430. /** Defines if astc texture compression is supported */
  31431. astc: any;
  31432. /** Defines if float textures are supported */
  31433. textureFloat: boolean;
  31434. /** Defines if vertex array objects are supported */
  31435. vertexArrayObject: boolean;
  31436. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31437. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31438. /** Gets the maximum level of anisotropy supported */
  31439. maxAnisotropy: number;
  31440. /** Defines if instancing is supported */
  31441. instancedArrays: boolean;
  31442. /** Defines if 32 bits indices are supported */
  31443. uintIndices: boolean;
  31444. /** Defines if high precision shaders are supported */
  31445. highPrecisionShaderSupported: boolean;
  31446. /** Defines if depth reading in the fragment shader is supported */
  31447. fragmentDepthSupported: boolean;
  31448. /** Defines if float texture linear filtering is supported*/
  31449. textureFloatLinearFiltering: boolean;
  31450. /** Defines if rendering to float textures is supported */
  31451. textureFloatRender: boolean;
  31452. /** Defines if half float textures are supported*/
  31453. textureHalfFloat: boolean;
  31454. /** Defines if half float texture linear filtering is supported*/
  31455. textureHalfFloatLinearFiltering: boolean;
  31456. /** Defines if rendering to half float textures is supported */
  31457. textureHalfFloatRender: boolean;
  31458. /** Defines if textureLOD shader command is supported */
  31459. textureLOD: boolean;
  31460. /** Defines if draw buffers extension is supported */
  31461. drawBuffersExtension: boolean;
  31462. /** Defines if depth textures are supported */
  31463. depthTextureExtension: boolean;
  31464. /** Defines if float color buffer are supported */
  31465. colorBufferFloat: boolean;
  31466. /** Gets disjoint timer query extension (null if not supported) */
  31467. timerQuery?: EXT_disjoint_timer_query;
  31468. /** Defines if timestamp can be used with timer query */
  31469. canUseTimestampForTimerQuery: boolean;
  31470. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31471. multiview?: any;
  31472. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31473. oculusMultiview?: any;
  31474. /** Function used to let the system compiles shaders in background */
  31475. parallelShaderCompile?: {
  31476. COMPLETION_STATUS_KHR: number;
  31477. };
  31478. /** Max number of texture samples for MSAA */
  31479. maxMSAASamples: number;
  31480. /** Defines if the blend min max extension is supported */
  31481. blendMinMax: boolean;
  31482. }
  31483. }
  31484. declare module "babylonjs/States/depthCullingState" {
  31485. import { Nullable } from "babylonjs/types";
  31486. /**
  31487. * @hidden
  31488. **/
  31489. export class DepthCullingState {
  31490. private _isDepthTestDirty;
  31491. private _isDepthMaskDirty;
  31492. private _isDepthFuncDirty;
  31493. private _isCullFaceDirty;
  31494. private _isCullDirty;
  31495. private _isZOffsetDirty;
  31496. private _isFrontFaceDirty;
  31497. private _depthTest;
  31498. private _depthMask;
  31499. private _depthFunc;
  31500. private _cull;
  31501. private _cullFace;
  31502. private _zOffset;
  31503. private _frontFace;
  31504. /**
  31505. * Initializes the state.
  31506. */
  31507. constructor();
  31508. get isDirty(): boolean;
  31509. get zOffset(): number;
  31510. set zOffset(value: number);
  31511. get cullFace(): Nullable<number>;
  31512. set cullFace(value: Nullable<number>);
  31513. get cull(): Nullable<boolean>;
  31514. set cull(value: Nullable<boolean>);
  31515. get depthFunc(): Nullable<number>;
  31516. set depthFunc(value: Nullable<number>);
  31517. get depthMask(): boolean;
  31518. set depthMask(value: boolean);
  31519. get depthTest(): boolean;
  31520. set depthTest(value: boolean);
  31521. get frontFace(): Nullable<number>;
  31522. set frontFace(value: Nullable<number>);
  31523. reset(): void;
  31524. apply(gl: WebGLRenderingContext): void;
  31525. }
  31526. }
  31527. declare module "babylonjs/States/stencilState" {
  31528. /**
  31529. * @hidden
  31530. **/
  31531. export class StencilState {
  31532. /** 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 */
  31533. static readonly ALWAYS: number;
  31534. /** Passed to stencilOperation to specify that stencil value must be kept */
  31535. static readonly KEEP: number;
  31536. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31537. static readonly REPLACE: number;
  31538. private _isStencilTestDirty;
  31539. private _isStencilMaskDirty;
  31540. private _isStencilFuncDirty;
  31541. private _isStencilOpDirty;
  31542. private _stencilTest;
  31543. private _stencilMask;
  31544. private _stencilFunc;
  31545. private _stencilFuncRef;
  31546. private _stencilFuncMask;
  31547. private _stencilOpStencilFail;
  31548. private _stencilOpDepthFail;
  31549. private _stencilOpStencilDepthPass;
  31550. get isDirty(): boolean;
  31551. get stencilFunc(): number;
  31552. set stencilFunc(value: number);
  31553. get stencilFuncRef(): number;
  31554. set stencilFuncRef(value: number);
  31555. get stencilFuncMask(): number;
  31556. set stencilFuncMask(value: number);
  31557. get stencilOpStencilFail(): number;
  31558. set stencilOpStencilFail(value: number);
  31559. get stencilOpDepthFail(): number;
  31560. set stencilOpDepthFail(value: number);
  31561. get stencilOpStencilDepthPass(): number;
  31562. set stencilOpStencilDepthPass(value: number);
  31563. get stencilMask(): number;
  31564. set stencilMask(value: number);
  31565. get stencilTest(): boolean;
  31566. set stencilTest(value: boolean);
  31567. constructor();
  31568. reset(): void;
  31569. apply(gl: WebGLRenderingContext): void;
  31570. }
  31571. }
  31572. declare module "babylonjs/States/alphaCullingState" {
  31573. /**
  31574. * @hidden
  31575. **/
  31576. export class AlphaState {
  31577. private _isAlphaBlendDirty;
  31578. private _isBlendFunctionParametersDirty;
  31579. private _isBlendEquationParametersDirty;
  31580. private _isBlendConstantsDirty;
  31581. private _alphaBlend;
  31582. private _blendFunctionParameters;
  31583. private _blendEquationParameters;
  31584. private _blendConstants;
  31585. /**
  31586. * Initializes the state.
  31587. */
  31588. constructor();
  31589. get isDirty(): boolean;
  31590. get alphaBlend(): boolean;
  31591. set alphaBlend(value: boolean);
  31592. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31593. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31594. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31595. reset(): void;
  31596. apply(gl: WebGLRenderingContext): void;
  31597. }
  31598. }
  31599. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31600. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31601. /** @hidden */
  31602. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31603. attributeProcessor(attribute: string): string;
  31604. varyingProcessor(varying: string, isFragment: boolean): string;
  31605. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31606. }
  31607. }
  31608. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31609. /**
  31610. * Interface for attribute information associated with buffer instanciation
  31611. */
  31612. export interface InstancingAttributeInfo {
  31613. /**
  31614. * Name of the GLSL attribute
  31615. * if attribute index is not specified, this is used to retrieve the index from the effect
  31616. */
  31617. attributeName: string;
  31618. /**
  31619. * Index/offset of the attribute in the vertex shader
  31620. * if not specified, this will be computes from the name.
  31621. */
  31622. index?: number;
  31623. /**
  31624. * size of the attribute, 1, 2, 3 or 4
  31625. */
  31626. attributeSize: number;
  31627. /**
  31628. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31629. */
  31630. offset: number;
  31631. /**
  31632. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31633. * default to 1
  31634. */
  31635. divisor?: number;
  31636. /**
  31637. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31638. * default is FLOAT
  31639. */
  31640. attributeType?: number;
  31641. /**
  31642. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31643. */
  31644. normalized?: boolean;
  31645. }
  31646. }
  31647. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31648. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31649. import { Nullable } from "babylonjs/types";
  31650. module "babylonjs/Engines/thinEngine" {
  31651. interface ThinEngine {
  31652. /**
  31653. * Update a video texture
  31654. * @param texture defines the texture to update
  31655. * @param video defines the video element to use
  31656. * @param invertY defines if data must be stored with Y axis inverted
  31657. */
  31658. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31659. }
  31660. }
  31661. }
  31662. declare module "babylonjs/Materials/Textures/videoTexture" {
  31663. import { Observable } from "babylonjs/Misc/observable";
  31664. import { Nullable } from "babylonjs/types";
  31665. import { Scene } from "babylonjs/scene";
  31666. import { Texture } from "babylonjs/Materials/Textures/texture";
  31667. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31668. /**
  31669. * Settings for finer control over video usage
  31670. */
  31671. export interface VideoTextureSettings {
  31672. /**
  31673. * Applies `autoplay` to video, if specified
  31674. */
  31675. autoPlay?: boolean;
  31676. /**
  31677. * Applies `loop` to video, if specified
  31678. */
  31679. loop?: boolean;
  31680. /**
  31681. * Automatically updates internal texture from video at every frame in the render loop
  31682. */
  31683. autoUpdateTexture: boolean;
  31684. /**
  31685. * Image src displayed during the video loading or until the user interacts with the video.
  31686. */
  31687. poster?: string;
  31688. }
  31689. /**
  31690. * If you want to display a video in your scene, this is the special texture for that.
  31691. * This special texture works similar to other textures, with the exception of a few parameters.
  31692. * @see https://doc.babylonjs.com/how_to/video_texture
  31693. */
  31694. export class VideoTexture extends Texture {
  31695. /**
  31696. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31697. */
  31698. readonly autoUpdateTexture: boolean;
  31699. /**
  31700. * The video instance used by the texture internally
  31701. */
  31702. readonly video: HTMLVideoElement;
  31703. private _onUserActionRequestedObservable;
  31704. /**
  31705. * Event triggerd when a dom action is required by the user to play the video.
  31706. * This happens due to recent changes in browser policies preventing video to auto start.
  31707. */
  31708. get onUserActionRequestedObservable(): Observable<Texture>;
  31709. private _generateMipMaps;
  31710. private _engine;
  31711. private _stillImageCaptured;
  31712. private _displayingPosterTexture;
  31713. private _settings;
  31714. private _createInternalTextureOnEvent;
  31715. private _frameId;
  31716. private _currentSrc;
  31717. /**
  31718. * Creates a video texture.
  31719. * If you want to display a video in your scene, this is the special texture for that.
  31720. * This special texture works similar to other textures, with the exception of a few parameters.
  31721. * @see https://doc.babylonjs.com/how_to/video_texture
  31722. * @param name optional name, will detect from video source, if not defined
  31723. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31724. * @param scene is obviously the current scene.
  31725. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31726. * @param invertY is false by default but can be used to invert video on Y axis
  31727. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31728. * @param settings allows finer control over video usage
  31729. */
  31730. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31731. private _getName;
  31732. private _getVideo;
  31733. private _createInternalTexture;
  31734. private reset;
  31735. /**
  31736. * @hidden Internal method to initiate `update`.
  31737. */
  31738. _rebuild(): void;
  31739. /**
  31740. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31741. */
  31742. update(): void;
  31743. /**
  31744. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31745. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31746. */
  31747. updateTexture(isVisible: boolean): void;
  31748. protected _updateInternalTexture: () => void;
  31749. /**
  31750. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31751. * @param url New url.
  31752. */
  31753. updateURL(url: string): void;
  31754. /**
  31755. * Clones the texture.
  31756. * @returns the cloned texture
  31757. */
  31758. clone(): VideoTexture;
  31759. /**
  31760. * Dispose the texture and release its associated resources.
  31761. */
  31762. dispose(): void;
  31763. /**
  31764. * Creates a video texture straight from a stream.
  31765. * @param scene Define the scene the texture should be created in
  31766. * @param stream Define the stream the texture should be created from
  31767. * @returns The created video texture as a promise
  31768. */
  31769. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31770. /**
  31771. * Creates a video texture straight from your WebCam video feed.
  31772. * @param scene Define the scene the texture should be created in
  31773. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31774. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31775. * @returns The created video texture as a promise
  31776. */
  31777. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31778. minWidth: number;
  31779. maxWidth: number;
  31780. minHeight: number;
  31781. maxHeight: number;
  31782. deviceId: string;
  31783. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31784. /**
  31785. * Creates a video texture straight from your WebCam video feed.
  31786. * @param scene Define the scene the texture should be created in
  31787. * @param onReady Define a callback to triggered once the texture will be ready
  31788. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31789. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31790. */
  31791. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31792. minWidth: number;
  31793. maxWidth: number;
  31794. minHeight: number;
  31795. maxHeight: number;
  31796. deviceId: string;
  31797. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31798. }
  31799. }
  31800. declare module "babylonjs/Engines/thinEngine" {
  31801. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31802. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31803. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31804. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31805. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31806. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31807. import { Observable } from "babylonjs/Misc/observable";
  31808. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31809. import { StencilState } from "babylonjs/States/stencilState";
  31810. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31812. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31813. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31814. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31815. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31816. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31817. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31818. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31820. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31821. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31822. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31823. import { WebRequest } from "babylonjs/Misc/webRequest";
  31824. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31825. /**
  31826. * Defines the interface used by objects working like Scene
  31827. * @hidden
  31828. */
  31829. export interface ISceneLike {
  31830. _addPendingData(data: any): void;
  31831. _removePendingData(data: any): void;
  31832. offlineProvider: IOfflineProvider;
  31833. }
  31834. /** Interface defining initialization parameters for Engine class */
  31835. export interface EngineOptions extends WebGLContextAttributes {
  31836. /**
  31837. * Defines if the engine should no exceed a specified device ratio
  31838. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31839. */
  31840. limitDeviceRatio?: number;
  31841. /**
  31842. * Defines if webvr should be enabled automatically
  31843. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31844. */
  31845. autoEnableWebVR?: boolean;
  31846. /**
  31847. * Defines if webgl2 should be turned off even if supported
  31848. * @see http://doc.babylonjs.com/features/webgl2
  31849. */
  31850. disableWebGL2Support?: boolean;
  31851. /**
  31852. * Defines if webaudio should be initialized as well
  31853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31854. */
  31855. audioEngine?: boolean;
  31856. /**
  31857. * Defines if animations should run using a deterministic lock step
  31858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31859. */
  31860. deterministicLockstep?: boolean;
  31861. /** Defines the maximum steps to use with deterministic lock step mode */
  31862. lockstepMaxSteps?: number;
  31863. /** Defines the seconds between each deterministic lock step */
  31864. timeStep?: number;
  31865. /**
  31866. * Defines that engine should ignore context lost events
  31867. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31868. */
  31869. doNotHandleContextLost?: boolean;
  31870. /**
  31871. * Defines that engine should ignore modifying touch action attribute and style
  31872. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31873. */
  31874. doNotHandleTouchAction?: boolean;
  31875. /**
  31876. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31877. */
  31878. useHighPrecisionFloats?: boolean;
  31879. }
  31880. /**
  31881. * The base engine class (root of all engines)
  31882. */
  31883. export class ThinEngine {
  31884. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31885. static ExceptionList: ({
  31886. key: string;
  31887. capture: string;
  31888. captureConstraint: number;
  31889. targets: string[];
  31890. } | {
  31891. key: string;
  31892. capture: null;
  31893. captureConstraint: null;
  31894. targets: string[];
  31895. })[];
  31896. /** @hidden */
  31897. static _TextureLoaders: IInternalTextureLoader[];
  31898. /**
  31899. * Returns the current npm package of the sdk
  31900. */
  31901. static get NpmPackage(): string;
  31902. /**
  31903. * Returns the current version of the framework
  31904. */
  31905. static get Version(): string;
  31906. /**
  31907. * Returns a string describing the current engine
  31908. */
  31909. get description(): string;
  31910. /**
  31911. * Gets or sets the epsilon value used by collision engine
  31912. */
  31913. static CollisionsEpsilon: number;
  31914. /**
  31915. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31916. */
  31917. static get ShadersRepository(): string;
  31918. static set ShadersRepository(value: string);
  31919. /** @hidden */
  31920. _shaderProcessor: IShaderProcessor;
  31921. /**
  31922. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31923. */
  31924. forcePOTTextures: boolean;
  31925. /**
  31926. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31927. */
  31928. isFullscreen: boolean;
  31929. /**
  31930. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31931. */
  31932. cullBackFaces: boolean;
  31933. /**
  31934. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31935. */
  31936. renderEvenInBackground: boolean;
  31937. /**
  31938. * Gets or sets a boolean indicating that cache can be kept between frames
  31939. */
  31940. preventCacheWipeBetweenFrames: boolean;
  31941. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31942. validateShaderPrograms: boolean;
  31943. /**
  31944. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31945. * This can provide greater z depth for distant objects.
  31946. */
  31947. useReverseDepthBuffer: boolean;
  31948. /**
  31949. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31950. */
  31951. disableUniformBuffers: boolean;
  31952. /** @hidden */
  31953. _uniformBuffers: UniformBuffer[];
  31954. /**
  31955. * Gets a boolean indicating that the engine supports uniform buffers
  31956. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31957. */
  31958. get supportsUniformBuffers(): boolean;
  31959. /** @hidden */
  31960. _gl: WebGLRenderingContext;
  31961. /** @hidden */
  31962. _webGLVersion: number;
  31963. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31964. protected _windowIsBackground: boolean;
  31965. protected _creationOptions: EngineOptions;
  31966. protected _highPrecisionShadersAllowed: boolean;
  31967. /** @hidden */
  31968. get _shouldUseHighPrecisionShader(): boolean;
  31969. /**
  31970. * Gets a boolean indicating that only power of 2 textures are supported
  31971. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31972. */
  31973. get needPOTTextures(): boolean;
  31974. /** @hidden */
  31975. _badOS: boolean;
  31976. /** @hidden */
  31977. _badDesktopOS: boolean;
  31978. private _hardwareScalingLevel;
  31979. /** @hidden */
  31980. _caps: EngineCapabilities;
  31981. private _isStencilEnable;
  31982. private _glVersion;
  31983. private _glRenderer;
  31984. private _glVendor;
  31985. /** @hidden */
  31986. _videoTextureSupported: boolean;
  31987. protected _renderingQueueLaunched: boolean;
  31988. protected _activeRenderLoops: (() => void)[];
  31989. /**
  31990. * Observable signaled when a context lost event is raised
  31991. */
  31992. onContextLostObservable: Observable<ThinEngine>;
  31993. /**
  31994. * Observable signaled when a context restored event is raised
  31995. */
  31996. onContextRestoredObservable: Observable<ThinEngine>;
  31997. private _onContextLost;
  31998. private _onContextRestored;
  31999. protected _contextWasLost: boolean;
  32000. /** @hidden */
  32001. _doNotHandleContextLost: boolean;
  32002. /**
  32003. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32005. */
  32006. get doNotHandleContextLost(): boolean;
  32007. set doNotHandleContextLost(value: boolean);
  32008. /**
  32009. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32010. */
  32011. disableVertexArrayObjects: boolean;
  32012. /** @hidden */
  32013. protected _colorWrite: boolean;
  32014. /** @hidden */
  32015. protected _colorWriteChanged: boolean;
  32016. /** @hidden */
  32017. protected _depthCullingState: DepthCullingState;
  32018. /** @hidden */
  32019. protected _stencilState: StencilState;
  32020. /** @hidden */
  32021. _alphaState: AlphaState;
  32022. /** @hidden */
  32023. _alphaMode: number;
  32024. /** @hidden */
  32025. _alphaEquation: number;
  32026. /** @hidden */
  32027. _internalTexturesCache: InternalTexture[];
  32028. /** @hidden */
  32029. protected _activeChannel: number;
  32030. private _currentTextureChannel;
  32031. /** @hidden */
  32032. protected _boundTexturesCache: {
  32033. [key: string]: Nullable<InternalTexture>;
  32034. };
  32035. /** @hidden */
  32036. protected _currentEffect: Nullable<Effect>;
  32037. /** @hidden */
  32038. protected _currentProgram: Nullable<WebGLProgram>;
  32039. private _compiledEffects;
  32040. private _vertexAttribArraysEnabled;
  32041. /** @hidden */
  32042. protected _cachedViewport: Nullable<IViewportLike>;
  32043. private _cachedVertexArrayObject;
  32044. /** @hidden */
  32045. protected _cachedVertexBuffers: any;
  32046. /** @hidden */
  32047. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32048. /** @hidden */
  32049. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32050. /** @hidden */
  32051. _currentRenderTarget: Nullable<InternalTexture>;
  32052. private _uintIndicesCurrentlySet;
  32053. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32054. /** @hidden */
  32055. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32056. private _currentBufferPointers;
  32057. private _currentInstanceLocations;
  32058. private _currentInstanceBuffers;
  32059. private _textureUnits;
  32060. /** @hidden */
  32061. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32062. /** @hidden */
  32063. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32064. /** @hidden */
  32065. _boundRenderFunction: any;
  32066. private _vaoRecordInProgress;
  32067. private _mustWipeVertexAttributes;
  32068. private _emptyTexture;
  32069. private _emptyCubeTexture;
  32070. private _emptyTexture3D;
  32071. private _emptyTexture2DArray;
  32072. /** @hidden */
  32073. _frameHandler: number;
  32074. private _nextFreeTextureSlots;
  32075. private _maxSimultaneousTextures;
  32076. private _activeRequests;
  32077. protected _texturesSupported: string[];
  32078. /** @hidden */
  32079. _textureFormatInUse: Nullable<string>;
  32080. protected get _supportsHardwareTextureRescaling(): boolean;
  32081. /**
  32082. * Gets the list of texture formats supported
  32083. */
  32084. get texturesSupported(): Array<string>;
  32085. /**
  32086. * Gets the list of texture formats in use
  32087. */
  32088. get textureFormatInUse(): Nullable<string>;
  32089. /**
  32090. * Gets the current viewport
  32091. */
  32092. get currentViewport(): Nullable<IViewportLike>;
  32093. /**
  32094. * Gets the default empty texture
  32095. */
  32096. get emptyTexture(): InternalTexture;
  32097. /**
  32098. * Gets the default empty 3D texture
  32099. */
  32100. get emptyTexture3D(): InternalTexture;
  32101. /**
  32102. * Gets the default empty 2D array texture
  32103. */
  32104. get emptyTexture2DArray(): InternalTexture;
  32105. /**
  32106. * Gets the default empty cube texture
  32107. */
  32108. get emptyCubeTexture(): InternalTexture;
  32109. /**
  32110. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32111. */
  32112. readonly premultipliedAlpha: boolean;
  32113. /**
  32114. * Observable event triggered before each texture is initialized
  32115. */
  32116. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32117. /**
  32118. * Creates a new engine
  32119. * @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
  32120. * @param antialias defines enable antialiasing (default: false)
  32121. * @param options defines further options to be sent to the getContext() function
  32122. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32123. */
  32124. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32125. private _rebuildInternalTextures;
  32126. private _rebuildEffects;
  32127. /**
  32128. * Gets a boolean indicating if all created effects are ready
  32129. * @returns true if all effects are ready
  32130. */
  32131. areAllEffectsReady(): boolean;
  32132. protected _rebuildBuffers(): void;
  32133. private _initGLContext;
  32134. /**
  32135. * Gets version of the current webGL context
  32136. */
  32137. get webGLVersion(): number;
  32138. /**
  32139. * Gets a string idenfifying the name of the class
  32140. * @returns "Engine" string
  32141. */
  32142. getClassName(): string;
  32143. /**
  32144. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32145. */
  32146. get isStencilEnable(): boolean;
  32147. /** @hidden */
  32148. _prepareWorkingCanvas(): void;
  32149. /**
  32150. * Reset the texture cache to empty state
  32151. */
  32152. resetTextureCache(): void;
  32153. /**
  32154. * Gets an object containing information about the current webGL context
  32155. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32156. */
  32157. getGlInfo(): {
  32158. vendor: string;
  32159. renderer: string;
  32160. version: string;
  32161. };
  32162. /**
  32163. * Defines the hardware scaling level.
  32164. * By default the hardware scaling level is computed from the window device ratio.
  32165. * 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.
  32166. * @param level defines the level to use
  32167. */
  32168. setHardwareScalingLevel(level: number): void;
  32169. /**
  32170. * Gets the current hardware scaling level.
  32171. * By default the hardware scaling level is computed from the window device ratio.
  32172. * 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.
  32173. * @returns a number indicating the current hardware scaling level
  32174. */
  32175. getHardwareScalingLevel(): number;
  32176. /**
  32177. * Gets the list of loaded textures
  32178. * @returns an array containing all loaded textures
  32179. */
  32180. getLoadedTexturesCache(): InternalTexture[];
  32181. /**
  32182. * Gets the object containing all engine capabilities
  32183. * @returns the EngineCapabilities object
  32184. */
  32185. getCaps(): EngineCapabilities;
  32186. /**
  32187. * stop executing a render loop function and remove it from the execution array
  32188. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32189. */
  32190. stopRenderLoop(renderFunction?: () => void): void;
  32191. /** @hidden */
  32192. _renderLoop(): void;
  32193. /**
  32194. * Gets the HTML canvas attached with the current webGL context
  32195. * @returns a HTML canvas
  32196. */
  32197. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32198. /**
  32199. * Gets host window
  32200. * @returns the host window object
  32201. */
  32202. getHostWindow(): Nullable<Window>;
  32203. /**
  32204. * Gets the current render width
  32205. * @param useScreen defines if screen size must be used (or the current render target if any)
  32206. * @returns a number defining the current render width
  32207. */
  32208. getRenderWidth(useScreen?: boolean): number;
  32209. /**
  32210. * Gets the current render height
  32211. * @param useScreen defines if screen size must be used (or the current render target if any)
  32212. * @returns a number defining the current render height
  32213. */
  32214. getRenderHeight(useScreen?: boolean): number;
  32215. /**
  32216. * Can be used to override the current requestAnimationFrame requester.
  32217. * @hidden
  32218. */
  32219. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32220. /**
  32221. * Register and execute a render loop. The engine can have more than one render function
  32222. * @param renderFunction defines the function to continuously execute
  32223. */
  32224. runRenderLoop(renderFunction: () => void): void;
  32225. /**
  32226. * Clear the current render buffer or the current render target (if any is set up)
  32227. * @param color defines the color to use
  32228. * @param backBuffer defines if the back buffer must be cleared
  32229. * @param depth defines if the depth buffer must be cleared
  32230. * @param stencil defines if the stencil buffer must be cleared
  32231. */
  32232. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32233. private _viewportCached;
  32234. /** @hidden */
  32235. _viewport(x: number, y: number, width: number, height: number): void;
  32236. /**
  32237. * Set the WebGL's viewport
  32238. * @param viewport defines the viewport element to be used
  32239. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32240. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32241. */
  32242. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32243. /**
  32244. * Begin a new frame
  32245. */
  32246. beginFrame(): void;
  32247. /**
  32248. * Enf the current frame
  32249. */
  32250. endFrame(): void;
  32251. /**
  32252. * Resize the view according to the canvas' size
  32253. */
  32254. resize(): void;
  32255. /**
  32256. * Force a specific size of the canvas
  32257. * @param width defines the new canvas' width
  32258. * @param height defines the new canvas' height
  32259. */
  32260. setSize(width: number, height: number): void;
  32261. /**
  32262. * Binds the frame buffer to the specified texture.
  32263. * @param texture The texture to render to or null for the default canvas
  32264. * @param faceIndex The face of the texture to render to in case of cube texture
  32265. * @param requiredWidth The width of the target to render to
  32266. * @param requiredHeight The height of the target to render to
  32267. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32268. * @param lodLevel defines the lod level to bind to the frame buffer
  32269. * @param layer defines the 2d array index to bind to frame buffer to
  32270. */
  32271. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32272. /** @hidden */
  32273. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32274. /**
  32275. * Unbind the current render target texture from the webGL context
  32276. * @param texture defines the render target texture to unbind
  32277. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32278. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32279. */
  32280. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32281. /**
  32282. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32283. */
  32284. flushFramebuffer(): void;
  32285. /**
  32286. * Unbind the current render target and bind the default framebuffer
  32287. */
  32288. restoreDefaultFramebuffer(): void;
  32289. /** @hidden */
  32290. protected _resetVertexBufferBinding(): void;
  32291. /**
  32292. * Creates a vertex buffer
  32293. * @param data the data for the vertex buffer
  32294. * @returns the new WebGL static buffer
  32295. */
  32296. createVertexBuffer(data: DataArray): DataBuffer;
  32297. private _createVertexBuffer;
  32298. /**
  32299. * Creates a dynamic vertex buffer
  32300. * @param data the data for the dynamic vertex buffer
  32301. * @returns the new WebGL dynamic buffer
  32302. */
  32303. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32304. protected _resetIndexBufferBinding(): void;
  32305. /**
  32306. * Creates a new index buffer
  32307. * @param indices defines the content of the index buffer
  32308. * @param updatable defines if the index buffer must be updatable
  32309. * @returns a new webGL buffer
  32310. */
  32311. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32312. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32313. /**
  32314. * Bind a webGL buffer to the webGL context
  32315. * @param buffer defines the buffer to bind
  32316. */
  32317. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32318. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32319. private bindBuffer;
  32320. /**
  32321. * update the bound buffer with the given data
  32322. * @param data defines the data to update
  32323. */
  32324. updateArrayBuffer(data: Float32Array): void;
  32325. private _vertexAttribPointer;
  32326. /** @hidden */
  32327. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32328. private _bindVertexBuffersAttributes;
  32329. /**
  32330. * Records a vertex array object
  32331. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32332. * @param vertexBuffers defines the list of vertex buffers to store
  32333. * @param indexBuffer defines the index buffer to store
  32334. * @param effect defines the effect to store
  32335. * @returns the new vertex array object
  32336. */
  32337. recordVertexArrayObject(vertexBuffers: {
  32338. [key: string]: VertexBuffer;
  32339. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32340. /**
  32341. * Bind a specific vertex array object
  32342. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32343. * @param vertexArrayObject defines the vertex array object to bind
  32344. * @param indexBuffer defines the index buffer to bind
  32345. */
  32346. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32347. /**
  32348. * Bind webGl buffers directly to the webGL context
  32349. * @param vertexBuffer defines the vertex buffer to bind
  32350. * @param indexBuffer defines the index buffer to bind
  32351. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32352. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32353. * @param effect defines the effect associated with the vertex buffer
  32354. */
  32355. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32356. private _unbindVertexArrayObject;
  32357. /**
  32358. * Bind a list of vertex buffers to the webGL context
  32359. * @param vertexBuffers defines the list of vertex buffers to bind
  32360. * @param indexBuffer defines the index buffer to bind
  32361. * @param effect defines the effect associated with the vertex buffers
  32362. */
  32363. bindBuffers(vertexBuffers: {
  32364. [key: string]: Nullable<VertexBuffer>;
  32365. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32366. /**
  32367. * Unbind all instance attributes
  32368. */
  32369. unbindInstanceAttributes(): void;
  32370. /**
  32371. * Release and free the memory of a vertex array object
  32372. * @param vao defines the vertex array object to delete
  32373. */
  32374. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32375. /** @hidden */
  32376. _releaseBuffer(buffer: DataBuffer): boolean;
  32377. protected _deleteBuffer(buffer: DataBuffer): void;
  32378. /**
  32379. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32380. * @param instancesBuffer defines the webGL buffer to update and bind
  32381. * @param data defines the data to store in the buffer
  32382. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32383. */
  32384. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32385. /**
  32386. * Bind the content of a webGL buffer used with instantiation
  32387. * @param instancesBuffer defines the webGL buffer to bind
  32388. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32389. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32390. */
  32391. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32392. /**
  32393. * Disable the instance attribute corresponding to the name in parameter
  32394. * @param name defines the name of the attribute to disable
  32395. */
  32396. disableInstanceAttributeByName(name: string): void;
  32397. /**
  32398. * Disable the instance attribute corresponding to the location in parameter
  32399. * @param attributeLocation defines the attribute location of the attribute to disable
  32400. */
  32401. disableInstanceAttribute(attributeLocation: number): void;
  32402. /**
  32403. * Disable the attribute corresponding to the location in parameter
  32404. * @param attributeLocation defines the attribute location of the attribute to disable
  32405. */
  32406. disableAttributeByIndex(attributeLocation: number): void;
  32407. /**
  32408. * Send a draw order
  32409. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32410. * @param indexStart defines the starting index
  32411. * @param indexCount defines the number of index to draw
  32412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32413. */
  32414. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32415. /**
  32416. * Draw a list of points
  32417. * @param verticesStart defines the index of first vertex to draw
  32418. * @param verticesCount defines the count of vertices to draw
  32419. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32420. */
  32421. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32422. /**
  32423. * Draw a list of unindexed primitives
  32424. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32425. * @param verticesStart defines the index of first vertex to draw
  32426. * @param verticesCount defines the count of vertices to draw
  32427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32428. */
  32429. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32430. /**
  32431. * Draw a list of indexed primitives
  32432. * @param fillMode defines the primitive to use
  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. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32438. /**
  32439. * Draw a list of unindexed primitives
  32440. * @param fillMode defines the primitive to use
  32441. * @param verticesStart defines the index of first vertex to draw
  32442. * @param verticesCount defines the count of vertices to draw
  32443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32444. */
  32445. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32446. private _drawMode;
  32447. /** @hidden */
  32448. protected _reportDrawCall(): void;
  32449. /** @hidden */
  32450. _releaseEffect(effect: Effect): void;
  32451. /** @hidden */
  32452. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32453. /**
  32454. * Create a new effect (used to store vertex/fragment shaders)
  32455. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32456. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32457. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32458. * @param samplers defines an array of string used to represent textures
  32459. * @param defines defines the string containing the defines to use to compile the shaders
  32460. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32461. * @param onCompiled defines a function to call when the effect creation is successful
  32462. * @param onError defines a function to call when the effect creation has failed
  32463. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32464. * @returns the new Effect
  32465. */
  32466. 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;
  32467. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32468. private _compileShader;
  32469. private _compileRawShader;
  32470. /**
  32471. * Directly creates a webGL program
  32472. * @param pipelineContext defines the pipeline context to attach to
  32473. * @param vertexCode defines the vertex shader code to use
  32474. * @param fragmentCode defines the fragment shader code to use
  32475. * @param context defines the webGL context to use (if not set, the current one will be used)
  32476. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32477. * @returns the new webGL program
  32478. */
  32479. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32480. /**
  32481. * Creates a webGL program
  32482. * @param pipelineContext defines the pipeline context to attach to
  32483. * @param vertexCode defines the vertex shader code to use
  32484. * @param fragmentCode defines the fragment shader code to use
  32485. * @param defines defines the string containing the defines to use to compile the shaders
  32486. * @param context defines the webGL context to use (if not set, the current one will be used)
  32487. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32488. * @returns the new webGL program
  32489. */
  32490. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32491. /**
  32492. * Creates a new pipeline context
  32493. * @returns the new pipeline
  32494. */
  32495. createPipelineContext(): IPipelineContext;
  32496. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32497. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32498. /** @hidden */
  32499. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32500. /** @hidden */
  32501. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32502. /** @hidden */
  32503. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32504. /**
  32505. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32506. * @param pipelineContext defines the pipeline context to use
  32507. * @param uniformsNames defines the list of uniform names
  32508. * @returns an array of webGL uniform locations
  32509. */
  32510. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32511. /**
  32512. * Gets the lsit of active attributes for a given webGL program
  32513. * @param pipelineContext defines the pipeline context to use
  32514. * @param attributesNames defines the list of attribute names to get
  32515. * @returns an array of indices indicating the offset of each attribute
  32516. */
  32517. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32518. /**
  32519. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32520. * @param effect defines the effect to activate
  32521. */
  32522. enableEffect(effect: Nullable<Effect>): void;
  32523. /**
  32524. * Set the value of an uniform to a number (int)
  32525. * @param uniform defines the webGL uniform location where to store the value
  32526. * @param value defines the int number to store
  32527. */
  32528. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32529. /**
  32530. * Set the value of an uniform to an array of int32
  32531. * @param uniform defines the webGL uniform location where to store the value
  32532. * @param array defines the array of int32 to store
  32533. */
  32534. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32535. /**
  32536. * Set the value of an uniform to an array of int32 (stored as vec2)
  32537. * @param uniform defines the webGL uniform location where to store the value
  32538. * @param array defines the array of int32 to store
  32539. */
  32540. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32541. /**
  32542. * Set the value of an uniform to an array of int32 (stored as vec3)
  32543. * @param uniform defines the webGL uniform location where to store the value
  32544. * @param array defines the array of int32 to store
  32545. */
  32546. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32547. /**
  32548. * Set the value of an uniform to an array of int32 (stored as vec4)
  32549. * @param uniform defines the webGL uniform location where to store the value
  32550. * @param array defines the array of int32 to store
  32551. */
  32552. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32553. /**
  32554. * Set the value of an uniform to an array of number
  32555. * @param uniform defines the webGL uniform location where to store the value
  32556. * @param array defines the array of number to store
  32557. */
  32558. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32559. /**
  32560. * Set the value of an uniform to an array of number (stored as vec2)
  32561. * @param uniform defines the webGL uniform location where to store the value
  32562. * @param array defines the array of number to store
  32563. */
  32564. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32565. /**
  32566. * Set the value of an uniform to an array of number (stored as vec3)
  32567. * @param uniform defines the webGL uniform location where to store the value
  32568. * @param array defines the array of number to store
  32569. */
  32570. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32571. /**
  32572. * Set the value of an uniform to an array of number (stored as vec4)
  32573. * @param uniform defines the webGL uniform location where to store the value
  32574. * @param array defines the array of number to store
  32575. */
  32576. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32577. /**
  32578. * Set the value of an uniform to an array of float32 (stored as matrices)
  32579. * @param uniform defines the webGL uniform location where to store the value
  32580. * @param matrices defines the array of float32 to store
  32581. */
  32582. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32583. /**
  32584. * Set the value of an uniform to a matrix (3x3)
  32585. * @param uniform defines the webGL uniform location where to store the value
  32586. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32587. */
  32588. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32589. /**
  32590. * Set the value of an uniform to a matrix (2x2)
  32591. * @param uniform defines the webGL uniform location where to store the value
  32592. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32593. */
  32594. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32595. /**
  32596. * Set the value of an uniform to a number (float)
  32597. * @param uniform defines the webGL uniform location where to store the value
  32598. * @param value defines the float number to store
  32599. */
  32600. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32601. /**
  32602. * Set the value of an uniform to a vec2
  32603. * @param uniform defines the webGL uniform location where to store the value
  32604. * @param x defines the 1st component of the value
  32605. * @param y defines the 2nd component of the value
  32606. */
  32607. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32608. /**
  32609. * Set the value of an uniform to a vec3
  32610. * @param uniform defines the webGL uniform location where to store the value
  32611. * @param x defines the 1st component of the value
  32612. * @param y defines the 2nd component of the value
  32613. * @param z defines the 3rd component of the value
  32614. */
  32615. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32616. /**
  32617. * Set the value of an uniform to a vec4
  32618. * @param uniform defines the webGL uniform location where to store the value
  32619. * @param x defines the 1st component of the value
  32620. * @param y defines the 2nd component of the value
  32621. * @param z defines the 3rd component of the value
  32622. * @param w defines the 4th component of the value
  32623. */
  32624. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32625. /**
  32626. * Apply all cached states (depth, culling, stencil and alpha)
  32627. */
  32628. applyStates(): void;
  32629. /**
  32630. * Enable or disable color writing
  32631. * @param enable defines the state to set
  32632. */
  32633. setColorWrite(enable: boolean): void;
  32634. /**
  32635. * Gets a boolean indicating if color writing is enabled
  32636. * @returns the current color writing state
  32637. */
  32638. getColorWrite(): boolean;
  32639. /**
  32640. * Gets the depth culling state manager
  32641. */
  32642. get depthCullingState(): DepthCullingState;
  32643. /**
  32644. * Gets the alpha state manager
  32645. */
  32646. get alphaState(): AlphaState;
  32647. /**
  32648. * Gets the stencil state manager
  32649. */
  32650. get stencilState(): StencilState;
  32651. /**
  32652. * Clears the list of texture accessible through engine.
  32653. * This can help preventing texture load conflict due to name collision.
  32654. */
  32655. clearInternalTexturesCache(): void;
  32656. /**
  32657. * Force the entire cache to be cleared
  32658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32660. */
  32661. wipeCaches(bruteForce?: boolean): void;
  32662. /** @hidden */
  32663. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32664. min: number;
  32665. mag: number;
  32666. };
  32667. /** @hidden */
  32668. _createTexture(): WebGLTexture;
  32669. /**
  32670. * Usually called from Texture.ts.
  32671. * Passed information to create a WebGLTexture
  32672. * @param urlArg defines a value which contains one of the following:
  32673. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32674. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32675. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32677. * @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)
  32678. * @param scene needed for loading to the correct scene
  32679. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32680. * @param onLoad optional callback to be called upon successful completion
  32681. * @param onError optional callback to be called upon failure
  32682. * @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
  32683. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32684. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32685. * @param forcedExtension defines the extension to use to pick the right loader
  32686. * @param mimeType defines an optional mime type
  32687. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32688. */
  32689. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32690. /**
  32691. * Loads an image as an HTMLImageElement.
  32692. * @param input url string, ArrayBuffer, or Blob to load
  32693. * @param onLoad callback called when the image successfully loads
  32694. * @param onError callback called when the image fails to load
  32695. * @param offlineProvider offline provider for caching
  32696. * @param mimeType optional mime type
  32697. * @returns the HTMLImageElement of the loaded image
  32698. * @hidden
  32699. */
  32700. 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>;
  32701. /**
  32702. * @hidden
  32703. */
  32704. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32705. /**
  32706. * Creates a raw texture
  32707. * @param data defines the data to store in the texture
  32708. * @param width defines the width of the texture
  32709. * @param height defines the height of the texture
  32710. * @param format defines the format of the data
  32711. * @param generateMipMaps defines if the engine should generate the mip levels
  32712. * @param invertY defines if data must be stored with Y axis inverted
  32713. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32714. * @param compression defines the compression used (null by default)
  32715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32716. * @returns the raw texture inside an InternalTexture
  32717. */
  32718. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32719. /**
  32720. * Creates a new raw cube texture
  32721. * @param data defines the array of data to use to create each face
  32722. * @param size defines the size of the textures
  32723. * @param format defines the format of the data
  32724. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32725. * @param generateMipMaps defines if the engine should generate the mip levels
  32726. * @param invertY defines if data must be stored with Y axis inverted
  32727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32728. * @param compression defines the compression used (null by default)
  32729. * @returns the cube texture as an InternalTexture
  32730. */
  32731. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32732. /**
  32733. * Creates a new raw 3D texture
  32734. * @param data defines the data used to create the texture
  32735. * @param width defines the width of the texture
  32736. * @param height defines the height of the texture
  32737. * @param depth defines the depth of the texture
  32738. * @param format defines the format of the texture
  32739. * @param generateMipMaps defines if the engine must generate mip levels
  32740. * @param invertY defines if data must be stored with Y axis inverted
  32741. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32742. * @param compression defines the compressed used (can be null)
  32743. * @param textureType defines the compressed used (can be null)
  32744. * @returns a new raw 3D texture (stored in an InternalTexture)
  32745. */
  32746. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32747. /**
  32748. * Creates a new raw 2D array texture
  32749. * @param data defines the data used to create the texture
  32750. * @param width defines the width of the texture
  32751. * @param height defines the height of the texture
  32752. * @param depth defines the number of layers of the texture
  32753. * @param format defines the format of the texture
  32754. * @param generateMipMaps defines if the engine must generate mip levels
  32755. * @param invertY defines if data must be stored with Y axis inverted
  32756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32757. * @param compression defines the compressed used (can be null)
  32758. * @param textureType defines the compressed used (can be null)
  32759. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32760. */
  32761. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32762. private _unpackFlipYCached;
  32763. /**
  32764. * In case you are sharing the context with other applications, it might
  32765. * be interested to not cache the unpack flip y state to ensure a consistent
  32766. * value would be set.
  32767. */
  32768. enableUnpackFlipYCached: boolean;
  32769. /** @hidden */
  32770. _unpackFlipY(value: boolean): void;
  32771. /** @hidden */
  32772. _getUnpackAlignement(): number;
  32773. private _getTextureTarget;
  32774. /**
  32775. * Update the sampling mode of a given texture
  32776. * @param samplingMode defines the required sampling mode
  32777. * @param texture defines the texture to update
  32778. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32779. */
  32780. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32781. /**
  32782. * Update the sampling mode of a given texture
  32783. * @param texture defines the texture to update
  32784. * @param wrapU defines the texture wrap mode of the u coordinates
  32785. * @param wrapV defines the texture wrap mode of the v coordinates
  32786. * @param wrapR defines the texture wrap mode of the r coordinates
  32787. */
  32788. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32789. /** @hidden */
  32790. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32791. width: number;
  32792. height: number;
  32793. layers?: number;
  32794. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32795. /** @hidden */
  32796. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32797. /** @hidden */
  32798. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32799. /**
  32800. * Update a portion of an internal texture
  32801. * @param texture defines the texture to update
  32802. * @param imageData defines the data to store into the texture
  32803. * @param xOffset defines the x coordinates of the update rectangle
  32804. * @param yOffset defines the y coordinates of the update rectangle
  32805. * @param width defines the width of the update rectangle
  32806. * @param height defines the height of the update rectangle
  32807. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32808. * @param lod defines the lod level to update (0 by default)
  32809. */
  32810. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32811. /** @hidden */
  32812. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32813. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32814. private _prepareWebGLTexture;
  32815. /** @hidden */
  32816. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32817. private _getDepthStencilBuffer;
  32818. /** @hidden */
  32819. _releaseFramebufferObjects(texture: InternalTexture): void;
  32820. /** @hidden */
  32821. _releaseTexture(texture: InternalTexture): void;
  32822. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32823. protected _setProgram(program: WebGLProgram): void;
  32824. protected _boundUniforms: {
  32825. [key: number]: WebGLUniformLocation;
  32826. };
  32827. /**
  32828. * Binds an effect to the webGL context
  32829. * @param effect defines the effect to bind
  32830. */
  32831. bindSamplers(effect: Effect): void;
  32832. private _activateCurrentTexture;
  32833. /** @hidden */
  32834. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32835. /** @hidden */
  32836. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32837. /**
  32838. * Unbind all textures from the webGL context
  32839. */
  32840. unbindAllTextures(): void;
  32841. /**
  32842. * Sets a texture to the according uniform.
  32843. * @param channel The texture channel
  32844. * @param uniform The uniform to set
  32845. * @param texture The texture to apply
  32846. */
  32847. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32848. private _bindSamplerUniformToChannel;
  32849. private _getTextureWrapMode;
  32850. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32851. /**
  32852. * Sets an array of texture to the webGL context
  32853. * @param channel defines the channel where the texture array must be set
  32854. * @param uniform defines the associated uniform location
  32855. * @param textures defines the array of textures to bind
  32856. */
  32857. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32858. /** @hidden */
  32859. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32860. private _setTextureParameterFloat;
  32861. private _setTextureParameterInteger;
  32862. /**
  32863. * Unbind all vertex attributes from the webGL context
  32864. */
  32865. unbindAllAttributes(): void;
  32866. /**
  32867. * 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
  32868. */
  32869. releaseEffects(): void;
  32870. /**
  32871. * Dispose and release all associated resources
  32872. */
  32873. dispose(): void;
  32874. /**
  32875. * Attach a new callback raised when context lost event is fired
  32876. * @param callback defines the callback to call
  32877. */
  32878. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32879. /**
  32880. * Attach a new callback raised when context restored event is fired
  32881. * @param callback defines the callback to call
  32882. */
  32883. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32884. /**
  32885. * Get the current error code of the webGL context
  32886. * @returns the error code
  32887. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32888. */
  32889. getError(): number;
  32890. private _canRenderToFloatFramebuffer;
  32891. private _canRenderToHalfFloatFramebuffer;
  32892. private _canRenderToFramebuffer;
  32893. /** @hidden */
  32894. _getWebGLTextureType(type: number): number;
  32895. /** @hidden */
  32896. _getInternalFormat(format: number): number;
  32897. /** @hidden */
  32898. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32899. /** @hidden */
  32900. _getRGBAMultiSampleBufferFormat(type: number): number;
  32901. /** @hidden */
  32902. _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;
  32903. /**
  32904. * Loads a file from a url
  32905. * @param url url to load
  32906. * @param onSuccess callback called when the file successfully loads
  32907. * @param onProgress callback called while file is loading (if the server supports this mode)
  32908. * @param offlineProvider defines the offline provider for caching
  32909. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32910. * @param onError callback called when the file fails to load
  32911. * @returns a file request object
  32912. * @hidden
  32913. */
  32914. 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;
  32915. /**
  32916. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32917. * @param x defines the x coordinate of the rectangle where pixels must be read
  32918. * @param y defines the y coordinate of the rectangle where pixels must be read
  32919. * @param width defines the width of the rectangle where pixels must be read
  32920. * @param height defines the height of the rectangle where pixels must be read
  32921. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32922. * @returns a Uint8Array containing RGBA colors
  32923. */
  32924. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32925. private static _isSupported;
  32926. /**
  32927. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32928. * @returns true if the engine can be created
  32929. * @ignorenaming
  32930. */
  32931. static isSupported(): boolean;
  32932. /**
  32933. * Find the next highest power of two.
  32934. * @param x Number to start search from.
  32935. * @return Next highest power of two.
  32936. */
  32937. static CeilingPOT(x: number): number;
  32938. /**
  32939. * Find the next lowest power of two.
  32940. * @param x Number to start search from.
  32941. * @return Next lowest power of two.
  32942. */
  32943. static FloorPOT(x: number): number;
  32944. /**
  32945. * Find the nearest power of two.
  32946. * @param x Number to start search from.
  32947. * @return Next nearest power of two.
  32948. */
  32949. static NearestPOT(x: number): number;
  32950. /**
  32951. * Get the closest exponent of two
  32952. * @param value defines the value to approximate
  32953. * @param max defines the maximum value to return
  32954. * @param mode defines how to define the closest value
  32955. * @returns closest exponent of two of the given value
  32956. */
  32957. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32958. /**
  32959. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32960. * @param func - the function to be called
  32961. * @param requester - the object that will request the next frame. Falls back to window.
  32962. * @returns frame number
  32963. */
  32964. static QueueNewFrame(func: () => void, requester?: any): number;
  32965. /**
  32966. * Gets host document
  32967. * @returns the host document object
  32968. */
  32969. getHostDocument(): Nullable<Document>;
  32970. }
  32971. }
  32972. declare module "babylonjs/Maths/sphericalPolynomial" {
  32973. import { Vector3 } from "babylonjs/Maths/math.vector";
  32974. import { Color3 } from "babylonjs/Maths/math.color";
  32975. /**
  32976. * Class representing spherical harmonics coefficients to the 3rd degree
  32977. */
  32978. export class SphericalHarmonics {
  32979. /**
  32980. * Defines whether or not the harmonics have been prescaled for rendering.
  32981. */
  32982. preScaled: boolean;
  32983. /**
  32984. * The l0,0 coefficients of the spherical harmonics
  32985. */
  32986. l00: Vector3;
  32987. /**
  32988. * The l1,-1 coefficients of the spherical harmonics
  32989. */
  32990. l1_1: Vector3;
  32991. /**
  32992. * The l1,0 coefficients of the spherical harmonics
  32993. */
  32994. l10: Vector3;
  32995. /**
  32996. * The l1,1 coefficients of the spherical harmonics
  32997. */
  32998. l11: Vector3;
  32999. /**
  33000. * The l2,-2 coefficients of the spherical harmonics
  33001. */
  33002. l2_2: Vector3;
  33003. /**
  33004. * The l2,-1 coefficients of the spherical harmonics
  33005. */
  33006. l2_1: Vector3;
  33007. /**
  33008. * The l2,0 coefficients of the spherical harmonics
  33009. */
  33010. l20: Vector3;
  33011. /**
  33012. * The l2,1 coefficients of the spherical harmonics
  33013. */
  33014. l21: Vector3;
  33015. /**
  33016. * The l2,2 coefficients of the spherical harmonics
  33017. */
  33018. l22: Vector3;
  33019. /**
  33020. * Adds a light to the spherical harmonics
  33021. * @param direction the direction of the light
  33022. * @param color the color of the light
  33023. * @param deltaSolidAngle the delta solid angle of the light
  33024. */
  33025. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33026. /**
  33027. * Scales the spherical harmonics by the given amount
  33028. * @param scale the amount to scale
  33029. */
  33030. scaleInPlace(scale: number): void;
  33031. /**
  33032. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33033. *
  33034. * ```
  33035. * E_lm = A_l * L_lm
  33036. * ```
  33037. *
  33038. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33039. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33040. * the scaling factors are given in equation 9.
  33041. */
  33042. convertIncidentRadianceToIrradiance(): void;
  33043. /**
  33044. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33045. *
  33046. * ```
  33047. * L = (1/pi) * E * rho
  33048. * ```
  33049. *
  33050. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33051. */
  33052. convertIrradianceToLambertianRadiance(): void;
  33053. /**
  33054. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33055. * required operations at run time.
  33056. *
  33057. * This is simply done by scaling back the SH with Ylm constants parameter.
  33058. * The trigonometric part being applied by the shader at run time.
  33059. */
  33060. preScaleForRendering(): void;
  33061. /**
  33062. * Constructs a spherical harmonics from an array.
  33063. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33064. * @returns the spherical harmonics
  33065. */
  33066. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33067. /**
  33068. * Gets the spherical harmonics from polynomial
  33069. * @param polynomial the spherical polynomial
  33070. * @returns the spherical harmonics
  33071. */
  33072. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33073. }
  33074. /**
  33075. * Class representing spherical polynomial coefficients to the 3rd degree
  33076. */
  33077. export class SphericalPolynomial {
  33078. private _harmonics;
  33079. /**
  33080. * The spherical harmonics used to create the polynomials.
  33081. */
  33082. get preScaledHarmonics(): SphericalHarmonics;
  33083. /**
  33084. * The x coefficients of the spherical polynomial
  33085. */
  33086. x: Vector3;
  33087. /**
  33088. * The y coefficients of the spherical polynomial
  33089. */
  33090. y: Vector3;
  33091. /**
  33092. * The z coefficients of the spherical polynomial
  33093. */
  33094. z: Vector3;
  33095. /**
  33096. * The xx coefficients of the spherical polynomial
  33097. */
  33098. xx: Vector3;
  33099. /**
  33100. * The yy coefficients of the spherical polynomial
  33101. */
  33102. yy: Vector3;
  33103. /**
  33104. * The zz coefficients of the spherical polynomial
  33105. */
  33106. zz: Vector3;
  33107. /**
  33108. * The xy coefficients of the spherical polynomial
  33109. */
  33110. xy: Vector3;
  33111. /**
  33112. * The yz coefficients of the spherical polynomial
  33113. */
  33114. yz: Vector3;
  33115. /**
  33116. * The zx coefficients of the spherical polynomial
  33117. */
  33118. zx: Vector3;
  33119. /**
  33120. * Adds an ambient color to the spherical polynomial
  33121. * @param color the color to add
  33122. */
  33123. addAmbient(color: Color3): void;
  33124. /**
  33125. * Scales the spherical polynomial by the given amount
  33126. * @param scale the amount to scale
  33127. */
  33128. scaleInPlace(scale: number): void;
  33129. /**
  33130. * Gets the spherical polynomial from harmonics
  33131. * @param harmonics the spherical harmonics
  33132. * @returns the spherical polynomial
  33133. */
  33134. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33135. /**
  33136. * Constructs a spherical polynomial from an array.
  33137. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33138. * @returns the spherical polynomial
  33139. */
  33140. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33141. }
  33142. }
  33143. declare module "babylonjs/Materials/Textures/internalTexture" {
  33144. import { Observable } from "babylonjs/Misc/observable";
  33145. import { Nullable, int } from "babylonjs/types";
  33146. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33148. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33149. /**
  33150. * Defines the source of the internal texture
  33151. */
  33152. export enum InternalTextureSource {
  33153. /**
  33154. * The source of the texture data is unknown
  33155. */
  33156. Unknown = 0,
  33157. /**
  33158. * Texture data comes from an URL
  33159. */
  33160. Url = 1,
  33161. /**
  33162. * Texture data is only used for temporary storage
  33163. */
  33164. Temp = 2,
  33165. /**
  33166. * Texture data comes from raw data (ArrayBuffer)
  33167. */
  33168. Raw = 3,
  33169. /**
  33170. * Texture content is dynamic (video or dynamic texture)
  33171. */
  33172. Dynamic = 4,
  33173. /**
  33174. * Texture content is generated by rendering to it
  33175. */
  33176. RenderTarget = 5,
  33177. /**
  33178. * Texture content is part of a multi render target process
  33179. */
  33180. MultiRenderTarget = 6,
  33181. /**
  33182. * Texture data comes from a cube data file
  33183. */
  33184. Cube = 7,
  33185. /**
  33186. * Texture data comes from a raw cube data
  33187. */
  33188. CubeRaw = 8,
  33189. /**
  33190. * Texture data come from a prefiltered cube data file
  33191. */
  33192. CubePrefiltered = 9,
  33193. /**
  33194. * Texture content is raw 3D data
  33195. */
  33196. Raw3D = 10,
  33197. /**
  33198. * Texture content is raw 2D array data
  33199. */
  33200. Raw2DArray = 11,
  33201. /**
  33202. * Texture content is a depth texture
  33203. */
  33204. Depth = 12,
  33205. /**
  33206. * Texture data comes from a raw cube data encoded with RGBD
  33207. */
  33208. CubeRawRGBD = 13
  33209. }
  33210. /**
  33211. * Class used to store data associated with WebGL texture data for the engine
  33212. * This class should not be used directly
  33213. */
  33214. export class InternalTexture {
  33215. /** @hidden */
  33216. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33217. /**
  33218. * Defines if the texture is ready
  33219. */
  33220. isReady: boolean;
  33221. /**
  33222. * Defines if the texture is a cube texture
  33223. */
  33224. isCube: boolean;
  33225. /**
  33226. * Defines if the texture contains 3D data
  33227. */
  33228. is3D: boolean;
  33229. /**
  33230. * Defines if the texture contains 2D array data
  33231. */
  33232. is2DArray: boolean;
  33233. /**
  33234. * Defines if the texture contains multiview data
  33235. */
  33236. isMultiview: boolean;
  33237. /**
  33238. * Gets the URL used to load this texture
  33239. */
  33240. url: string;
  33241. /**
  33242. * Gets the sampling mode of the texture
  33243. */
  33244. samplingMode: number;
  33245. /**
  33246. * Gets a boolean indicating if the texture needs mipmaps generation
  33247. */
  33248. generateMipMaps: boolean;
  33249. /**
  33250. * Gets the number of samples used by the texture (WebGL2+ only)
  33251. */
  33252. samples: number;
  33253. /**
  33254. * Gets the type of the texture (int, float...)
  33255. */
  33256. type: number;
  33257. /**
  33258. * Gets the format of the texture (RGB, RGBA...)
  33259. */
  33260. format: number;
  33261. /**
  33262. * Observable called when the texture is loaded
  33263. */
  33264. onLoadedObservable: Observable<InternalTexture>;
  33265. /**
  33266. * Gets the width of the texture
  33267. */
  33268. width: number;
  33269. /**
  33270. * Gets the height of the texture
  33271. */
  33272. height: number;
  33273. /**
  33274. * Gets the depth of the texture
  33275. */
  33276. depth: number;
  33277. /**
  33278. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33279. */
  33280. baseWidth: number;
  33281. /**
  33282. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33283. */
  33284. baseHeight: number;
  33285. /**
  33286. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33287. */
  33288. baseDepth: number;
  33289. /**
  33290. * Gets a boolean indicating if the texture is inverted on Y axis
  33291. */
  33292. invertY: boolean;
  33293. /** @hidden */
  33294. _invertVScale: boolean;
  33295. /** @hidden */
  33296. _associatedChannel: number;
  33297. /** @hidden */
  33298. _source: InternalTextureSource;
  33299. /** @hidden */
  33300. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33301. /** @hidden */
  33302. _bufferView: Nullable<ArrayBufferView>;
  33303. /** @hidden */
  33304. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33305. /** @hidden */
  33306. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33307. /** @hidden */
  33308. _size: number;
  33309. /** @hidden */
  33310. _extension: string;
  33311. /** @hidden */
  33312. _files: Nullable<string[]>;
  33313. /** @hidden */
  33314. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33315. /** @hidden */
  33316. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33317. /** @hidden */
  33318. _framebuffer: Nullable<WebGLFramebuffer>;
  33319. /** @hidden */
  33320. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33321. /** @hidden */
  33322. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33323. /** @hidden */
  33324. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33325. /** @hidden */
  33326. _attachments: Nullable<number[]>;
  33327. /** @hidden */
  33328. _cachedCoordinatesMode: Nullable<number>;
  33329. /** @hidden */
  33330. _cachedWrapU: Nullable<number>;
  33331. /** @hidden */
  33332. _cachedWrapV: Nullable<number>;
  33333. /** @hidden */
  33334. _cachedWrapR: Nullable<number>;
  33335. /** @hidden */
  33336. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33337. /** @hidden */
  33338. _isDisabled: boolean;
  33339. /** @hidden */
  33340. _compression: Nullable<string>;
  33341. /** @hidden */
  33342. _generateStencilBuffer: boolean;
  33343. /** @hidden */
  33344. _generateDepthBuffer: boolean;
  33345. /** @hidden */
  33346. _comparisonFunction: number;
  33347. /** @hidden */
  33348. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33349. /** @hidden */
  33350. _lodGenerationScale: number;
  33351. /** @hidden */
  33352. _lodGenerationOffset: number;
  33353. /** @hidden */
  33354. _depthStencilTexture: Nullable<InternalTexture>;
  33355. /** @hidden */
  33356. _colorTextureArray: Nullable<WebGLTexture>;
  33357. /** @hidden */
  33358. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33359. /** @hidden */
  33360. _lodTextureHigh: Nullable<BaseTexture>;
  33361. /** @hidden */
  33362. _lodTextureMid: Nullable<BaseTexture>;
  33363. /** @hidden */
  33364. _lodTextureLow: Nullable<BaseTexture>;
  33365. /** @hidden */
  33366. _isRGBD: boolean;
  33367. /** @hidden */
  33368. _linearSpecularLOD: boolean;
  33369. /** @hidden */
  33370. _irradianceTexture: Nullable<BaseTexture>;
  33371. /** @hidden */
  33372. _webGLTexture: Nullable<WebGLTexture>;
  33373. /** @hidden */
  33374. _references: number;
  33375. private _engine;
  33376. /**
  33377. * Gets the Engine the texture belongs to.
  33378. * @returns The babylon engine
  33379. */
  33380. getEngine(): ThinEngine;
  33381. /**
  33382. * Gets the data source type of the texture
  33383. */
  33384. get source(): InternalTextureSource;
  33385. /**
  33386. * Creates a new InternalTexture
  33387. * @param engine defines the engine to use
  33388. * @param source defines the type of data that will be used
  33389. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33390. */
  33391. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33392. /**
  33393. * Increments the number of references (ie. the number of Texture that point to it)
  33394. */
  33395. incrementReferences(): void;
  33396. /**
  33397. * Change the size of the texture (not the size of the content)
  33398. * @param width defines the new width
  33399. * @param height defines the new height
  33400. * @param depth defines the new depth (1 by default)
  33401. */
  33402. updateSize(width: int, height: int, depth?: int): void;
  33403. /** @hidden */
  33404. _rebuild(): void;
  33405. /** @hidden */
  33406. _swapAndDie(target: InternalTexture): void;
  33407. /**
  33408. * Dispose the current allocated resources
  33409. */
  33410. dispose(): void;
  33411. }
  33412. }
  33413. declare module "babylonjs/Audio/analyser" {
  33414. import { Scene } from "babylonjs/scene";
  33415. /**
  33416. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33418. */
  33419. export class Analyser {
  33420. /**
  33421. * Gets or sets the smoothing
  33422. * @ignorenaming
  33423. */
  33424. SMOOTHING: number;
  33425. /**
  33426. * Gets or sets the FFT table size
  33427. * @ignorenaming
  33428. */
  33429. FFT_SIZE: number;
  33430. /**
  33431. * Gets or sets the bar graph amplitude
  33432. * @ignorenaming
  33433. */
  33434. BARGRAPHAMPLITUDE: number;
  33435. /**
  33436. * Gets or sets the position of the debug canvas
  33437. * @ignorenaming
  33438. */
  33439. DEBUGCANVASPOS: {
  33440. x: number;
  33441. y: number;
  33442. };
  33443. /**
  33444. * Gets or sets the debug canvas size
  33445. * @ignorenaming
  33446. */
  33447. DEBUGCANVASSIZE: {
  33448. width: number;
  33449. height: number;
  33450. };
  33451. private _byteFreqs;
  33452. private _byteTime;
  33453. private _floatFreqs;
  33454. private _webAudioAnalyser;
  33455. private _debugCanvas;
  33456. private _debugCanvasContext;
  33457. private _scene;
  33458. private _registerFunc;
  33459. private _audioEngine;
  33460. /**
  33461. * Creates a new analyser
  33462. * @param scene defines hosting scene
  33463. */
  33464. constructor(scene: Scene);
  33465. /**
  33466. * Get the number of data values you will have to play with for the visualization
  33467. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33468. * @returns a number
  33469. */
  33470. getFrequencyBinCount(): number;
  33471. /**
  33472. * Gets the current frequency data as a byte array
  33473. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33474. * @returns a Uint8Array
  33475. */
  33476. getByteFrequencyData(): Uint8Array;
  33477. /**
  33478. * Gets the current waveform as a byte array
  33479. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33480. * @returns a Uint8Array
  33481. */
  33482. getByteTimeDomainData(): Uint8Array;
  33483. /**
  33484. * Gets the current frequency data as a float array
  33485. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33486. * @returns a Float32Array
  33487. */
  33488. getFloatFrequencyData(): Float32Array;
  33489. /**
  33490. * Renders the debug canvas
  33491. */
  33492. drawDebugCanvas(): void;
  33493. /**
  33494. * Stops rendering the debug canvas and removes it
  33495. */
  33496. stopDebugCanvas(): void;
  33497. /**
  33498. * Connects two audio nodes
  33499. * @param inputAudioNode defines first node to connect
  33500. * @param outputAudioNode defines second node to connect
  33501. */
  33502. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33503. /**
  33504. * Releases all associated resources
  33505. */
  33506. dispose(): void;
  33507. }
  33508. }
  33509. declare module "babylonjs/Audio/audioEngine" {
  33510. import { IDisposable } from "babylonjs/scene";
  33511. import { Analyser } from "babylonjs/Audio/analyser";
  33512. import { Nullable } from "babylonjs/types";
  33513. import { Observable } from "babylonjs/Misc/observable";
  33514. /**
  33515. * This represents an audio engine and it is responsible
  33516. * to play, synchronize and analyse sounds throughout the application.
  33517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33518. */
  33519. export interface IAudioEngine extends IDisposable {
  33520. /**
  33521. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33522. */
  33523. readonly canUseWebAudio: boolean;
  33524. /**
  33525. * Gets the current AudioContext if available.
  33526. */
  33527. readonly audioContext: Nullable<AudioContext>;
  33528. /**
  33529. * The master gain node defines the global audio volume of your audio engine.
  33530. */
  33531. readonly masterGain: GainNode;
  33532. /**
  33533. * Gets whether or not mp3 are supported by your browser.
  33534. */
  33535. readonly isMP3supported: boolean;
  33536. /**
  33537. * Gets whether or not ogg are supported by your browser.
  33538. */
  33539. readonly isOGGsupported: boolean;
  33540. /**
  33541. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33542. * @ignoreNaming
  33543. */
  33544. WarnedWebAudioUnsupported: boolean;
  33545. /**
  33546. * Defines if the audio engine relies on a custom unlocked button.
  33547. * In this case, the embedded button will not be displayed.
  33548. */
  33549. useCustomUnlockedButton: boolean;
  33550. /**
  33551. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33552. */
  33553. readonly unlocked: boolean;
  33554. /**
  33555. * Event raised when audio has been unlocked on the browser.
  33556. */
  33557. onAudioUnlockedObservable: Observable<AudioEngine>;
  33558. /**
  33559. * Event raised when audio has been locked on the browser.
  33560. */
  33561. onAudioLockedObservable: Observable<AudioEngine>;
  33562. /**
  33563. * Flags the audio engine in Locked state.
  33564. * This happens due to new browser policies preventing audio to autoplay.
  33565. */
  33566. lock(): void;
  33567. /**
  33568. * Unlocks the audio engine once a user action has been done on the dom.
  33569. * This is helpful to resume play once browser policies have been satisfied.
  33570. */
  33571. unlock(): void;
  33572. }
  33573. /**
  33574. * This represents the default audio engine used in babylon.
  33575. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33577. */
  33578. export class AudioEngine implements IAudioEngine {
  33579. private _audioContext;
  33580. private _audioContextInitialized;
  33581. private _muteButton;
  33582. private _hostElement;
  33583. /**
  33584. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33585. */
  33586. canUseWebAudio: boolean;
  33587. /**
  33588. * The master gain node defines the global audio volume of your audio engine.
  33589. */
  33590. masterGain: GainNode;
  33591. /**
  33592. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33593. * @ignoreNaming
  33594. */
  33595. WarnedWebAudioUnsupported: boolean;
  33596. /**
  33597. * Gets whether or not mp3 are supported by your browser.
  33598. */
  33599. isMP3supported: boolean;
  33600. /**
  33601. * Gets whether or not ogg are supported by your browser.
  33602. */
  33603. isOGGsupported: boolean;
  33604. /**
  33605. * Gets whether audio has been unlocked on the device.
  33606. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33607. * a user interaction has happened.
  33608. */
  33609. unlocked: boolean;
  33610. /**
  33611. * Defines if the audio engine relies on a custom unlocked button.
  33612. * In this case, the embedded button will not be displayed.
  33613. */
  33614. useCustomUnlockedButton: boolean;
  33615. /**
  33616. * Event raised when audio has been unlocked on the browser.
  33617. */
  33618. onAudioUnlockedObservable: Observable<AudioEngine>;
  33619. /**
  33620. * Event raised when audio has been locked on the browser.
  33621. */
  33622. onAudioLockedObservable: Observable<AudioEngine>;
  33623. /**
  33624. * Gets the current AudioContext if available.
  33625. */
  33626. get audioContext(): Nullable<AudioContext>;
  33627. private _connectedAnalyser;
  33628. /**
  33629. * Instantiates a new audio engine.
  33630. *
  33631. * There should be only one per page as some browsers restrict the number
  33632. * of audio contexts you can create.
  33633. * @param hostElement defines the host element where to display the mute icon if necessary
  33634. */
  33635. constructor(hostElement?: Nullable<HTMLElement>);
  33636. /**
  33637. * Flags the audio engine in Locked state.
  33638. * This happens due to new browser policies preventing audio to autoplay.
  33639. */
  33640. lock(): void;
  33641. /**
  33642. * Unlocks the audio engine once a user action has been done on the dom.
  33643. * This is helpful to resume play once browser policies have been satisfied.
  33644. */
  33645. unlock(): void;
  33646. private _resumeAudioContext;
  33647. private _initializeAudioContext;
  33648. private _tryToRun;
  33649. private _triggerRunningState;
  33650. private _triggerSuspendedState;
  33651. private _displayMuteButton;
  33652. private _moveButtonToTopLeft;
  33653. private _onResize;
  33654. private _hideMuteButton;
  33655. /**
  33656. * Destroy and release the resources associated with the audio ccontext.
  33657. */
  33658. dispose(): void;
  33659. /**
  33660. * Gets the global volume sets on the master gain.
  33661. * @returns the global volume if set or -1 otherwise
  33662. */
  33663. getGlobalVolume(): number;
  33664. /**
  33665. * Sets the global volume of your experience (sets on the master gain).
  33666. * @param newVolume Defines the new global volume of the application
  33667. */
  33668. setGlobalVolume(newVolume: number): void;
  33669. /**
  33670. * Connect the audio engine to an audio analyser allowing some amazing
  33671. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33673. * @param analyser The analyser to connect to the engine
  33674. */
  33675. connectToAnalyser(analyser: Analyser): void;
  33676. }
  33677. }
  33678. declare module "babylonjs/Loading/loadingScreen" {
  33679. /**
  33680. * Interface used to present a loading screen while loading a scene
  33681. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33682. */
  33683. export interface ILoadingScreen {
  33684. /**
  33685. * Function called to display the loading screen
  33686. */
  33687. displayLoadingUI: () => void;
  33688. /**
  33689. * Function called to hide the loading screen
  33690. */
  33691. hideLoadingUI: () => void;
  33692. /**
  33693. * Gets or sets the color to use for the background
  33694. */
  33695. loadingUIBackgroundColor: string;
  33696. /**
  33697. * Gets or sets the text to display while loading
  33698. */
  33699. loadingUIText: string;
  33700. }
  33701. /**
  33702. * Class used for the default loading screen
  33703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33704. */
  33705. export class DefaultLoadingScreen implements ILoadingScreen {
  33706. private _renderingCanvas;
  33707. private _loadingText;
  33708. private _loadingDivBackgroundColor;
  33709. private _loadingDiv;
  33710. private _loadingTextDiv;
  33711. /** Gets or sets the logo url to use for the default loading screen */
  33712. static DefaultLogoUrl: string;
  33713. /** Gets or sets the spinner url to use for the default loading screen */
  33714. static DefaultSpinnerUrl: string;
  33715. /**
  33716. * Creates a new default loading screen
  33717. * @param _renderingCanvas defines the canvas used to render the scene
  33718. * @param _loadingText defines the default text to display
  33719. * @param _loadingDivBackgroundColor defines the default background color
  33720. */
  33721. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33722. /**
  33723. * Function called to display the loading screen
  33724. */
  33725. displayLoadingUI(): void;
  33726. /**
  33727. * Function called to hide the loading screen
  33728. */
  33729. hideLoadingUI(): void;
  33730. /**
  33731. * Gets or sets the text to display while loading
  33732. */
  33733. set loadingUIText(text: string);
  33734. get loadingUIText(): string;
  33735. /**
  33736. * Gets or sets the color to use for the background
  33737. */
  33738. get loadingUIBackgroundColor(): string;
  33739. set loadingUIBackgroundColor(color: string);
  33740. private _resizeLoadingUI;
  33741. }
  33742. }
  33743. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33744. /**
  33745. * Interface for any object that can request an animation frame
  33746. */
  33747. export interface ICustomAnimationFrameRequester {
  33748. /**
  33749. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33750. */
  33751. renderFunction?: Function;
  33752. /**
  33753. * Called to request the next frame to render to
  33754. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33755. */
  33756. requestAnimationFrame: Function;
  33757. /**
  33758. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33759. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33760. */
  33761. requestID?: number;
  33762. }
  33763. }
  33764. declare module "babylonjs/Misc/performanceMonitor" {
  33765. /**
  33766. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33767. */
  33768. export class PerformanceMonitor {
  33769. private _enabled;
  33770. private _rollingFrameTime;
  33771. private _lastFrameTimeMs;
  33772. /**
  33773. * constructor
  33774. * @param frameSampleSize The number of samples required to saturate the sliding window
  33775. */
  33776. constructor(frameSampleSize?: number);
  33777. /**
  33778. * Samples current frame
  33779. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33780. */
  33781. sampleFrame(timeMs?: number): void;
  33782. /**
  33783. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33784. */
  33785. get averageFrameTime(): number;
  33786. /**
  33787. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33788. */
  33789. get averageFrameTimeVariance(): number;
  33790. /**
  33791. * Returns the frame time of the most recent frame
  33792. */
  33793. get instantaneousFrameTime(): number;
  33794. /**
  33795. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33796. */
  33797. get averageFPS(): number;
  33798. /**
  33799. * Returns the average framerate in frames per second using the most recent frame time
  33800. */
  33801. get instantaneousFPS(): number;
  33802. /**
  33803. * Returns true if enough samples have been taken to completely fill the sliding window
  33804. */
  33805. get isSaturated(): boolean;
  33806. /**
  33807. * Enables contributions to the sliding window sample set
  33808. */
  33809. enable(): void;
  33810. /**
  33811. * Disables contributions to the sliding window sample set
  33812. * Samples will not be interpolated over the disabled period
  33813. */
  33814. disable(): void;
  33815. /**
  33816. * Returns true if sampling is enabled
  33817. */
  33818. get isEnabled(): boolean;
  33819. /**
  33820. * Resets performance monitor
  33821. */
  33822. reset(): void;
  33823. }
  33824. /**
  33825. * RollingAverage
  33826. *
  33827. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33828. */
  33829. export class RollingAverage {
  33830. /**
  33831. * Current average
  33832. */
  33833. average: number;
  33834. /**
  33835. * Current variance
  33836. */
  33837. variance: number;
  33838. protected _samples: Array<number>;
  33839. protected _sampleCount: number;
  33840. protected _pos: number;
  33841. protected _m2: number;
  33842. /**
  33843. * constructor
  33844. * @param length The number of samples required to saturate the sliding window
  33845. */
  33846. constructor(length: number);
  33847. /**
  33848. * Adds a sample to the sample set
  33849. * @param v The sample value
  33850. */
  33851. add(v: number): void;
  33852. /**
  33853. * Returns previously added values or null if outside of history or outside the sliding window domain
  33854. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33855. * @return Value previously recorded with add() or null if outside of range
  33856. */
  33857. history(i: number): number;
  33858. /**
  33859. * Returns true if enough samples have been taken to completely fill the sliding window
  33860. * @return true if sample-set saturated
  33861. */
  33862. isSaturated(): boolean;
  33863. /**
  33864. * Resets the rolling average (equivalent to 0 samples taken so far)
  33865. */
  33866. reset(): void;
  33867. /**
  33868. * Wraps a value around the sample range boundaries
  33869. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33870. * @return Wrapped position in sample range
  33871. */
  33872. protected _wrapPosition(i: number): number;
  33873. }
  33874. }
  33875. declare module "babylonjs/Misc/perfCounter" {
  33876. /**
  33877. * This class is used to track a performance counter which is number based.
  33878. * The user has access to many properties which give statistics of different nature.
  33879. *
  33880. * The implementer can track two kinds of Performance Counter: time and count.
  33881. * 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.
  33882. * 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.
  33883. */
  33884. export class PerfCounter {
  33885. /**
  33886. * Gets or sets a global boolean to turn on and off all the counters
  33887. */
  33888. static Enabled: boolean;
  33889. /**
  33890. * Returns the smallest value ever
  33891. */
  33892. get min(): number;
  33893. /**
  33894. * Returns the biggest value ever
  33895. */
  33896. get max(): number;
  33897. /**
  33898. * Returns the average value since the performance counter is running
  33899. */
  33900. get average(): number;
  33901. /**
  33902. * Returns the average value of the last second the counter was monitored
  33903. */
  33904. get lastSecAverage(): number;
  33905. /**
  33906. * Returns the current value
  33907. */
  33908. get current(): number;
  33909. /**
  33910. * Gets the accumulated total
  33911. */
  33912. get total(): number;
  33913. /**
  33914. * Gets the total value count
  33915. */
  33916. get count(): number;
  33917. /**
  33918. * Creates a new counter
  33919. */
  33920. constructor();
  33921. /**
  33922. * Call this method to start monitoring a new frame.
  33923. * 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.
  33924. */
  33925. fetchNewFrame(): void;
  33926. /**
  33927. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33928. * @param newCount the count value to add to the monitored count
  33929. * @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.
  33930. */
  33931. addCount(newCount: number, fetchResult: boolean): void;
  33932. /**
  33933. * Start monitoring this performance counter
  33934. */
  33935. beginMonitoring(): void;
  33936. /**
  33937. * Compute the time lapsed since the previous beginMonitoring() call.
  33938. * @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
  33939. */
  33940. endMonitoring(newFrame?: boolean): void;
  33941. private _fetchResult;
  33942. private _startMonitoringTime;
  33943. private _min;
  33944. private _max;
  33945. private _average;
  33946. private _current;
  33947. private _totalValueCount;
  33948. private _totalAccumulated;
  33949. private _lastSecAverage;
  33950. private _lastSecAccumulated;
  33951. private _lastSecTime;
  33952. private _lastSecValueCount;
  33953. }
  33954. }
  33955. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33956. module "babylonjs/Engines/thinEngine" {
  33957. interface ThinEngine {
  33958. /**
  33959. * Sets alpha constants used by some alpha blending modes
  33960. * @param r defines the red component
  33961. * @param g defines the green component
  33962. * @param b defines the blue component
  33963. * @param a defines the alpha component
  33964. */
  33965. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33966. /**
  33967. * Sets the current alpha mode
  33968. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33969. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33970. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33971. */
  33972. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33973. /**
  33974. * Gets the current alpha mode
  33975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33976. * @returns the current alpha mode
  33977. */
  33978. getAlphaMode(): number;
  33979. /**
  33980. * Sets the current alpha equation
  33981. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33982. */
  33983. setAlphaEquation(equation: number): void;
  33984. /**
  33985. * Gets the current alpha equation.
  33986. * @returns the current alpha equation
  33987. */
  33988. getAlphaEquation(): number;
  33989. }
  33990. }
  33991. }
  33992. declare module "babylonjs/Engines/engine" {
  33993. import { Observable } from "babylonjs/Misc/observable";
  33994. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33995. import { Scene } from "babylonjs/scene";
  33996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33997. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33998. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33999. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34000. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34002. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34003. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34004. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34006. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34007. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34008. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34009. import "babylonjs/Engines/Extensions/engine.alpha";
  34010. import { Material } from "babylonjs/Materials/material";
  34011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34012. /**
  34013. * Defines the interface used by display changed events
  34014. */
  34015. export interface IDisplayChangedEventArgs {
  34016. /** Gets the vrDisplay object (if any) */
  34017. vrDisplay: Nullable<any>;
  34018. /** Gets a boolean indicating if webVR is supported */
  34019. vrSupported: boolean;
  34020. }
  34021. /**
  34022. * Defines the interface used by objects containing a viewport (like a camera)
  34023. */
  34024. interface IViewportOwnerLike {
  34025. /**
  34026. * Gets or sets the viewport
  34027. */
  34028. viewport: IViewportLike;
  34029. }
  34030. /**
  34031. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34032. */
  34033. export class Engine extends ThinEngine {
  34034. /** Defines that alpha blending is disabled */
  34035. static readonly ALPHA_DISABLE: number;
  34036. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34037. static readonly ALPHA_ADD: number;
  34038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34039. static readonly ALPHA_COMBINE: number;
  34040. /** Defines that alpha blending to DEST - SRC * DEST */
  34041. static readonly ALPHA_SUBTRACT: number;
  34042. /** Defines that alpha blending to SRC * DEST */
  34043. static readonly ALPHA_MULTIPLY: number;
  34044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34045. static readonly ALPHA_MAXIMIZED: number;
  34046. /** Defines that alpha blending to SRC + DEST */
  34047. static readonly ALPHA_ONEONE: number;
  34048. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34049. static readonly ALPHA_PREMULTIPLIED: number;
  34050. /**
  34051. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34052. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34053. */
  34054. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34055. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34056. static readonly ALPHA_INTERPOLATE: number;
  34057. /**
  34058. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34059. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34060. */
  34061. static readonly ALPHA_SCREENMODE: number;
  34062. /** Defines that the ressource is not delayed*/
  34063. static readonly DELAYLOADSTATE_NONE: number;
  34064. /** Defines that the ressource was successfully delay loaded */
  34065. static readonly DELAYLOADSTATE_LOADED: number;
  34066. /** Defines that the ressource is currently delay loading */
  34067. static readonly DELAYLOADSTATE_LOADING: number;
  34068. /** Defines that the ressource is delayed and has not started loading */
  34069. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34071. static readonly NEVER: number;
  34072. /** 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 */
  34073. static readonly ALWAYS: number;
  34074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34075. static readonly LESS: number;
  34076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34077. static readonly EQUAL: number;
  34078. /** 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 */
  34079. static readonly LEQUAL: number;
  34080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34081. static readonly GREATER: number;
  34082. /** 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 */
  34083. static readonly GEQUAL: number;
  34084. /** 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 */
  34085. static readonly NOTEQUAL: number;
  34086. /** Passed to stencilOperation to specify that stencil value must be kept */
  34087. static readonly KEEP: number;
  34088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34089. static readonly REPLACE: number;
  34090. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34091. static readonly INCR: number;
  34092. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34093. static readonly DECR: number;
  34094. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34095. static readonly INVERT: number;
  34096. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34097. static readonly INCR_WRAP: number;
  34098. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34099. static readonly DECR_WRAP: number;
  34100. /** Texture is not repeating outside of 0..1 UVs */
  34101. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34102. /** Texture is repeating outside of 0..1 UVs */
  34103. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34104. /** Texture is repeating and mirrored */
  34105. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34106. /** ALPHA */
  34107. static readonly TEXTUREFORMAT_ALPHA: number;
  34108. /** LUMINANCE */
  34109. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34110. /** LUMINANCE_ALPHA */
  34111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34112. /** RGB */
  34113. static readonly TEXTUREFORMAT_RGB: number;
  34114. /** RGBA */
  34115. static readonly TEXTUREFORMAT_RGBA: number;
  34116. /** RED */
  34117. static readonly TEXTUREFORMAT_RED: number;
  34118. /** RED (2nd reference) */
  34119. static readonly TEXTUREFORMAT_R: number;
  34120. /** RG */
  34121. static readonly TEXTUREFORMAT_RG: number;
  34122. /** RED_INTEGER */
  34123. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34124. /** RED_INTEGER (2nd reference) */
  34125. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34126. /** RG_INTEGER */
  34127. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34128. /** RGB_INTEGER */
  34129. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34130. /** RGBA_INTEGER */
  34131. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34132. /** UNSIGNED_BYTE */
  34133. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34134. /** UNSIGNED_BYTE (2nd reference) */
  34135. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34136. /** FLOAT */
  34137. static readonly TEXTURETYPE_FLOAT: number;
  34138. /** HALF_FLOAT */
  34139. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34140. /** BYTE */
  34141. static readonly TEXTURETYPE_BYTE: number;
  34142. /** SHORT */
  34143. static readonly TEXTURETYPE_SHORT: number;
  34144. /** UNSIGNED_SHORT */
  34145. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34146. /** INT */
  34147. static readonly TEXTURETYPE_INT: number;
  34148. /** UNSIGNED_INT */
  34149. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34150. /** UNSIGNED_SHORT_4_4_4_4 */
  34151. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34152. /** UNSIGNED_SHORT_5_5_5_1 */
  34153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34154. /** UNSIGNED_SHORT_5_6_5 */
  34155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34156. /** UNSIGNED_INT_2_10_10_10_REV */
  34157. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34158. /** UNSIGNED_INT_24_8 */
  34159. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34160. /** UNSIGNED_INT_10F_11F_11F_REV */
  34161. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34162. /** UNSIGNED_INT_5_9_9_9_REV */
  34163. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34164. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34165. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34166. /** nearest is mag = nearest and min = nearest and mip = linear */
  34167. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34170. /** Trilinear is mag = linear and min = linear and mip = linear */
  34171. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34172. /** nearest is mag = nearest and min = nearest and mip = linear */
  34173. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34175. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34176. /** Trilinear is mag = linear and min = linear and mip = linear */
  34177. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34178. /** mag = nearest and min = nearest and mip = nearest */
  34179. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34180. /** mag = nearest and min = linear and mip = nearest */
  34181. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34182. /** mag = nearest and min = linear and mip = linear */
  34183. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34184. /** mag = nearest and min = linear and mip = none */
  34185. static readonly TEXTURE_NEAREST_LINEAR: number;
  34186. /** mag = nearest and min = nearest and mip = none */
  34187. static readonly TEXTURE_NEAREST_NEAREST: number;
  34188. /** mag = linear and min = nearest and mip = nearest */
  34189. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34190. /** mag = linear and min = nearest and mip = linear */
  34191. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34192. /** mag = linear and min = linear and mip = none */
  34193. static readonly TEXTURE_LINEAR_LINEAR: number;
  34194. /** mag = linear and min = nearest and mip = none */
  34195. static readonly TEXTURE_LINEAR_NEAREST: number;
  34196. /** Explicit coordinates mode */
  34197. static readonly TEXTURE_EXPLICIT_MODE: number;
  34198. /** Spherical coordinates mode */
  34199. static readonly TEXTURE_SPHERICAL_MODE: number;
  34200. /** Planar coordinates mode */
  34201. static readonly TEXTURE_PLANAR_MODE: number;
  34202. /** Cubic coordinates mode */
  34203. static readonly TEXTURE_CUBIC_MODE: number;
  34204. /** Projection coordinates mode */
  34205. static readonly TEXTURE_PROJECTION_MODE: number;
  34206. /** Skybox coordinates mode */
  34207. static readonly TEXTURE_SKYBOX_MODE: number;
  34208. /** Inverse Cubic coordinates mode */
  34209. static readonly TEXTURE_INVCUBIC_MODE: number;
  34210. /** Equirectangular coordinates mode */
  34211. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34212. /** Equirectangular Fixed coordinates mode */
  34213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34214. /** Equirectangular Fixed Mirrored coordinates mode */
  34215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34216. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34217. static readonly SCALEMODE_FLOOR: number;
  34218. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34219. static readonly SCALEMODE_NEAREST: number;
  34220. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34221. static readonly SCALEMODE_CEILING: number;
  34222. /**
  34223. * Returns the current npm package of the sdk
  34224. */
  34225. static get NpmPackage(): string;
  34226. /**
  34227. * Returns the current version of the framework
  34228. */
  34229. static get Version(): string;
  34230. /** Gets the list of created engines */
  34231. static get Instances(): Engine[];
  34232. /**
  34233. * Gets the latest created engine
  34234. */
  34235. static get LastCreatedEngine(): Nullable<Engine>;
  34236. /**
  34237. * Gets the latest created scene
  34238. */
  34239. static get LastCreatedScene(): Nullable<Scene>;
  34240. /**
  34241. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34242. * @param flag defines which part of the materials must be marked as dirty
  34243. * @param predicate defines a predicate used to filter which materials should be affected
  34244. */
  34245. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34246. /**
  34247. * Method called to create the default loading screen.
  34248. * This can be overriden in your own app.
  34249. * @param canvas The rendering canvas element
  34250. * @returns The loading screen
  34251. */
  34252. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34253. /**
  34254. * Method called to create the default rescale post process on each engine.
  34255. */
  34256. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34257. /**
  34258. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34259. **/
  34260. enableOfflineSupport: boolean;
  34261. /**
  34262. * 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)
  34263. **/
  34264. disableManifestCheck: boolean;
  34265. /**
  34266. * Gets the list of created scenes
  34267. */
  34268. scenes: Scene[];
  34269. /**
  34270. * Event raised when a new scene is created
  34271. */
  34272. onNewSceneAddedObservable: Observable<Scene>;
  34273. /**
  34274. * Gets the list of created postprocesses
  34275. */
  34276. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34277. /**
  34278. * Gets a boolean indicating if the pointer is currently locked
  34279. */
  34280. isPointerLock: boolean;
  34281. /**
  34282. * Observable event triggered each time the rendering canvas is resized
  34283. */
  34284. onResizeObservable: Observable<Engine>;
  34285. /**
  34286. * Observable event triggered each time the canvas loses focus
  34287. */
  34288. onCanvasBlurObservable: Observable<Engine>;
  34289. /**
  34290. * Observable event triggered each time the canvas gains focus
  34291. */
  34292. onCanvasFocusObservable: Observable<Engine>;
  34293. /**
  34294. * Observable event triggered each time the canvas receives pointerout event
  34295. */
  34296. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34297. /**
  34298. * Observable raised when the engine begins a new frame
  34299. */
  34300. onBeginFrameObservable: Observable<Engine>;
  34301. /**
  34302. * If set, will be used to request the next animation frame for the render loop
  34303. */
  34304. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34305. /**
  34306. * Observable raised when the engine ends the current frame
  34307. */
  34308. onEndFrameObservable: Observable<Engine>;
  34309. /**
  34310. * Observable raised when the engine is about to compile a shader
  34311. */
  34312. onBeforeShaderCompilationObservable: Observable<Engine>;
  34313. /**
  34314. * Observable raised when the engine has jsut compiled a shader
  34315. */
  34316. onAfterShaderCompilationObservable: Observable<Engine>;
  34317. /**
  34318. * Gets the audio engine
  34319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34320. * @ignorenaming
  34321. */
  34322. static audioEngine: IAudioEngine;
  34323. /**
  34324. * Default AudioEngine factory responsible of creating the Audio Engine.
  34325. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34326. */
  34327. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34328. /**
  34329. * Default offline support factory responsible of creating a tool used to store data locally.
  34330. * By default, this will create a Database object if the workload has been embedded.
  34331. */
  34332. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34333. private _loadingScreen;
  34334. private _pointerLockRequested;
  34335. private _dummyFramebuffer;
  34336. private _rescalePostProcess;
  34337. private _deterministicLockstep;
  34338. private _lockstepMaxSteps;
  34339. private _timeStep;
  34340. protected get _supportsHardwareTextureRescaling(): boolean;
  34341. private _fps;
  34342. private _deltaTime;
  34343. /** @hidden */
  34344. _drawCalls: PerfCounter;
  34345. /** 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 */
  34346. canvasTabIndex: number;
  34347. /**
  34348. * Turn this value on if you want to pause FPS computation when in background
  34349. */
  34350. disablePerformanceMonitorInBackground: boolean;
  34351. private _performanceMonitor;
  34352. /**
  34353. * Gets the performance monitor attached to this engine
  34354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34355. */
  34356. get performanceMonitor(): PerformanceMonitor;
  34357. private _onFocus;
  34358. private _onBlur;
  34359. private _onCanvasPointerOut;
  34360. private _onCanvasBlur;
  34361. private _onCanvasFocus;
  34362. private _onFullscreenChange;
  34363. private _onPointerLockChange;
  34364. /**
  34365. * Gets the HTML element used to attach event listeners
  34366. * @returns a HTML element
  34367. */
  34368. getInputElement(): Nullable<HTMLElement>;
  34369. /**
  34370. * Creates a new engine
  34371. * @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
  34372. * @param antialias defines enable antialiasing (default: false)
  34373. * @param options defines further options to be sent to the getContext() function
  34374. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34375. */
  34376. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34377. /**
  34378. * Gets current aspect ratio
  34379. * @param viewportOwner defines the camera to use to get the aspect ratio
  34380. * @param useScreen defines if screen size must be used (or the current render target if any)
  34381. * @returns a number defining the aspect ratio
  34382. */
  34383. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34384. /**
  34385. * Gets current screen aspect ratio
  34386. * @returns a number defining the aspect ratio
  34387. */
  34388. getScreenAspectRatio(): number;
  34389. /**
  34390. * Gets the client rect of the HTML canvas attached with the current webGL context
  34391. * @returns a client rectanglee
  34392. */
  34393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34394. /**
  34395. * Gets the client rect of the HTML element used for events
  34396. * @returns a client rectanglee
  34397. */
  34398. getInputElementClientRect(): Nullable<ClientRect>;
  34399. /**
  34400. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34402. * @returns true if engine is in deterministic lock step mode
  34403. */
  34404. isDeterministicLockStep(): boolean;
  34405. /**
  34406. * Gets the max steps when engine is running in deterministic lock step
  34407. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34408. * @returns the max steps
  34409. */
  34410. getLockstepMaxSteps(): number;
  34411. /**
  34412. * Returns the time in ms between steps when using deterministic lock step.
  34413. * @returns time step in (ms)
  34414. */
  34415. getTimeStep(): number;
  34416. /**
  34417. * Force the mipmap generation for the given render target texture
  34418. * @param texture defines the render target texture to use
  34419. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34420. */
  34421. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34422. /** States */
  34423. /**
  34424. * Set various states to the webGL context
  34425. * @param culling defines backface culling state
  34426. * @param zOffset defines the value to apply to zOffset (0 by default)
  34427. * @param force defines if states must be applied even if cache is up to date
  34428. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34429. */
  34430. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34431. /**
  34432. * Set the z offset to apply to current rendering
  34433. * @param value defines the offset to apply
  34434. */
  34435. setZOffset(value: number): void;
  34436. /**
  34437. * Gets the current value of the zOffset
  34438. * @returns the current zOffset state
  34439. */
  34440. getZOffset(): number;
  34441. /**
  34442. * Enable or disable depth buffering
  34443. * @param enable defines the state to set
  34444. */
  34445. setDepthBuffer(enable: boolean): void;
  34446. /**
  34447. * Gets a boolean indicating if depth writing is enabled
  34448. * @returns the current depth writing state
  34449. */
  34450. getDepthWrite(): boolean;
  34451. /**
  34452. * Enable or disable depth writing
  34453. * @param enable defines the state to set
  34454. */
  34455. setDepthWrite(enable: boolean): void;
  34456. /**
  34457. * Gets a boolean indicating if stencil buffer is enabled
  34458. * @returns the current stencil buffer state
  34459. */
  34460. getStencilBuffer(): boolean;
  34461. /**
  34462. * Enable or disable the stencil buffer
  34463. * @param enable defines if the stencil buffer must be enabled or disabled
  34464. */
  34465. setStencilBuffer(enable: boolean): void;
  34466. /**
  34467. * Gets the current stencil mask
  34468. * @returns a number defining the new stencil mask to use
  34469. */
  34470. getStencilMask(): number;
  34471. /**
  34472. * Sets the current stencil mask
  34473. * @param mask defines the new stencil mask to use
  34474. */
  34475. setStencilMask(mask: number): void;
  34476. /**
  34477. * Gets the current stencil function
  34478. * @returns a number defining the stencil function to use
  34479. */
  34480. getStencilFunction(): number;
  34481. /**
  34482. * Gets the current stencil reference value
  34483. * @returns a number defining the stencil reference value to use
  34484. */
  34485. getStencilFunctionReference(): number;
  34486. /**
  34487. * Gets the current stencil mask
  34488. * @returns a number defining the stencil mask to use
  34489. */
  34490. getStencilFunctionMask(): number;
  34491. /**
  34492. * Sets the current stencil function
  34493. * @param stencilFunc defines the new stencil function to use
  34494. */
  34495. setStencilFunction(stencilFunc: number): void;
  34496. /**
  34497. * Sets the current stencil reference
  34498. * @param reference defines the new stencil reference to use
  34499. */
  34500. setStencilFunctionReference(reference: number): void;
  34501. /**
  34502. * Sets the current stencil mask
  34503. * @param mask defines the new stencil mask to use
  34504. */
  34505. setStencilFunctionMask(mask: number): void;
  34506. /**
  34507. * Gets the current stencil operation when stencil fails
  34508. * @returns a number defining stencil operation to use when stencil fails
  34509. */
  34510. getStencilOperationFail(): number;
  34511. /**
  34512. * Gets the current stencil operation when depth fails
  34513. * @returns a number defining stencil operation to use when depth fails
  34514. */
  34515. getStencilOperationDepthFail(): number;
  34516. /**
  34517. * Gets the current stencil operation when stencil passes
  34518. * @returns a number defining stencil operation to use when stencil passes
  34519. */
  34520. getStencilOperationPass(): number;
  34521. /**
  34522. * Sets the stencil operation to use when stencil fails
  34523. * @param operation defines the stencil operation to use when stencil fails
  34524. */
  34525. setStencilOperationFail(operation: number): void;
  34526. /**
  34527. * Sets the stencil operation to use when depth fails
  34528. * @param operation defines the stencil operation to use when depth fails
  34529. */
  34530. setStencilOperationDepthFail(operation: number): void;
  34531. /**
  34532. * Sets the stencil operation to use when stencil passes
  34533. * @param operation defines the stencil operation to use when stencil passes
  34534. */
  34535. setStencilOperationPass(operation: number): void;
  34536. /**
  34537. * Sets a boolean indicating if the dithering state is enabled or disabled
  34538. * @param value defines the dithering state
  34539. */
  34540. setDitheringState(value: boolean): void;
  34541. /**
  34542. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34543. * @param value defines the rasterizer state
  34544. */
  34545. setRasterizerState(value: boolean): void;
  34546. /**
  34547. * Gets the current depth function
  34548. * @returns a number defining the depth function
  34549. */
  34550. getDepthFunction(): Nullable<number>;
  34551. /**
  34552. * Sets the current depth function
  34553. * @param depthFunc defines the function to use
  34554. */
  34555. setDepthFunction(depthFunc: number): void;
  34556. /**
  34557. * Sets the current depth function to GREATER
  34558. */
  34559. setDepthFunctionToGreater(): void;
  34560. /**
  34561. * Sets the current depth function to GEQUAL
  34562. */
  34563. setDepthFunctionToGreaterOrEqual(): void;
  34564. /**
  34565. * Sets the current depth function to LESS
  34566. */
  34567. setDepthFunctionToLess(): void;
  34568. /**
  34569. * Sets the current depth function to LEQUAL
  34570. */
  34571. setDepthFunctionToLessOrEqual(): void;
  34572. private _cachedStencilBuffer;
  34573. private _cachedStencilFunction;
  34574. private _cachedStencilMask;
  34575. private _cachedStencilOperationPass;
  34576. private _cachedStencilOperationFail;
  34577. private _cachedStencilOperationDepthFail;
  34578. private _cachedStencilReference;
  34579. /**
  34580. * Caches the the state of the stencil buffer
  34581. */
  34582. cacheStencilState(): void;
  34583. /**
  34584. * Restores the state of the stencil buffer
  34585. */
  34586. restoreStencilState(): void;
  34587. /**
  34588. * Directly set the WebGL Viewport
  34589. * @param x defines the x coordinate of the viewport (in screen space)
  34590. * @param y defines the y coordinate of the viewport (in screen space)
  34591. * @param width defines the width of the viewport (in screen space)
  34592. * @param height defines the height of the viewport (in screen space)
  34593. * @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
  34594. */
  34595. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34596. /**
  34597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34599. * @param y defines the y-coordinate of the corner of the clear rectangle
  34600. * @param width defines the width of the clear rectangle
  34601. * @param height defines the height of the clear rectangle
  34602. * @param clearColor defines the clear color
  34603. */
  34604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34605. /**
  34606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34608. * @param y defines the y-coordinate of the corner of the clear rectangle
  34609. * @param width defines the width of the clear rectangle
  34610. * @param height defines the height of the clear rectangle
  34611. */
  34612. enableScissor(x: number, y: number, width: number, height: number): void;
  34613. /**
  34614. * Disable previously set scissor test rectangle
  34615. */
  34616. disableScissor(): void;
  34617. protected _reportDrawCall(): void;
  34618. /**
  34619. * Initializes a webVR display and starts listening to display change events
  34620. * The onVRDisplayChangedObservable will be notified upon these changes
  34621. * @returns The onVRDisplayChangedObservable
  34622. */
  34623. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34624. /** @hidden */
  34625. _prepareVRComponent(): void;
  34626. /** @hidden */
  34627. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34628. /** @hidden */
  34629. _submitVRFrame(): void;
  34630. /**
  34631. * Call this function to leave webVR mode
  34632. * Will do nothing if webVR is not supported or if there is no webVR device
  34633. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34634. */
  34635. disableVR(): void;
  34636. /**
  34637. * Gets a boolean indicating that the system is in VR mode and is presenting
  34638. * @returns true if VR mode is engaged
  34639. */
  34640. isVRPresenting(): boolean;
  34641. /** @hidden */
  34642. _requestVRFrame(): void;
  34643. /** @hidden */
  34644. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34645. /**
  34646. * Gets the source code of the vertex shader associated with a specific webGL program
  34647. * @param program defines the program to use
  34648. * @returns a string containing the source code of the vertex shader associated with the program
  34649. */
  34650. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34651. /**
  34652. * Gets the source code of the fragment shader associated with a specific webGL program
  34653. * @param program defines the program to use
  34654. * @returns a string containing the source code of the fragment shader associated with the program
  34655. */
  34656. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34657. /**
  34658. * Sets a depth stencil texture from a render target to the according uniform.
  34659. * @param channel The texture channel
  34660. * @param uniform The uniform to set
  34661. * @param texture The render target texture containing the depth stencil texture to apply
  34662. */
  34663. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34664. /**
  34665. * Sets a texture to the webGL context from a postprocess
  34666. * @param channel defines the channel to use
  34667. * @param postProcess defines the source postprocess
  34668. */
  34669. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34670. /**
  34671. * Binds the output of the passed in post process to the texture channel specified
  34672. * @param channel The channel the texture should be bound to
  34673. * @param postProcess The post process which's output should be bound
  34674. */
  34675. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34676. /** @hidden */
  34677. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34678. protected _rebuildBuffers(): void;
  34679. /** @hidden */
  34680. _renderFrame(): void;
  34681. _renderLoop(): void;
  34682. /** @hidden */
  34683. _renderViews(): boolean;
  34684. /**
  34685. * Toggle full screen mode
  34686. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34687. */
  34688. switchFullscreen(requestPointerLock: boolean): void;
  34689. /**
  34690. * Enters full screen mode
  34691. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34692. */
  34693. enterFullscreen(requestPointerLock: boolean): void;
  34694. /**
  34695. * Exits full screen mode
  34696. */
  34697. exitFullscreen(): void;
  34698. /**
  34699. * Enters Pointerlock mode
  34700. */
  34701. enterPointerlock(): void;
  34702. /**
  34703. * Exits Pointerlock mode
  34704. */
  34705. exitPointerlock(): void;
  34706. /**
  34707. * Begin a new frame
  34708. */
  34709. beginFrame(): void;
  34710. /**
  34711. * Enf the current frame
  34712. */
  34713. endFrame(): void;
  34714. resize(): void;
  34715. /**
  34716. * Force a specific size of the canvas
  34717. * @param width defines the new canvas' width
  34718. * @param height defines the new canvas' height
  34719. */
  34720. setSize(width: number, height: number): void;
  34721. /**
  34722. * Updates a dynamic vertex buffer.
  34723. * @param vertexBuffer the vertex buffer to update
  34724. * @param data the data used to update the vertex buffer
  34725. * @param byteOffset the byte offset of the data
  34726. * @param byteLength the byte length of the data
  34727. */
  34728. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34729. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34730. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34731. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34732. _releaseTexture(texture: InternalTexture): void;
  34733. /**
  34734. * @hidden
  34735. * Rescales a texture
  34736. * @param source input texutre
  34737. * @param destination destination texture
  34738. * @param scene scene to use to render the resize
  34739. * @param internalFormat format to use when resizing
  34740. * @param onComplete callback to be called when resize has completed
  34741. */
  34742. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34743. /**
  34744. * Gets the current framerate
  34745. * @returns a number representing the framerate
  34746. */
  34747. getFps(): number;
  34748. /**
  34749. * Gets the time spent between current and previous frame
  34750. * @returns a number representing the delta time in ms
  34751. */
  34752. getDeltaTime(): number;
  34753. private _measureFps;
  34754. /** @hidden */
  34755. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34756. /**
  34757. * Update a dynamic index buffer
  34758. * @param indexBuffer defines the target index buffer
  34759. * @param indices defines the data to update
  34760. * @param offset defines the offset in the target index buffer where update should start
  34761. */
  34762. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34763. /**
  34764. * Updates the sample count of a render target texture
  34765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34766. * @param texture defines the texture to update
  34767. * @param samples defines the sample count to set
  34768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34769. */
  34770. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34771. /**
  34772. * Updates a depth texture Comparison Mode and Function.
  34773. * If the comparison Function is equal to 0, the mode will be set to none.
  34774. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34775. * @param texture The texture to set the comparison function for
  34776. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34777. */
  34778. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34779. /**
  34780. * Creates a webGL buffer to use with instanciation
  34781. * @param capacity defines the size of the buffer
  34782. * @returns the webGL buffer
  34783. */
  34784. createInstancesBuffer(capacity: number): DataBuffer;
  34785. /**
  34786. * Delete a webGL buffer used with instanciation
  34787. * @param buffer defines the webGL buffer to delete
  34788. */
  34789. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34790. private _clientWaitAsync;
  34791. /** @hidden */
  34792. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34793. /** @hidden */
  34794. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34795. dispose(): void;
  34796. private _disableTouchAction;
  34797. /**
  34798. * Display the loading screen
  34799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34800. */
  34801. displayLoadingUI(): void;
  34802. /**
  34803. * Hide the loading screen
  34804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34805. */
  34806. hideLoadingUI(): void;
  34807. /**
  34808. * Gets the current loading screen object
  34809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34810. */
  34811. get loadingScreen(): ILoadingScreen;
  34812. /**
  34813. * Sets the current loading screen object
  34814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34815. */
  34816. set loadingScreen(loadingScreen: ILoadingScreen);
  34817. /**
  34818. * Sets the current loading screen text
  34819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34820. */
  34821. set loadingUIText(text: string);
  34822. /**
  34823. * Sets the current loading screen background color
  34824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34825. */
  34826. set loadingUIBackgroundColor(color: string);
  34827. /** Pointerlock and fullscreen */
  34828. /**
  34829. * Ask the browser to promote the current element to pointerlock mode
  34830. * @param element defines the DOM element to promote
  34831. */
  34832. static _RequestPointerlock(element: HTMLElement): void;
  34833. /**
  34834. * Asks the browser to exit pointerlock mode
  34835. */
  34836. static _ExitPointerlock(): void;
  34837. /**
  34838. * Ask the browser to promote the current element to fullscreen rendering mode
  34839. * @param element defines the DOM element to promote
  34840. */
  34841. static _RequestFullscreen(element: HTMLElement): void;
  34842. /**
  34843. * Asks the browser to exit fullscreen mode
  34844. */
  34845. static _ExitFullscreen(): void;
  34846. }
  34847. }
  34848. declare module "babylonjs/Engines/engineStore" {
  34849. import { Nullable } from "babylonjs/types";
  34850. import { Engine } from "babylonjs/Engines/engine";
  34851. import { Scene } from "babylonjs/scene";
  34852. /**
  34853. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34854. * during the life time of the application.
  34855. */
  34856. export class EngineStore {
  34857. /** Gets the list of created engines */
  34858. static Instances: import("babylonjs/Engines/engine").Engine[];
  34859. /** @hidden */
  34860. static _LastCreatedScene: Nullable<Scene>;
  34861. /**
  34862. * Gets the latest created engine
  34863. */
  34864. static get LastCreatedEngine(): Nullable<Engine>;
  34865. /**
  34866. * Gets the latest created scene
  34867. */
  34868. static get LastCreatedScene(): Nullable<Scene>;
  34869. /**
  34870. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34871. * @ignorenaming
  34872. */
  34873. static UseFallbackTexture: boolean;
  34874. /**
  34875. * Texture content used if a texture cannot loaded
  34876. * @ignorenaming
  34877. */
  34878. static FallbackTexture: string;
  34879. }
  34880. }
  34881. declare module "babylonjs/Misc/promise" {
  34882. /**
  34883. * Helper class that provides a small promise polyfill
  34884. */
  34885. export class PromisePolyfill {
  34886. /**
  34887. * Static function used to check if the polyfill is required
  34888. * If this is the case then the function will inject the polyfill to window.Promise
  34889. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34890. */
  34891. static Apply(force?: boolean): void;
  34892. }
  34893. }
  34894. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34895. /**
  34896. * Interface for screenshot methods with describe argument called `size` as object with options
  34897. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34898. */
  34899. export interface IScreenshotSize {
  34900. /**
  34901. * number in pixels for canvas height
  34902. */
  34903. height?: number;
  34904. /**
  34905. * multiplier allowing render at a higher or lower resolution
  34906. * If value is defined then height and width will be ignored and taken from camera
  34907. */
  34908. precision?: number;
  34909. /**
  34910. * number in pixels for canvas width
  34911. */
  34912. width?: number;
  34913. }
  34914. }
  34915. declare module "babylonjs/Misc/tools" {
  34916. import { Nullable, float } from "babylonjs/types";
  34917. import { DomManagement } from "babylonjs/Misc/domManagement";
  34918. import { WebRequest } from "babylonjs/Misc/webRequest";
  34919. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34920. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34921. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34922. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34923. import { Camera } from "babylonjs/Cameras/camera";
  34924. import { Engine } from "babylonjs/Engines/engine";
  34925. interface IColor4Like {
  34926. r: float;
  34927. g: float;
  34928. b: float;
  34929. a: float;
  34930. }
  34931. /**
  34932. * Class containing a set of static utilities functions
  34933. */
  34934. export class Tools {
  34935. /**
  34936. * Gets or sets the base URL to use to load assets
  34937. */
  34938. static get BaseUrl(): string;
  34939. static set BaseUrl(value: string);
  34940. /**
  34941. * Enable/Disable Custom HTTP Request Headers globally.
  34942. * default = false
  34943. * @see CustomRequestHeaders
  34944. */
  34945. static UseCustomRequestHeaders: boolean;
  34946. /**
  34947. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34948. * i.e. when loading files, where the server/service expects an Authorization header
  34949. */
  34950. static CustomRequestHeaders: {
  34951. [key: string]: string;
  34952. };
  34953. /**
  34954. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34955. */
  34956. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34957. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34958. /**
  34959. * Default behaviour for cors in the application.
  34960. * It can be a string if the expected behavior is identical in the entire app.
  34961. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34962. */
  34963. static CorsBehavior: string | ((url: string | string[]) => string);
  34964. /**
  34965. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34966. * @ignorenaming
  34967. */
  34968. static get UseFallbackTexture(): boolean;
  34969. static set UseFallbackTexture(value: boolean);
  34970. /**
  34971. * Use this object to register external classes like custom textures or material
  34972. * to allow the laoders to instantiate them
  34973. */
  34974. static get RegisteredExternalClasses(): {
  34975. [key: string]: Object;
  34976. };
  34977. static set RegisteredExternalClasses(classes: {
  34978. [key: string]: Object;
  34979. });
  34980. /**
  34981. * Texture content used if a texture cannot loaded
  34982. * @ignorenaming
  34983. */
  34984. static get fallbackTexture(): string;
  34985. static set fallbackTexture(value: string);
  34986. /**
  34987. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34988. * @param u defines the coordinate on X axis
  34989. * @param v defines the coordinate on Y axis
  34990. * @param width defines the width of the source data
  34991. * @param height defines the height of the source data
  34992. * @param pixels defines the source byte array
  34993. * @param color defines the output color
  34994. */
  34995. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34996. /**
  34997. * Interpolates between a and b via alpha
  34998. * @param a The lower value (returned when alpha = 0)
  34999. * @param b The upper value (returned when alpha = 1)
  35000. * @param alpha The interpolation-factor
  35001. * @return The mixed value
  35002. */
  35003. static Mix(a: number, b: number, alpha: number): number;
  35004. /**
  35005. * Tries to instantiate a new object from a given class name
  35006. * @param className defines the class name to instantiate
  35007. * @returns the new object or null if the system was not able to do the instantiation
  35008. */
  35009. static Instantiate(className: string): any;
  35010. /**
  35011. * Provides a slice function that will work even on IE
  35012. * @param data defines the array to slice
  35013. * @param start defines the start of the data (optional)
  35014. * @param end defines the end of the data (optional)
  35015. * @returns the new sliced array
  35016. */
  35017. static Slice<T>(data: T, start?: number, end?: number): T;
  35018. /**
  35019. * Polyfill for setImmediate
  35020. * @param action defines the action to execute after the current execution block
  35021. */
  35022. static SetImmediate(action: () => void): void;
  35023. /**
  35024. * Function indicating if a number is an exponent of 2
  35025. * @param value defines the value to test
  35026. * @returns true if the value is an exponent of 2
  35027. */
  35028. static IsExponentOfTwo(value: number): boolean;
  35029. private static _tmpFloatArray;
  35030. /**
  35031. * Returns the nearest 32-bit single precision float representation of a Number
  35032. * @param value A Number. If the parameter is of a different type, it will get converted
  35033. * to a number or to NaN if it cannot be converted
  35034. * @returns number
  35035. */
  35036. static FloatRound(value: number): number;
  35037. /**
  35038. * Extracts the filename from a path
  35039. * @param path defines the path to use
  35040. * @returns the filename
  35041. */
  35042. static GetFilename(path: string): string;
  35043. /**
  35044. * Extracts the "folder" part of a path (everything before the filename).
  35045. * @param uri The URI to extract the info from
  35046. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35047. * @returns The "folder" part of the path
  35048. */
  35049. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35050. /**
  35051. * Extracts text content from a DOM element hierarchy
  35052. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35053. */
  35054. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35055. /**
  35056. * Convert an angle in radians to degrees
  35057. * @param angle defines the angle to convert
  35058. * @returns the angle in degrees
  35059. */
  35060. static ToDegrees(angle: number): number;
  35061. /**
  35062. * Convert an angle in degrees to radians
  35063. * @param angle defines the angle to convert
  35064. * @returns the angle in radians
  35065. */
  35066. static ToRadians(angle: number): number;
  35067. /**
  35068. * Returns an array if obj is not an array
  35069. * @param obj defines the object to evaluate as an array
  35070. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35071. * @returns either obj directly if obj is an array or a new array containing obj
  35072. */
  35073. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35074. /**
  35075. * Gets the pointer prefix to use
  35076. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35077. */
  35078. static GetPointerPrefix(): string;
  35079. /**
  35080. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35081. * @param url define the url we are trying
  35082. * @param element define the dom element where to configure the cors policy
  35083. */
  35084. static SetCorsBehavior(url: string | string[], element: {
  35085. crossOrigin: string | null;
  35086. }): void;
  35087. /**
  35088. * Removes unwanted characters from an url
  35089. * @param url defines the url to clean
  35090. * @returns the cleaned url
  35091. */
  35092. static CleanUrl(url: string): string;
  35093. /**
  35094. * Gets or sets a function used to pre-process url before using them to load assets
  35095. */
  35096. static get PreprocessUrl(): (url: string) => string;
  35097. static set PreprocessUrl(processor: (url: string) => string);
  35098. /**
  35099. * Loads an image as an HTMLImageElement.
  35100. * @param input url string, ArrayBuffer, or Blob to load
  35101. * @param onLoad callback called when the image successfully loads
  35102. * @param onError callback called when the image fails to load
  35103. * @param offlineProvider offline provider for caching
  35104. * @param mimeType optional mime type
  35105. * @returns the HTMLImageElement of the loaded image
  35106. */
  35107. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35108. /**
  35109. * Loads a file from a url
  35110. * @param url url string, ArrayBuffer, or Blob to load
  35111. * @param onSuccess callback called when the file successfully loads
  35112. * @param onProgress callback called while file is loading (if the server supports this mode)
  35113. * @param offlineProvider defines the offline provider for caching
  35114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35115. * @param onError callback called when the file fails to load
  35116. * @returns a file request object
  35117. */
  35118. 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;
  35119. /**
  35120. * Loads a file from a url
  35121. * @param url the file url to load
  35122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35123. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35124. */
  35125. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35126. /**
  35127. * Load a script (identified by an url). When the url returns, the
  35128. * content of this file is added into a new script element, attached to the DOM (body element)
  35129. * @param scriptUrl defines the url of the script to laod
  35130. * @param onSuccess defines the callback called when the script is loaded
  35131. * @param onError defines the callback to call if an error occurs
  35132. * @param scriptId defines the id of the script element
  35133. */
  35134. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35135. /**
  35136. * Load an asynchronous script (identified by an url). When the url returns, the
  35137. * content of this file is added into a new script element, attached to the DOM (body element)
  35138. * @param scriptUrl defines the url of the script to laod
  35139. * @param scriptId defines the id of the script element
  35140. * @returns a promise request object
  35141. */
  35142. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35143. /**
  35144. * Loads a file from a blob
  35145. * @param fileToLoad defines the blob to use
  35146. * @param callback defines the callback to call when data is loaded
  35147. * @param progressCallback defines the callback to call during loading process
  35148. * @returns a file request object
  35149. */
  35150. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35151. /**
  35152. * Reads a file from a File object
  35153. * @param file defines the file to load
  35154. * @param onSuccess defines the callback to call when data is loaded
  35155. * @param onProgress defines the callback to call during loading process
  35156. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35157. * @param onError defines the callback to call when an error occurs
  35158. * @returns a file request object
  35159. */
  35160. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35161. /**
  35162. * Creates a data url from a given string content
  35163. * @param content defines the content to convert
  35164. * @returns the new data url link
  35165. */
  35166. static FileAsURL(content: string): string;
  35167. /**
  35168. * Format the given number to a specific decimal format
  35169. * @param value defines the number to format
  35170. * @param decimals defines the number of decimals to use
  35171. * @returns the formatted string
  35172. */
  35173. static Format(value: number, decimals?: number): string;
  35174. /**
  35175. * Tries to copy an object by duplicating every property
  35176. * @param source defines the source object
  35177. * @param destination defines the target object
  35178. * @param doNotCopyList defines a list of properties to avoid
  35179. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35180. */
  35181. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35182. /**
  35183. * Gets a boolean indicating if the given object has no own property
  35184. * @param obj defines the object to test
  35185. * @returns true if object has no own property
  35186. */
  35187. static IsEmpty(obj: any): boolean;
  35188. /**
  35189. * Function used to register events at window level
  35190. * @param windowElement defines the Window object to use
  35191. * @param events defines the events to register
  35192. */
  35193. static RegisterTopRootEvents(windowElement: Window, events: {
  35194. name: string;
  35195. handler: Nullable<(e: FocusEvent) => any>;
  35196. }[]): void;
  35197. /**
  35198. * Function used to unregister events from window level
  35199. * @param windowElement defines the Window object to use
  35200. * @param events defines the events to unregister
  35201. */
  35202. static UnregisterTopRootEvents(windowElement: Window, events: {
  35203. name: string;
  35204. handler: Nullable<(e: FocusEvent) => any>;
  35205. }[]): void;
  35206. /**
  35207. * @ignore
  35208. */
  35209. static _ScreenshotCanvas: HTMLCanvasElement;
  35210. /**
  35211. * Dumps the current bound framebuffer
  35212. * @param width defines the rendering width
  35213. * @param height defines the rendering height
  35214. * @param engine defines the hosting engine
  35215. * @param successCallback defines the callback triggered once the data are available
  35216. * @param mimeType defines the mime type of the result
  35217. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35218. */
  35219. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35220. /**
  35221. * Converts the canvas data to blob.
  35222. * This acts as a polyfill for browsers not supporting the to blob function.
  35223. * @param canvas Defines the canvas to extract the data from
  35224. * @param successCallback Defines the callback triggered once the data are available
  35225. * @param mimeType Defines the mime type of the result
  35226. */
  35227. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35228. /**
  35229. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35230. * @param successCallback defines the callback triggered once the data are available
  35231. * @param mimeType defines the mime type of the result
  35232. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35233. */
  35234. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35235. /**
  35236. * Downloads a blob in the browser
  35237. * @param blob defines the blob to download
  35238. * @param fileName defines the name of the downloaded file
  35239. */
  35240. static Download(blob: Blob, fileName: string): void;
  35241. /**
  35242. * Captures a screenshot of the current rendering
  35243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35244. * @param engine defines the rendering engine
  35245. * @param camera defines the source camera
  35246. * @param size This parameter can be set to a single number or to an object with the
  35247. * following (optional) properties: precision, width, height. If a single number is passed,
  35248. * it will be used for both width and height. If an object is passed, the screenshot size
  35249. * will be derived from the parameters. The precision property is a multiplier allowing
  35250. * rendering at a higher or lower resolution
  35251. * @param successCallback defines the callback receives a single parameter which contains the
  35252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35253. * src parameter of an <img> to display it
  35254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35255. * Check your browser for supported MIME types
  35256. */
  35257. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35258. /**
  35259. * Captures a screenshot of the current rendering
  35260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35261. * @param engine defines the rendering engine
  35262. * @param camera defines the source camera
  35263. * @param size This parameter can be set to a single number or to an object with the
  35264. * following (optional) properties: precision, width, height. If a single number is passed,
  35265. * it will be used for both width and height. If an object is passed, the screenshot size
  35266. * will be derived from the parameters. The precision property is a multiplier allowing
  35267. * rendering at a higher or lower resolution
  35268. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35269. * Check your browser for supported MIME types
  35270. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35271. * to the src parameter of an <img> to display it
  35272. */
  35273. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35274. /**
  35275. * Generates an image screenshot from the specified camera.
  35276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35277. * @param engine The engine to use for rendering
  35278. * @param camera The camera to use for rendering
  35279. * @param size This parameter can be set to a single number or to an object with the
  35280. * following (optional) properties: precision, width, height. If a single number is passed,
  35281. * it will be used for both width and height. If an object is passed, the screenshot size
  35282. * will be derived from the parameters. The precision property is a multiplier allowing
  35283. * rendering at a higher or lower resolution
  35284. * @param successCallback The callback receives a single parameter which contains the
  35285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35286. * src parameter of an <img> to display it
  35287. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35288. * Check your browser for supported MIME types
  35289. * @param samples Texture samples (default: 1)
  35290. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35291. * @param fileName A name for for the downloaded file.
  35292. */
  35293. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35294. /**
  35295. * Generates an image screenshot from the specified camera.
  35296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35297. * @param engine The engine to use for rendering
  35298. * @param camera The camera to use for rendering
  35299. * @param size This parameter can be set to a single number or to an object with the
  35300. * following (optional) properties: precision, width, height. If a single number is passed,
  35301. * it will be used for both width and height. If an object is passed, the screenshot size
  35302. * will be derived from the parameters. The precision property is a multiplier allowing
  35303. * rendering at a higher or lower resolution
  35304. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35305. * Check your browser for supported MIME types
  35306. * @param samples Texture samples (default: 1)
  35307. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35308. * @param fileName A name for for the downloaded file.
  35309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35310. * to the src parameter of an <img> to display it
  35311. */
  35312. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35313. /**
  35314. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35315. * Be aware Math.random() could cause collisions, but:
  35316. * "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"
  35317. * @returns a pseudo random id
  35318. */
  35319. static RandomId(): string;
  35320. /**
  35321. * Test if the given uri is a base64 string
  35322. * @param uri The uri to test
  35323. * @return True if the uri is a base64 string or false otherwise
  35324. */
  35325. static IsBase64(uri: string): boolean;
  35326. /**
  35327. * Decode the given base64 uri.
  35328. * @param uri The uri to decode
  35329. * @return The decoded base64 data.
  35330. */
  35331. static DecodeBase64(uri: string): ArrayBuffer;
  35332. /**
  35333. * Gets the absolute url.
  35334. * @param url the input url
  35335. * @return the absolute url
  35336. */
  35337. static GetAbsoluteUrl(url: string): string;
  35338. /**
  35339. * No log
  35340. */
  35341. static readonly NoneLogLevel: number;
  35342. /**
  35343. * Only message logs
  35344. */
  35345. static readonly MessageLogLevel: number;
  35346. /**
  35347. * Only warning logs
  35348. */
  35349. static readonly WarningLogLevel: number;
  35350. /**
  35351. * Only error logs
  35352. */
  35353. static readonly ErrorLogLevel: number;
  35354. /**
  35355. * All logs
  35356. */
  35357. static readonly AllLogLevel: number;
  35358. /**
  35359. * Gets a value indicating the number of loading errors
  35360. * @ignorenaming
  35361. */
  35362. static get errorsCount(): number;
  35363. /**
  35364. * Callback called when a new log is added
  35365. */
  35366. static OnNewCacheEntry: (entry: string) => void;
  35367. /**
  35368. * Log a message to the console
  35369. * @param message defines the message to log
  35370. */
  35371. static Log(message: string): void;
  35372. /**
  35373. * Write a warning message to the console
  35374. * @param message defines the message to log
  35375. */
  35376. static Warn(message: string): void;
  35377. /**
  35378. * Write an error message to the console
  35379. * @param message defines the message to log
  35380. */
  35381. static Error(message: string): void;
  35382. /**
  35383. * Gets current log cache (list of logs)
  35384. */
  35385. static get LogCache(): string;
  35386. /**
  35387. * Clears the log cache
  35388. */
  35389. static ClearLogCache(): void;
  35390. /**
  35391. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35392. */
  35393. static set LogLevels(level: number);
  35394. /**
  35395. * Checks if the window object exists
  35396. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35397. */
  35398. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35399. /**
  35400. * No performance log
  35401. */
  35402. static readonly PerformanceNoneLogLevel: number;
  35403. /**
  35404. * Use user marks to log performance
  35405. */
  35406. static readonly PerformanceUserMarkLogLevel: number;
  35407. /**
  35408. * Log performance to the console
  35409. */
  35410. static readonly PerformanceConsoleLogLevel: number;
  35411. private static _performance;
  35412. /**
  35413. * Sets the current performance log level
  35414. */
  35415. static set PerformanceLogLevel(level: number);
  35416. private static _StartPerformanceCounterDisabled;
  35417. private static _EndPerformanceCounterDisabled;
  35418. private static _StartUserMark;
  35419. private static _EndUserMark;
  35420. private static _StartPerformanceConsole;
  35421. private static _EndPerformanceConsole;
  35422. /**
  35423. * Starts a performance counter
  35424. */
  35425. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35426. /**
  35427. * Ends a specific performance coutner
  35428. */
  35429. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35430. /**
  35431. * Gets either window.performance.now() if supported or Date.now() else
  35432. */
  35433. static get Now(): number;
  35434. /**
  35435. * This method will return the name of the class used to create the instance of the given object.
  35436. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35437. * @param object the object to get the class name from
  35438. * @param isType defines if the object is actually a type
  35439. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35440. */
  35441. static GetClassName(object: any, isType?: boolean): string;
  35442. /**
  35443. * Gets the first element of an array satisfying a given predicate
  35444. * @param array defines the array to browse
  35445. * @param predicate defines the predicate to use
  35446. * @returns null if not found or the element
  35447. */
  35448. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35449. /**
  35450. * This method will return the name of the full name of the class, including its owning module (if any).
  35451. * 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).
  35452. * @param object the object to get the class name from
  35453. * @param isType defines if the object is actually a type
  35454. * @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.
  35455. * @ignorenaming
  35456. */
  35457. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35458. /**
  35459. * Returns a promise that resolves after the given amount of time.
  35460. * @param delay Number of milliseconds to delay
  35461. * @returns Promise that resolves after the given amount of time
  35462. */
  35463. static DelayAsync(delay: number): Promise<void>;
  35464. /**
  35465. * Utility function to detect if the current user agent is Safari
  35466. * @returns whether or not the current user agent is safari
  35467. */
  35468. static IsSafari(): boolean;
  35469. }
  35470. /**
  35471. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35472. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35473. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35474. * @param name The name of the class, case should be preserved
  35475. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35476. */
  35477. export function className(name: string, module?: string): (target: Object) => void;
  35478. /**
  35479. * An implementation of a loop for asynchronous functions.
  35480. */
  35481. export class AsyncLoop {
  35482. /**
  35483. * Defines the number of iterations for the loop
  35484. */
  35485. iterations: number;
  35486. /**
  35487. * Defines the current index of the loop.
  35488. */
  35489. index: number;
  35490. private _done;
  35491. private _fn;
  35492. private _successCallback;
  35493. /**
  35494. * Constructor.
  35495. * @param iterations the number of iterations.
  35496. * @param func the function to run each iteration
  35497. * @param successCallback the callback that will be called upon succesful execution
  35498. * @param offset starting offset.
  35499. */
  35500. constructor(
  35501. /**
  35502. * Defines the number of iterations for the loop
  35503. */
  35504. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35505. /**
  35506. * Execute the next iteration. Must be called after the last iteration was finished.
  35507. */
  35508. executeNext(): void;
  35509. /**
  35510. * Break the loop and run the success callback.
  35511. */
  35512. breakLoop(): void;
  35513. /**
  35514. * Create and run an async loop.
  35515. * @param iterations the number of iterations.
  35516. * @param fn the function to run each iteration
  35517. * @param successCallback the callback that will be called upon succesful execution
  35518. * @param offset starting offset.
  35519. * @returns the created async loop object
  35520. */
  35521. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35522. /**
  35523. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35524. * @param iterations total number of iterations
  35525. * @param syncedIterations number of synchronous iterations in each async iteration.
  35526. * @param fn the function to call each iteration.
  35527. * @param callback a success call back that will be called when iterating stops.
  35528. * @param breakFunction a break condition (optional)
  35529. * @param timeout timeout settings for the setTimeout function. default - 0.
  35530. * @returns the created async loop object
  35531. */
  35532. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35533. }
  35534. }
  35535. declare module "babylonjs/Misc/stringDictionary" {
  35536. import { Nullable } from "babylonjs/types";
  35537. /**
  35538. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35539. * The underlying implementation relies on an associative array to ensure the best performances.
  35540. * The value can be anything including 'null' but except 'undefined'
  35541. */
  35542. export class StringDictionary<T> {
  35543. /**
  35544. * This will clear this dictionary and copy the content from the 'source' one.
  35545. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35546. * @param source the dictionary to take the content from and copy to this dictionary
  35547. */
  35548. copyFrom(source: StringDictionary<T>): void;
  35549. /**
  35550. * Get a value based from its key
  35551. * @param key the given key to get the matching value from
  35552. * @return the value if found, otherwise undefined is returned
  35553. */
  35554. get(key: string): T | undefined;
  35555. /**
  35556. * Get a value from its key or add it if it doesn't exist.
  35557. * This method will ensure you that a given key/data will be present in the dictionary.
  35558. * @param key the given key to get the matching value from
  35559. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35560. * The factory will only be invoked if there's no data for the given key.
  35561. * @return the value corresponding to the key.
  35562. */
  35563. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35564. /**
  35565. * Get a value from its key if present in the dictionary otherwise add it
  35566. * @param key the key to get the value from
  35567. * @param val if there's no such key/value pair in the dictionary add it with this value
  35568. * @return the value corresponding to the key
  35569. */
  35570. getOrAdd(key: string, val: T): T;
  35571. /**
  35572. * Check if there's a given key in the dictionary
  35573. * @param key the key to check for
  35574. * @return true if the key is present, false otherwise
  35575. */
  35576. contains(key: string): boolean;
  35577. /**
  35578. * Add a new key and its corresponding value
  35579. * @param key the key to add
  35580. * @param value the value corresponding to the key
  35581. * @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
  35582. */
  35583. add(key: string, value: T): boolean;
  35584. /**
  35585. * Update a specific value associated to a key
  35586. * @param key defines the key to use
  35587. * @param value defines the value to store
  35588. * @returns true if the value was updated (or false if the key was not found)
  35589. */
  35590. set(key: string, value: T): boolean;
  35591. /**
  35592. * Get the element of the given key and remove it from the dictionary
  35593. * @param key defines the key to search
  35594. * @returns the value associated with the key or null if not found
  35595. */
  35596. getAndRemove(key: string): Nullable<T>;
  35597. /**
  35598. * Remove a key/value from the dictionary.
  35599. * @param key the key to remove
  35600. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35601. */
  35602. remove(key: string): boolean;
  35603. /**
  35604. * Clear the whole content of the dictionary
  35605. */
  35606. clear(): void;
  35607. /**
  35608. * Gets the current count
  35609. */
  35610. get count(): number;
  35611. /**
  35612. * Execute a callback on each key/val of the dictionary.
  35613. * Note that you can remove any element in this dictionary in the callback implementation
  35614. * @param callback the callback to execute on a given key/value pair
  35615. */
  35616. forEach(callback: (key: string, val: T) => void): void;
  35617. /**
  35618. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35619. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35620. * Note that you can remove any element in this dictionary in the callback implementation
  35621. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35622. * @returns the first item
  35623. */
  35624. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35625. private _count;
  35626. private _data;
  35627. }
  35628. }
  35629. declare module "babylonjs/Collisions/collisionCoordinator" {
  35630. import { Nullable } from "babylonjs/types";
  35631. import { Scene } from "babylonjs/scene";
  35632. import { Vector3 } from "babylonjs/Maths/math.vector";
  35633. import { Collider } from "babylonjs/Collisions/collider";
  35634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35635. /** @hidden */
  35636. export interface ICollisionCoordinator {
  35637. createCollider(): Collider;
  35638. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35639. init(scene: Scene): void;
  35640. }
  35641. /** @hidden */
  35642. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35643. private _scene;
  35644. private _scaledPosition;
  35645. private _scaledVelocity;
  35646. private _finalPosition;
  35647. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35648. createCollider(): Collider;
  35649. init(scene: Scene): void;
  35650. private _collideWithWorld;
  35651. }
  35652. }
  35653. declare module "babylonjs/Inputs/scene.inputManager" {
  35654. import { Nullable } from "babylonjs/types";
  35655. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35656. import { Vector2 } from "babylonjs/Maths/math.vector";
  35657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35658. import { Scene } from "babylonjs/scene";
  35659. /**
  35660. * Class used to manage all inputs for the scene.
  35661. */
  35662. export class InputManager {
  35663. /** The distance in pixel that you have to move to prevent some events */
  35664. static DragMovementThreshold: number;
  35665. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35666. static LongPressDelay: number;
  35667. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35668. static DoubleClickDelay: number;
  35669. /** If you need to check double click without raising a single click at first click, enable this flag */
  35670. static ExclusiveDoubleClickMode: boolean;
  35671. private _wheelEventName;
  35672. private _onPointerMove;
  35673. private _onPointerDown;
  35674. private _onPointerUp;
  35675. private _initClickEvent;
  35676. private _initActionManager;
  35677. private _delayedSimpleClick;
  35678. private _delayedSimpleClickTimeout;
  35679. private _previousDelayedSimpleClickTimeout;
  35680. private _meshPickProceed;
  35681. private _previousButtonPressed;
  35682. private _currentPickResult;
  35683. private _previousPickResult;
  35684. private _totalPointersPressed;
  35685. private _doubleClickOccured;
  35686. private _pointerOverMesh;
  35687. private _pickedDownMesh;
  35688. private _pickedUpMesh;
  35689. private _pointerX;
  35690. private _pointerY;
  35691. private _unTranslatedPointerX;
  35692. private _unTranslatedPointerY;
  35693. private _startingPointerPosition;
  35694. private _previousStartingPointerPosition;
  35695. private _startingPointerTime;
  35696. private _previousStartingPointerTime;
  35697. private _pointerCaptures;
  35698. private _onKeyDown;
  35699. private _onKeyUp;
  35700. private _onCanvasFocusObserver;
  35701. private _onCanvasBlurObserver;
  35702. private _scene;
  35703. /**
  35704. * Creates a new InputManager
  35705. * @param scene defines the hosting scene
  35706. */
  35707. constructor(scene: Scene);
  35708. /**
  35709. * Gets the mesh that is currently under the pointer
  35710. */
  35711. get meshUnderPointer(): Nullable<AbstractMesh>;
  35712. /**
  35713. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35714. */
  35715. get unTranslatedPointer(): Vector2;
  35716. /**
  35717. * Gets or sets the current on-screen X position of the pointer
  35718. */
  35719. get pointerX(): number;
  35720. set pointerX(value: number);
  35721. /**
  35722. * Gets or sets the current on-screen Y position of the pointer
  35723. */
  35724. get pointerY(): number;
  35725. set pointerY(value: number);
  35726. private _updatePointerPosition;
  35727. private _processPointerMove;
  35728. private _setRayOnPointerInfo;
  35729. private _checkPrePointerObservable;
  35730. /**
  35731. * Use this method to simulate a pointer move on a mesh
  35732. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35733. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35734. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35735. */
  35736. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35737. /**
  35738. * Use this method to simulate a pointer down on a mesh
  35739. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35740. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35741. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35742. */
  35743. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35744. private _processPointerDown;
  35745. /** @hidden */
  35746. _isPointerSwiping(): boolean;
  35747. /**
  35748. * Use this method to simulate a pointer up on a mesh
  35749. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35750. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35751. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35752. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35753. */
  35754. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35755. private _processPointerUp;
  35756. /**
  35757. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35758. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35759. * @returns true if the pointer was captured
  35760. */
  35761. isPointerCaptured(pointerId?: number): boolean;
  35762. /**
  35763. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35764. * @param attachUp defines if you want to attach events to pointerup
  35765. * @param attachDown defines if you want to attach events to pointerdown
  35766. * @param attachMove defines if you want to attach events to pointermove
  35767. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35768. */
  35769. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35770. /**
  35771. * Detaches all event handlers
  35772. */
  35773. detachControl(): void;
  35774. /**
  35775. * Force the value of meshUnderPointer
  35776. * @param mesh defines the mesh to use
  35777. */
  35778. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35779. /**
  35780. * Gets the mesh under the pointer
  35781. * @returns a Mesh or null if no mesh is under the pointer
  35782. */
  35783. getPointerOverMesh(): Nullable<AbstractMesh>;
  35784. }
  35785. }
  35786. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35787. /**
  35788. * Helper class used to generate session unique ID
  35789. */
  35790. export class UniqueIdGenerator {
  35791. private static _UniqueIdCounter;
  35792. /**
  35793. * Gets an unique (relatively to the current scene) Id
  35794. */
  35795. static get UniqueId(): number;
  35796. }
  35797. }
  35798. declare module "babylonjs/Animations/animationGroup" {
  35799. import { Animatable } from "babylonjs/Animations/animatable";
  35800. import { Animation } from "babylonjs/Animations/animation";
  35801. import { Scene, IDisposable } from "babylonjs/scene";
  35802. import { Observable } from "babylonjs/Misc/observable";
  35803. import { Nullable } from "babylonjs/types";
  35804. import "babylonjs/Animations/animatable";
  35805. /**
  35806. * This class defines the direct association between an animation and a target
  35807. */
  35808. export class TargetedAnimation {
  35809. /**
  35810. * Animation to perform
  35811. */
  35812. animation: Animation;
  35813. /**
  35814. * Target to animate
  35815. */
  35816. target: any;
  35817. /**
  35818. * Serialize the object
  35819. * @returns the JSON object representing the current entity
  35820. */
  35821. serialize(): any;
  35822. }
  35823. /**
  35824. * Use this class to create coordinated animations on multiple targets
  35825. */
  35826. export class AnimationGroup implements IDisposable {
  35827. /** The name of the animation group */
  35828. name: string;
  35829. private _scene;
  35830. private _targetedAnimations;
  35831. private _animatables;
  35832. private _from;
  35833. private _to;
  35834. private _isStarted;
  35835. private _isPaused;
  35836. private _speedRatio;
  35837. private _loopAnimation;
  35838. /**
  35839. * Gets or sets the unique id of the node
  35840. */
  35841. uniqueId: number;
  35842. /**
  35843. * This observable will notify when one animation have ended
  35844. */
  35845. onAnimationEndObservable: Observable<TargetedAnimation>;
  35846. /**
  35847. * Observer raised when one animation loops
  35848. */
  35849. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35850. /**
  35851. * Observer raised when all animations have looped
  35852. */
  35853. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35854. /**
  35855. * This observable will notify when all animations have ended.
  35856. */
  35857. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35858. /**
  35859. * This observable will notify when all animations have paused.
  35860. */
  35861. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35862. /**
  35863. * This observable will notify when all animations are playing.
  35864. */
  35865. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35866. /**
  35867. * Gets the first frame
  35868. */
  35869. get from(): number;
  35870. /**
  35871. * Gets the last frame
  35872. */
  35873. get to(): number;
  35874. /**
  35875. * Define if the animations are started
  35876. */
  35877. get isStarted(): boolean;
  35878. /**
  35879. * Gets a value indicating that the current group is playing
  35880. */
  35881. get isPlaying(): boolean;
  35882. /**
  35883. * Gets or sets the speed ratio to use for all animations
  35884. */
  35885. get speedRatio(): number;
  35886. /**
  35887. * Gets or sets the speed ratio to use for all animations
  35888. */
  35889. set speedRatio(value: number);
  35890. /**
  35891. * Gets or sets if all animations should loop or not
  35892. */
  35893. get loopAnimation(): boolean;
  35894. set loopAnimation(value: boolean);
  35895. /**
  35896. * Gets the targeted animations for this animation group
  35897. */
  35898. get targetedAnimations(): Array<TargetedAnimation>;
  35899. /**
  35900. * returning the list of animatables controlled by this animation group.
  35901. */
  35902. get animatables(): Array<Animatable>;
  35903. /**
  35904. * Instantiates a new Animation Group.
  35905. * This helps managing several animations at once.
  35906. * @see http://doc.babylonjs.com/how_to/group
  35907. * @param name Defines the name of the group
  35908. * @param scene Defines the scene the group belongs to
  35909. */
  35910. constructor(
  35911. /** The name of the animation group */
  35912. name: string, scene?: Nullable<Scene>);
  35913. /**
  35914. * Add an animation (with its target) in the group
  35915. * @param animation defines the animation we want to add
  35916. * @param target defines the target of the animation
  35917. * @returns the TargetedAnimation object
  35918. */
  35919. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35920. /**
  35921. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35922. * It can add constant keys at begin or end
  35923. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35924. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35925. * @returns the animation group
  35926. */
  35927. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35928. private _animationLoopCount;
  35929. private _animationLoopFlags;
  35930. private _processLoop;
  35931. /**
  35932. * Start all animations on given targets
  35933. * @param loop defines if animations must loop
  35934. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35935. * @param from defines the from key (optional)
  35936. * @param to defines the to key (optional)
  35937. * @returns the current animation group
  35938. */
  35939. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35940. /**
  35941. * Pause all animations
  35942. * @returns the animation group
  35943. */
  35944. pause(): AnimationGroup;
  35945. /**
  35946. * Play all animations to initial state
  35947. * This function will start() the animations if they were not started or will restart() them if they were paused
  35948. * @param loop defines if animations must loop
  35949. * @returns the animation group
  35950. */
  35951. play(loop?: boolean): AnimationGroup;
  35952. /**
  35953. * Reset all animations to initial state
  35954. * @returns the animation group
  35955. */
  35956. reset(): AnimationGroup;
  35957. /**
  35958. * Restart animations from key 0
  35959. * @returns the animation group
  35960. */
  35961. restart(): AnimationGroup;
  35962. /**
  35963. * Stop all animations
  35964. * @returns the animation group
  35965. */
  35966. stop(): AnimationGroup;
  35967. /**
  35968. * Set animation weight for all animatables
  35969. * @param weight defines the weight to use
  35970. * @return the animationGroup
  35971. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35972. */
  35973. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35974. /**
  35975. * Synchronize and normalize all animatables with a source animatable
  35976. * @param root defines the root animatable to synchronize with
  35977. * @return the animationGroup
  35978. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35979. */
  35980. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35981. /**
  35982. * Goes to a specific frame in this animation group
  35983. * @param frame the frame number to go to
  35984. * @return the animationGroup
  35985. */
  35986. goToFrame(frame: number): AnimationGroup;
  35987. /**
  35988. * Dispose all associated resources
  35989. */
  35990. dispose(): void;
  35991. private _checkAnimationGroupEnded;
  35992. /**
  35993. * Clone the current animation group and returns a copy
  35994. * @param newName defines the name of the new group
  35995. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35996. * @returns the new aniamtion group
  35997. */
  35998. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35999. /**
  36000. * Serializes the animationGroup to an object
  36001. * @returns Serialized object
  36002. */
  36003. serialize(): any;
  36004. /**
  36005. * Returns a new AnimationGroup object parsed from the source provided.
  36006. * @param parsedAnimationGroup defines the source
  36007. * @param scene defines the scene that will receive the animationGroup
  36008. * @returns a new AnimationGroup
  36009. */
  36010. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36011. /**
  36012. * Returns the string "AnimationGroup"
  36013. * @returns "AnimationGroup"
  36014. */
  36015. getClassName(): string;
  36016. /**
  36017. * Creates a detailled string about the object
  36018. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36019. * @returns a string representing the object
  36020. */
  36021. toString(fullDetails?: boolean): string;
  36022. }
  36023. }
  36024. declare module "babylonjs/scene" {
  36025. import { Nullable } from "babylonjs/types";
  36026. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36027. import { Observable } from "babylonjs/Misc/observable";
  36028. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36029. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36030. import { Geometry } from "babylonjs/Meshes/geometry";
  36031. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36034. import { Mesh } from "babylonjs/Meshes/mesh";
  36035. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36036. import { Bone } from "babylonjs/Bones/bone";
  36037. import { Skeleton } from "babylonjs/Bones/skeleton";
  36038. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36039. import { Camera } from "babylonjs/Cameras/camera";
  36040. import { AbstractScene } from "babylonjs/abstractScene";
  36041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36042. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36043. import { Material } from "babylonjs/Materials/material";
  36044. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36045. import { Effect } from "babylonjs/Materials/effect";
  36046. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36047. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36048. import { Light } from "babylonjs/Lights/light";
  36049. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36050. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36051. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36052. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36053. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36054. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36055. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36056. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36057. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36058. import { Engine } from "babylonjs/Engines/engine";
  36059. import { Node } from "babylonjs/node";
  36060. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36061. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36062. import { WebRequest } from "babylonjs/Misc/webRequest";
  36063. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36064. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36065. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36066. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36067. import { Plane } from "babylonjs/Maths/math.plane";
  36068. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36069. import { Ray } from "babylonjs/Culling/ray";
  36070. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36071. import { Animation } from "babylonjs/Animations/animation";
  36072. import { Animatable } from "babylonjs/Animations/animatable";
  36073. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36074. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36075. import { Collider } from "babylonjs/Collisions/collider";
  36076. /**
  36077. * Define an interface for all classes that will hold resources
  36078. */
  36079. export interface IDisposable {
  36080. /**
  36081. * Releases all held resources
  36082. */
  36083. dispose(): void;
  36084. }
  36085. /** Interface defining initialization parameters for Scene class */
  36086. export interface SceneOptions {
  36087. /**
  36088. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36089. * It will improve performance when the number of geometries becomes important.
  36090. */
  36091. useGeometryUniqueIdsMap?: boolean;
  36092. /**
  36093. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36094. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36095. */
  36096. useMaterialMeshMap?: boolean;
  36097. /**
  36098. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36099. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36100. */
  36101. useClonedMeshMap?: boolean;
  36102. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36103. virtual?: boolean;
  36104. }
  36105. /**
  36106. * Represents a scene to be rendered by the engine.
  36107. * @see http://doc.babylonjs.com/features/scene
  36108. */
  36109. export class Scene extends AbstractScene implements IAnimatable {
  36110. /** The fog is deactivated */
  36111. static readonly FOGMODE_NONE: number;
  36112. /** The fog density is following an exponential function */
  36113. static readonly FOGMODE_EXP: number;
  36114. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36115. static readonly FOGMODE_EXP2: number;
  36116. /** The fog density is following a linear function. */
  36117. static readonly FOGMODE_LINEAR: number;
  36118. /**
  36119. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36121. */
  36122. static MinDeltaTime: number;
  36123. /**
  36124. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36126. */
  36127. static MaxDeltaTime: number;
  36128. /**
  36129. * Factory used to create the default material.
  36130. * @param name The name of the material to create
  36131. * @param scene The scene to create the material for
  36132. * @returns The default material
  36133. */
  36134. static DefaultMaterialFactory(scene: Scene): Material;
  36135. /**
  36136. * Factory used to create the a collision coordinator.
  36137. * @returns The collision coordinator
  36138. */
  36139. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36140. /** @hidden */
  36141. _inputManager: InputManager;
  36142. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36143. cameraToUseForPointers: Nullable<Camera>;
  36144. /** @hidden */
  36145. readonly _isScene: boolean;
  36146. /** @hidden */
  36147. _blockEntityCollection: boolean;
  36148. /**
  36149. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36150. */
  36151. autoClear: boolean;
  36152. /**
  36153. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36154. */
  36155. autoClearDepthAndStencil: boolean;
  36156. /**
  36157. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36158. */
  36159. clearColor: Color4;
  36160. /**
  36161. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36162. */
  36163. ambientColor: Color3;
  36164. /**
  36165. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36166. * It should only be one of the following (if not the default embedded one):
  36167. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36168. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36169. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36170. * The material properties need to be setup according to the type of texture in use.
  36171. */
  36172. environmentBRDFTexture: BaseTexture;
  36173. /** @hidden */
  36174. protected _environmentTexture: Nullable<BaseTexture>;
  36175. /**
  36176. * Texture used in all pbr material as the reflection texture.
  36177. * As in the majority of the scene they are the same (exception for multi room and so on),
  36178. * this is easier to reference from here than from all the materials.
  36179. */
  36180. get environmentTexture(): Nullable<BaseTexture>;
  36181. /**
  36182. * Texture used in all pbr material as the reflection texture.
  36183. * As in the majority of the scene they are the same (exception for multi room and so on),
  36184. * this is easier to set here than in all the materials.
  36185. */
  36186. set environmentTexture(value: Nullable<BaseTexture>);
  36187. /** @hidden */
  36188. protected _environmentIntensity: number;
  36189. /**
  36190. * Intensity of the environment in all pbr material.
  36191. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36192. * As in the majority of the scene they are the same (exception for multi room and so on),
  36193. * this is easier to reference from here than from all the materials.
  36194. */
  36195. get environmentIntensity(): number;
  36196. /**
  36197. * Intensity of the environment in all pbr material.
  36198. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36199. * As in the majority of the scene they are the same (exception for multi room and so on),
  36200. * this is easier to set here than in all the materials.
  36201. */
  36202. set environmentIntensity(value: number);
  36203. /** @hidden */
  36204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36205. /**
  36206. * Default image processing configuration used either in the rendering
  36207. * Forward main pass or through the imageProcessingPostProcess if present.
  36208. * As in the majority of the scene they are the same (exception for multi camera),
  36209. * this is easier to reference from here than from all the materials and post process.
  36210. *
  36211. * No setter as we it is a shared configuration, you can set the values instead.
  36212. */
  36213. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36214. private _forceWireframe;
  36215. /**
  36216. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36217. */
  36218. set forceWireframe(value: boolean);
  36219. get forceWireframe(): boolean;
  36220. private _skipFrustumClipping;
  36221. /**
  36222. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36223. */
  36224. set skipFrustumClipping(value: boolean);
  36225. get skipFrustumClipping(): boolean;
  36226. private _forcePointsCloud;
  36227. /**
  36228. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36229. */
  36230. set forcePointsCloud(value: boolean);
  36231. get forcePointsCloud(): boolean;
  36232. /**
  36233. * Gets or sets the active clipplane 1
  36234. */
  36235. clipPlane: Nullable<Plane>;
  36236. /**
  36237. * Gets or sets the active clipplane 2
  36238. */
  36239. clipPlane2: Nullable<Plane>;
  36240. /**
  36241. * Gets or sets the active clipplane 3
  36242. */
  36243. clipPlane3: Nullable<Plane>;
  36244. /**
  36245. * Gets or sets the active clipplane 4
  36246. */
  36247. clipPlane4: Nullable<Plane>;
  36248. /**
  36249. * Gets or sets the active clipplane 5
  36250. */
  36251. clipPlane5: Nullable<Plane>;
  36252. /**
  36253. * Gets or sets the active clipplane 6
  36254. */
  36255. clipPlane6: Nullable<Plane>;
  36256. /**
  36257. * Gets or sets a boolean indicating if animations are enabled
  36258. */
  36259. animationsEnabled: boolean;
  36260. private _animationPropertiesOverride;
  36261. /**
  36262. * Gets or sets the animation properties override
  36263. */
  36264. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36265. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36266. /**
  36267. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36268. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36269. */
  36270. useConstantAnimationDeltaTime: boolean;
  36271. /**
  36272. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36273. * Please note that it requires to run a ray cast through the scene on every frame
  36274. */
  36275. constantlyUpdateMeshUnderPointer: boolean;
  36276. /**
  36277. * Defines the HTML cursor to use when hovering over interactive elements
  36278. */
  36279. hoverCursor: string;
  36280. /**
  36281. * Defines the HTML default cursor to use (empty by default)
  36282. */
  36283. defaultCursor: string;
  36284. /**
  36285. * Defines whether cursors are handled by the scene.
  36286. */
  36287. doNotHandleCursors: boolean;
  36288. /**
  36289. * This is used to call preventDefault() on pointer down
  36290. * in order to block unwanted artifacts like system double clicks
  36291. */
  36292. preventDefaultOnPointerDown: boolean;
  36293. /**
  36294. * This is used to call preventDefault() on pointer up
  36295. * in order to block unwanted artifacts like system double clicks
  36296. */
  36297. preventDefaultOnPointerUp: boolean;
  36298. /**
  36299. * Gets or sets user defined metadata
  36300. */
  36301. metadata: any;
  36302. /**
  36303. * For internal use only. Please do not use.
  36304. */
  36305. reservedDataStore: any;
  36306. /**
  36307. * Gets the name of the plugin used to load this scene (null by default)
  36308. */
  36309. loadingPluginName: string;
  36310. /**
  36311. * Use this array to add regular expressions used to disable offline support for specific urls
  36312. */
  36313. disableOfflineSupportExceptionRules: RegExp[];
  36314. /**
  36315. * An event triggered when the scene is disposed.
  36316. */
  36317. onDisposeObservable: Observable<Scene>;
  36318. private _onDisposeObserver;
  36319. /** Sets a function to be executed when this scene is disposed. */
  36320. set onDispose(callback: () => void);
  36321. /**
  36322. * An event triggered before rendering the scene (right after animations and physics)
  36323. */
  36324. onBeforeRenderObservable: Observable<Scene>;
  36325. private _onBeforeRenderObserver;
  36326. /** Sets a function to be executed before rendering this scene */
  36327. set beforeRender(callback: Nullable<() => void>);
  36328. /**
  36329. * An event triggered after rendering the scene
  36330. */
  36331. onAfterRenderObservable: Observable<Scene>;
  36332. /**
  36333. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36334. */
  36335. onAfterRenderCameraObservable: Observable<Camera>;
  36336. private _onAfterRenderObserver;
  36337. /** Sets a function to be executed after rendering this scene */
  36338. set afterRender(callback: Nullable<() => void>);
  36339. /**
  36340. * An event triggered before animating the scene
  36341. */
  36342. onBeforeAnimationsObservable: Observable<Scene>;
  36343. /**
  36344. * An event triggered after animations processing
  36345. */
  36346. onAfterAnimationsObservable: Observable<Scene>;
  36347. /**
  36348. * An event triggered before draw calls are ready to be sent
  36349. */
  36350. onBeforeDrawPhaseObservable: Observable<Scene>;
  36351. /**
  36352. * An event triggered after draw calls have been sent
  36353. */
  36354. onAfterDrawPhaseObservable: Observable<Scene>;
  36355. /**
  36356. * An event triggered when the scene is ready
  36357. */
  36358. onReadyObservable: Observable<Scene>;
  36359. /**
  36360. * An event triggered before rendering a camera
  36361. */
  36362. onBeforeCameraRenderObservable: Observable<Camera>;
  36363. private _onBeforeCameraRenderObserver;
  36364. /** Sets a function to be executed before rendering a camera*/
  36365. set beforeCameraRender(callback: () => void);
  36366. /**
  36367. * An event triggered after rendering a camera
  36368. */
  36369. onAfterCameraRenderObservable: Observable<Camera>;
  36370. private _onAfterCameraRenderObserver;
  36371. /** Sets a function to be executed after rendering a camera*/
  36372. set afterCameraRender(callback: () => void);
  36373. /**
  36374. * An event triggered when active meshes evaluation is about to start
  36375. */
  36376. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36377. /**
  36378. * An event triggered when active meshes evaluation is done
  36379. */
  36380. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36381. /**
  36382. * An event triggered when particles rendering is about to start
  36383. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36384. */
  36385. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36386. /**
  36387. * An event triggered when particles rendering is done
  36388. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36389. */
  36390. onAfterParticlesRenderingObservable: Observable<Scene>;
  36391. /**
  36392. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36393. */
  36394. onDataLoadedObservable: Observable<Scene>;
  36395. /**
  36396. * An event triggered when a camera is created
  36397. */
  36398. onNewCameraAddedObservable: Observable<Camera>;
  36399. /**
  36400. * An event triggered when a camera is removed
  36401. */
  36402. onCameraRemovedObservable: Observable<Camera>;
  36403. /**
  36404. * An event triggered when a light is created
  36405. */
  36406. onNewLightAddedObservable: Observable<Light>;
  36407. /**
  36408. * An event triggered when a light is removed
  36409. */
  36410. onLightRemovedObservable: Observable<Light>;
  36411. /**
  36412. * An event triggered when a geometry is created
  36413. */
  36414. onNewGeometryAddedObservable: Observable<Geometry>;
  36415. /**
  36416. * An event triggered when a geometry is removed
  36417. */
  36418. onGeometryRemovedObservable: Observable<Geometry>;
  36419. /**
  36420. * An event triggered when a transform node is created
  36421. */
  36422. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36423. /**
  36424. * An event triggered when a transform node is removed
  36425. */
  36426. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36427. /**
  36428. * An event triggered when a mesh is created
  36429. */
  36430. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36431. /**
  36432. * An event triggered when a mesh is removed
  36433. */
  36434. onMeshRemovedObservable: Observable<AbstractMesh>;
  36435. /**
  36436. * An event triggered when a skeleton is created
  36437. */
  36438. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36439. /**
  36440. * An event triggered when a skeleton is removed
  36441. */
  36442. onSkeletonRemovedObservable: Observable<Skeleton>;
  36443. /**
  36444. * An event triggered when a material is created
  36445. */
  36446. onNewMaterialAddedObservable: Observable<Material>;
  36447. /**
  36448. * An event triggered when a material is removed
  36449. */
  36450. onMaterialRemovedObservable: Observable<Material>;
  36451. /**
  36452. * An event triggered when a texture is created
  36453. */
  36454. onNewTextureAddedObservable: Observable<BaseTexture>;
  36455. /**
  36456. * An event triggered when a texture is removed
  36457. */
  36458. onTextureRemovedObservable: Observable<BaseTexture>;
  36459. /**
  36460. * An event triggered when render targets are about to be rendered
  36461. * Can happen multiple times per frame.
  36462. */
  36463. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36464. /**
  36465. * An event triggered when render targets were rendered.
  36466. * Can happen multiple times per frame.
  36467. */
  36468. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36469. /**
  36470. * An event triggered before calculating deterministic simulation step
  36471. */
  36472. onBeforeStepObservable: Observable<Scene>;
  36473. /**
  36474. * An event triggered after calculating deterministic simulation step
  36475. */
  36476. onAfterStepObservable: Observable<Scene>;
  36477. /**
  36478. * An event triggered when the activeCamera property is updated
  36479. */
  36480. onActiveCameraChanged: Observable<Scene>;
  36481. /**
  36482. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36483. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36484. * 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)
  36485. */
  36486. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36487. /**
  36488. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36489. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36490. * 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)
  36491. */
  36492. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36493. /**
  36494. * This Observable will when a mesh has been imported into the scene.
  36495. */
  36496. onMeshImportedObservable: Observable<AbstractMesh>;
  36497. /**
  36498. * This Observable will when an animation file has been imported into the scene.
  36499. */
  36500. onAnimationFileImportedObservable: Observable<Scene>;
  36501. /**
  36502. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36503. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36504. */
  36505. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36506. /** @hidden */
  36507. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36508. /**
  36509. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36510. */
  36511. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36512. /**
  36513. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36514. */
  36515. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36516. /**
  36517. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36518. */
  36519. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36520. /** Callback called when a pointer move is detected */
  36521. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36522. /** Callback called when a pointer down is detected */
  36523. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36524. /** Callback called when a pointer up is detected */
  36525. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36526. /** Callback called when a pointer pick is detected */
  36527. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36528. /**
  36529. * 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).
  36530. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36531. */
  36532. onPrePointerObservable: Observable<PointerInfoPre>;
  36533. /**
  36534. * Observable event triggered each time an input event is received from the rendering canvas
  36535. */
  36536. onPointerObservable: Observable<PointerInfo>;
  36537. /**
  36538. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36539. */
  36540. get unTranslatedPointer(): Vector2;
  36541. /**
  36542. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36543. */
  36544. static get DragMovementThreshold(): number;
  36545. static set DragMovementThreshold(value: number);
  36546. /**
  36547. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36548. */
  36549. static get LongPressDelay(): number;
  36550. static set LongPressDelay(value: number);
  36551. /**
  36552. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36553. */
  36554. static get DoubleClickDelay(): number;
  36555. static set DoubleClickDelay(value: number);
  36556. /** If you need to check double click without raising a single click at first click, enable this flag */
  36557. static get ExclusiveDoubleClickMode(): boolean;
  36558. static set ExclusiveDoubleClickMode(value: boolean);
  36559. /** @hidden */
  36560. _mirroredCameraPosition: Nullable<Vector3>;
  36561. /**
  36562. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36563. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36564. */
  36565. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36566. /**
  36567. * Observable event triggered each time an keyboard event is received from the hosting window
  36568. */
  36569. onKeyboardObservable: Observable<KeyboardInfo>;
  36570. private _useRightHandedSystem;
  36571. /**
  36572. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36573. */
  36574. set useRightHandedSystem(value: boolean);
  36575. get useRightHandedSystem(): boolean;
  36576. private _timeAccumulator;
  36577. private _currentStepId;
  36578. private _currentInternalStep;
  36579. /**
  36580. * Sets the step Id used by deterministic lock step
  36581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36582. * @param newStepId defines the step Id
  36583. */
  36584. setStepId(newStepId: number): void;
  36585. /**
  36586. * Gets the step Id used by deterministic lock step
  36587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36588. * @returns the step Id
  36589. */
  36590. getStepId(): number;
  36591. /**
  36592. * Gets the internal step used by deterministic lock step
  36593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36594. * @returns the internal step
  36595. */
  36596. getInternalStep(): number;
  36597. private _fogEnabled;
  36598. /**
  36599. * Gets or sets a boolean indicating if fog is enabled on this scene
  36600. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36601. * (Default is true)
  36602. */
  36603. set fogEnabled(value: boolean);
  36604. get fogEnabled(): boolean;
  36605. private _fogMode;
  36606. /**
  36607. * Gets or sets the fog mode to use
  36608. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36609. * | mode | value |
  36610. * | --- | --- |
  36611. * | FOGMODE_NONE | 0 |
  36612. * | FOGMODE_EXP | 1 |
  36613. * | FOGMODE_EXP2 | 2 |
  36614. * | FOGMODE_LINEAR | 3 |
  36615. */
  36616. set fogMode(value: number);
  36617. get fogMode(): number;
  36618. /**
  36619. * Gets or sets the fog color to use
  36620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36621. * (Default is Color3(0.2, 0.2, 0.3))
  36622. */
  36623. fogColor: Color3;
  36624. /**
  36625. * Gets or sets the fog density to use
  36626. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36627. * (Default is 0.1)
  36628. */
  36629. fogDensity: number;
  36630. /**
  36631. * Gets or sets the fog start distance to use
  36632. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36633. * (Default is 0)
  36634. */
  36635. fogStart: number;
  36636. /**
  36637. * Gets or sets the fog end distance to use
  36638. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36639. * (Default is 1000)
  36640. */
  36641. fogEnd: number;
  36642. private _shadowsEnabled;
  36643. /**
  36644. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36645. */
  36646. set shadowsEnabled(value: boolean);
  36647. get shadowsEnabled(): boolean;
  36648. private _lightsEnabled;
  36649. /**
  36650. * Gets or sets a boolean indicating if lights are enabled on this scene
  36651. */
  36652. set lightsEnabled(value: boolean);
  36653. get lightsEnabled(): boolean;
  36654. /** All of the active cameras added to this scene. */
  36655. activeCameras: Camera[];
  36656. /** @hidden */
  36657. _activeCamera: Nullable<Camera>;
  36658. /** Gets or sets the current active camera */
  36659. get activeCamera(): Nullable<Camera>;
  36660. set activeCamera(value: Nullable<Camera>);
  36661. private _defaultMaterial;
  36662. /** The default material used on meshes when no material is affected */
  36663. get defaultMaterial(): Material;
  36664. /** The default material used on meshes when no material is affected */
  36665. set defaultMaterial(value: Material);
  36666. private _texturesEnabled;
  36667. /**
  36668. * Gets or sets a boolean indicating if textures are enabled on this scene
  36669. */
  36670. set texturesEnabled(value: boolean);
  36671. get texturesEnabled(): boolean;
  36672. /**
  36673. * Gets or sets a boolean indicating if particles are enabled on this scene
  36674. */
  36675. particlesEnabled: boolean;
  36676. /**
  36677. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36678. */
  36679. spritesEnabled: boolean;
  36680. private _skeletonsEnabled;
  36681. /**
  36682. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36683. */
  36684. set skeletonsEnabled(value: boolean);
  36685. get skeletonsEnabled(): boolean;
  36686. /**
  36687. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36688. */
  36689. lensFlaresEnabled: boolean;
  36690. /**
  36691. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36693. */
  36694. collisionsEnabled: boolean;
  36695. private _collisionCoordinator;
  36696. /** @hidden */
  36697. get collisionCoordinator(): ICollisionCoordinator;
  36698. /**
  36699. * Defines the gravity applied to this scene (used only for collisions)
  36700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36701. */
  36702. gravity: Vector3;
  36703. /**
  36704. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36705. */
  36706. postProcessesEnabled: boolean;
  36707. /**
  36708. * The list of postprocesses added to the scene
  36709. */
  36710. postProcesses: PostProcess[];
  36711. /**
  36712. * Gets the current postprocess manager
  36713. */
  36714. postProcessManager: PostProcessManager;
  36715. /**
  36716. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36717. */
  36718. renderTargetsEnabled: boolean;
  36719. /**
  36720. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36721. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36722. */
  36723. dumpNextRenderTargets: boolean;
  36724. /**
  36725. * The list of user defined render targets added to the scene
  36726. */
  36727. customRenderTargets: RenderTargetTexture[];
  36728. /**
  36729. * Defines if texture loading must be delayed
  36730. * If true, textures will only be loaded when they need to be rendered
  36731. */
  36732. useDelayedTextureLoading: boolean;
  36733. /**
  36734. * Gets the list of meshes imported to the scene through SceneLoader
  36735. */
  36736. importedMeshesFiles: String[];
  36737. /**
  36738. * Gets or sets a boolean indicating if probes are enabled on this scene
  36739. */
  36740. probesEnabled: boolean;
  36741. /**
  36742. * Gets or sets the current offline provider to use to store scene data
  36743. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36744. */
  36745. offlineProvider: IOfflineProvider;
  36746. /**
  36747. * Gets or sets the action manager associated with the scene
  36748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36749. */
  36750. actionManager: AbstractActionManager;
  36751. private _meshesForIntersections;
  36752. /**
  36753. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36754. */
  36755. proceduralTexturesEnabled: boolean;
  36756. private _engine;
  36757. private _totalVertices;
  36758. /** @hidden */
  36759. _activeIndices: PerfCounter;
  36760. /** @hidden */
  36761. _activeParticles: PerfCounter;
  36762. /** @hidden */
  36763. _activeBones: PerfCounter;
  36764. private _animationRatio;
  36765. /** @hidden */
  36766. _animationTimeLast: number;
  36767. /** @hidden */
  36768. _animationTime: number;
  36769. /**
  36770. * Gets or sets a general scale for animation speed
  36771. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36772. */
  36773. animationTimeScale: number;
  36774. /** @hidden */
  36775. _cachedMaterial: Nullable<Material>;
  36776. /** @hidden */
  36777. _cachedEffect: Nullable<Effect>;
  36778. /** @hidden */
  36779. _cachedVisibility: Nullable<number>;
  36780. private _renderId;
  36781. private _frameId;
  36782. private _executeWhenReadyTimeoutId;
  36783. private _intermediateRendering;
  36784. private _viewUpdateFlag;
  36785. private _projectionUpdateFlag;
  36786. /** @hidden */
  36787. _toBeDisposed: Nullable<IDisposable>[];
  36788. private _activeRequests;
  36789. /** @hidden */
  36790. _pendingData: any[];
  36791. private _isDisposed;
  36792. /**
  36793. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36794. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36795. */
  36796. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36797. private _activeMeshes;
  36798. private _processedMaterials;
  36799. private _renderTargets;
  36800. /** @hidden */
  36801. _activeParticleSystems: SmartArray<IParticleSystem>;
  36802. private _activeSkeletons;
  36803. private _softwareSkinnedMeshes;
  36804. private _renderingManager;
  36805. /** @hidden */
  36806. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36807. private _transformMatrix;
  36808. private _sceneUbo;
  36809. /** @hidden */
  36810. _viewMatrix: Matrix;
  36811. private _projectionMatrix;
  36812. /** @hidden */
  36813. _forcedViewPosition: Nullable<Vector3>;
  36814. /** @hidden */
  36815. _frustumPlanes: Plane[];
  36816. /**
  36817. * Gets the list of frustum planes (built from the active camera)
  36818. */
  36819. get frustumPlanes(): Plane[];
  36820. /**
  36821. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36822. * This is useful if there are more lights that the maximum simulteanous authorized
  36823. */
  36824. requireLightSorting: boolean;
  36825. /** @hidden */
  36826. readonly useMaterialMeshMap: boolean;
  36827. /** @hidden */
  36828. readonly useClonedMeshMap: boolean;
  36829. private _externalData;
  36830. private _uid;
  36831. /**
  36832. * @hidden
  36833. * Backing store of defined scene components.
  36834. */
  36835. _components: ISceneComponent[];
  36836. /**
  36837. * @hidden
  36838. * Backing store of defined scene components.
  36839. */
  36840. _serializableComponents: ISceneSerializableComponent[];
  36841. /**
  36842. * List of components to register on the next registration step.
  36843. */
  36844. private _transientComponents;
  36845. /**
  36846. * Registers the transient components if needed.
  36847. */
  36848. private _registerTransientComponents;
  36849. /**
  36850. * @hidden
  36851. * Add a component to the scene.
  36852. * Note that the ccomponent could be registered on th next frame if this is called after
  36853. * the register component stage.
  36854. * @param component Defines the component to add to the scene
  36855. */
  36856. _addComponent(component: ISceneComponent): void;
  36857. /**
  36858. * @hidden
  36859. * Gets a component from the scene.
  36860. * @param name defines the name of the component to retrieve
  36861. * @returns the component or null if not present
  36862. */
  36863. _getComponent(name: string): Nullable<ISceneComponent>;
  36864. /**
  36865. * @hidden
  36866. * Defines the actions happening before camera updates.
  36867. */
  36868. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36869. /**
  36870. * @hidden
  36871. * Defines the actions happening before clear the canvas.
  36872. */
  36873. _beforeClearStage: Stage<SimpleStageAction>;
  36874. /**
  36875. * @hidden
  36876. * Defines the actions when collecting render targets for the frame.
  36877. */
  36878. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36879. /**
  36880. * @hidden
  36881. * Defines the actions happening for one camera in the frame.
  36882. */
  36883. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36884. /**
  36885. * @hidden
  36886. * Defines the actions happening during the per mesh ready checks.
  36887. */
  36888. _isReadyForMeshStage: Stage<MeshStageAction>;
  36889. /**
  36890. * @hidden
  36891. * Defines the actions happening before evaluate active mesh checks.
  36892. */
  36893. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36894. /**
  36895. * @hidden
  36896. * Defines the actions happening during the evaluate sub mesh checks.
  36897. */
  36898. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36899. /**
  36900. * @hidden
  36901. * Defines the actions happening during the active mesh stage.
  36902. */
  36903. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36904. /**
  36905. * @hidden
  36906. * Defines the actions happening during the per camera render target step.
  36907. */
  36908. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36909. /**
  36910. * @hidden
  36911. * Defines the actions happening just before the active camera is drawing.
  36912. */
  36913. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36914. /**
  36915. * @hidden
  36916. * Defines the actions happening just before a render target is drawing.
  36917. */
  36918. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36919. /**
  36920. * @hidden
  36921. * Defines the actions happening just before a rendering group is drawing.
  36922. */
  36923. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36924. /**
  36925. * @hidden
  36926. * Defines the actions happening just before a mesh is drawing.
  36927. */
  36928. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36929. /**
  36930. * @hidden
  36931. * Defines the actions happening just after a mesh has been drawn.
  36932. */
  36933. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36934. /**
  36935. * @hidden
  36936. * Defines the actions happening just after a rendering group has been drawn.
  36937. */
  36938. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36939. /**
  36940. * @hidden
  36941. * Defines the actions happening just after the active camera has been drawn.
  36942. */
  36943. _afterCameraDrawStage: Stage<CameraStageAction>;
  36944. /**
  36945. * @hidden
  36946. * Defines the actions happening just after a render target has been drawn.
  36947. */
  36948. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36949. /**
  36950. * @hidden
  36951. * Defines the actions happening just after rendering all cameras and computing intersections.
  36952. */
  36953. _afterRenderStage: Stage<SimpleStageAction>;
  36954. /**
  36955. * @hidden
  36956. * Defines the actions happening when a pointer move event happens.
  36957. */
  36958. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36959. /**
  36960. * @hidden
  36961. * Defines the actions happening when a pointer down event happens.
  36962. */
  36963. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36964. /**
  36965. * @hidden
  36966. * Defines the actions happening when a pointer up event happens.
  36967. */
  36968. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36969. /**
  36970. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36971. */
  36972. private geometriesByUniqueId;
  36973. /**
  36974. * Creates a new Scene
  36975. * @param engine defines the engine to use to render this scene
  36976. * @param options defines the scene options
  36977. */
  36978. constructor(engine: Engine, options?: SceneOptions);
  36979. /**
  36980. * Gets a string idenfifying the name of the class
  36981. * @returns "Scene" string
  36982. */
  36983. getClassName(): string;
  36984. private _defaultMeshCandidates;
  36985. /**
  36986. * @hidden
  36987. */
  36988. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36989. private _defaultSubMeshCandidates;
  36990. /**
  36991. * @hidden
  36992. */
  36993. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36994. /**
  36995. * Sets the default candidate providers for the scene.
  36996. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36997. * and getCollidingSubMeshCandidates to their default function
  36998. */
  36999. setDefaultCandidateProviders(): void;
  37000. /**
  37001. * Gets the mesh that is currently under the pointer
  37002. */
  37003. get meshUnderPointer(): Nullable<AbstractMesh>;
  37004. /**
  37005. * Gets or sets the current on-screen X position of the pointer
  37006. */
  37007. get pointerX(): number;
  37008. set pointerX(value: number);
  37009. /**
  37010. * Gets or sets the current on-screen Y position of the pointer
  37011. */
  37012. get pointerY(): number;
  37013. set pointerY(value: number);
  37014. /**
  37015. * Gets the cached material (ie. the latest rendered one)
  37016. * @returns the cached material
  37017. */
  37018. getCachedMaterial(): Nullable<Material>;
  37019. /**
  37020. * Gets the cached effect (ie. the latest rendered one)
  37021. * @returns the cached effect
  37022. */
  37023. getCachedEffect(): Nullable<Effect>;
  37024. /**
  37025. * Gets the cached visibility state (ie. the latest rendered one)
  37026. * @returns the cached visibility state
  37027. */
  37028. getCachedVisibility(): Nullable<number>;
  37029. /**
  37030. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37031. * @param material defines the current material
  37032. * @param effect defines the current effect
  37033. * @param visibility defines the current visibility state
  37034. * @returns true if one parameter is not cached
  37035. */
  37036. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37037. /**
  37038. * Gets the engine associated with the scene
  37039. * @returns an Engine
  37040. */
  37041. getEngine(): Engine;
  37042. /**
  37043. * Gets the total number of vertices rendered per frame
  37044. * @returns the total number of vertices rendered per frame
  37045. */
  37046. getTotalVertices(): number;
  37047. /**
  37048. * Gets the performance counter for total vertices
  37049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37050. */
  37051. get totalVerticesPerfCounter(): PerfCounter;
  37052. /**
  37053. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37054. * @returns the total number of active indices rendered per frame
  37055. */
  37056. getActiveIndices(): number;
  37057. /**
  37058. * Gets the performance counter for active indices
  37059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37060. */
  37061. get totalActiveIndicesPerfCounter(): PerfCounter;
  37062. /**
  37063. * Gets the total number of active particles rendered per frame
  37064. * @returns the total number of active particles rendered per frame
  37065. */
  37066. getActiveParticles(): number;
  37067. /**
  37068. * Gets the performance counter for active particles
  37069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37070. */
  37071. get activeParticlesPerfCounter(): PerfCounter;
  37072. /**
  37073. * Gets the total number of active bones rendered per frame
  37074. * @returns the total number of active bones rendered per frame
  37075. */
  37076. getActiveBones(): number;
  37077. /**
  37078. * Gets the performance counter for active bones
  37079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37080. */
  37081. get activeBonesPerfCounter(): PerfCounter;
  37082. /**
  37083. * Gets the array of active meshes
  37084. * @returns an array of AbstractMesh
  37085. */
  37086. getActiveMeshes(): SmartArray<AbstractMesh>;
  37087. /**
  37088. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37089. * @returns a number
  37090. */
  37091. getAnimationRatio(): number;
  37092. /**
  37093. * Gets an unique Id for the current render phase
  37094. * @returns a number
  37095. */
  37096. getRenderId(): number;
  37097. /**
  37098. * Gets an unique Id for the current frame
  37099. * @returns a number
  37100. */
  37101. getFrameId(): number;
  37102. /** Call this function if you want to manually increment the render Id*/
  37103. incrementRenderId(): void;
  37104. private _createUbo;
  37105. /**
  37106. * Use this method to simulate a pointer move on a mesh
  37107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37110. * @returns the current scene
  37111. */
  37112. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37113. /**
  37114. * Use this method to simulate a pointer down on a mesh
  37115. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37116. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37117. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37118. * @returns the current scene
  37119. */
  37120. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37121. /**
  37122. * Use this method to simulate a pointer up on a mesh
  37123. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37124. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37125. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37126. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37127. * @returns the current scene
  37128. */
  37129. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37130. /**
  37131. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37132. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37133. * @returns true if the pointer was captured
  37134. */
  37135. isPointerCaptured(pointerId?: number): boolean;
  37136. /**
  37137. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37138. * @param attachUp defines if you want to attach events to pointerup
  37139. * @param attachDown defines if you want to attach events to pointerdown
  37140. * @param attachMove defines if you want to attach events to pointermove
  37141. */
  37142. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37143. /** Detaches all event handlers*/
  37144. detachControl(): void;
  37145. /**
  37146. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37147. * Delay loaded resources are not taking in account
  37148. * @return true if all required resources are ready
  37149. */
  37150. isReady(): boolean;
  37151. /** Resets all cached information relative to material (including effect and visibility) */
  37152. resetCachedMaterial(): void;
  37153. /**
  37154. * Registers a function to be called before every frame render
  37155. * @param func defines the function to register
  37156. */
  37157. registerBeforeRender(func: () => void): void;
  37158. /**
  37159. * Unregisters a function called before every frame render
  37160. * @param func defines the function to unregister
  37161. */
  37162. unregisterBeforeRender(func: () => void): void;
  37163. /**
  37164. * Registers a function to be called after every frame render
  37165. * @param func defines the function to register
  37166. */
  37167. registerAfterRender(func: () => void): void;
  37168. /**
  37169. * Unregisters a function called after every frame render
  37170. * @param func defines the function to unregister
  37171. */
  37172. unregisterAfterRender(func: () => void): void;
  37173. private _executeOnceBeforeRender;
  37174. /**
  37175. * The provided function will run before render once and will be disposed afterwards.
  37176. * A timeout delay can be provided so that the function will be executed in N ms.
  37177. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37178. * @param func The function to be executed.
  37179. * @param timeout optional delay in ms
  37180. */
  37181. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37182. /** @hidden */
  37183. _addPendingData(data: any): void;
  37184. /** @hidden */
  37185. _removePendingData(data: any): void;
  37186. /**
  37187. * Returns the number of items waiting to be loaded
  37188. * @returns the number of items waiting to be loaded
  37189. */
  37190. getWaitingItemsCount(): number;
  37191. /**
  37192. * Returns a boolean indicating if the scene is still loading data
  37193. */
  37194. get isLoading(): boolean;
  37195. /**
  37196. * Registers a function to be executed when the scene is ready
  37197. * @param {Function} func - the function to be executed
  37198. */
  37199. executeWhenReady(func: () => void): void;
  37200. /**
  37201. * Returns a promise that resolves when the scene is ready
  37202. * @returns A promise that resolves when the scene is ready
  37203. */
  37204. whenReadyAsync(): Promise<void>;
  37205. /** @hidden */
  37206. _checkIsReady(): void;
  37207. /**
  37208. * Gets all animatable attached to the scene
  37209. */
  37210. get animatables(): Animatable[];
  37211. /**
  37212. * Resets the last animation time frame.
  37213. * Useful to override when animations start running when loading a scene for the first time.
  37214. */
  37215. resetLastAnimationTimeFrame(): void;
  37216. /**
  37217. * Gets the current view matrix
  37218. * @returns a Matrix
  37219. */
  37220. getViewMatrix(): Matrix;
  37221. /**
  37222. * Gets the current projection matrix
  37223. * @returns a Matrix
  37224. */
  37225. getProjectionMatrix(): Matrix;
  37226. /**
  37227. * Gets the current transform matrix
  37228. * @returns a Matrix made of View * Projection
  37229. */
  37230. getTransformMatrix(): Matrix;
  37231. /**
  37232. * Sets the current transform matrix
  37233. * @param viewL defines the View matrix to use
  37234. * @param projectionL defines the Projection matrix to use
  37235. * @param viewR defines the right View matrix to use (if provided)
  37236. * @param projectionR defines the right Projection matrix to use (if provided)
  37237. */
  37238. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37239. /**
  37240. * Gets the uniform buffer used to store scene data
  37241. * @returns a UniformBuffer
  37242. */
  37243. getSceneUniformBuffer(): UniformBuffer;
  37244. /**
  37245. * Gets an unique (relatively to the current scene) Id
  37246. * @returns an unique number for the scene
  37247. */
  37248. getUniqueId(): number;
  37249. /**
  37250. * Add a mesh to the list of scene's meshes
  37251. * @param newMesh defines the mesh to add
  37252. * @param recursive if all child meshes should also be added to the scene
  37253. */
  37254. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37255. /**
  37256. * Remove a mesh for the list of scene's meshes
  37257. * @param toRemove defines the mesh to remove
  37258. * @param recursive if all child meshes should also be removed from the scene
  37259. * @returns the index where the mesh was in the mesh list
  37260. */
  37261. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37262. /**
  37263. * Add a transform node to the list of scene's transform nodes
  37264. * @param newTransformNode defines the transform node to add
  37265. */
  37266. addTransformNode(newTransformNode: TransformNode): void;
  37267. /**
  37268. * Remove a transform node for the list of scene's transform nodes
  37269. * @param toRemove defines the transform node to remove
  37270. * @returns the index where the transform node was in the transform node list
  37271. */
  37272. removeTransformNode(toRemove: TransformNode): number;
  37273. /**
  37274. * Remove a skeleton for the list of scene's skeletons
  37275. * @param toRemove defines the skeleton to remove
  37276. * @returns the index where the skeleton was in the skeleton list
  37277. */
  37278. removeSkeleton(toRemove: Skeleton): number;
  37279. /**
  37280. * Remove a morph target for the list of scene's morph targets
  37281. * @param toRemove defines the morph target to remove
  37282. * @returns the index where the morph target was in the morph target list
  37283. */
  37284. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37285. /**
  37286. * Remove a light for the list of scene's lights
  37287. * @param toRemove defines the light to remove
  37288. * @returns the index where the light was in the light list
  37289. */
  37290. removeLight(toRemove: Light): number;
  37291. /**
  37292. * Remove a camera for the list of scene's cameras
  37293. * @param toRemove defines the camera to remove
  37294. * @returns the index where the camera was in the camera list
  37295. */
  37296. removeCamera(toRemove: Camera): number;
  37297. /**
  37298. * Remove a particle system for the list of scene's particle systems
  37299. * @param toRemove defines the particle system to remove
  37300. * @returns the index where the particle system was in the particle system list
  37301. */
  37302. removeParticleSystem(toRemove: IParticleSystem): number;
  37303. /**
  37304. * Remove a animation for the list of scene's animations
  37305. * @param toRemove defines the animation to remove
  37306. * @returns the index where the animation was in the animation list
  37307. */
  37308. removeAnimation(toRemove: Animation): number;
  37309. /**
  37310. * Will stop the animation of the given target
  37311. * @param target - the target
  37312. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37313. * @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)
  37314. */
  37315. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37316. /**
  37317. * Removes the given animation group from this scene.
  37318. * @param toRemove The animation group to remove
  37319. * @returns The index of the removed animation group
  37320. */
  37321. removeAnimationGroup(toRemove: AnimationGroup): number;
  37322. /**
  37323. * Removes the given multi-material from this scene.
  37324. * @param toRemove The multi-material to remove
  37325. * @returns The index of the removed multi-material
  37326. */
  37327. removeMultiMaterial(toRemove: MultiMaterial): number;
  37328. /**
  37329. * Removes the given material from this scene.
  37330. * @param toRemove The material to remove
  37331. * @returns The index of the removed material
  37332. */
  37333. removeMaterial(toRemove: Material): number;
  37334. /**
  37335. * Removes the given action manager from this scene.
  37336. * @param toRemove The action manager to remove
  37337. * @returns The index of the removed action manager
  37338. */
  37339. removeActionManager(toRemove: AbstractActionManager): number;
  37340. /**
  37341. * Removes the given texture from this scene.
  37342. * @param toRemove The texture to remove
  37343. * @returns The index of the removed texture
  37344. */
  37345. removeTexture(toRemove: BaseTexture): number;
  37346. /**
  37347. * Adds the given light to this scene
  37348. * @param newLight The light to add
  37349. */
  37350. addLight(newLight: Light): void;
  37351. /**
  37352. * Sorts the list list based on light priorities
  37353. */
  37354. sortLightsByPriority(): void;
  37355. /**
  37356. * Adds the given camera to this scene
  37357. * @param newCamera The camera to add
  37358. */
  37359. addCamera(newCamera: Camera): void;
  37360. /**
  37361. * Adds the given skeleton to this scene
  37362. * @param newSkeleton The skeleton to add
  37363. */
  37364. addSkeleton(newSkeleton: Skeleton): void;
  37365. /**
  37366. * Adds the given particle system to this scene
  37367. * @param newParticleSystem The particle system to add
  37368. */
  37369. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37370. /**
  37371. * Adds the given animation to this scene
  37372. * @param newAnimation The animation to add
  37373. */
  37374. addAnimation(newAnimation: Animation): void;
  37375. /**
  37376. * Adds the given animation group to this scene.
  37377. * @param newAnimationGroup The animation group to add
  37378. */
  37379. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37380. /**
  37381. * Adds the given multi-material to this scene
  37382. * @param newMultiMaterial The multi-material to add
  37383. */
  37384. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37385. /**
  37386. * Adds the given material to this scene
  37387. * @param newMaterial The material to add
  37388. */
  37389. addMaterial(newMaterial: Material): void;
  37390. /**
  37391. * Adds the given morph target to this scene
  37392. * @param newMorphTargetManager The morph target to add
  37393. */
  37394. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37395. /**
  37396. * Adds the given geometry to this scene
  37397. * @param newGeometry The geometry to add
  37398. */
  37399. addGeometry(newGeometry: Geometry): void;
  37400. /**
  37401. * Adds the given action manager to this scene
  37402. * @param newActionManager The action manager to add
  37403. */
  37404. addActionManager(newActionManager: AbstractActionManager): void;
  37405. /**
  37406. * Adds the given texture to this scene.
  37407. * @param newTexture The texture to add
  37408. */
  37409. addTexture(newTexture: BaseTexture): void;
  37410. /**
  37411. * Switch active camera
  37412. * @param newCamera defines the new active camera
  37413. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37414. */
  37415. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37416. /**
  37417. * sets the active camera of the scene using its ID
  37418. * @param id defines the camera's ID
  37419. * @return the new active camera or null if none found.
  37420. */
  37421. setActiveCameraByID(id: string): Nullable<Camera>;
  37422. /**
  37423. * sets the active camera of the scene using its name
  37424. * @param name defines the camera's name
  37425. * @returns the new active camera or null if none found.
  37426. */
  37427. setActiveCameraByName(name: string): Nullable<Camera>;
  37428. /**
  37429. * get an animation group using its name
  37430. * @param name defines the material's name
  37431. * @return the animation group or null if none found.
  37432. */
  37433. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37434. /**
  37435. * Get a material using its unique id
  37436. * @param uniqueId defines the material's unique id
  37437. * @return the material or null if none found.
  37438. */
  37439. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37440. /**
  37441. * get a material using its id
  37442. * @param id defines the material's ID
  37443. * @return the material or null if none found.
  37444. */
  37445. getMaterialByID(id: string): Nullable<Material>;
  37446. /**
  37447. * Gets a the last added material using a given id
  37448. * @param id defines the material's ID
  37449. * @return the last material with the given id or null if none found.
  37450. */
  37451. getLastMaterialByID(id: string): Nullable<Material>;
  37452. /**
  37453. * Gets a material using its name
  37454. * @param name defines the material's name
  37455. * @return the material or null if none found.
  37456. */
  37457. getMaterialByName(name: string): Nullable<Material>;
  37458. /**
  37459. * Get a texture using its unique id
  37460. * @param uniqueId defines the texture's unique id
  37461. * @return the texture or null if none found.
  37462. */
  37463. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37464. /**
  37465. * Gets a camera using its id
  37466. * @param id defines the id to look for
  37467. * @returns the camera or null if not found
  37468. */
  37469. getCameraByID(id: string): Nullable<Camera>;
  37470. /**
  37471. * Gets a camera using its unique id
  37472. * @param uniqueId defines the unique id to look for
  37473. * @returns the camera or null if not found
  37474. */
  37475. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37476. /**
  37477. * Gets a camera using its name
  37478. * @param name defines the camera's name
  37479. * @return the camera or null if none found.
  37480. */
  37481. getCameraByName(name: string): Nullable<Camera>;
  37482. /**
  37483. * Gets a bone using its id
  37484. * @param id defines the bone's id
  37485. * @return the bone or null if not found
  37486. */
  37487. getBoneByID(id: string): Nullable<Bone>;
  37488. /**
  37489. * Gets a bone using its id
  37490. * @param name defines the bone's name
  37491. * @return the bone or null if not found
  37492. */
  37493. getBoneByName(name: string): Nullable<Bone>;
  37494. /**
  37495. * Gets a light node using its name
  37496. * @param name defines the the light's name
  37497. * @return the light or null if none found.
  37498. */
  37499. getLightByName(name: string): Nullable<Light>;
  37500. /**
  37501. * Gets a light node using its id
  37502. * @param id defines the light's id
  37503. * @return the light or null if none found.
  37504. */
  37505. getLightByID(id: string): Nullable<Light>;
  37506. /**
  37507. * Gets a light node using its scene-generated unique ID
  37508. * @param uniqueId defines the light's unique id
  37509. * @return the light or null if none found.
  37510. */
  37511. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37512. /**
  37513. * Gets a particle system by id
  37514. * @param id defines the particle system id
  37515. * @return the corresponding system or null if none found
  37516. */
  37517. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37518. /**
  37519. * Gets a geometry using its ID
  37520. * @param id defines the geometry's id
  37521. * @return the geometry or null if none found.
  37522. */
  37523. getGeometryByID(id: string): Nullable<Geometry>;
  37524. private _getGeometryByUniqueID;
  37525. /**
  37526. * Add a new geometry to this scene
  37527. * @param geometry defines the geometry to be added to the scene.
  37528. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37529. * @return a boolean defining if the geometry was added or not
  37530. */
  37531. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37532. /**
  37533. * Removes an existing geometry
  37534. * @param geometry defines the geometry to be removed from the scene
  37535. * @return a boolean defining if the geometry was removed or not
  37536. */
  37537. removeGeometry(geometry: Geometry): boolean;
  37538. /**
  37539. * Gets the list of geometries attached to the scene
  37540. * @returns an array of Geometry
  37541. */
  37542. getGeometries(): Geometry[];
  37543. /**
  37544. * Gets the first added mesh found of a given ID
  37545. * @param id defines the id to search for
  37546. * @return the mesh found or null if not found at all
  37547. */
  37548. getMeshByID(id: string): Nullable<AbstractMesh>;
  37549. /**
  37550. * Gets a list of meshes using their id
  37551. * @param id defines the id to search for
  37552. * @returns a list of meshes
  37553. */
  37554. getMeshesByID(id: string): Array<AbstractMesh>;
  37555. /**
  37556. * Gets the first added transform node found of a given ID
  37557. * @param id defines the id to search for
  37558. * @return the found transform node or null if not found at all.
  37559. */
  37560. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37561. /**
  37562. * Gets a transform node with its auto-generated unique id
  37563. * @param uniqueId efines the unique id to search for
  37564. * @return the found transform node or null if not found at all.
  37565. */
  37566. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37567. /**
  37568. * Gets a list of transform nodes using their id
  37569. * @param id defines the id to search for
  37570. * @returns a list of transform nodes
  37571. */
  37572. getTransformNodesByID(id: string): Array<TransformNode>;
  37573. /**
  37574. * Gets a mesh with its auto-generated unique id
  37575. * @param uniqueId defines the unique id to search for
  37576. * @return the found mesh or null if not found at all.
  37577. */
  37578. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37579. /**
  37580. * Gets a the last added mesh using a given id
  37581. * @param id defines the id to search for
  37582. * @return the found mesh or null if not found at all.
  37583. */
  37584. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37585. /**
  37586. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37587. * @param id defines the id to search for
  37588. * @return the found node or null if not found at all
  37589. */
  37590. getLastEntryByID(id: string): Nullable<Node>;
  37591. /**
  37592. * Gets a node (Mesh, Camera, Light) using a given id
  37593. * @param id defines the id to search for
  37594. * @return the found node or null if not found at all
  37595. */
  37596. getNodeByID(id: string): Nullable<Node>;
  37597. /**
  37598. * Gets a node (Mesh, Camera, Light) using a given name
  37599. * @param name defines the name to search for
  37600. * @return the found node or null if not found at all.
  37601. */
  37602. getNodeByName(name: string): Nullable<Node>;
  37603. /**
  37604. * Gets a mesh using a given name
  37605. * @param name defines the name to search for
  37606. * @return the found mesh or null if not found at all.
  37607. */
  37608. getMeshByName(name: string): Nullable<AbstractMesh>;
  37609. /**
  37610. * Gets a transform node using a given name
  37611. * @param name defines the name to search for
  37612. * @return the found transform node or null if not found at all.
  37613. */
  37614. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37615. /**
  37616. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37617. * @param id defines the id to search for
  37618. * @return the found skeleton or null if not found at all.
  37619. */
  37620. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37621. /**
  37622. * Gets a skeleton using a given auto generated unique id
  37623. * @param uniqueId defines the unique id to search for
  37624. * @return the found skeleton or null if not found at all.
  37625. */
  37626. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37627. /**
  37628. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37629. * @param id defines the id to search for
  37630. * @return the found skeleton or null if not found at all.
  37631. */
  37632. getSkeletonById(id: string): Nullable<Skeleton>;
  37633. /**
  37634. * Gets a skeleton using a given name
  37635. * @param name defines the name to search for
  37636. * @return the found skeleton or null if not found at all.
  37637. */
  37638. getSkeletonByName(name: string): Nullable<Skeleton>;
  37639. /**
  37640. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37641. * @param id defines the id to search for
  37642. * @return the found morph target manager or null if not found at all.
  37643. */
  37644. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37645. /**
  37646. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37647. * @param id defines the id to search for
  37648. * @return the found morph target or null if not found at all.
  37649. */
  37650. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37651. /**
  37652. * Gets a boolean indicating if the given mesh is active
  37653. * @param mesh defines the mesh to look for
  37654. * @returns true if the mesh is in the active list
  37655. */
  37656. isActiveMesh(mesh: AbstractMesh): boolean;
  37657. /**
  37658. * Return a unique id as a string which can serve as an identifier for the scene
  37659. */
  37660. get uid(): string;
  37661. /**
  37662. * Add an externaly attached data from its key.
  37663. * This method call will fail and return false, if such key already exists.
  37664. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37665. * @param key the unique key that identifies the data
  37666. * @param data the data object to associate to the key for this Engine instance
  37667. * @return true if no such key were already present and the data was added successfully, false otherwise
  37668. */
  37669. addExternalData<T>(key: string, data: T): boolean;
  37670. /**
  37671. * Get an externaly attached data from its key
  37672. * @param key the unique key that identifies the data
  37673. * @return the associated data, if present (can be null), or undefined if not present
  37674. */
  37675. getExternalData<T>(key: string): Nullable<T>;
  37676. /**
  37677. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37678. * @param key the unique key that identifies the data
  37679. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37680. * @return the associated data, can be null if the factory returned null.
  37681. */
  37682. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37683. /**
  37684. * Remove an externaly attached data from the Engine instance
  37685. * @param key the unique key that identifies the data
  37686. * @return true if the data was successfully removed, false if it doesn't exist
  37687. */
  37688. removeExternalData(key: string): boolean;
  37689. private _evaluateSubMesh;
  37690. /**
  37691. * Clear the processed materials smart array preventing retention point in material dispose.
  37692. */
  37693. freeProcessedMaterials(): void;
  37694. private _preventFreeActiveMeshesAndRenderingGroups;
  37695. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37696. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37697. * when disposing several meshes in a row or a hierarchy of meshes.
  37698. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37699. */
  37700. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37701. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37702. /**
  37703. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37704. */
  37705. freeActiveMeshes(): void;
  37706. /**
  37707. * Clear the info related to rendering groups preventing retention points during dispose.
  37708. */
  37709. freeRenderingGroups(): void;
  37710. /** @hidden */
  37711. _isInIntermediateRendering(): boolean;
  37712. /**
  37713. * Lambda returning the list of potentially active meshes.
  37714. */
  37715. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37716. /**
  37717. * Lambda returning the list of potentially active sub meshes.
  37718. */
  37719. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37720. /**
  37721. * Lambda returning the list of potentially intersecting sub meshes.
  37722. */
  37723. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37724. /**
  37725. * Lambda returning the list of potentially colliding sub meshes.
  37726. */
  37727. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37728. private _activeMeshesFrozen;
  37729. private _skipEvaluateActiveMeshesCompletely;
  37730. /**
  37731. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37732. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37733. * @returns the current scene
  37734. */
  37735. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37736. /**
  37737. * Use this function to restart evaluating active meshes on every frame
  37738. * @returns the current scene
  37739. */
  37740. unfreezeActiveMeshes(): Scene;
  37741. private _evaluateActiveMeshes;
  37742. private _activeMesh;
  37743. /**
  37744. * Update the transform matrix to update from the current active camera
  37745. * @param force defines a boolean used to force the update even if cache is up to date
  37746. */
  37747. updateTransformMatrix(force?: boolean): void;
  37748. private _bindFrameBuffer;
  37749. /** @hidden */
  37750. _allowPostProcessClearColor: boolean;
  37751. /** @hidden */
  37752. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37753. private _processSubCameras;
  37754. private _checkIntersections;
  37755. /** @hidden */
  37756. _advancePhysicsEngineStep(step: number): void;
  37757. /**
  37758. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37759. */
  37760. getDeterministicFrameTime: () => number;
  37761. /** @hidden */
  37762. _animate(): void;
  37763. /** Execute all animations (for a frame) */
  37764. animate(): void;
  37765. /**
  37766. * Render the scene
  37767. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37768. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37769. */
  37770. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37771. /**
  37772. * Freeze all materials
  37773. * A frozen material will not be updatable but should be faster to render
  37774. */
  37775. freezeMaterials(): void;
  37776. /**
  37777. * Unfreeze all materials
  37778. * A frozen material will not be updatable but should be faster to render
  37779. */
  37780. unfreezeMaterials(): void;
  37781. /**
  37782. * Releases all held ressources
  37783. */
  37784. dispose(): void;
  37785. /**
  37786. * Gets if the scene is already disposed
  37787. */
  37788. get isDisposed(): boolean;
  37789. /**
  37790. * Call this function to reduce memory footprint of the scene.
  37791. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37792. */
  37793. clearCachedVertexData(): void;
  37794. /**
  37795. * This function will remove the local cached buffer data from texture.
  37796. * It will save memory but will prevent the texture from being rebuilt
  37797. */
  37798. cleanCachedTextureBuffer(): void;
  37799. /**
  37800. * Get the world extend vectors with an optional filter
  37801. *
  37802. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37803. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37804. */
  37805. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37806. min: Vector3;
  37807. max: Vector3;
  37808. };
  37809. /**
  37810. * Creates a ray that can be used to pick in the scene
  37811. * @param x defines the x coordinate of the origin (on-screen)
  37812. * @param y defines the y coordinate of the origin (on-screen)
  37813. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37814. * @param camera defines the camera to use for the picking
  37815. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37816. * @returns a Ray
  37817. */
  37818. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37819. /**
  37820. * Creates a ray that can be used to pick in the scene
  37821. * @param x defines the x coordinate of the origin (on-screen)
  37822. * @param y defines the y coordinate of the origin (on-screen)
  37823. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37824. * @param result defines the ray where to store the picking ray
  37825. * @param camera defines the camera to use for the picking
  37826. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37827. * @returns the current scene
  37828. */
  37829. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37830. /**
  37831. * Creates a ray that can be used to pick in the scene
  37832. * @param x defines the x coordinate of the origin (on-screen)
  37833. * @param y defines the y coordinate of the origin (on-screen)
  37834. * @param camera defines the camera to use for the picking
  37835. * @returns a Ray
  37836. */
  37837. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37838. /**
  37839. * Creates a ray that can be used to pick in the scene
  37840. * @param x defines the x coordinate of the origin (on-screen)
  37841. * @param y defines the y coordinate of the origin (on-screen)
  37842. * @param result defines the ray where to store the picking ray
  37843. * @param camera defines the camera to use for the picking
  37844. * @returns the current scene
  37845. */
  37846. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37847. /** Launch a ray to try to pick a mesh in the scene
  37848. * @param x position on screen
  37849. * @param y position on screen
  37850. * @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
  37851. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37852. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37854. * @returns a PickingInfo
  37855. */
  37856. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37857. /** Use the given ray to pick a mesh in the scene
  37858. * @param ray The ray to use to pick meshes
  37859. * @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
  37860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37862. * @returns a PickingInfo
  37863. */
  37864. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37865. /**
  37866. * Launch a ray to try to pick a mesh in the scene
  37867. * @param x X position on screen
  37868. * @param y Y position on screen
  37869. * @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
  37870. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37872. * @returns an array of PickingInfo
  37873. */
  37874. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37875. /**
  37876. * Launch a ray to try to pick a mesh in the scene
  37877. * @param ray Ray to use
  37878. * @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
  37879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37880. * @returns an array of PickingInfo
  37881. */
  37882. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37883. /**
  37884. * Force the value of meshUnderPointer
  37885. * @param mesh defines the mesh to use
  37886. */
  37887. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37888. /**
  37889. * Gets the mesh under the pointer
  37890. * @returns a Mesh or null if no mesh is under the pointer
  37891. */
  37892. getPointerOverMesh(): Nullable<AbstractMesh>;
  37893. /** @hidden */
  37894. _rebuildGeometries(): void;
  37895. /** @hidden */
  37896. _rebuildTextures(): void;
  37897. private _getByTags;
  37898. /**
  37899. * Get a list of meshes by tags
  37900. * @param tagsQuery defines the tags query to use
  37901. * @param forEach defines a predicate used to filter results
  37902. * @returns an array of Mesh
  37903. */
  37904. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37905. /**
  37906. * Get a list of cameras by tags
  37907. * @param tagsQuery defines the tags query to use
  37908. * @param forEach defines a predicate used to filter results
  37909. * @returns an array of Camera
  37910. */
  37911. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37912. /**
  37913. * Get a list of lights by tags
  37914. * @param tagsQuery defines the tags query to use
  37915. * @param forEach defines a predicate used to filter results
  37916. * @returns an array of Light
  37917. */
  37918. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37919. /**
  37920. * Get a list of materials by tags
  37921. * @param tagsQuery defines the tags query to use
  37922. * @param forEach defines a predicate used to filter results
  37923. * @returns an array of Material
  37924. */
  37925. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37926. /**
  37927. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37928. * This allowed control for front to back rendering or reversly depending of the special needs.
  37929. *
  37930. * @param renderingGroupId The rendering group id corresponding to its index
  37931. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37932. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37933. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37934. */
  37935. 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;
  37936. /**
  37937. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37938. *
  37939. * @param renderingGroupId The rendering group id corresponding to its index
  37940. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37941. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37942. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37943. */
  37944. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37945. /**
  37946. * Gets the current auto clear configuration for one rendering group of the rendering
  37947. * manager.
  37948. * @param index the rendering group index to get the information for
  37949. * @returns The auto clear setup for the requested rendering group
  37950. */
  37951. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37952. private _blockMaterialDirtyMechanism;
  37953. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37954. get blockMaterialDirtyMechanism(): boolean;
  37955. set blockMaterialDirtyMechanism(value: boolean);
  37956. /**
  37957. * Will flag all materials as dirty to trigger new shader compilation
  37958. * @param flag defines the flag used to specify which material part must be marked as dirty
  37959. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37960. */
  37961. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37962. /** @hidden */
  37963. _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;
  37964. /** @hidden */
  37965. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37966. /** @hidden */
  37967. _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;
  37968. /** @hidden */
  37969. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37970. /** @hidden */
  37971. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37972. /** @hidden */
  37973. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37974. }
  37975. }
  37976. declare module "babylonjs/assetContainer" {
  37977. import { AbstractScene } from "babylonjs/abstractScene";
  37978. import { Scene } from "babylonjs/scene";
  37979. import { Mesh } from "babylonjs/Meshes/mesh";
  37980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37981. import { Skeleton } from "babylonjs/Bones/skeleton";
  37982. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37983. import { Animatable } from "babylonjs/Animations/animatable";
  37984. import { Nullable } from "babylonjs/types";
  37985. import { Node } from "babylonjs/node";
  37986. /**
  37987. * Set of assets to keep when moving a scene into an asset container.
  37988. */
  37989. export class KeepAssets extends AbstractScene {
  37990. }
  37991. /**
  37992. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37993. */
  37994. export class InstantiatedEntries {
  37995. /**
  37996. * List of new root nodes (eg. nodes with no parent)
  37997. */
  37998. rootNodes: TransformNode[];
  37999. /**
  38000. * List of new skeletons
  38001. */
  38002. skeletons: Skeleton[];
  38003. /**
  38004. * List of new animation groups
  38005. */
  38006. animationGroups: AnimationGroup[];
  38007. }
  38008. /**
  38009. * Container with a set of assets that can be added or removed from a scene.
  38010. */
  38011. export class AssetContainer extends AbstractScene {
  38012. private _wasAddedToScene;
  38013. /**
  38014. * The scene the AssetContainer belongs to.
  38015. */
  38016. scene: Scene;
  38017. /**
  38018. * Instantiates an AssetContainer.
  38019. * @param scene The scene the AssetContainer belongs to.
  38020. */
  38021. constructor(scene: Scene);
  38022. /**
  38023. * Instantiate or clone all meshes and add the new ones to the scene.
  38024. * Skeletons and animation groups will all be cloned
  38025. * @param nameFunction defines an optional function used to get new names for clones
  38026. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38027. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38028. */
  38029. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38030. /**
  38031. * Adds all the assets from the container to the scene.
  38032. */
  38033. addAllToScene(): void;
  38034. /**
  38035. * Removes all the assets in the container from the scene
  38036. */
  38037. removeAllFromScene(): void;
  38038. /**
  38039. * Disposes all the assets in the container
  38040. */
  38041. dispose(): void;
  38042. private _moveAssets;
  38043. /**
  38044. * Removes all the assets contained in the scene and adds them to the container.
  38045. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38046. */
  38047. moveAllFromScene(keepAssets?: KeepAssets): void;
  38048. /**
  38049. * 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.
  38050. * @returns the root mesh
  38051. */
  38052. createRootMesh(): Mesh;
  38053. /**
  38054. * Merge animations from this asset container into a scene
  38055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38056. * @param animatables set of animatables to retarget to a node from the scene
  38057. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38058. */
  38059. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38060. }
  38061. }
  38062. declare module "babylonjs/abstractScene" {
  38063. import { Scene } from "babylonjs/scene";
  38064. import { Nullable } from "babylonjs/types";
  38065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38066. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38067. import { Geometry } from "babylonjs/Meshes/geometry";
  38068. import { Skeleton } from "babylonjs/Bones/skeleton";
  38069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38070. import { AssetContainer } from "babylonjs/assetContainer";
  38071. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38072. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38074. import { Material } from "babylonjs/Materials/material";
  38075. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38076. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38077. import { Camera } from "babylonjs/Cameras/camera";
  38078. import { Light } from "babylonjs/Lights/light";
  38079. import { Node } from "babylonjs/node";
  38080. import { Animation } from "babylonjs/Animations/animation";
  38081. /**
  38082. * Defines how the parser contract is defined.
  38083. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38084. */
  38085. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38086. /**
  38087. * Defines how the individual parser contract is defined.
  38088. * These parser can parse an individual asset
  38089. */
  38090. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38091. /**
  38092. * Base class of the scene acting as a container for the different elements composing a scene.
  38093. * This class is dynamically extended by the different components of the scene increasing
  38094. * flexibility and reducing coupling
  38095. */
  38096. export abstract class AbstractScene {
  38097. /**
  38098. * Stores the list of available parsers in the application.
  38099. */
  38100. private static _BabylonFileParsers;
  38101. /**
  38102. * Stores the list of available individual parsers in the application.
  38103. */
  38104. private static _IndividualBabylonFileParsers;
  38105. /**
  38106. * Adds a parser in the list of available ones
  38107. * @param name Defines the name of the parser
  38108. * @param parser Defines the parser to add
  38109. */
  38110. static AddParser(name: string, parser: BabylonFileParser): void;
  38111. /**
  38112. * Gets a general parser from the list of avaialble ones
  38113. * @param name Defines the name of the parser
  38114. * @returns the requested parser or null
  38115. */
  38116. static GetParser(name: string): Nullable<BabylonFileParser>;
  38117. /**
  38118. * Adds n individual parser in the list of available ones
  38119. * @param name Defines the name of the parser
  38120. * @param parser Defines the parser to add
  38121. */
  38122. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38123. /**
  38124. * Gets an individual parser from the list of avaialble ones
  38125. * @param name Defines the name of the parser
  38126. * @returns the requested parser or null
  38127. */
  38128. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38129. /**
  38130. * Parser json data and populate both a scene and its associated container object
  38131. * @param jsonData Defines the data to parse
  38132. * @param scene Defines the scene to parse the data for
  38133. * @param container Defines the container attached to the parsing sequence
  38134. * @param rootUrl Defines the root url of the data
  38135. */
  38136. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38137. /**
  38138. * Gets the list of root nodes (ie. nodes with no parent)
  38139. */
  38140. rootNodes: Node[];
  38141. /** All of the cameras added to this scene
  38142. * @see http://doc.babylonjs.com/babylon101/cameras
  38143. */
  38144. cameras: Camera[];
  38145. /**
  38146. * All of the lights added to this scene
  38147. * @see http://doc.babylonjs.com/babylon101/lights
  38148. */
  38149. lights: Light[];
  38150. /**
  38151. * All of the (abstract) meshes added to this scene
  38152. */
  38153. meshes: AbstractMesh[];
  38154. /**
  38155. * The list of skeletons added to the scene
  38156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38157. */
  38158. skeletons: Skeleton[];
  38159. /**
  38160. * All of the particle systems added to this scene
  38161. * @see http://doc.babylonjs.com/babylon101/particles
  38162. */
  38163. particleSystems: IParticleSystem[];
  38164. /**
  38165. * Gets a list of Animations associated with the scene
  38166. */
  38167. animations: Animation[];
  38168. /**
  38169. * All of the animation groups added to this scene
  38170. * @see http://doc.babylonjs.com/how_to/group
  38171. */
  38172. animationGroups: AnimationGroup[];
  38173. /**
  38174. * All of the multi-materials added to this scene
  38175. * @see http://doc.babylonjs.com/how_to/multi_materials
  38176. */
  38177. multiMaterials: MultiMaterial[];
  38178. /**
  38179. * All of the materials added to this scene
  38180. * In the context of a Scene, it is not supposed to be modified manually.
  38181. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38182. * Note also that the order of the Material within the array is not significant and might change.
  38183. * @see http://doc.babylonjs.com/babylon101/materials
  38184. */
  38185. materials: Material[];
  38186. /**
  38187. * The list of morph target managers added to the scene
  38188. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38189. */
  38190. morphTargetManagers: MorphTargetManager[];
  38191. /**
  38192. * The list of geometries used in the scene.
  38193. */
  38194. geometries: Geometry[];
  38195. /**
  38196. * All of the tranform nodes added to this scene
  38197. * In the context of a Scene, it is not supposed to be modified manually.
  38198. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38199. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38200. * @see http://doc.babylonjs.com/how_to/transformnode
  38201. */
  38202. transformNodes: TransformNode[];
  38203. /**
  38204. * ActionManagers available on the scene.
  38205. */
  38206. actionManagers: AbstractActionManager[];
  38207. /**
  38208. * Textures to keep.
  38209. */
  38210. textures: BaseTexture[];
  38211. /**
  38212. * Environment texture for the scene
  38213. */
  38214. environmentTexture: Nullable<BaseTexture>;
  38215. /**
  38216. * @returns all meshes, lights, cameras, transformNodes and bones
  38217. */
  38218. getNodes(): Array<Node>;
  38219. }
  38220. }
  38221. declare module "babylonjs/Audio/sound" {
  38222. import { Observable } from "babylonjs/Misc/observable";
  38223. import { Vector3 } from "babylonjs/Maths/math.vector";
  38224. import { Nullable } from "babylonjs/types";
  38225. import { Scene } from "babylonjs/scene";
  38226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38227. /**
  38228. * Interface used to define options for Sound class
  38229. */
  38230. export interface ISoundOptions {
  38231. /**
  38232. * Does the sound autoplay once loaded.
  38233. */
  38234. autoplay?: boolean;
  38235. /**
  38236. * Does the sound loop after it finishes playing once.
  38237. */
  38238. loop?: boolean;
  38239. /**
  38240. * Sound's volume
  38241. */
  38242. volume?: number;
  38243. /**
  38244. * Is it a spatial sound?
  38245. */
  38246. spatialSound?: boolean;
  38247. /**
  38248. * Maximum distance to hear that sound
  38249. */
  38250. maxDistance?: number;
  38251. /**
  38252. * Uses user defined attenuation function
  38253. */
  38254. useCustomAttenuation?: boolean;
  38255. /**
  38256. * Define the roll off factor of spatial sounds.
  38257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38258. */
  38259. rolloffFactor?: number;
  38260. /**
  38261. * Define the reference distance the sound should be heard perfectly.
  38262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38263. */
  38264. refDistance?: number;
  38265. /**
  38266. * Define the distance attenuation model the sound will follow.
  38267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38268. */
  38269. distanceModel?: string;
  38270. /**
  38271. * Defines the playback speed (1 by default)
  38272. */
  38273. playbackRate?: number;
  38274. /**
  38275. * Defines if the sound is from a streaming source
  38276. */
  38277. streaming?: boolean;
  38278. /**
  38279. * Defines an optional length (in seconds) inside the sound file
  38280. */
  38281. length?: number;
  38282. /**
  38283. * Defines an optional offset (in seconds) inside the sound file
  38284. */
  38285. offset?: number;
  38286. /**
  38287. * If true, URLs will not be required to state the audio file codec to use.
  38288. */
  38289. skipCodecCheck?: boolean;
  38290. }
  38291. /**
  38292. * Defines a sound that can be played in the application.
  38293. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38295. */
  38296. export class Sound {
  38297. /**
  38298. * The name of the sound in the scene.
  38299. */
  38300. name: string;
  38301. /**
  38302. * Does the sound autoplay once loaded.
  38303. */
  38304. autoplay: boolean;
  38305. /**
  38306. * Does the sound loop after it finishes playing once.
  38307. */
  38308. loop: boolean;
  38309. /**
  38310. * Does the sound use a custom attenuation curve to simulate the falloff
  38311. * happening when the source gets further away from the camera.
  38312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38313. */
  38314. useCustomAttenuation: boolean;
  38315. /**
  38316. * The sound track id this sound belongs to.
  38317. */
  38318. soundTrackId: number;
  38319. /**
  38320. * Is this sound currently played.
  38321. */
  38322. isPlaying: boolean;
  38323. /**
  38324. * Is this sound currently paused.
  38325. */
  38326. isPaused: boolean;
  38327. /**
  38328. * Does this sound enables spatial sound.
  38329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38330. */
  38331. spatialSound: boolean;
  38332. /**
  38333. * Define the reference distance the sound should be heard perfectly.
  38334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38335. */
  38336. refDistance: number;
  38337. /**
  38338. * Define the roll off factor of spatial sounds.
  38339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38340. */
  38341. rolloffFactor: number;
  38342. /**
  38343. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38345. */
  38346. maxDistance: number;
  38347. /**
  38348. * Define the distance attenuation model the sound will follow.
  38349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38350. */
  38351. distanceModel: string;
  38352. /**
  38353. * @hidden
  38354. * Back Compat
  38355. **/
  38356. onended: () => any;
  38357. /**
  38358. * Observable event when the current playing sound finishes.
  38359. */
  38360. onEndedObservable: Observable<Sound>;
  38361. private _panningModel;
  38362. private _playbackRate;
  38363. private _streaming;
  38364. private _startTime;
  38365. private _startOffset;
  38366. private _position;
  38367. /** @hidden */
  38368. _positionInEmitterSpace: boolean;
  38369. private _localDirection;
  38370. private _volume;
  38371. private _isReadyToPlay;
  38372. private _isDirectional;
  38373. private _readyToPlayCallback;
  38374. private _audioBuffer;
  38375. private _soundSource;
  38376. private _streamingSource;
  38377. private _soundPanner;
  38378. private _soundGain;
  38379. private _inputAudioNode;
  38380. private _outputAudioNode;
  38381. private _coneInnerAngle;
  38382. private _coneOuterAngle;
  38383. private _coneOuterGain;
  38384. private _scene;
  38385. private _connectedTransformNode;
  38386. private _customAttenuationFunction;
  38387. private _registerFunc;
  38388. private _isOutputConnected;
  38389. private _htmlAudioElement;
  38390. private _urlType;
  38391. private _length?;
  38392. private _offset?;
  38393. /** @hidden */
  38394. static _SceneComponentInitialization: (scene: Scene) => void;
  38395. /**
  38396. * Create a sound and attach it to a scene
  38397. * @param name Name of your sound
  38398. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38399. * @param scene defines the scene the sound belongs to
  38400. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38401. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38402. */
  38403. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38404. /**
  38405. * Release the sound and its associated resources
  38406. */
  38407. dispose(): void;
  38408. /**
  38409. * Gets if the sounds is ready to be played or not.
  38410. * @returns true if ready, otherwise false
  38411. */
  38412. isReady(): boolean;
  38413. private _soundLoaded;
  38414. /**
  38415. * Sets the data of the sound from an audiobuffer
  38416. * @param audioBuffer The audioBuffer containing the data
  38417. */
  38418. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38419. /**
  38420. * Updates the current sounds options such as maxdistance, loop...
  38421. * @param options A JSON object containing values named as the object properties
  38422. */
  38423. updateOptions(options: ISoundOptions): void;
  38424. private _createSpatialParameters;
  38425. private _updateSpatialParameters;
  38426. /**
  38427. * Switch the panning model to HRTF:
  38428. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38430. */
  38431. switchPanningModelToHRTF(): void;
  38432. /**
  38433. * Switch the panning model to Equal Power:
  38434. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38436. */
  38437. switchPanningModelToEqualPower(): void;
  38438. private _switchPanningModel;
  38439. /**
  38440. * Connect this sound to a sound track audio node like gain...
  38441. * @param soundTrackAudioNode the sound track audio node to connect to
  38442. */
  38443. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38444. /**
  38445. * Transform this sound into a directional source
  38446. * @param coneInnerAngle Size of the inner cone in degree
  38447. * @param coneOuterAngle Size of the outer cone in degree
  38448. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38449. */
  38450. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38451. /**
  38452. * Gets or sets the inner angle for the directional cone.
  38453. */
  38454. get directionalConeInnerAngle(): number;
  38455. /**
  38456. * Gets or sets the inner angle for the directional cone.
  38457. */
  38458. set directionalConeInnerAngle(value: number);
  38459. /**
  38460. * Gets or sets the outer angle for the directional cone.
  38461. */
  38462. get directionalConeOuterAngle(): number;
  38463. /**
  38464. * Gets or sets the outer angle for the directional cone.
  38465. */
  38466. set directionalConeOuterAngle(value: number);
  38467. /**
  38468. * Sets the position of the emitter if spatial sound is enabled
  38469. * @param newPosition Defines the new posisiton
  38470. */
  38471. setPosition(newPosition: Vector3): void;
  38472. /**
  38473. * Sets the local direction of the emitter if spatial sound is enabled
  38474. * @param newLocalDirection Defines the new local direction
  38475. */
  38476. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38477. private _updateDirection;
  38478. /** @hidden */
  38479. updateDistanceFromListener(): void;
  38480. /**
  38481. * Sets a new custom attenuation function for the sound.
  38482. * @param callback Defines the function used for the attenuation
  38483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38484. */
  38485. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38486. /**
  38487. * Play the sound
  38488. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38489. * @param offset (optional) Start the sound at a specific time in seconds
  38490. * @param length (optional) Sound duration (in seconds)
  38491. */
  38492. play(time?: number, offset?: number, length?: number): void;
  38493. private _onended;
  38494. /**
  38495. * Stop the sound
  38496. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38497. */
  38498. stop(time?: number): void;
  38499. /**
  38500. * Put the sound in pause
  38501. */
  38502. pause(): void;
  38503. /**
  38504. * Sets a dedicated volume for this sounds
  38505. * @param newVolume Define the new volume of the sound
  38506. * @param time Define time for gradual change to new volume
  38507. */
  38508. setVolume(newVolume: number, time?: number): void;
  38509. /**
  38510. * Set the sound play back rate
  38511. * @param newPlaybackRate Define the playback rate the sound should be played at
  38512. */
  38513. setPlaybackRate(newPlaybackRate: number): void;
  38514. /**
  38515. * Gets the volume of the sound.
  38516. * @returns the volume of the sound
  38517. */
  38518. getVolume(): number;
  38519. /**
  38520. * Attach the sound to a dedicated mesh
  38521. * @param transformNode The transform node to connect the sound with
  38522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38523. */
  38524. attachToMesh(transformNode: TransformNode): void;
  38525. /**
  38526. * Detach the sound from the previously attached mesh
  38527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38528. */
  38529. detachFromMesh(): void;
  38530. private _onRegisterAfterWorldMatrixUpdate;
  38531. /**
  38532. * Clone the current sound in the scene.
  38533. * @returns the new sound clone
  38534. */
  38535. clone(): Nullable<Sound>;
  38536. /**
  38537. * Gets the current underlying audio buffer containing the data
  38538. * @returns the audio buffer
  38539. */
  38540. getAudioBuffer(): Nullable<AudioBuffer>;
  38541. /**
  38542. * Serializes the Sound in a JSON representation
  38543. * @returns the JSON representation of the sound
  38544. */
  38545. serialize(): any;
  38546. /**
  38547. * Parse a JSON representation of a sound to innstantiate in a given scene
  38548. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38549. * @param scene Define the scene the new parsed sound should be created in
  38550. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38551. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38552. * @returns the newly parsed sound
  38553. */
  38554. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38555. }
  38556. }
  38557. declare module "babylonjs/Actions/directAudioActions" {
  38558. import { Action } from "babylonjs/Actions/action";
  38559. import { Condition } from "babylonjs/Actions/condition";
  38560. import { Sound } from "babylonjs/Audio/sound";
  38561. /**
  38562. * This defines an action helpful to play a defined sound on a triggered action.
  38563. */
  38564. export class PlaySoundAction extends Action {
  38565. private _sound;
  38566. /**
  38567. * Instantiate the action
  38568. * @param triggerOptions defines the trigger options
  38569. * @param sound defines the sound to play
  38570. * @param condition defines the trigger related conditions
  38571. */
  38572. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38573. /** @hidden */
  38574. _prepare(): void;
  38575. /**
  38576. * Execute the action and play the sound.
  38577. */
  38578. execute(): void;
  38579. /**
  38580. * Serializes the actions and its related information.
  38581. * @param parent defines the object to serialize in
  38582. * @returns the serialized object
  38583. */
  38584. serialize(parent: any): any;
  38585. }
  38586. /**
  38587. * This defines an action helpful to stop a defined sound on a triggered action.
  38588. */
  38589. export class StopSoundAction extends Action {
  38590. private _sound;
  38591. /**
  38592. * Instantiate the action
  38593. * @param triggerOptions defines the trigger options
  38594. * @param sound defines the sound to stop
  38595. * @param condition defines the trigger related conditions
  38596. */
  38597. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38598. /** @hidden */
  38599. _prepare(): void;
  38600. /**
  38601. * Execute the action and stop the sound.
  38602. */
  38603. execute(): void;
  38604. /**
  38605. * Serializes the actions and its related information.
  38606. * @param parent defines the object to serialize in
  38607. * @returns the serialized object
  38608. */
  38609. serialize(parent: any): any;
  38610. }
  38611. }
  38612. declare module "babylonjs/Actions/interpolateValueAction" {
  38613. import { Action } from "babylonjs/Actions/action";
  38614. import { Condition } from "babylonjs/Actions/condition";
  38615. import { Observable } from "babylonjs/Misc/observable";
  38616. /**
  38617. * This defines an action responsible to change the value of a property
  38618. * by interpolating between its current value and the newly set one once triggered.
  38619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38620. */
  38621. export class InterpolateValueAction extends Action {
  38622. /**
  38623. * Defines the path of the property where the value should be interpolated
  38624. */
  38625. propertyPath: string;
  38626. /**
  38627. * Defines the target value at the end of the interpolation.
  38628. */
  38629. value: any;
  38630. /**
  38631. * Defines the time it will take for the property to interpolate to the value.
  38632. */
  38633. duration: number;
  38634. /**
  38635. * Defines if the other scene animations should be stopped when the action has been triggered
  38636. */
  38637. stopOtherAnimations?: boolean;
  38638. /**
  38639. * Defines a callback raised once the interpolation animation has been done.
  38640. */
  38641. onInterpolationDone?: () => void;
  38642. /**
  38643. * Observable triggered once the interpolation animation has been done.
  38644. */
  38645. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38646. private _target;
  38647. private _effectiveTarget;
  38648. private _property;
  38649. /**
  38650. * Instantiate the action
  38651. * @param triggerOptions defines the trigger options
  38652. * @param target defines the object containing the value to interpolate
  38653. * @param propertyPath defines the path to the property in the target object
  38654. * @param value defines the target value at the end of the interpolation
  38655. * @param duration deines the time it will take for the property to interpolate to the value.
  38656. * @param condition defines the trigger related conditions
  38657. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38658. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38659. */
  38660. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38661. /** @hidden */
  38662. _prepare(): void;
  38663. /**
  38664. * Execute the action starts the value interpolation.
  38665. */
  38666. execute(): void;
  38667. /**
  38668. * Serializes the actions and its related information.
  38669. * @param parent defines the object to serialize in
  38670. * @returns the serialized object
  38671. */
  38672. serialize(parent: any): any;
  38673. }
  38674. }
  38675. declare module "babylonjs/Actions/index" {
  38676. export * from "babylonjs/Actions/abstractActionManager";
  38677. export * from "babylonjs/Actions/action";
  38678. export * from "babylonjs/Actions/actionEvent";
  38679. export * from "babylonjs/Actions/actionManager";
  38680. export * from "babylonjs/Actions/condition";
  38681. export * from "babylonjs/Actions/directActions";
  38682. export * from "babylonjs/Actions/directAudioActions";
  38683. export * from "babylonjs/Actions/interpolateValueAction";
  38684. }
  38685. declare module "babylonjs/Animations/index" {
  38686. export * from "babylonjs/Animations/animatable";
  38687. export * from "babylonjs/Animations/animation";
  38688. export * from "babylonjs/Animations/animationGroup";
  38689. export * from "babylonjs/Animations/animationPropertiesOverride";
  38690. export * from "babylonjs/Animations/easing";
  38691. export * from "babylonjs/Animations/runtimeAnimation";
  38692. export * from "babylonjs/Animations/animationEvent";
  38693. export * from "babylonjs/Animations/animationGroup";
  38694. export * from "babylonjs/Animations/animationKey";
  38695. export * from "babylonjs/Animations/animationRange";
  38696. export * from "babylonjs/Animations/animatable.interface";
  38697. }
  38698. declare module "babylonjs/Audio/soundTrack" {
  38699. import { Sound } from "babylonjs/Audio/sound";
  38700. import { Analyser } from "babylonjs/Audio/analyser";
  38701. import { Scene } from "babylonjs/scene";
  38702. /**
  38703. * Options allowed during the creation of a sound track.
  38704. */
  38705. export interface ISoundTrackOptions {
  38706. /**
  38707. * The volume the sound track should take during creation
  38708. */
  38709. volume?: number;
  38710. /**
  38711. * Define if the sound track is the main sound track of the scene
  38712. */
  38713. mainTrack?: boolean;
  38714. }
  38715. /**
  38716. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38717. * It will be also used in a future release to apply effects on a specific track.
  38718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38719. */
  38720. export class SoundTrack {
  38721. /**
  38722. * The unique identifier of the sound track in the scene.
  38723. */
  38724. id: number;
  38725. /**
  38726. * The list of sounds included in the sound track.
  38727. */
  38728. soundCollection: Array<Sound>;
  38729. private _outputAudioNode;
  38730. private _scene;
  38731. private _connectedAnalyser;
  38732. private _options;
  38733. private _isInitialized;
  38734. /**
  38735. * Creates a new sound track.
  38736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38737. * @param scene Define the scene the sound track belongs to
  38738. * @param options
  38739. */
  38740. constructor(scene: Scene, options?: ISoundTrackOptions);
  38741. private _initializeSoundTrackAudioGraph;
  38742. /**
  38743. * Release the sound track and its associated resources
  38744. */
  38745. dispose(): void;
  38746. /**
  38747. * Adds a sound to this sound track
  38748. * @param sound define the cound to add
  38749. * @ignoreNaming
  38750. */
  38751. AddSound(sound: Sound): void;
  38752. /**
  38753. * Removes a sound to this sound track
  38754. * @param sound define the cound to remove
  38755. * @ignoreNaming
  38756. */
  38757. RemoveSound(sound: Sound): void;
  38758. /**
  38759. * Set a global volume for the full sound track.
  38760. * @param newVolume Define the new volume of the sound track
  38761. */
  38762. setVolume(newVolume: number): void;
  38763. /**
  38764. * Switch the panning model to HRTF:
  38765. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38767. */
  38768. switchPanningModelToHRTF(): void;
  38769. /**
  38770. * Switch the panning model to Equal Power:
  38771. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38773. */
  38774. switchPanningModelToEqualPower(): void;
  38775. /**
  38776. * Connect the sound track to an audio analyser allowing some amazing
  38777. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38779. * @param analyser The analyser to connect to the engine
  38780. */
  38781. connectToAnalyser(analyser: Analyser): void;
  38782. }
  38783. }
  38784. declare module "babylonjs/Audio/audioSceneComponent" {
  38785. import { Sound } from "babylonjs/Audio/sound";
  38786. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38787. import { Nullable } from "babylonjs/types";
  38788. import { Vector3 } from "babylonjs/Maths/math.vector";
  38789. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38790. import { Scene } from "babylonjs/scene";
  38791. import { AbstractScene } from "babylonjs/abstractScene";
  38792. import "babylonjs/Audio/audioEngine";
  38793. module "babylonjs/abstractScene" {
  38794. interface AbstractScene {
  38795. /**
  38796. * The list of sounds used in the scene.
  38797. */
  38798. sounds: Nullable<Array<Sound>>;
  38799. }
  38800. }
  38801. module "babylonjs/scene" {
  38802. interface Scene {
  38803. /**
  38804. * @hidden
  38805. * Backing field
  38806. */
  38807. _mainSoundTrack: SoundTrack;
  38808. /**
  38809. * The main sound track played by the scene.
  38810. * It cotains your primary collection of sounds.
  38811. */
  38812. mainSoundTrack: SoundTrack;
  38813. /**
  38814. * The list of sound tracks added to the scene
  38815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38816. */
  38817. soundTracks: Nullable<Array<SoundTrack>>;
  38818. /**
  38819. * Gets a sound using a given name
  38820. * @param name defines the name to search for
  38821. * @return the found sound or null if not found at all.
  38822. */
  38823. getSoundByName(name: string): Nullable<Sound>;
  38824. /**
  38825. * Gets or sets if audio support is enabled
  38826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38827. */
  38828. audioEnabled: boolean;
  38829. /**
  38830. * Gets or sets if audio will be output to headphones
  38831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38832. */
  38833. headphone: boolean;
  38834. /**
  38835. * Gets or sets custom audio listener position provider
  38836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38837. */
  38838. audioListenerPositionProvider: Nullable<() => Vector3>;
  38839. /**
  38840. * Gets or sets a refresh rate when using 3D audio positioning
  38841. */
  38842. audioPositioningRefreshRate: number;
  38843. }
  38844. }
  38845. /**
  38846. * Defines the sound scene component responsible to manage any sounds
  38847. * in a given scene.
  38848. */
  38849. export class AudioSceneComponent implements ISceneSerializableComponent {
  38850. /**
  38851. * The component name helpfull to identify the component in the list of scene components.
  38852. */
  38853. readonly name: string;
  38854. /**
  38855. * The scene the component belongs to.
  38856. */
  38857. scene: Scene;
  38858. private _audioEnabled;
  38859. /**
  38860. * Gets whether audio is enabled or not.
  38861. * Please use related enable/disable method to switch state.
  38862. */
  38863. get audioEnabled(): boolean;
  38864. private _headphone;
  38865. /**
  38866. * Gets whether audio is outputing to headphone or not.
  38867. * Please use the according Switch methods to change output.
  38868. */
  38869. get headphone(): boolean;
  38870. /**
  38871. * Gets or sets a refresh rate when using 3D audio positioning
  38872. */
  38873. audioPositioningRefreshRate: number;
  38874. private _audioListenerPositionProvider;
  38875. /**
  38876. * Gets the current audio listener position provider
  38877. */
  38878. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38879. /**
  38880. * Sets a custom listener position for all sounds in the scene
  38881. * By default, this is the position of the first active camera
  38882. */
  38883. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38884. /**
  38885. * Creates a new instance of the component for the given scene
  38886. * @param scene Defines the scene to register the component in
  38887. */
  38888. constructor(scene: Scene);
  38889. /**
  38890. * Registers the component in a given scene
  38891. */
  38892. register(): void;
  38893. /**
  38894. * Rebuilds the elements related to this component in case of
  38895. * context lost for instance.
  38896. */
  38897. rebuild(): void;
  38898. /**
  38899. * Serializes the component data to the specified json object
  38900. * @param serializationObject The object to serialize to
  38901. */
  38902. serialize(serializationObject: any): void;
  38903. /**
  38904. * Adds all the elements from the container to the scene
  38905. * @param container the container holding the elements
  38906. */
  38907. addFromContainer(container: AbstractScene): void;
  38908. /**
  38909. * Removes all the elements in the container from the scene
  38910. * @param container contains the elements to remove
  38911. * @param dispose if the removed element should be disposed (default: false)
  38912. */
  38913. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38914. /**
  38915. * Disposes the component and the associated ressources.
  38916. */
  38917. dispose(): void;
  38918. /**
  38919. * Disables audio in the associated scene.
  38920. */
  38921. disableAudio(): void;
  38922. /**
  38923. * Enables audio in the associated scene.
  38924. */
  38925. enableAudio(): void;
  38926. /**
  38927. * Switch audio to headphone output.
  38928. */
  38929. switchAudioModeForHeadphones(): void;
  38930. /**
  38931. * Switch audio to normal speakers.
  38932. */
  38933. switchAudioModeForNormalSpeakers(): void;
  38934. private _cachedCameraDirection;
  38935. private _cachedCameraPosition;
  38936. private _lastCheck;
  38937. private _afterRender;
  38938. }
  38939. }
  38940. declare module "babylonjs/Audio/weightedsound" {
  38941. import { Sound } from "babylonjs/Audio/sound";
  38942. /**
  38943. * Wraps one or more Sound objects and selects one with random weight for playback.
  38944. */
  38945. export class WeightedSound {
  38946. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38947. loop: boolean;
  38948. private _coneInnerAngle;
  38949. private _coneOuterAngle;
  38950. private _volume;
  38951. /** A Sound is currently playing. */
  38952. isPlaying: boolean;
  38953. /** A Sound is currently paused. */
  38954. isPaused: boolean;
  38955. private _sounds;
  38956. private _weights;
  38957. private _currentIndex?;
  38958. /**
  38959. * Creates a new WeightedSound from the list of sounds given.
  38960. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38961. * @param sounds Array of Sounds that will be selected from.
  38962. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38963. */
  38964. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38965. /**
  38966. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38967. */
  38968. get directionalConeInnerAngle(): number;
  38969. /**
  38970. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38971. */
  38972. set directionalConeInnerAngle(value: number);
  38973. /**
  38974. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38975. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38976. */
  38977. get directionalConeOuterAngle(): number;
  38978. /**
  38979. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38980. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38981. */
  38982. set directionalConeOuterAngle(value: number);
  38983. /**
  38984. * Playback volume.
  38985. */
  38986. get volume(): number;
  38987. /**
  38988. * Playback volume.
  38989. */
  38990. set volume(value: number);
  38991. private _onended;
  38992. /**
  38993. * Suspend playback
  38994. */
  38995. pause(): void;
  38996. /**
  38997. * Stop playback
  38998. */
  38999. stop(): void;
  39000. /**
  39001. * Start playback.
  39002. * @param startOffset Position the clip head at a specific time in seconds.
  39003. */
  39004. play(startOffset?: number): void;
  39005. }
  39006. }
  39007. declare module "babylonjs/Audio/index" {
  39008. export * from "babylonjs/Audio/analyser";
  39009. export * from "babylonjs/Audio/audioEngine";
  39010. export * from "babylonjs/Audio/audioSceneComponent";
  39011. export * from "babylonjs/Audio/sound";
  39012. export * from "babylonjs/Audio/soundTrack";
  39013. export * from "babylonjs/Audio/weightedsound";
  39014. }
  39015. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39016. import { Behavior } from "babylonjs/Behaviors/behavior";
  39017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39018. import { BackEase } from "babylonjs/Animations/easing";
  39019. /**
  39020. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39022. */
  39023. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39024. /**
  39025. * Gets the name of the behavior.
  39026. */
  39027. get name(): string;
  39028. /**
  39029. * The easing function used by animations
  39030. */
  39031. static EasingFunction: BackEase;
  39032. /**
  39033. * The easing mode used by animations
  39034. */
  39035. static EasingMode: number;
  39036. /**
  39037. * The duration of the animation, in milliseconds
  39038. */
  39039. transitionDuration: number;
  39040. /**
  39041. * Length of the distance animated by the transition when lower radius is reached
  39042. */
  39043. lowerRadiusTransitionRange: number;
  39044. /**
  39045. * Length of the distance animated by the transition when upper radius is reached
  39046. */
  39047. upperRadiusTransitionRange: number;
  39048. private _autoTransitionRange;
  39049. /**
  39050. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39051. */
  39052. get autoTransitionRange(): boolean;
  39053. /**
  39054. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39055. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39056. */
  39057. set autoTransitionRange(value: boolean);
  39058. private _attachedCamera;
  39059. private _onAfterCheckInputsObserver;
  39060. private _onMeshTargetChangedObserver;
  39061. /**
  39062. * Initializes the behavior.
  39063. */
  39064. init(): void;
  39065. /**
  39066. * Attaches the behavior to its arc rotate camera.
  39067. * @param camera Defines the camera to attach the behavior to
  39068. */
  39069. attach(camera: ArcRotateCamera): void;
  39070. /**
  39071. * Detaches the behavior from its current arc rotate camera.
  39072. */
  39073. detach(): void;
  39074. private _radiusIsAnimating;
  39075. private _radiusBounceTransition;
  39076. private _animatables;
  39077. private _cachedWheelPrecision;
  39078. /**
  39079. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39080. * @param radiusLimit The limit to check against.
  39081. * @return Bool to indicate if at limit.
  39082. */
  39083. private _isRadiusAtLimit;
  39084. /**
  39085. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39086. * @param radiusDelta The delta by which to animate to. Can be negative.
  39087. */
  39088. private _applyBoundRadiusAnimation;
  39089. /**
  39090. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39091. */
  39092. protected _clearAnimationLocks(): void;
  39093. /**
  39094. * Stops and removes all animations that have been applied to the camera
  39095. */
  39096. stopAllAnimations(): void;
  39097. }
  39098. }
  39099. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39100. import { Behavior } from "babylonjs/Behaviors/behavior";
  39101. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39102. import { ExponentialEase } from "babylonjs/Animations/easing";
  39103. import { Nullable } from "babylonjs/types";
  39104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39105. import { Vector3 } from "babylonjs/Maths/math.vector";
  39106. /**
  39107. * 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.
  39108. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39109. */
  39110. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39111. /**
  39112. * Gets the name of the behavior.
  39113. */
  39114. get name(): string;
  39115. private _mode;
  39116. private _radiusScale;
  39117. private _positionScale;
  39118. private _defaultElevation;
  39119. private _elevationReturnTime;
  39120. private _elevationReturnWaitTime;
  39121. private _zoomStopsAnimation;
  39122. private _framingTime;
  39123. /**
  39124. * The easing function used by animations
  39125. */
  39126. static EasingFunction: ExponentialEase;
  39127. /**
  39128. * The easing mode used by animations
  39129. */
  39130. static EasingMode: number;
  39131. /**
  39132. * Sets the current mode used by the behavior
  39133. */
  39134. set mode(mode: number);
  39135. /**
  39136. * Gets current mode used by the behavior.
  39137. */
  39138. get mode(): number;
  39139. /**
  39140. * Sets the scale applied to the radius (1 by default)
  39141. */
  39142. set radiusScale(radius: number);
  39143. /**
  39144. * Gets the scale applied to the radius
  39145. */
  39146. get radiusScale(): number;
  39147. /**
  39148. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39149. */
  39150. set positionScale(scale: number);
  39151. /**
  39152. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39153. */
  39154. get positionScale(): number;
  39155. /**
  39156. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39157. * behaviour is triggered, in radians.
  39158. */
  39159. set defaultElevation(elevation: number);
  39160. /**
  39161. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39162. * behaviour is triggered, in radians.
  39163. */
  39164. get defaultElevation(): number;
  39165. /**
  39166. * Sets the time (in milliseconds) taken to return to the default beta position.
  39167. * Negative value indicates camera should not return to default.
  39168. */
  39169. set elevationReturnTime(speed: number);
  39170. /**
  39171. * Gets the time (in milliseconds) taken to return to the default beta position.
  39172. * Negative value indicates camera should not return to default.
  39173. */
  39174. get elevationReturnTime(): number;
  39175. /**
  39176. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39177. */
  39178. set elevationReturnWaitTime(time: number);
  39179. /**
  39180. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39181. */
  39182. get elevationReturnWaitTime(): number;
  39183. /**
  39184. * Sets the flag that indicates if user zooming should stop animation.
  39185. */
  39186. set zoomStopsAnimation(flag: boolean);
  39187. /**
  39188. * Gets the flag that indicates if user zooming should stop animation.
  39189. */
  39190. get zoomStopsAnimation(): boolean;
  39191. /**
  39192. * Sets the transition time when framing the mesh, in milliseconds
  39193. */
  39194. set framingTime(time: number);
  39195. /**
  39196. * Gets the transition time when framing the mesh, in milliseconds
  39197. */
  39198. get framingTime(): number;
  39199. /**
  39200. * Define if the behavior should automatically change the configured
  39201. * camera limits and sensibilities.
  39202. */
  39203. autoCorrectCameraLimitsAndSensibility: boolean;
  39204. private _onPrePointerObservableObserver;
  39205. private _onAfterCheckInputsObserver;
  39206. private _onMeshTargetChangedObserver;
  39207. private _attachedCamera;
  39208. private _isPointerDown;
  39209. private _lastInteractionTime;
  39210. /**
  39211. * Initializes the behavior.
  39212. */
  39213. init(): void;
  39214. /**
  39215. * Attaches the behavior to its arc rotate camera.
  39216. * @param camera Defines the camera to attach the behavior to
  39217. */
  39218. attach(camera: ArcRotateCamera): void;
  39219. /**
  39220. * Detaches the behavior from its current arc rotate camera.
  39221. */
  39222. detach(): void;
  39223. private _animatables;
  39224. private _betaIsAnimating;
  39225. private _betaTransition;
  39226. private _radiusTransition;
  39227. private _vectorTransition;
  39228. /**
  39229. * Targets the given mesh and updates zoom level accordingly.
  39230. * @param mesh The mesh to target.
  39231. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39232. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39233. */
  39234. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39235. /**
  39236. * Targets the given mesh with its children and updates zoom level accordingly.
  39237. * @param mesh The mesh to target.
  39238. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39239. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39240. */
  39241. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39242. /**
  39243. * Targets the given meshes with their children and updates zoom level accordingly.
  39244. * @param meshes The mesh to target.
  39245. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39246. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39247. */
  39248. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39249. /**
  39250. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39251. * @param minimumWorld Determines the smaller position of the bounding box extend
  39252. * @param maximumWorld Determines the bigger position of the bounding box extend
  39253. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39254. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39255. */
  39256. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39257. /**
  39258. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39259. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39260. * frustum width.
  39261. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39262. * to fully enclose the mesh in the viewing frustum.
  39263. */
  39264. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39265. /**
  39266. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39267. * is automatically returned to its default position (expected to be above ground plane).
  39268. */
  39269. private _maintainCameraAboveGround;
  39270. /**
  39271. * Returns the frustum slope based on the canvas ratio and camera FOV
  39272. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39273. */
  39274. private _getFrustumSlope;
  39275. /**
  39276. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39277. */
  39278. private _clearAnimationLocks;
  39279. /**
  39280. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39281. */
  39282. private _applyUserInteraction;
  39283. /**
  39284. * Stops and removes all animations that have been applied to the camera
  39285. */
  39286. stopAllAnimations(): void;
  39287. /**
  39288. * Gets a value indicating if the user is moving the camera
  39289. */
  39290. get isUserIsMoving(): boolean;
  39291. /**
  39292. * The camera can move all the way towards the mesh.
  39293. */
  39294. static IgnoreBoundsSizeMode: number;
  39295. /**
  39296. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39297. */
  39298. static FitFrustumSidesMode: number;
  39299. }
  39300. }
  39301. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39302. import { Nullable } from "babylonjs/types";
  39303. import { Camera } from "babylonjs/Cameras/camera";
  39304. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39305. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39306. /**
  39307. * Base class for Camera Pointer Inputs.
  39308. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39309. * for example usage.
  39310. */
  39311. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39312. /**
  39313. * Defines the camera the input is attached to.
  39314. */
  39315. abstract camera: Camera;
  39316. /**
  39317. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39318. */
  39319. protected _altKey: boolean;
  39320. protected _ctrlKey: boolean;
  39321. protected _metaKey: boolean;
  39322. protected _shiftKey: boolean;
  39323. /**
  39324. * Which mouse buttons were pressed at time of last mouse event.
  39325. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39326. */
  39327. protected _buttonsPressed: number;
  39328. /**
  39329. * Defines the buttons associated with the input to handle camera move.
  39330. */
  39331. buttons: number[];
  39332. /**
  39333. * Attach the input controls to a specific dom element to get the input from.
  39334. * @param element Defines the element the controls should be listened from
  39335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39336. */
  39337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39338. /**
  39339. * Detach the current controls from the specified dom element.
  39340. * @param element Defines the element to stop listening the inputs from
  39341. */
  39342. detachControl(element: Nullable<HTMLElement>): void;
  39343. /**
  39344. * Gets the class name of the current input.
  39345. * @returns the class name
  39346. */
  39347. getClassName(): string;
  39348. /**
  39349. * Get the friendly name associated with the input class.
  39350. * @returns the input friendly name
  39351. */
  39352. getSimpleName(): string;
  39353. /**
  39354. * Called on pointer POINTERDOUBLETAP event.
  39355. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39356. */
  39357. protected onDoubleTap(type: string): void;
  39358. /**
  39359. * Called on pointer POINTERMOVE event if only a single touch is active.
  39360. * Override this method to provide functionality.
  39361. */
  39362. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39363. /**
  39364. * Called on pointer POINTERMOVE event if multiple touches are active.
  39365. * Override this method to provide functionality.
  39366. */
  39367. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39368. /**
  39369. * Called on JS contextmenu event.
  39370. * Override this method to provide functionality.
  39371. */
  39372. protected onContextMenu(evt: PointerEvent): void;
  39373. /**
  39374. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39375. * press.
  39376. * Override this method to provide functionality.
  39377. */
  39378. protected onButtonDown(evt: PointerEvent): void;
  39379. /**
  39380. * Called each time a new POINTERUP event occurs. Ie, for each button
  39381. * release.
  39382. * Override this method to provide functionality.
  39383. */
  39384. protected onButtonUp(evt: PointerEvent): void;
  39385. /**
  39386. * Called when window becomes inactive.
  39387. * Override this method to provide functionality.
  39388. */
  39389. protected onLostFocus(): void;
  39390. private _pointerInput;
  39391. private _observer;
  39392. private _onLostFocus;
  39393. private pointA;
  39394. private pointB;
  39395. }
  39396. }
  39397. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39398. import { Nullable } from "babylonjs/types";
  39399. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39400. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39401. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39402. /**
  39403. * Manage the pointers inputs to control an arc rotate camera.
  39404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39405. */
  39406. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39407. /**
  39408. * Defines the camera the input is attached to.
  39409. */
  39410. camera: ArcRotateCamera;
  39411. /**
  39412. * Gets the class name of the current input.
  39413. * @returns the class name
  39414. */
  39415. getClassName(): string;
  39416. /**
  39417. * Defines the buttons associated with the input to handle camera move.
  39418. */
  39419. buttons: number[];
  39420. /**
  39421. * Defines the pointer angular sensibility along the X axis or how fast is
  39422. * the camera rotating.
  39423. */
  39424. angularSensibilityX: number;
  39425. /**
  39426. * Defines the pointer angular sensibility along the Y axis or how fast is
  39427. * the camera rotating.
  39428. */
  39429. angularSensibilityY: number;
  39430. /**
  39431. * Defines the pointer pinch precision or how fast is the camera zooming.
  39432. */
  39433. pinchPrecision: number;
  39434. /**
  39435. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39436. * from 0.
  39437. * It defines the percentage of current camera.radius to use as delta when
  39438. * pinch zoom is used.
  39439. */
  39440. pinchDeltaPercentage: number;
  39441. /**
  39442. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39443. * that any object in the plane at the camera's target point will scale
  39444. * perfectly with finger motion.
  39445. * Overrides pinchDeltaPercentage and pinchPrecision.
  39446. */
  39447. useNaturalPinchZoom: boolean;
  39448. /**
  39449. * Defines the pointer panning sensibility or how fast is the camera moving.
  39450. */
  39451. panningSensibility: number;
  39452. /**
  39453. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39454. */
  39455. multiTouchPanning: boolean;
  39456. /**
  39457. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39458. * zoom (pinch) through multitouch.
  39459. */
  39460. multiTouchPanAndZoom: boolean;
  39461. /**
  39462. * Revers pinch action direction.
  39463. */
  39464. pinchInwards: boolean;
  39465. private _isPanClick;
  39466. private _twoFingerActivityCount;
  39467. private _isPinching;
  39468. /**
  39469. * Called on pointer POINTERMOVE event if only a single touch is active.
  39470. */
  39471. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39472. /**
  39473. * Called on pointer POINTERDOUBLETAP event.
  39474. */
  39475. protected onDoubleTap(type: string): void;
  39476. /**
  39477. * Called on pointer POINTERMOVE event if multiple touches are active.
  39478. */
  39479. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39480. /**
  39481. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39482. * press.
  39483. */
  39484. protected onButtonDown(evt: PointerEvent): void;
  39485. /**
  39486. * Called each time a new POINTERUP event occurs. Ie, for each button
  39487. * release.
  39488. */
  39489. protected onButtonUp(evt: PointerEvent): void;
  39490. /**
  39491. * Called when window becomes inactive.
  39492. */
  39493. protected onLostFocus(): void;
  39494. }
  39495. }
  39496. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39497. import { Nullable } from "babylonjs/types";
  39498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39500. /**
  39501. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39503. */
  39504. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39505. /**
  39506. * Defines the camera the input is attached to.
  39507. */
  39508. camera: ArcRotateCamera;
  39509. /**
  39510. * Defines the list of key codes associated with the up action (increase alpha)
  39511. */
  39512. keysUp: number[];
  39513. /**
  39514. * Defines the list of key codes associated with the down action (decrease alpha)
  39515. */
  39516. keysDown: number[];
  39517. /**
  39518. * Defines the list of key codes associated with the left action (increase beta)
  39519. */
  39520. keysLeft: number[];
  39521. /**
  39522. * Defines the list of key codes associated with the right action (decrease beta)
  39523. */
  39524. keysRight: number[];
  39525. /**
  39526. * Defines the list of key codes associated with the reset action.
  39527. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39528. */
  39529. keysReset: number[];
  39530. /**
  39531. * Defines the panning sensibility of the inputs.
  39532. * (How fast is the camera panning)
  39533. */
  39534. panningSensibility: number;
  39535. /**
  39536. * Defines the zooming sensibility of the inputs.
  39537. * (How fast is the camera zooming)
  39538. */
  39539. zoomingSensibility: number;
  39540. /**
  39541. * Defines whether maintaining the alt key down switch the movement mode from
  39542. * orientation to zoom.
  39543. */
  39544. useAltToZoom: boolean;
  39545. /**
  39546. * Rotation speed of the camera
  39547. */
  39548. angularSpeed: number;
  39549. private _keys;
  39550. private _ctrlPressed;
  39551. private _altPressed;
  39552. private _onCanvasBlurObserver;
  39553. private _onKeyboardObserver;
  39554. private _engine;
  39555. private _scene;
  39556. /**
  39557. * Attach the input controls to a specific dom element to get the input from.
  39558. * @param element Defines the element the controls should be listened from
  39559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39560. */
  39561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39562. /**
  39563. * Detach the current controls from the specified dom element.
  39564. * @param element Defines the element to stop listening the inputs from
  39565. */
  39566. detachControl(element: Nullable<HTMLElement>): void;
  39567. /**
  39568. * Update the current camera state depending on the inputs that have been used this frame.
  39569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39570. */
  39571. checkInputs(): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39585. import { Nullable } from "babylonjs/types";
  39586. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39587. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39588. /**
  39589. * Manage the mouse wheel inputs to control an arc rotate camera.
  39590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39591. */
  39592. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39593. /**
  39594. * Defines the camera the input is attached to.
  39595. */
  39596. camera: ArcRotateCamera;
  39597. /**
  39598. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39599. */
  39600. wheelPrecision: number;
  39601. /**
  39602. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39603. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39604. */
  39605. wheelDeltaPercentage: number;
  39606. private _wheel;
  39607. private _observer;
  39608. private computeDeltaFromMouseWheelLegacyEvent;
  39609. /**
  39610. * Attach the input controls to a specific dom element to get the input from.
  39611. * @param element Defines the element the controls should be listened from
  39612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39613. */
  39614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39615. /**
  39616. * Detach the current controls from the specified dom element.
  39617. * @param element Defines the element to stop listening the inputs from
  39618. */
  39619. detachControl(element: Nullable<HTMLElement>): void;
  39620. /**
  39621. * Gets the class name of the current intput.
  39622. * @returns the class name
  39623. */
  39624. getClassName(): string;
  39625. /**
  39626. * Get the friendly name associated with the input class.
  39627. * @returns the input friendly name
  39628. */
  39629. getSimpleName(): string;
  39630. }
  39631. }
  39632. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39634. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39635. /**
  39636. * Default Inputs manager for the ArcRotateCamera.
  39637. * It groups all the default supported inputs for ease of use.
  39638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39639. */
  39640. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39641. /**
  39642. * Instantiates a new ArcRotateCameraInputsManager.
  39643. * @param camera Defines the camera the inputs belong to
  39644. */
  39645. constructor(camera: ArcRotateCamera);
  39646. /**
  39647. * Add mouse wheel input support to the input manager.
  39648. * @returns the current input manager
  39649. */
  39650. addMouseWheel(): ArcRotateCameraInputsManager;
  39651. /**
  39652. * Add pointers input support to the input manager.
  39653. * @returns the current input manager
  39654. */
  39655. addPointers(): ArcRotateCameraInputsManager;
  39656. /**
  39657. * Add keyboard input support to the input manager.
  39658. * @returns the current input manager
  39659. */
  39660. addKeyboard(): ArcRotateCameraInputsManager;
  39661. }
  39662. }
  39663. declare module "babylonjs/Cameras/arcRotateCamera" {
  39664. import { Observable } from "babylonjs/Misc/observable";
  39665. import { Nullable } from "babylonjs/types";
  39666. import { Scene } from "babylonjs/scene";
  39667. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39669. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39670. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39671. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39672. import { Camera } from "babylonjs/Cameras/camera";
  39673. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39674. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39675. import { Collider } from "babylonjs/Collisions/collider";
  39676. /**
  39677. * This represents an orbital type of camera.
  39678. *
  39679. * 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.
  39680. * 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.
  39681. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39682. */
  39683. export class ArcRotateCamera extends TargetCamera {
  39684. /**
  39685. * Defines the rotation angle of the camera along the longitudinal axis.
  39686. */
  39687. alpha: number;
  39688. /**
  39689. * Defines the rotation angle of the camera along the latitudinal axis.
  39690. */
  39691. beta: number;
  39692. /**
  39693. * Defines the radius of the camera from it s target point.
  39694. */
  39695. radius: number;
  39696. protected _target: Vector3;
  39697. protected _targetHost: Nullable<AbstractMesh>;
  39698. /**
  39699. * Defines the target point of the camera.
  39700. * The camera looks towards it form the radius distance.
  39701. */
  39702. get target(): Vector3;
  39703. set target(value: Vector3);
  39704. /**
  39705. * Define the current local position of the camera in the scene
  39706. */
  39707. get position(): Vector3;
  39708. set position(newPosition: Vector3);
  39709. protected _upVector: Vector3;
  39710. protected _upToYMatrix: Matrix;
  39711. protected _YToUpMatrix: Matrix;
  39712. /**
  39713. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39714. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39715. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39716. */
  39717. set upVector(vec: Vector3);
  39718. get upVector(): Vector3;
  39719. /**
  39720. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39721. */
  39722. setMatUp(): void;
  39723. /**
  39724. * Current inertia value on the longitudinal axis.
  39725. * The bigger this number the longer it will take for the camera to stop.
  39726. */
  39727. inertialAlphaOffset: number;
  39728. /**
  39729. * Current inertia value on the latitudinal axis.
  39730. * The bigger this number the longer it will take for the camera to stop.
  39731. */
  39732. inertialBetaOffset: number;
  39733. /**
  39734. * Current inertia value on the radius axis.
  39735. * The bigger this number the longer it will take for the camera to stop.
  39736. */
  39737. inertialRadiusOffset: number;
  39738. /**
  39739. * Minimum allowed angle on the longitudinal axis.
  39740. * This can help limiting how the Camera is able to move in the scene.
  39741. */
  39742. lowerAlphaLimit: Nullable<number>;
  39743. /**
  39744. * Maximum allowed angle on the longitudinal axis.
  39745. * This can help limiting how the Camera is able to move in the scene.
  39746. */
  39747. upperAlphaLimit: Nullable<number>;
  39748. /**
  39749. * Minimum allowed angle on the latitudinal axis.
  39750. * This can help limiting how the Camera is able to move in the scene.
  39751. */
  39752. lowerBetaLimit: number;
  39753. /**
  39754. * Maximum allowed angle on the latitudinal axis.
  39755. * This can help limiting how the Camera is able to move in the scene.
  39756. */
  39757. upperBetaLimit: number;
  39758. /**
  39759. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39760. * This can help limiting how the Camera is able to move in the scene.
  39761. */
  39762. lowerRadiusLimit: Nullable<number>;
  39763. /**
  39764. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39765. * This can help limiting how the Camera is able to move in the scene.
  39766. */
  39767. upperRadiusLimit: Nullable<number>;
  39768. /**
  39769. * Defines the current inertia value used during panning of the camera along the X axis.
  39770. */
  39771. inertialPanningX: number;
  39772. /**
  39773. * Defines the current inertia value used during panning of the camera along the Y axis.
  39774. */
  39775. inertialPanningY: number;
  39776. /**
  39777. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39778. * Basically if your fingers moves away from more than this distance you will be considered
  39779. * in pinch mode.
  39780. */
  39781. pinchToPanMaxDistance: number;
  39782. /**
  39783. * Defines the maximum distance the camera can pan.
  39784. * This could help keeping the cammera always in your scene.
  39785. */
  39786. panningDistanceLimit: Nullable<number>;
  39787. /**
  39788. * Defines the target of the camera before paning.
  39789. */
  39790. panningOriginTarget: Vector3;
  39791. /**
  39792. * Defines the value of the inertia used during panning.
  39793. * 0 would mean stop inertia and one would mean no decelleration at all.
  39794. */
  39795. panningInertia: number;
  39796. /**
  39797. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39798. */
  39799. get angularSensibilityX(): number;
  39800. set angularSensibilityX(value: number);
  39801. /**
  39802. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39803. */
  39804. get angularSensibilityY(): number;
  39805. set angularSensibilityY(value: number);
  39806. /**
  39807. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39808. */
  39809. get pinchPrecision(): number;
  39810. set pinchPrecision(value: number);
  39811. /**
  39812. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39813. * It will be used instead of pinchDeltaPrecision if different from 0.
  39814. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39815. */
  39816. get pinchDeltaPercentage(): number;
  39817. set pinchDeltaPercentage(value: number);
  39818. /**
  39819. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39820. * and pinch delta percentage.
  39821. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39822. * that any object in the plane at the camera's target point will scale
  39823. * perfectly with finger motion.
  39824. */
  39825. get useNaturalPinchZoom(): boolean;
  39826. set useNaturalPinchZoom(value: boolean);
  39827. /**
  39828. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39829. */
  39830. get panningSensibility(): number;
  39831. set panningSensibility(value: number);
  39832. /**
  39833. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39834. */
  39835. get keysUp(): number[];
  39836. set keysUp(value: number[]);
  39837. /**
  39838. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39839. */
  39840. get keysDown(): number[];
  39841. set keysDown(value: number[]);
  39842. /**
  39843. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39844. */
  39845. get keysLeft(): number[];
  39846. set keysLeft(value: number[]);
  39847. /**
  39848. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39849. */
  39850. get keysRight(): number[];
  39851. set keysRight(value: number[]);
  39852. /**
  39853. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39854. */
  39855. get wheelPrecision(): number;
  39856. set wheelPrecision(value: number);
  39857. /**
  39858. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39859. * It will be used instead of pinchDeltaPrecision if different from 0.
  39860. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39861. */
  39862. get wheelDeltaPercentage(): number;
  39863. set wheelDeltaPercentage(value: number);
  39864. /**
  39865. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39866. */
  39867. zoomOnFactor: number;
  39868. /**
  39869. * Defines a screen offset for the camera position.
  39870. */
  39871. targetScreenOffset: Vector2;
  39872. /**
  39873. * Allows the camera to be completely reversed.
  39874. * If false the camera can not arrive upside down.
  39875. */
  39876. allowUpsideDown: boolean;
  39877. /**
  39878. * Define if double tap/click is used to restore the previously saved state of the camera.
  39879. */
  39880. useInputToRestoreState: boolean;
  39881. /** @hidden */
  39882. _viewMatrix: Matrix;
  39883. /** @hidden */
  39884. _useCtrlForPanning: boolean;
  39885. /** @hidden */
  39886. _panningMouseButton: number;
  39887. /**
  39888. * Defines the input associated to the camera.
  39889. */
  39890. inputs: ArcRotateCameraInputsManager;
  39891. /** @hidden */
  39892. _reset: () => void;
  39893. /**
  39894. * Defines the allowed panning axis.
  39895. */
  39896. panningAxis: Vector3;
  39897. protected _localDirection: Vector3;
  39898. protected _transformedDirection: Vector3;
  39899. private _bouncingBehavior;
  39900. /**
  39901. * Gets the bouncing behavior of the camera if it has been enabled.
  39902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39903. */
  39904. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39905. /**
  39906. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39907. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39908. */
  39909. get useBouncingBehavior(): boolean;
  39910. set useBouncingBehavior(value: boolean);
  39911. private _framingBehavior;
  39912. /**
  39913. * Gets the framing behavior of the camera if it has been enabled.
  39914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39915. */
  39916. get framingBehavior(): Nullable<FramingBehavior>;
  39917. /**
  39918. * Defines if the framing behavior of the camera is enabled on the camera.
  39919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39920. */
  39921. get useFramingBehavior(): boolean;
  39922. set useFramingBehavior(value: boolean);
  39923. private _autoRotationBehavior;
  39924. /**
  39925. * Gets the auto rotation behavior of the camera if it has been enabled.
  39926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39927. */
  39928. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39929. /**
  39930. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39931. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39932. */
  39933. get useAutoRotationBehavior(): boolean;
  39934. set useAutoRotationBehavior(value: boolean);
  39935. /**
  39936. * Observable triggered when the mesh target has been changed on the camera.
  39937. */
  39938. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39939. /**
  39940. * Event raised when the camera is colliding with a mesh.
  39941. */
  39942. onCollide: (collidedMesh: AbstractMesh) => void;
  39943. /**
  39944. * Defines whether the camera should check collision with the objects oh the scene.
  39945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39946. */
  39947. checkCollisions: boolean;
  39948. /**
  39949. * Defines the collision radius of the camera.
  39950. * This simulates a sphere around the camera.
  39951. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39952. */
  39953. collisionRadius: Vector3;
  39954. protected _collider: Collider;
  39955. protected _previousPosition: Vector3;
  39956. protected _collisionVelocity: Vector3;
  39957. protected _newPosition: Vector3;
  39958. protected _previousAlpha: number;
  39959. protected _previousBeta: number;
  39960. protected _previousRadius: number;
  39961. protected _collisionTriggered: boolean;
  39962. protected _targetBoundingCenter: Nullable<Vector3>;
  39963. private _computationVector;
  39964. /**
  39965. * Instantiates a new ArcRotateCamera in a given scene
  39966. * @param name Defines the name of the camera
  39967. * @param alpha Defines the camera rotation along the logitudinal axis
  39968. * @param beta Defines the camera rotation along the latitudinal axis
  39969. * @param radius Defines the camera distance from its target
  39970. * @param target Defines the camera target
  39971. * @param scene Defines the scene the camera belongs to
  39972. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39973. */
  39974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39975. /** @hidden */
  39976. _initCache(): void;
  39977. /** @hidden */
  39978. _updateCache(ignoreParentClass?: boolean): void;
  39979. protected _getTargetPosition(): Vector3;
  39980. private _storedAlpha;
  39981. private _storedBeta;
  39982. private _storedRadius;
  39983. private _storedTarget;
  39984. private _storedTargetScreenOffset;
  39985. /**
  39986. * Stores the current state of the camera (alpha, beta, radius and target)
  39987. * @returns the camera itself
  39988. */
  39989. storeState(): Camera;
  39990. /**
  39991. * @hidden
  39992. * Restored camera state. You must call storeState() first
  39993. */
  39994. _restoreStateValues(): boolean;
  39995. /** @hidden */
  39996. _isSynchronizedViewMatrix(): boolean;
  39997. /**
  39998. * Attached controls to the current camera.
  39999. * @param element Defines the element the controls should be listened from
  40000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40001. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40002. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40003. */
  40004. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40005. /**
  40006. * Detach the current controls from the camera.
  40007. * The camera will stop reacting to inputs.
  40008. * @param element Defines the element to stop listening the inputs from
  40009. */
  40010. detachControl(element: HTMLElement): void;
  40011. /** @hidden */
  40012. _checkInputs(): void;
  40013. protected _checkLimits(): void;
  40014. /**
  40015. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40016. */
  40017. rebuildAnglesAndRadius(): void;
  40018. /**
  40019. * Use a position to define the current camera related information like alpha, beta and radius
  40020. * @param position Defines the position to set the camera at
  40021. */
  40022. setPosition(position: Vector3): void;
  40023. /**
  40024. * Defines the target the camera should look at.
  40025. * This will automatically adapt alpha beta and radius to fit within the new target.
  40026. * @param target Defines the new target as a Vector or a mesh
  40027. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40028. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40029. */
  40030. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40031. /** @hidden */
  40032. _getViewMatrix(): Matrix;
  40033. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40034. /**
  40035. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40036. * @param meshes Defines the mesh to zoom on
  40037. * @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)
  40038. */
  40039. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40040. /**
  40041. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40042. * The target will be changed but the radius
  40043. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40044. * @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)
  40045. */
  40046. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40047. min: Vector3;
  40048. max: Vector3;
  40049. distance: number;
  40050. }, doNotUpdateMaxZ?: boolean): void;
  40051. /**
  40052. * @override
  40053. * Override Camera.createRigCamera
  40054. */
  40055. createRigCamera(name: string, cameraIndex: number): Camera;
  40056. /**
  40057. * @hidden
  40058. * @override
  40059. * Override Camera._updateRigCameras
  40060. */
  40061. _updateRigCameras(): void;
  40062. /**
  40063. * Destroy the camera and release the current resources hold by it.
  40064. */
  40065. dispose(): void;
  40066. /**
  40067. * Gets the current object class name.
  40068. * @return the class name
  40069. */
  40070. getClassName(): string;
  40071. }
  40072. }
  40073. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40074. import { Behavior } from "babylonjs/Behaviors/behavior";
  40075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40076. /**
  40077. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40079. */
  40080. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40081. /**
  40082. * Gets the name of the behavior.
  40083. */
  40084. get name(): string;
  40085. private _zoomStopsAnimation;
  40086. private _idleRotationSpeed;
  40087. private _idleRotationWaitTime;
  40088. private _idleRotationSpinupTime;
  40089. /**
  40090. * Sets the flag that indicates if user zooming should stop animation.
  40091. */
  40092. set zoomStopsAnimation(flag: boolean);
  40093. /**
  40094. * Gets the flag that indicates if user zooming should stop animation.
  40095. */
  40096. get zoomStopsAnimation(): boolean;
  40097. /**
  40098. * Sets the default speed at which the camera rotates around the model.
  40099. */
  40100. set idleRotationSpeed(speed: number);
  40101. /**
  40102. * Gets the default speed at which the camera rotates around the model.
  40103. */
  40104. get idleRotationSpeed(): number;
  40105. /**
  40106. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40107. */
  40108. set idleRotationWaitTime(time: number);
  40109. /**
  40110. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40111. */
  40112. get idleRotationWaitTime(): number;
  40113. /**
  40114. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40115. */
  40116. set idleRotationSpinupTime(time: number);
  40117. /**
  40118. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40119. */
  40120. get idleRotationSpinupTime(): number;
  40121. /**
  40122. * Gets a value indicating if the camera is currently rotating because of this behavior
  40123. */
  40124. get rotationInProgress(): boolean;
  40125. private _onPrePointerObservableObserver;
  40126. private _onAfterCheckInputsObserver;
  40127. private _attachedCamera;
  40128. private _isPointerDown;
  40129. private _lastFrameTime;
  40130. private _lastInteractionTime;
  40131. private _cameraRotationSpeed;
  40132. /**
  40133. * Initializes the behavior.
  40134. */
  40135. init(): void;
  40136. /**
  40137. * Attaches the behavior to its arc rotate camera.
  40138. * @param camera Defines the camera to attach the behavior to
  40139. */
  40140. attach(camera: ArcRotateCamera): void;
  40141. /**
  40142. * Detaches the behavior from its current arc rotate camera.
  40143. */
  40144. detach(): void;
  40145. /**
  40146. * Returns true if user is scrolling.
  40147. * @return true if user is scrolling.
  40148. */
  40149. private _userIsZooming;
  40150. private _lastFrameRadius;
  40151. private _shouldAnimationStopForInteraction;
  40152. /**
  40153. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40154. */
  40155. private _applyUserInteraction;
  40156. private _userIsMoving;
  40157. }
  40158. }
  40159. declare module "babylonjs/Behaviors/Cameras/index" {
  40160. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40161. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40162. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40163. }
  40164. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40165. import { Mesh } from "babylonjs/Meshes/mesh";
  40166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40167. import { Behavior } from "babylonjs/Behaviors/behavior";
  40168. /**
  40169. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40170. */
  40171. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40172. private ui;
  40173. /**
  40174. * The name of the behavior
  40175. */
  40176. name: string;
  40177. /**
  40178. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40179. */
  40180. distanceAwayFromFace: number;
  40181. /**
  40182. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40183. */
  40184. distanceAwayFromBottomOfFace: number;
  40185. private _faceVectors;
  40186. private _target;
  40187. private _scene;
  40188. private _onRenderObserver;
  40189. private _tmpMatrix;
  40190. private _tmpVector;
  40191. /**
  40192. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40193. * @param ui The transform node that should be attched to the mesh
  40194. */
  40195. constructor(ui: TransformNode);
  40196. /**
  40197. * Initializes the behavior
  40198. */
  40199. init(): void;
  40200. private _closestFace;
  40201. private _zeroVector;
  40202. private _lookAtTmpMatrix;
  40203. private _lookAtToRef;
  40204. /**
  40205. * Attaches the AttachToBoxBehavior to the passed in mesh
  40206. * @param target The mesh that the specified node will be attached to
  40207. */
  40208. attach(target: Mesh): void;
  40209. /**
  40210. * Detaches the behavior from the mesh
  40211. */
  40212. detach(): void;
  40213. }
  40214. }
  40215. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40216. import { Behavior } from "babylonjs/Behaviors/behavior";
  40217. import { Mesh } from "babylonjs/Meshes/mesh";
  40218. /**
  40219. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40220. */
  40221. export class FadeInOutBehavior implements Behavior<Mesh> {
  40222. /**
  40223. * Time in milliseconds to delay before fading in (Default: 0)
  40224. */
  40225. delay: number;
  40226. /**
  40227. * Time in milliseconds for the mesh to fade in (Default: 300)
  40228. */
  40229. fadeInTime: number;
  40230. private _millisecondsPerFrame;
  40231. private _hovered;
  40232. private _hoverValue;
  40233. private _ownerNode;
  40234. /**
  40235. * Instatiates the FadeInOutBehavior
  40236. */
  40237. constructor();
  40238. /**
  40239. * The name of the behavior
  40240. */
  40241. get name(): string;
  40242. /**
  40243. * Initializes the behavior
  40244. */
  40245. init(): void;
  40246. /**
  40247. * Attaches the fade behavior on the passed in mesh
  40248. * @param ownerNode The mesh that will be faded in/out once attached
  40249. */
  40250. attach(ownerNode: Mesh): void;
  40251. /**
  40252. * Detaches the behavior from the mesh
  40253. */
  40254. detach(): void;
  40255. /**
  40256. * Triggers the mesh to begin fading in or out
  40257. * @param value if the object should fade in or out (true to fade in)
  40258. */
  40259. fadeIn(value: boolean): void;
  40260. private _update;
  40261. private _setAllVisibility;
  40262. }
  40263. }
  40264. declare module "babylonjs/Misc/pivotTools" {
  40265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40266. /**
  40267. * Class containing a set of static utilities functions for managing Pivots
  40268. * @hidden
  40269. */
  40270. export class PivotTools {
  40271. private static _PivotCached;
  40272. private static _OldPivotPoint;
  40273. private static _PivotTranslation;
  40274. private static _PivotTmpVector;
  40275. /** @hidden */
  40276. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40277. /** @hidden */
  40278. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40279. }
  40280. }
  40281. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40282. import { Scene } from "babylonjs/scene";
  40283. import { Vector4 } from "babylonjs/Maths/math.vector";
  40284. import { Mesh } from "babylonjs/Meshes/mesh";
  40285. import { Nullable } from "babylonjs/types";
  40286. import { Plane } from "babylonjs/Maths/math.plane";
  40287. /**
  40288. * Class containing static functions to help procedurally build meshes
  40289. */
  40290. export class PlaneBuilder {
  40291. /**
  40292. * Creates a plane mesh
  40293. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40294. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40295. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40299. * @param name defines the name of the mesh
  40300. * @param options defines the options used to create the mesh
  40301. * @param scene defines the hosting scene
  40302. * @returns the plane mesh
  40303. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40304. */
  40305. static CreatePlane(name: string, options: {
  40306. size?: number;
  40307. width?: number;
  40308. height?: number;
  40309. sideOrientation?: number;
  40310. frontUVs?: Vector4;
  40311. backUVs?: Vector4;
  40312. updatable?: boolean;
  40313. sourcePlane?: Plane;
  40314. }, scene?: Nullable<Scene>): Mesh;
  40315. }
  40316. }
  40317. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40318. import { Behavior } from "babylonjs/Behaviors/behavior";
  40319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40320. import { Observable } from "babylonjs/Misc/observable";
  40321. import { Vector3 } from "babylonjs/Maths/math.vector";
  40322. import { Ray } from "babylonjs/Culling/ray";
  40323. import "babylonjs/Meshes/Builders/planeBuilder";
  40324. /**
  40325. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40326. */
  40327. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40328. private static _AnyMouseID;
  40329. /**
  40330. * Abstract mesh the behavior is set on
  40331. */
  40332. attachedNode: AbstractMesh;
  40333. private _dragPlane;
  40334. private _scene;
  40335. private _pointerObserver;
  40336. private _beforeRenderObserver;
  40337. private static _planeScene;
  40338. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40339. /**
  40340. * 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)
  40341. */
  40342. maxDragAngle: number;
  40343. /**
  40344. * @hidden
  40345. */
  40346. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40347. /**
  40348. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40349. */
  40350. currentDraggingPointerID: number;
  40351. /**
  40352. * The last position where the pointer hit the drag plane in world space
  40353. */
  40354. lastDragPosition: Vector3;
  40355. /**
  40356. * If the behavior is currently in a dragging state
  40357. */
  40358. dragging: boolean;
  40359. /**
  40360. * 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)
  40361. */
  40362. dragDeltaRatio: number;
  40363. /**
  40364. * If the drag plane orientation should be updated during the dragging (Default: true)
  40365. */
  40366. updateDragPlane: boolean;
  40367. private _debugMode;
  40368. private _moving;
  40369. /**
  40370. * Fires each time the attached mesh is dragged with the pointer
  40371. * * delta between last drag position and current drag position in world space
  40372. * * dragDistance along the drag axis
  40373. * * dragPlaneNormal normal of the current drag plane used during the drag
  40374. * * dragPlanePoint in world space where the drag intersects the drag plane
  40375. */
  40376. onDragObservable: Observable<{
  40377. delta: Vector3;
  40378. dragPlanePoint: Vector3;
  40379. dragPlaneNormal: Vector3;
  40380. dragDistance: number;
  40381. pointerId: number;
  40382. }>;
  40383. /**
  40384. * Fires each time a drag begins (eg. mouse down on mesh)
  40385. */
  40386. onDragStartObservable: Observable<{
  40387. dragPlanePoint: Vector3;
  40388. pointerId: number;
  40389. }>;
  40390. /**
  40391. * Fires each time a drag ends (eg. mouse release after drag)
  40392. */
  40393. onDragEndObservable: Observable<{
  40394. dragPlanePoint: Vector3;
  40395. pointerId: number;
  40396. }>;
  40397. /**
  40398. * If the attached mesh should be moved when dragged
  40399. */
  40400. moveAttached: boolean;
  40401. /**
  40402. * If the drag behavior will react to drag events (Default: true)
  40403. */
  40404. enabled: boolean;
  40405. /**
  40406. * If pointer events should start and release the drag (Default: true)
  40407. */
  40408. startAndReleaseDragOnPointerEvents: boolean;
  40409. /**
  40410. * If camera controls should be detached during the drag
  40411. */
  40412. detachCameraControls: boolean;
  40413. /**
  40414. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40415. */
  40416. useObjectOrientationForDragging: boolean;
  40417. private _options;
  40418. /**
  40419. * Gets the options used by the behavior
  40420. */
  40421. get options(): {
  40422. dragAxis?: Vector3;
  40423. dragPlaneNormal?: Vector3;
  40424. };
  40425. /**
  40426. * Sets the options used by the behavior
  40427. */
  40428. set options(options: {
  40429. dragAxis?: Vector3;
  40430. dragPlaneNormal?: Vector3;
  40431. });
  40432. /**
  40433. * Creates a pointer drag behavior that can be attached to a mesh
  40434. * @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)
  40435. */
  40436. constructor(options?: {
  40437. dragAxis?: Vector3;
  40438. dragPlaneNormal?: Vector3;
  40439. });
  40440. /**
  40441. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40442. */
  40443. validateDrag: (targetPosition: Vector3) => boolean;
  40444. /**
  40445. * The name of the behavior
  40446. */
  40447. get name(): string;
  40448. /**
  40449. * Initializes the behavior
  40450. */
  40451. init(): void;
  40452. private _tmpVector;
  40453. private _alternatePickedPoint;
  40454. private _worldDragAxis;
  40455. private _targetPosition;
  40456. private _attachedElement;
  40457. /**
  40458. * Attaches the drag behavior the passed in mesh
  40459. * @param ownerNode The mesh that will be dragged around once attached
  40460. * @param predicate Predicate to use for pick filtering
  40461. */
  40462. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40463. /**
  40464. * Force relase the drag action by code.
  40465. */
  40466. releaseDrag(): void;
  40467. private _startDragRay;
  40468. private _lastPointerRay;
  40469. /**
  40470. * Simulates the start of a pointer drag event on the behavior
  40471. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40472. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40473. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40474. */
  40475. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40476. private _startDrag;
  40477. private _dragDelta;
  40478. private _moveDrag;
  40479. private _pickWithRayOnDragPlane;
  40480. private _pointA;
  40481. private _pointB;
  40482. private _pointC;
  40483. private _lineA;
  40484. private _lineB;
  40485. private _localAxis;
  40486. private _lookAt;
  40487. private _updateDragPlanePosition;
  40488. /**
  40489. * Detaches the behavior from the mesh
  40490. */
  40491. detach(): void;
  40492. }
  40493. }
  40494. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40495. import { Mesh } from "babylonjs/Meshes/mesh";
  40496. import { Behavior } from "babylonjs/Behaviors/behavior";
  40497. /**
  40498. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40499. */
  40500. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40501. private _dragBehaviorA;
  40502. private _dragBehaviorB;
  40503. private _startDistance;
  40504. private _initialScale;
  40505. private _targetScale;
  40506. private _ownerNode;
  40507. private _sceneRenderObserver;
  40508. /**
  40509. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40510. */
  40511. constructor();
  40512. /**
  40513. * The name of the behavior
  40514. */
  40515. get name(): string;
  40516. /**
  40517. * Initializes the behavior
  40518. */
  40519. init(): void;
  40520. private _getCurrentDistance;
  40521. /**
  40522. * Attaches the scale behavior the passed in mesh
  40523. * @param ownerNode The mesh that will be scaled around once attached
  40524. */
  40525. attach(ownerNode: Mesh): void;
  40526. /**
  40527. * Detaches the behavior from the mesh
  40528. */
  40529. detach(): void;
  40530. }
  40531. }
  40532. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40533. import { Behavior } from "babylonjs/Behaviors/behavior";
  40534. import { Mesh } from "babylonjs/Meshes/mesh";
  40535. import { Observable } from "babylonjs/Misc/observable";
  40536. /**
  40537. * 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
  40538. */
  40539. export class SixDofDragBehavior implements Behavior<Mesh> {
  40540. private static _virtualScene;
  40541. private _ownerNode;
  40542. private _sceneRenderObserver;
  40543. private _scene;
  40544. private _targetPosition;
  40545. private _virtualOriginMesh;
  40546. private _virtualDragMesh;
  40547. private _pointerObserver;
  40548. private _moving;
  40549. private _startingOrientation;
  40550. /**
  40551. * 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)
  40552. */
  40553. private zDragFactor;
  40554. /**
  40555. * If the object should rotate to face the drag origin
  40556. */
  40557. rotateDraggedObject: boolean;
  40558. /**
  40559. * If the behavior is currently in a dragging state
  40560. */
  40561. dragging: boolean;
  40562. /**
  40563. * 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)
  40564. */
  40565. dragDeltaRatio: number;
  40566. /**
  40567. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40568. */
  40569. currentDraggingPointerID: number;
  40570. /**
  40571. * If camera controls should be detached during the drag
  40572. */
  40573. detachCameraControls: boolean;
  40574. /**
  40575. * Fires each time a drag starts
  40576. */
  40577. onDragStartObservable: Observable<{}>;
  40578. /**
  40579. * Fires each time a drag ends (eg. mouse release after drag)
  40580. */
  40581. onDragEndObservable: Observable<{}>;
  40582. /**
  40583. * 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
  40584. */
  40585. constructor();
  40586. /**
  40587. * The name of the behavior
  40588. */
  40589. get name(): string;
  40590. /**
  40591. * Initializes the behavior
  40592. */
  40593. init(): void;
  40594. /**
  40595. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40596. */
  40597. private get _pointerCamera();
  40598. /**
  40599. * Attaches the scale behavior the passed in mesh
  40600. * @param ownerNode The mesh that will be scaled around once attached
  40601. */
  40602. attach(ownerNode: Mesh): void;
  40603. /**
  40604. * Detaches the behavior from the mesh
  40605. */
  40606. detach(): void;
  40607. }
  40608. }
  40609. declare module "babylonjs/Behaviors/Meshes/index" {
  40610. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40611. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40612. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40613. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40614. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40615. }
  40616. declare module "babylonjs/Behaviors/index" {
  40617. export * from "babylonjs/Behaviors/behavior";
  40618. export * from "babylonjs/Behaviors/Cameras/index";
  40619. export * from "babylonjs/Behaviors/Meshes/index";
  40620. }
  40621. declare module "babylonjs/Bones/boneIKController" {
  40622. import { Bone } from "babylonjs/Bones/bone";
  40623. import { Vector3 } from "babylonjs/Maths/math.vector";
  40624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40625. import { Nullable } from "babylonjs/types";
  40626. /**
  40627. * Class used to apply inverse kinematics to bones
  40628. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40629. */
  40630. export class BoneIKController {
  40631. private static _tmpVecs;
  40632. private static _tmpQuat;
  40633. private static _tmpMats;
  40634. /**
  40635. * Gets or sets the target mesh
  40636. */
  40637. targetMesh: AbstractMesh;
  40638. /** Gets or sets the mesh used as pole */
  40639. poleTargetMesh: AbstractMesh;
  40640. /**
  40641. * Gets or sets the bone used as pole
  40642. */
  40643. poleTargetBone: Nullable<Bone>;
  40644. /**
  40645. * Gets or sets the target position
  40646. */
  40647. targetPosition: Vector3;
  40648. /**
  40649. * Gets or sets the pole target position
  40650. */
  40651. poleTargetPosition: Vector3;
  40652. /**
  40653. * Gets or sets the pole target local offset
  40654. */
  40655. poleTargetLocalOffset: Vector3;
  40656. /**
  40657. * Gets or sets the pole angle
  40658. */
  40659. poleAngle: number;
  40660. /**
  40661. * Gets or sets the mesh associated with the controller
  40662. */
  40663. mesh: AbstractMesh;
  40664. /**
  40665. * 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)
  40666. */
  40667. slerpAmount: number;
  40668. private _bone1Quat;
  40669. private _bone1Mat;
  40670. private _bone2Ang;
  40671. private _bone1;
  40672. private _bone2;
  40673. private _bone1Length;
  40674. private _bone2Length;
  40675. private _maxAngle;
  40676. private _maxReach;
  40677. private _rightHandedSystem;
  40678. private _bendAxis;
  40679. private _slerping;
  40680. private _adjustRoll;
  40681. /**
  40682. * Gets or sets maximum allowed angle
  40683. */
  40684. get maxAngle(): number;
  40685. set maxAngle(value: number);
  40686. /**
  40687. * Creates a new BoneIKController
  40688. * @param mesh defines the mesh to control
  40689. * @param bone defines the bone to control
  40690. * @param options defines options to set up the controller
  40691. */
  40692. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40693. targetMesh?: AbstractMesh;
  40694. poleTargetMesh?: AbstractMesh;
  40695. poleTargetBone?: Bone;
  40696. poleTargetLocalOffset?: Vector3;
  40697. poleAngle?: number;
  40698. bendAxis?: Vector3;
  40699. maxAngle?: number;
  40700. slerpAmount?: number;
  40701. });
  40702. private _setMaxAngle;
  40703. /**
  40704. * Force the controller to update the bones
  40705. */
  40706. update(): void;
  40707. }
  40708. }
  40709. declare module "babylonjs/Bones/boneLookController" {
  40710. import { Vector3 } from "babylonjs/Maths/math.vector";
  40711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40712. import { Bone } from "babylonjs/Bones/bone";
  40713. import { Space } from "babylonjs/Maths/math.axis";
  40714. /**
  40715. * Class used to make a bone look toward a point in space
  40716. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40717. */
  40718. export class BoneLookController {
  40719. private static _tmpVecs;
  40720. private static _tmpQuat;
  40721. private static _tmpMats;
  40722. /**
  40723. * The target Vector3 that the bone will look at
  40724. */
  40725. target: Vector3;
  40726. /**
  40727. * The mesh that the bone is attached to
  40728. */
  40729. mesh: AbstractMesh;
  40730. /**
  40731. * The bone that will be looking to the target
  40732. */
  40733. bone: Bone;
  40734. /**
  40735. * The up axis of the coordinate system that is used when the bone is rotated
  40736. */
  40737. upAxis: Vector3;
  40738. /**
  40739. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40740. */
  40741. upAxisSpace: Space;
  40742. /**
  40743. * Used to make an adjustment to the yaw of the bone
  40744. */
  40745. adjustYaw: number;
  40746. /**
  40747. * Used to make an adjustment to the pitch of the bone
  40748. */
  40749. adjustPitch: number;
  40750. /**
  40751. * Used to make an adjustment to the roll of the bone
  40752. */
  40753. adjustRoll: number;
  40754. /**
  40755. * 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)
  40756. */
  40757. slerpAmount: number;
  40758. private _minYaw;
  40759. private _maxYaw;
  40760. private _minPitch;
  40761. private _maxPitch;
  40762. private _minYawSin;
  40763. private _minYawCos;
  40764. private _maxYawSin;
  40765. private _maxYawCos;
  40766. private _midYawConstraint;
  40767. private _minPitchTan;
  40768. private _maxPitchTan;
  40769. private _boneQuat;
  40770. private _slerping;
  40771. private _transformYawPitch;
  40772. private _transformYawPitchInv;
  40773. private _firstFrameSkipped;
  40774. private _yawRange;
  40775. private _fowardAxis;
  40776. /**
  40777. * Gets or sets the minimum yaw angle that the bone can look to
  40778. */
  40779. get minYaw(): number;
  40780. set minYaw(value: number);
  40781. /**
  40782. * Gets or sets the maximum yaw angle that the bone can look to
  40783. */
  40784. get maxYaw(): number;
  40785. set maxYaw(value: number);
  40786. /**
  40787. * Gets or sets the minimum pitch angle that the bone can look to
  40788. */
  40789. get minPitch(): number;
  40790. set minPitch(value: number);
  40791. /**
  40792. * Gets or sets the maximum pitch angle that the bone can look to
  40793. */
  40794. get maxPitch(): number;
  40795. set maxPitch(value: number);
  40796. /**
  40797. * Create a BoneLookController
  40798. * @param mesh the mesh that the bone belongs to
  40799. * @param bone the bone that will be looking to the target
  40800. * @param target the target Vector3 to look at
  40801. * @param options optional settings:
  40802. * * maxYaw: the maximum angle the bone will yaw to
  40803. * * minYaw: the minimum angle the bone will yaw to
  40804. * * maxPitch: the maximum angle the bone will pitch to
  40805. * * minPitch: the minimum angle the bone will yaw to
  40806. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40807. * * upAxis: the up axis of the coordinate system
  40808. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40809. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40810. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40811. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40812. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40813. * * adjustRoll: used to make an adjustment to the roll of the bone
  40814. **/
  40815. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40816. maxYaw?: number;
  40817. minYaw?: number;
  40818. maxPitch?: number;
  40819. minPitch?: number;
  40820. slerpAmount?: number;
  40821. upAxis?: Vector3;
  40822. upAxisSpace?: Space;
  40823. yawAxis?: Vector3;
  40824. pitchAxis?: Vector3;
  40825. adjustYaw?: number;
  40826. adjustPitch?: number;
  40827. adjustRoll?: number;
  40828. });
  40829. /**
  40830. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40831. */
  40832. update(): void;
  40833. private _getAngleDiff;
  40834. private _getAngleBetween;
  40835. private _isAngleBetween;
  40836. }
  40837. }
  40838. declare module "babylonjs/Bones/index" {
  40839. export * from "babylonjs/Bones/bone";
  40840. export * from "babylonjs/Bones/boneIKController";
  40841. export * from "babylonjs/Bones/boneLookController";
  40842. export * from "babylonjs/Bones/skeleton";
  40843. }
  40844. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40845. import { Nullable } from "babylonjs/types";
  40846. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40847. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40848. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40849. /**
  40850. * Manage the gamepad inputs to control an arc rotate camera.
  40851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40852. */
  40853. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40854. /**
  40855. * Defines the camera the input is attached to.
  40856. */
  40857. camera: ArcRotateCamera;
  40858. /**
  40859. * Defines the gamepad the input is gathering event from.
  40860. */
  40861. gamepad: Nullable<Gamepad>;
  40862. /**
  40863. * Defines the gamepad rotation sensiblity.
  40864. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40865. */
  40866. gamepadRotationSensibility: number;
  40867. /**
  40868. * Defines the gamepad move sensiblity.
  40869. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40870. */
  40871. gamepadMoveSensibility: number;
  40872. private _yAxisScale;
  40873. /**
  40874. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40875. */
  40876. get invertYAxis(): boolean;
  40877. set invertYAxis(value: boolean);
  40878. private _onGamepadConnectedObserver;
  40879. private _onGamepadDisconnectedObserver;
  40880. /**
  40881. * Attach the input controls to a specific dom element to get the input from.
  40882. * @param element Defines the element the controls should be listened from
  40883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40884. */
  40885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40886. /**
  40887. * Detach the current controls from the specified dom element.
  40888. * @param element Defines the element to stop listening the inputs from
  40889. */
  40890. detachControl(element: Nullable<HTMLElement>): void;
  40891. /**
  40892. * Update the current camera state depending on the inputs that have been used this frame.
  40893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40894. */
  40895. checkInputs(): void;
  40896. /**
  40897. * Gets the class name of the current intput.
  40898. * @returns the class name
  40899. */
  40900. getClassName(): string;
  40901. /**
  40902. * Get the friendly name associated with the input class.
  40903. * @returns the input friendly name
  40904. */
  40905. getSimpleName(): string;
  40906. }
  40907. }
  40908. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40909. import { Nullable } from "babylonjs/types";
  40910. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40911. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40912. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40913. interface ArcRotateCameraInputsManager {
  40914. /**
  40915. * Add orientation input support to the input manager.
  40916. * @returns the current input manager
  40917. */
  40918. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40919. }
  40920. }
  40921. /**
  40922. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40924. */
  40925. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40926. /**
  40927. * Defines the camera the input is attached to.
  40928. */
  40929. camera: ArcRotateCamera;
  40930. /**
  40931. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40932. */
  40933. alphaCorrection: number;
  40934. /**
  40935. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40936. */
  40937. gammaCorrection: number;
  40938. private _alpha;
  40939. private _gamma;
  40940. private _dirty;
  40941. private _deviceOrientationHandler;
  40942. /**
  40943. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40944. */
  40945. constructor();
  40946. /**
  40947. * Attach the input controls to a specific dom element to get the input from.
  40948. * @param element Defines the element the controls should be listened from
  40949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40950. */
  40951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40952. /** @hidden */
  40953. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40954. /**
  40955. * Update the current camera state depending on the inputs that have been used this frame.
  40956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40957. */
  40958. checkInputs(): void;
  40959. /**
  40960. * Detach the current controls from the specified dom element.
  40961. * @param element Defines the element to stop listening the inputs from
  40962. */
  40963. detachControl(element: Nullable<HTMLElement>): void;
  40964. /**
  40965. * Gets the class name of the current intput.
  40966. * @returns the class name
  40967. */
  40968. getClassName(): string;
  40969. /**
  40970. * Get the friendly name associated with the input class.
  40971. * @returns the input friendly name
  40972. */
  40973. getSimpleName(): string;
  40974. }
  40975. }
  40976. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40977. import { Nullable } from "babylonjs/types";
  40978. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40979. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40980. /**
  40981. * Listen to mouse events to control the camera.
  40982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40983. */
  40984. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40985. /**
  40986. * Defines the camera the input is attached to.
  40987. */
  40988. camera: FlyCamera;
  40989. /**
  40990. * Defines if touch is enabled. (Default is true.)
  40991. */
  40992. touchEnabled: boolean;
  40993. /**
  40994. * Defines the buttons associated with the input to handle camera rotation.
  40995. */
  40996. buttons: number[];
  40997. /**
  40998. * Assign buttons for Yaw control.
  40999. */
  41000. buttonsYaw: number[];
  41001. /**
  41002. * Assign buttons for Pitch control.
  41003. */
  41004. buttonsPitch: number[];
  41005. /**
  41006. * Assign buttons for Roll control.
  41007. */
  41008. buttonsRoll: number[];
  41009. /**
  41010. * Detect if any button is being pressed while mouse is moved.
  41011. * -1 = Mouse locked.
  41012. * 0 = Left button.
  41013. * 1 = Middle Button.
  41014. * 2 = Right Button.
  41015. */
  41016. activeButton: number;
  41017. /**
  41018. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41019. * Higher values reduce its sensitivity.
  41020. */
  41021. angularSensibility: number;
  41022. private _mousemoveCallback;
  41023. private _observer;
  41024. private _rollObserver;
  41025. private previousPosition;
  41026. private noPreventDefault;
  41027. private element;
  41028. /**
  41029. * Listen to mouse events to control the camera.
  41030. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41032. */
  41033. constructor(touchEnabled?: boolean);
  41034. /**
  41035. * Attach the mouse control to the HTML DOM element.
  41036. * @param element Defines the element that listens to the input events.
  41037. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41038. */
  41039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41040. /**
  41041. * Detach the current controls from the specified dom element.
  41042. * @param element Defines the element to stop listening the inputs from
  41043. */
  41044. detachControl(element: Nullable<HTMLElement>): void;
  41045. /**
  41046. * Gets the class name of the current input.
  41047. * @returns the class name.
  41048. */
  41049. getClassName(): string;
  41050. /**
  41051. * Get the friendly name associated with the input class.
  41052. * @returns the input's friendly name.
  41053. */
  41054. getSimpleName(): string;
  41055. private _pointerInput;
  41056. private _onMouseMove;
  41057. /**
  41058. * Rotate camera by mouse offset.
  41059. */
  41060. private rotateCamera;
  41061. }
  41062. }
  41063. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41064. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41065. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41066. /**
  41067. * Default Inputs manager for the FlyCamera.
  41068. * It groups all the default supported inputs for ease of use.
  41069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41070. */
  41071. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41072. /**
  41073. * Instantiates a new FlyCameraInputsManager.
  41074. * @param camera Defines the camera the inputs belong to.
  41075. */
  41076. constructor(camera: FlyCamera);
  41077. /**
  41078. * Add keyboard input support to the input manager.
  41079. * @returns the new FlyCameraKeyboardMoveInput().
  41080. */
  41081. addKeyboard(): FlyCameraInputsManager;
  41082. /**
  41083. * Add mouse input support to the input manager.
  41084. * @param touchEnabled Enable touch screen support.
  41085. * @returns the new FlyCameraMouseInput().
  41086. */
  41087. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41088. }
  41089. }
  41090. declare module "babylonjs/Cameras/flyCamera" {
  41091. import { Scene } from "babylonjs/scene";
  41092. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41094. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41095. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41096. /**
  41097. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41098. * such as in a 3D Space Shooter or a Flight Simulator.
  41099. */
  41100. export class FlyCamera extends TargetCamera {
  41101. /**
  41102. * Define the collision ellipsoid of the camera.
  41103. * This is helpful for simulating a camera body, like a player's body.
  41104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41105. */
  41106. ellipsoid: Vector3;
  41107. /**
  41108. * Define an offset for the position of the ellipsoid around the camera.
  41109. * This can be helpful if the camera is attached away from the player's body center,
  41110. * such as at its head.
  41111. */
  41112. ellipsoidOffset: Vector3;
  41113. /**
  41114. * Enable or disable collisions of the camera with the rest of the scene objects.
  41115. */
  41116. checkCollisions: boolean;
  41117. /**
  41118. * Enable or disable gravity on the camera.
  41119. */
  41120. applyGravity: boolean;
  41121. /**
  41122. * Define the current direction the camera is moving to.
  41123. */
  41124. cameraDirection: Vector3;
  41125. /**
  41126. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41127. * This overrides and empties cameraRotation.
  41128. */
  41129. rotationQuaternion: Quaternion;
  41130. /**
  41131. * Track Roll to maintain the wanted Rolling when looking around.
  41132. */
  41133. _trackRoll: number;
  41134. /**
  41135. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41136. */
  41137. rollCorrect: number;
  41138. /**
  41139. * Mimic a banked turn, Rolling the camera when Yawing.
  41140. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41141. */
  41142. bankedTurn: boolean;
  41143. /**
  41144. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41145. */
  41146. bankedTurnLimit: number;
  41147. /**
  41148. * Value of 0 disables the banked Roll.
  41149. * Value of 1 is equal to the Yaw angle in radians.
  41150. */
  41151. bankedTurnMultiplier: number;
  41152. /**
  41153. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41154. */
  41155. inputs: FlyCameraInputsManager;
  41156. /**
  41157. * Gets the input sensibility for mouse input.
  41158. * Higher values reduce sensitivity.
  41159. */
  41160. get angularSensibility(): number;
  41161. /**
  41162. * Sets the input sensibility for a mouse input.
  41163. * Higher values reduce sensitivity.
  41164. */
  41165. set angularSensibility(value: number);
  41166. /**
  41167. * Get the keys for camera movement forward.
  41168. */
  41169. get keysForward(): number[];
  41170. /**
  41171. * Set the keys for camera movement forward.
  41172. */
  41173. set keysForward(value: number[]);
  41174. /**
  41175. * Get the keys for camera movement backward.
  41176. */
  41177. get keysBackward(): number[];
  41178. set keysBackward(value: number[]);
  41179. /**
  41180. * Get the keys for camera movement up.
  41181. */
  41182. get keysUp(): number[];
  41183. /**
  41184. * Set the keys for camera movement up.
  41185. */
  41186. set keysUp(value: number[]);
  41187. /**
  41188. * Get the keys for camera movement down.
  41189. */
  41190. get keysDown(): number[];
  41191. /**
  41192. * Set the keys for camera movement down.
  41193. */
  41194. set keysDown(value: number[]);
  41195. /**
  41196. * Get the keys for camera movement left.
  41197. */
  41198. get keysLeft(): number[];
  41199. /**
  41200. * Set the keys for camera movement left.
  41201. */
  41202. set keysLeft(value: number[]);
  41203. /**
  41204. * Set the keys for camera movement right.
  41205. */
  41206. get keysRight(): number[];
  41207. /**
  41208. * Set the keys for camera movement right.
  41209. */
  41210. set keysRight(value: number[]);
  41211. /**
  41212. * Event raised when the camera collides with a mesh in the scene.
  41213. */
  41214. onCollide: (collidedMesh: AbstractMesh) => void;
  41215. private _collider;
  41216. private _needMoveForGravity;
  41217. private _oldPosition;
  41218. private _diffPosition;
  41219. private _newPosition;
  41220. /** @hidden */
  41221. _localDirection: Vector3;
  41222. /** @hidden */
  41223. _transformedDirection: Vector3;
  41224. /**
  41225. * Instantiates a FlyCamera.
  41226. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41227. * such as in a 3D Space Shooter or a Flight Simulator.
  41228. * @param name Define the name of the camera in the scene.
  41229. * @param position Define the starting position of the camera in the scene.
  41230. * @param scene Define the scene the camera belongs to.
  41231. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41232. */
  41233. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41234. /**
  41235. * Attach a control to the HTML DOM element.
  41236. * @param element Defines the element that listens to the input events.
  41237. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41238. */
  41239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41240. /**
  41241. * Detach a control from the HTML DOM element.
  41242. * The camera will stop reacting to that input.
  41243. * @param element Defines the element that listens to the input events.
  41244. */
  41245. detachControl(element: HTMLElement): void;
  41246. private _collisionMask;
  41247. /**
  41248. * Get the mask that the camera ignores in collision events.
  41249. */
  41250. get collisionMask(): number;
  41251. /**
  41252. * Set the mask that the camera ignores in collision events.
  41253. */
  41254. set collisionMask(mask: number);
  41255. /** @hidden */
  41256. _collideWithWorld(displacement: Vector3): void;
  41257. /** @hidden */
  41258. private _onCollisionPositionChange;
  41259. /** @hidden */
  41260. _checkInputs(): void;
  41261. /** @hidden */
  41262. _decideIfNeedsToMove(): boolean;
  41263. /** @hidden */
  41264. _updatePosition(): void;
  41265. /**
  41266. * Restore the Roll to its target value at the rate specified.
  41267. * @param rate - Higher means slower restoring.
  41268. * @hidden
  41269. */
  41270. restoreRoll(rate: number): void;
  41271. /**
  41272. * Destroy the camera and release the current resources held by it.
  41273. */
  41274. dispose(): void;
  41275. /**
  41276. * Get the current object class name.
  41277. * @returns the class name.
  41278. */
  41279. getClassName(): string;
  41280. }
  41281. }
  41282. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41283. import { Nullable } from "babylonjs/types";
  41284. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41285. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41286. /**
  41287. * Listen to keyboard events to control the camera.
  41288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41289. */
  41290. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41291. /**
  41292. * Defines the camera the input is attached to.
  41293. */
  41294. camera: FlyCamera;
  41295. /**
  41296. * The list of keyboard keys used to control the forward move of the camera.
  41297. */
  41298. keysForward: number[];
  41299. /**
  41300. * The list of keyboard keys used to control the backward move of the camera.
  41301. */
  41302. keysBackward: number[];
  41303. /**
  41304. * The list of keyboard keys used to control the forward move of the camera.
  41305. */
  41306. keysUp: number[];
  41307. /**
  41308. * The list of keyboard keys used to control the backward move of the camera.
  41309. */
  41310. keysDown: number[];
  41311. /**
  41312. * The list of keyboard keys used to control the right strafe move of the camera.
  41313. */
  41314. keysRight: number[];
  41315. /**
  41316. * The list of keyboard keys used to control the left strafe move of the camera.
  41317. */
  41318. keysLeft: number[];
  41319. private _keys;
  41320. private _onCanvasBlurObserver;
  41321. private _onKeyboardObserver;
  41322. private _engine;
  41323. private _scene;
  41324. /**
  41325. * Attach the input controls to a specific dom element to get the input from.
  41326. * @param element Defines the element the controls should be listened from
  41327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41328. */
  41329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41330. /**
  41331. * Detach the current controls from the specified dom element.
  41332. * @param element Defines the element to stop listening the inputs from
  41333. */
  41334. detachControl(element: Nullable<HTMLElement>): void;
  41335. /**
  41336. * Gets the class name of the current intput.
  41337. * @returns the class name
  41338. */
  41339. getClassName(): string;
  41340. /** @hidden */
  41341. _onLostFocus(e: FocusEvent): void;
  41342. /**
  41343. * Get the friendly name associated with the input class.
  41344. * @returns the input friendly name
  41345. */
  41346. getSimpleName(): string;
  41347. /**
  41348. * Update the current camera state depending on the inputs that have been used this frame.
  41349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41350. */
  41351. checkInputs(): void;
  41352. }
  41353. }
  41354. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41355. import { Nullable } from "babylonjs/types";
  41356. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41358. /**
  41359. * Manage the mouse wheel inputs to control a follow camera.
  41360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41361. */
  41362. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41363. /**
  41364. * Defines the camera the input is attached to.
  41365. */
  41366. camera: FollowCamera;
  41367. /**
  41368. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41369. */
  41370. axisControlRadius: boolean;
  41371. /**
  41372. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41373. */
  41374. axisControlHeight: boolean;
  41375. /**
  41376. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41377. */
  41378. axisControlRotation: boolean;
  41379. /**
  41380. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41381. * relation to mouseWheel events.
  41382. */
  41383. wheelPrecision: number;
  41384. /**
  41385. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41386. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41387. */
  41388. wheelDeltaPercentage: number;
  41389. private _wheel;
  41390. private _observer;
  41391. /**
  41392. * Attach the input controls to a specific dom element to get the input from.
  41393. * @param element Defines the element the controls should be listened from
  41394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41395. */
  41396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41397. /**
  41398. * Detach the current controls from the specified dom element.
  41399. * @param element Defines the element to stop listening the inputs from
  41400. */
  41401. detachControl(element: Nullable<HTMLElement>): void;
  41402. /**
  41403. * Gets the class name of the current intput.
  41404. * @returns the class name
  41405. */
  41406. getClassName(): string;
  41407. /**
  41408. * Get the friendly name associated with the input class.
  41409. * @returns the input friendly name
  41410. */
  41411. getSimpleName(): string;
  41412. }
  41413. }
  41414. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41415. import { Nullable } from "babylonjs/types";
  41416. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41417. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41418. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41419. /**
  41420. * Manage the pointers inputs to control an follow camera.
  41421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41422. */
  41423. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41424. /**
  41425. * Defines the camera the input is attached to.
  41426. */
  41427. camera: FollowCamera;
  41428. /**
  41429. * Gets the class name of the current input.
  41430. * @returns the class name
  41431. */
  41432. getClassName(): string;
  41433. /**
  41434. * Defines the pointer angular sensibility along the X axis or how fast is
  41435. * the camera rotating.
  41436. * A negative number will reverse the axis direction.
  41437. */
  41438. angularSensibilityX: number;
  41439. /**
  41440. * Defines the pointer angular sensibility along the Y axis or how fast is
  41441. * the camera rotating.
  41442. * A negative number will reverse the axis direction.
  41443. */
  41444. angularSensibilityY: number;
  41445. /**
  41446. * Defines the pointer pinch precision or how fast is the camera zooming.
  41447. * A negative number will reverse the axis direction.
  41448. */
  41449. pinchPrecision: number;
  41450. /**
  41451. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41452. * from 0.
  41453. * It defines the percentage of current camera.radius to use as delta when
  41454. * pinch zoom is used.
  41455. */
  41456. pinchDeltaPercentage: number;
  41457. /**
  41458. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41459. */
  41460. axisXControlRadius: boolean;
  41461. /**
  41462. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41463. */
  41464. axisXControlHeight: boolean;
  41465. /**
  41466. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41467. */
  41468. axisXControlRotation: boolean;
  41469. /**
  41470. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41471. */
  41472. axisYControlRadius: boolean;
  41473. /**
  41474. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41475. */
  41476. axisYControlHeight: boolean;
  41477. /**
  41478. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41479. */
  41480. axisYControlRotation: boolean;
  41481. /**
  41482. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41483. */
  41484. axisPinchControlRadius: boolean;
  41485. /**
  41486. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41487. */
  41488. axisPinchControlHeight: boolean;
  41489. /**
  41490. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41491. */
  41492. axisPinchControlRotation: boolean;
  41493. /**
  41494. * Log error messages if basic misconfiguration has occurred.
  41495. */
  41496. warningEnable: boolean;
  41497. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41498. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41499. private _warningCounter;
  41500. private _warning;
  41501. }
  41502. }
  41503. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41504. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41505. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41506. /**
  41507. * Default Inputs manager for the FollowCamera.
  41508. * It groups all the default supported inputs for ease of use.
  41509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41510. */
  41511. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41512. /**
  41513. * Instantiates a new FollowCameraInputsManager.
  41514. * @param camera Defines the camera the inputs belong to
  41515. */
  41516. constructor(camera: FollowCamera);
  41517. /**
  41518. * Add keyboard input support to the input manager.
  41519. * @returns the current input manager
  41520. */
  41521. addKeyboard(): FollowCameraInputsManager;
  41522. /**
  41523. * Add mouse wheel input support to the input manager.
  41524. * @returns the current input manager
  41525. */
  41526. addMouseWheel(): FollowCameraInputsManager;
  41527. /**
  41528. * Add pointers input support to the input manager.
  41529. * @returns the current input manager
  41530. */
  41531. addPointers(): FollowCameraInputsManager;
  41532. /**
  41533. * Add orientation input support to the input manager.
  41534. * @returns the current input manager
  41535. */
  41536. addVRDeviceOrientation(): FollowCameraInputsManager;
  41537. }
  41538. }
  41539. declare module "babylonjs/Cameras/followCamera" {
  41540. import { Nullable } from "babylonjs/types";
  41541. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41542. import { Scene } from "babylonjs/scene";
  41543. import { Vector3 } from "babylonjs/Maths/math.vector";
  41544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41545. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41546. /**
  41547. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41548. * an arc rotate version arcFollowCamera are available.
  41549. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41550. */
  41551. export class FollowCamera extends TargetCamera {
  41552. /**
  41553. * Distance the follow camera should follow an object at
  41554. */
  41555. radius: number;
  41556. /**
  41557. * Minimum allowed distance of the camera to the axis of rotation
  41558. * (The camera can not get closer).
  41559. * This can help limiting how the Camera is able to move in the scene.
  41560. */
  41561. lowerRadiusLimit: Nullable<number>;
  41562. /**
  41563. * Maximum allowed distance of the camera to the axis of rotation
  41564. * (The camera can not get further).
  41565. * This can help limiting how the Camera is able to move in the scene.
  41566. */
  41567. upperRadiusLimit: Nullable<number>;
  41568. /**
  41569. * Define a rotation offset between the camera and the object it follows
  41570. */
  41571. rotationOffset: number;
  41572. /**
  41573. * Minimum allowed angle to camera position relative to target object.
  41574. * This can help limiting how the Camera is able to move in the scene.
  41575. */
  41576. lowerRotationOffsetLimit: Nullable<number>;
  41577. /**
  41578. * Maximum allowed angle to camera position relative to target object.
  41579. * This can help limiting how the Camera is able to move in the scene.
  41580. */
  41581. upperRotationOffsetLimit: Nullable<number>;
  41582. /**
  41583. * Define a height offset between the camera and the object it follows.
  41584. * It can help following an object from the top (like a car chaing a plane)
  41585. */
  41586. heightOffset: number;
  41587. /**
  41588. * Minimum allowed height of camera position relative to target object.
  41589. * This can help limiting how the Camera is able to move in the scene.
  41590. */
  41591. lowerHeightOffsetLimit: Nullable<number>;
  41592. /**
  41593. * Maximum allowed height of camera position relative to target object.
  41594. * This can help limiting how the Camera is able to move in the scene.
  41595. */
  41596. upperHeightOffsetLimit: Nullable<number>;
  41597. /**
  41598. * Define how fast the camera can accelerate to follow it s target.
  41599. */
  41600. cameraAcceleration: number;
  41601. /**
  41602. * Define the speed limit of the camera following an object.
  41603. */
  41604. maxCameraSpeed: number;
  41605. /**
  41606. * Define the target of the camera.
  41607. */
  41608. lockedTarget: Nullable<AbstractMesh>;
  41609. /**
  41610. * Defines the input associated with the camera.
  41611. */
  41612. inputs: FollowCameraInputsManager;
  41613. /**
  41614. * Instantiates the follow camera.
  41615. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41616. * @param name Define the name of the camera in the scene
  41617. * @param position Define the position of the camera
  41618. * @param scene Define the scene the camera belong to
  41619. * @param lockedTarget Define the target of the camera
  41620. */
  41621. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41622. private _follow;
  41623. /**
  41624. * Attached controls to the current camera.
  41625. * @param element Defines the element the controls should be listened from
  41626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41627. */
  41628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41629. /**
  41630. * Detach the current controls from the camera.
  41631. * The camera will stop reacting to inputs.
  41632. * @param element Defines the element to stop listening the inputs from
  41633. */
  41634. detachControl(element: HTMLElement): void;
  41635. /** @hidden */
  41636. _checkInputs(): void;
  41637. private _checkLimits;
  41638. /**
  41639. * Gets the camera class name.
  41640. * @returns the class name
  41641. */
  41642. getClassName(): string;
  41643. }
  41644. /**
  41645. * Arc Rotate version of the follow camera.
  41646. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41647. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41648. */
  41649. export class ArcFollowCamera extends TargetCamera {
  41650. /** The longitudinal angle of the camera */
  41651. alpha: number;
  41652. /** The latitudinal angle of the camera */
  41653. beta: number;
  41654. /** The radius of the camera from its target */
  41655. radius: number;
  41656. /** Define the camera target (the messh it should follow) */
  41657. target: Nullable<AbstractMesh>;
  41658. private _cartesianCoordinates;
  41659. /**
  41660. * Instantiates a new ArcFollowCamera
  41661. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41662. * @param name Define the name of the camera
  41663. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41664. * @param beta Define the rotation angle of the camera around the elevation axis
  41665. * @param radius Define the radius of the camera from its target point
  41666. * @param target Define the target of the camera
  41667. * @param scene Define the scene the camera belongs to
  41668. */
  41669. constructor(name: string,
  41670. /** The longitudinal angle of the camera */
  41671. alpha: number,
  41672. /** The latitudinal angle of the camera */
  41673. beta: number,
  41674. /** The radius of the camera from its target */
  41675. radius: number,
  41676. /** Define the camera target (the messh it should follow) */
  41677. target: Nullable<AbstractMesh>, scene: Scene);
  41678. private _follow;
  41679. /** @hidden */
  41680. _checkInputs(): void;
  41681. /**
  41682. * Returns the class name of the object.
  41683. * It is mostly used internally for serialization purposes.
  41684. */
  41685. getClassName(): string;
  41686. }
  41687. }
  41688. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41690. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41691. import { Nullable } from "babylonjs/types";
  41692. /**
  41693. * Manage the keyboard inputs to control the movement of a follow camera.
  41694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41695. */
  41696. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41697. /**
  41698. * Defines the camera the input is attached to.
  41699. */
  41700. camera: FollowCamera;
  41701. /**
  41702. * Defines the list of key codes associated with the up action (increase heightOffset)
  41703. */
  41704. keysHeightOffsetIncr: number[];
  41705. /**
  41706. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41707. */
  41708. keysHeightOffsetDecr: number[];
  41709. /**
  41710. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41711. */
  41712. keysHeightOffsetModifierAlt: boolean;
  41713. /**
  41714. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41715. */
  41716. keysHeightOffsetModifierCtrl: boolean;
  41717. /**
  41718. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41719. */
  41720. keysHeightOffsetModifierShift: boolean;
  41721. /**
  41722. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41723. */
  41724. keysRotationOffsetIncr: number[];
  41725. /**
  41726. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41727. */
  41728. keysRotationOffsetDecr: number[];
  41729. /**
  41730. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41731. */
  41732. keysRotationOffsetModifierAlt: boolean;
  41733. /**
  41734. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41735. */
  41736. keysRotationOffsetModifierCtrl: boolean;
  41737. /**
  41738. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41739. */
  41740. keysRotationOffsetModifierShift: boolean;
  41741. /**
  41742. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41743. */
  41744. keysRadiusIncr: number[];
  41745. /**
  41746. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41747. */
  41748. keysRadiusDecr: number[];
  41749. /**
  41750. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41751. */
  41752. keysRadiusModifierAlt: boolean;
  41753. /**
  41754. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41755. */
  41756. keysRadiusModifierCtrl: boolean;
  41757. /**
  41758. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41759. */
  41760. keysRadiusModifierShift: boolean;
  41761. /**
  41762. * Defines the rate of change of heightOffset.
  41763. */
  41764. heightSensibility: number;
  41765. /**
  41766. * Defines the rate of change of rotationOffset.
  41767. */
  41768. rotationSensibility: number;
  41769. /**
  41770. * Defines the rate of change of radius.
  41771. */
  41772. radiusSensibility: number;
  41773. private _keys;
  41774. private _ctrlPressed;
  41775. private _altPressed;
  41776. private _shiftPressed;
  41777. private _onCanvasBlurObserver;
  41778. private _onKeyboardObserver;
  41779. private _engine;
  41780. private _scene;
  41781. /**
  41782. * Attach the input controls to a specific dom element to get the input from.
  41783. * @param element Defines the element the controls should be listened from
  41784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41785. */
  41786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41787. /**
  41788. * Detach the current controls from the specified dom element.
  41789. * @param element Defines the element to stop listening the inputs from
  41790. */
  41791. detachControl(element: Nullable<HTMLElement>): void;
  41792. /**
  41793. * Update the current camera state depending on the inputs that have been used this frame.
  41794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41795. */
  41796. checkInputs(): void;
  41797. /**
  41798. * Gets the class name of the current input.
  41799. * @returns the class name
  41800. */
  41801. getClassName(): string;
  41802. /**
  41803. * Get the friendly name associated with the input class.
  41804. * @returns the input friendly name
  41805. */
  41806. getSimpleName(): string;
  41807. /**
  41808. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41809. * allow modification of the heightOffset value.
  41810. */
  41811. private _modifierHeightOffset;
  41812. /**
  41813. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41814. * allow modification of the rotationOffset value.
  41815. */
  41816. private _modifierRotationOffset;
  41817. /**
  41818. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41819. * allow modification of the radius value.
  41820. */
  41821. private _modifierRadius;
  41822. }
  41823. }
  41824. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41825. import { Nullable } from "babylonjs/types";
  41826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41828. import { Observable } from "babylonjs/Misc/observable";
  41829. module "babylonjs/Cameras/freeCameraInputsManager" {
  41830. interface FreeCameraInputsManager {
  41831. /**
  41832. * @hidden
  41833. */
  41834. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41835. /**
  41836. * Add orientation input support to the input manager.
  41837. * @returns the current input manager
  41838. */
  41839. addDeviceOrientation(): FreeCameraInputsManager;
  41840. }
  41841. }
  41842. /**
  41843. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41844. * Screen rotation is taken into account.
  41845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41846. */
  41847. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41848. private _camera;
  41849. private _screenOrientationAngle;
  41850. private _constantTranform;
  41851. private _screenQuaternion;
  41852. private _alpha;
  41853. private _beta;
  41854. private _gamma;
  41855. /**
  41856. * Can be used to detect if a device orientation sensor is available on a device
  41857. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41858. * @returns a promise that will resolve on orientation change
  41859. */
  41860. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41861. /**
  41862. * @hidden
  41863. */
  41864. _onDeviceOrientationChangedObservable: Observable<void>;
  41865. /**
  41866. * Instantiates a new input
  41867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41868. */
  41869. constructor();
  41870. /**
  41871. * Define the camera controlled by the input.
  41872. */
  41873. get camera(): FreeCamera;
  41874. set camera(camera: FreeCamera);
  41875. /**
  41876. * Attach the input controls to a specific dom element to get the input from.
  41877. * @param element Defines the element the controls should be listened from
  41878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41879. */
  41880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41881. private _orientationChanged;
  41882. private _deviceOrientation;
  41883. /**
  41884. * Detach the current controls from the specified dom element.
  41885. * @param element Defines the element to stop listening the inputs from
  41886. */
  41887. detachControl(element: Nullable<HTMLElement>): void;
  41888. /**
  41889. * Update the current camera state depending on the inputs that have been used this frame.
  41890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41891. */
  41892. checkInputs(): void;
  41893. /**
  41894. * Gets the class name of the current intput.
  41895. * @returns the class name
  41896. */
  41897. getClassName(): string;
  41898. /**
  41899. * Get the friendly name associated with the input class.
  41900. * @returns the input friendly name
  41901. */
  41902. getSimpleName(): string;
  41903. }
  41904. }
  41905. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41906. import { Nullable } from "babylonjs/types";
  41907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41909. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41910. /**
  41911. * Manage the gamepad inputs to control a free camera.
  41912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41913. */
  41914. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41915. /**
  41916. * Define the camera the input is attached to.
  41917. */
  41918. camera: FreeCamera;
  41919. /**
  41920. * Define the Gamepad controlling the input
  41921. */
  41922. gamepad: Nullable<Gamepad>;
  41923. /**
  41924. * Defines the gamepad rotation sensiblity.
  41925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41926. */
  41927. gamepadAngularSensibility: number;
  41928. /**
  41929. * Defines the gamepad move sensiblity.
  41930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41931. */
  41932. gamepadMoveSensibility: number;
  41933. private _yAxisScale;
  41934. /**
  41935. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41936. */
  41937. get invertYAxis(): boolean;
  41938. set invertYAxis(value: boolean);
  41939. private _onGamepadConnectedObserver;
  41940. private _onGamepadDisconnectedObserver;
  41941. private _cameraTransform;
  41942. private _deltaTransform;
  41943. private _vector3;
  41944. private _vector2;
  41945. /**
  41946. * Attach the input controls to a specific dom element to get the input from.
  41947. * @param element Defines the element the controls should be listened from
  41948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41949. */
  41950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41951. /**
  41952. * Detach the current controls from the specified dom element.
  41953. * @param element Defines the element to stop listening the inputs from
  41954. */
  41955. detachControl(element: Nullable<HTMLElement>): void;
  41956. /**
  41957. * Update the current camera state depending on the inputs that have been used this frame.
  41958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41959. */
  41960. checkInputs(): void;
  41961. /**
  41962. * Gets the class name of the current intput.
  41963. * @returns the class name
  41964. */
  41965. getClassName(): string;
  41966. /**
  41967. * Get the friendly name associated with the input class.
  41968. * @returns the input friendly name
  41969. */
  41970. getSimpleName(): string;
  41971. }
  41972. }
  41973. declare module "babylonjs/Misc/virtualJoystick" {
  41974. import { Nullable } from "babylonjs/types";
  41975. import { Vector3 } from "babylonjs/Maths/math.vector";
  41976. /**
  41977. * Defines the potential axis of a Joystick
  41978. */
  41979. export enum JoystickAxis {
  41980. /** X axis */
  41981. X = 0,
  41982. /** Y axis */
  41983. Y = 1,
  41984. /** Z axis */
  41985. Z = 2
  41986. }
  41987. /**
  41988. * Class used to define virtual joystick (used in touch mode)
  41989. */
  41990. export class VirtualJoystick {
  41991. /**
  41992. * Gets or sets a boolean indicating that left and right values must be inverted
  41993. */
  41994. reverseLeftRight: boolean;
  41995. /**
  41996. * Gets or sets a boolean indicating that up and down values must be inverted
  41997. */
  41998. reverseUpDown: boolean;
  41999. /**
  42000. * Gets the offset value for the position (ie. the change of the position value)
  42001. */
  42002. deltaPosition: Vector3;
  42003. /**
  42004. * Gets a boolean indicating if the virtual joystick was pressed
  42005. */
  42006. pressed: boolean;
  42007. /**
  42008. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42009. */
  42010. static Canvas: Nullable<HTMLCanvasElement>;
  42011. private static _globalJoystickIndex;
  42012. private static vjCanvasContext;
  42013. private static vjCanvasWidth;
  42014. private static vjCanvasHeight;
  42015. private static halfWidth;
  42016. private _action;
  42017. private _axisTargetedByLeftAndRight;
  42018. private _axisTargetedByUpAndDown;
  42019. private _joystickSensibility;
  42020. private _inversedSensibility;
  42021. private _joystickPointerID;
  42022. private _joystickColor;
  42023. private _joystickPointerPos;
  42024. private _joystickPreviousPointerPos;
  42025. private _joystickPointerStartPos;
  42026. private _deltaJoystickVector;
  42027. private _leftJoystick;
  42028. private _touches;
  42029. private _onPointerDownHandlerRef;
  42030. private _onPointerMoveHandlerRef;
  42031. private _onPointerUpHandlerRef;
  42032. private _onResize;
  42033. /**
  42034. * Creates a new virtual joystick
  42035. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42036. */
  42037. constructor(leftJoystick?: boolean);
  42038. /**
  42039. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42040. * @param newJoystickSensibility defines the new sensibility
  42041. */
  42042. setJoystickSensibility(newJoystickSensibility: number): void;
  42043. private _onPointerDown;
  42044. private _onPointerMove;
  42045. private _onPointerUp;
  42046. /**
  42047. * Change the color of the virtual joystick
  42048. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42049. */
  42050. setJoystickColor(newColor: string): void;
  42051. /**
  42052. * Defines a callback to call when the joystick is touched
  42053. * @param action defines the callback
  42054. */
  42055. setActionOnTouch(action: () => any): void;
  42056. /**
  42057. * Defines which axis you'd like to control for left & right
  42058. * @param axis defines the axis to use
  42059. */
  42060. setAxisForLeftRight(axis: JoystickAxis): void;
  42061. /**
  42062. * Defines which axis you'd like to control for up & down
  42063. * @param axis defines the axis to use
  42064. */
  42065. setAxisForUpDown(axis: JoystickAxis): void;
  42066. private _drawVirtualJoystick;
  42067. /**
  42068. * Release internal HTML canvas
  42069. */
  42070. releaseCanvas(): void;
  42071. }
  42072. }
  42073. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42074. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42075. import { Nullable } from "babylonjs/types";
  42076. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42077. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42078. module "babylonjs/Cameras/freeCameraInputsManager" {
  42079. interface FreeCameraInputsManager {
  42080. /**
  42081. * Add virtual joystick input support to the input manager.
  42082. * @returns the current input manager
  42083. */
  42084. addVirtualJoystick(): FreeCameraInputsManager;
  42085. }
  42086. }
  42087. /**
  42088. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42090. */
  42091. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42092. /**
  42093. * Defines the camera the input is attached to.
  42094. */
  42095. camera: FreeCamera;
  42096. private _leftjoystick;
  42097. private _rightjoystick;
  42098. /**
  42099. * Gets the left stick of the virtual joystick.
  42100. * @returns The virtual Joystick
  42101. */
  42102. getLeftJoystick(): VirtualJoystick;
  42103. /**
  42104. * Gets the right stick of the virtual joystick.
  42105. * @returns The virtual Joystick
  42106. */
  42107. getRightJoystick(): VirtualJoystick;
  42108. /**
  42109. * Update the current camera state depending on the inputs that have been used this frame.
  42110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42111. */
  42112. checkInputs(): void;
  42113. /**
  42114. * Attach the input controls to a specific dom element to get the input from.
  42115. * @param element Defines the element the controls should be listened from
  42116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42117. */
  42118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42119. /**
  42120. * Detach the current controls from the specified dom element.
  42121. * @param element Defines the element to stop listening the inputs from
  42122. */
  42123. detachControl(element: Nullable<HTMLElement>): void;
  42124. /**
  42125. * Gets the class name of the current intput.
  42126. * @returns the class name
  42127. */
  42128. getClassName(): string;
  42129. /**
  42130. * Get the friendly name associated with the input class.
  42131. * @returns the input friendly name
  42132. */
  42133. getSimpleName(): string;
  42134. }
  42135. }
  42136. declare module "babylonjs/Cameras/Inputs/index" {
  42137. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42138. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42139. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42140. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42141. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42142. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42143. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42144. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42145. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42146. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42147. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42148. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42149. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42150. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42151. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42152. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42153. }
  42154. declare module "babylonjs/Cameras/touchCamera" {
  42155. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42156. import { Scene } from "babylonjs/scene";
  42157. import { Vector3 } from "babylonjs/Maths/math.vector";
  42158. /**
  42159. * This represents a FPS type of camera controlled by touch.
  42160. * This is like a universal camera minus the Gamepad controls.
  42161. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42162. */
  42163. export class TouchCamera extends FreeCamera {
  42164. /**
  42165. * Defines the touch sensibility for rotation.
  42166. * The higher the faster.
  42167. */
  42168. get touchAngularSensibility(): number;
  42169. set touchAngularSensibility(value: number);
  42170. /**
  42171. * Defines the touch sensibility for move.
  42172. * The higher the faster.
  42173. */
  42174. get touchMoveSensibility(): number;
  42175. set touchMoveSensibility(value: number);
  42176. /**
  42177. * Instantiates a new touch camera.
  42178. * This represents a FPS type of camera controlled by touch.
  42179. * This is like a universal camera minus the Gamepad controls.
  42180. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42181. * @param name Define the name of the camera in the scene
  42182. * @param position Define the start position of the camera in the scene
  42183. * @param scene Define the scene the camera belongs to
  42184. */
  42185. constructor(name: string, position: Vector3, scene: Scene);
  42186. /**
  42187. * Gets the current object class name.
  42188. * @return the class name
  42189. */
  42190. getClassName(): string;
  42191. /** @hidden */
  42192. _setupInputs(): void;
  42193. }
  42194. }
  42195. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42197. import { Scene } from "babylonjs/scene";
  42198. import { Vector3 } from "babylonjs/Maths/math.vector";
  42199. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42200. import { Axis } from "babylonjs/Maths/math.axis";
  42201. /**
  42202. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42203. * being tilted forward or back and left or right.
  42204. */
  42205. export class DeviceOrientationCamera extends FreeCamera {
  42206. private _initialQuaternion;
  42207. private _quaternionCache;
  42208. private _tmpDragQuaternion;
  42209. private _disablePointerInputWhenUsingDeviceOrientation;
  42210. /**
  42211. * Creates a new device orientation camera
  42212. * @param name The name of the camera
  42213. * @param position The start position camera
  42214. * @param scene The scene the camera belongs to
  42215. */
  42216. constructor(name: string, position: Vector3, scene: Scene);
  42217. /**
  42218. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42219. */
  42220. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42221. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42222. private _dragFactor;
  42223. /**
  42224. * Enabled turning on the y axis when the orientation sensor is active
  42225. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42226. */
  42227. enableHorizontalDragging(dragFactor?: number): void;
  42228. /**
  42229. * Gets the current instance class name ("DeviceOrientationCamera").
  42230. * This helps avoiding instanceof at run time.
  42231. * @returns the class name
  42232. */
  42233. getClassName(): string;
  42234. /**
  42235. * @hidden
  42236. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42237. */
  42238. _checkInputs(): void;
  42239. /**
  42240. * Reset the camera to its default orientation on the specified axis only.
  42241. * @param axis The axis to reset
  42242. */
  42243. resetToCurrentRotation(axis?: Axis): void;
  42244. }
  42245. }
  42246. declare module "babylonjs/Gamepads/xboxGamepad" {
  42247. import { Observable } from "babylonjs/Misc/observable";
  42248. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42249. /**
  42250. * Defines supported buttons for XBox360 compatible gamepads
  42251. */
  42252. export enum Xbox360Button {
  42253. /** A */
  42254. A = 0,
  42255. /** B */
  42256. B = 1,
  42257. /** X */
  42258. X = 2,
  42259. /** Y */
  42260. Y = 3,
  42261. /** Start */
  42262. Start = 4,
  42263. /** Back */
  42264. Back = 5,
  42265. /** Left button */
  42266. LB = 6,
  42267. /** Right button */
  42268. RB = 7,
  42269. /** Left stick */
  42270. LeftStick = 8,
  42271. /** Right stick */
  42272. RightStick = 9
  42273. }
  42274. /** Defines values for XBox360 DPad */
  42275. export enum Xbox360Dpad {
  42276. /** Up */
  42277. Up = 0,
  42278. /** Down */
  42279. Down = 1,
  42280. /** Left */
  42281. Left = 2,
  42282. /** Right */
  42283. Right = 3
  42284. }
  42285. /**
  42286. * Defines a XBox360 gamepad
  42287. */
  42288. export class Xbox360Pad extends Gamepad {
  42289. private _leftTrigger;
  42290. private _rightTrigger;
  42291. private _onlefttriggerchanged;
  42292. private _onrighttriggerchanged;
  42293. private _onbuttondown;
  42294. private _onbuttonup;
  42295. private _ondpaddown;
  42296. private _ondpadup;
  42297. /** Observable raised when a button is pressed */
  42298. onButtonDownObservable: Observable<Xbox360Button>;
  42299. /** Observable raised when a button is released */
  42300. onButtonUpObservable: Observable<Xbox360Button>;
  42301. /** Observable raised when a pad is pressed */
  42302. onPadDownObservable: Observable<Xbox360Dpad>;
  42303. /** Observable raised when a pad is released */
  42304. onPadUpObservable: Observable<Xbox360Dpad>;
  42305. private _buttonA;
  42306. private _buttonB;
  42307. private _buttonX;
  42308. private _buttonY;
  42309. private _buttonBack;
  42310. private _buttonStart;
  42311. private _buttonLB;
  42312. private _buttonRB;
  42313. private _buttonLeftStick;
  42314. private _buttonRightStick;
  42315. private _dPadUp;
  42316. private _dPadDown;
  42317. private _dPadLeft;
  42318. private _dPadRight;
  42319. private _isXboxOnePad;
  42320. /**
  42321. * Creates a new XBox360 gamepad object
  42322. * @param id defines the id of this gamepad
  42323. * @param index defines its index
  42324. * @param gamepad defines the internal HTML gamepad object
  42325. * @param xboxOne defines if it is a XBox One gamepad
  42326. */
  42327. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42328. /**
  42329. * Defines the callback to call when left trigger is pressed
  42330. * @param callback defines the callback to use
  42331. */
  42332. onlefttriggerchanged(callback: (value: number) => void): void;
  42333. /**
  42334. * Defines the callback to call when right trigger is pressed
  42335. * @param callback defines the callback to use
  42336. */
  42337. onrighttriggerchanged(callback: (value: number) => void): void;
  42338. /**
  42339. * Gets the left trigger value
  42340. */
  42341. get leftTrigger(): number;
  42342. /**
  42343. * Sets the left trigger value
  42344. */
  42345. set leftTrigger(newValue: number);
  42346. /**
  42347. * Gets the right trigger value
  42348. */
  42349. get rightTrigger(): number;
  42350. /**
  42351. * Sets the right trigger value
  42352. */
  42353. set rightTrigger(newValue: number);
  42354. /**
  42355. * Defines the callback to call when a button is pressed
  42356. * @param callback defines the callback to use
  42357. */
  42358. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42359. /**
  42360. * Defines the callback to call when a button is released
  42361. * @param callback defines the callback to use
  42362. */
  42363. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42364. /**
  42365. * Defines the callback to call when a pad is pressed
  42366. * @param callback defines the callback to use
  42367. */
  42368. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42369. /**
  42370. * Defines the callback to call when a pad is released
  42371. * @param callback defines the callback to use
  42372. */
  42373. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42374. private _setButtonValue;
  42375. private _setDPadValue;
  42376. /**
  42377. * Gets the value of the `A` button
  42378. */
  42379. get buttonA(): number;
  42380. /**
  42381. * Sets the value of the `A` button
  42382. */
  42383. set buttonA(value: number);
  42384. /**
  42385. * Gets the value of the `B` button
  42386. */
  42387. get buttonB(): number;
  42388. /**
  42389. * Sets the value of the `B` button
  42390. */
  42391. set buttonB(value: number);
  42392. /**
  42393. * Gets the value of the `X` button
  42394. */
  42395. get buttonX(): number;
  42396. /**
  42397. * Sets the value of the `X` button
  42398. */
  42399. set buttonX(value: number);
  42400. /**
  42401. * Gets the value of the `Y` button
  42402. */
  42403. get buttonY(): number;
  42404. /**
  42405. * Sets the value of the `Y` button
  42406. */
  42407. set buttonY(value: number);
  42408. /**
  42409. * Gets the value of the `Start` button
  42410. */
  42411. get buttonStart(): number;
  42412. /**
  42413. * Sets the value of the `Start` button
  42414. */
  42415. set buttonStart(value: number);
  42416. /**
  42417. * Gets the value of the `Back` button
  42418. */
  42419. get buttonBack(): number;
  42420. /**
  42421. * Sets the value of the `Back` button
  42422. */
  42423. set buttonBack(value: number);
  42424. /**
  42425. * Gets the value of the `Left` button
  42426. */
  42427. get buttonLB(): number;
  42428. /**
  42429. * Sets the value of the `Left` button
  42430. */
  42431. set buttonLB(value: number);
  42432. /**
  42433. * Gets the value of the `Right` button
  42434. */
  42435. get buttonRB(): number;
  42436. /**
  42437. * Sets the value of the `Right` button
  42438. */
  42439. set buttonRB(value: number);
  42440. /**
  42441. * Gets the value of the Left joystick
  42442. */
  42443. get buttonLeftStick(): number;
  42444. /**
  42445. * Sets the value of the Left joystick
  42446. */
  42447. set buttonLeftStick(value: number);
  42448. /**
  42449. * Gets the value of the Right joystick
  42450. */
  42451. get buttonRightStick(): number;
  42452. /**
  42453. * Sets the value of the Right joystick
  42454. */
  42455. set buttonRightStick(value: number);
  42456. /**
  42457. * Gets the value of D-pad up
  42458. */
  42459. get dPadUp(): number;
  42460. /**
  42461. * Sets the value of D-pad up
  42462. */
  42463. set dPadUp(value: number);
  42464. /**
  42465. * Gets the value of D-pad down
  42466. */
  42467. get dPadDown(): number;
  42468. /**
  42469. * Sets the value of D-pad down
  42470. */
  42471. set dPadDown(value: number);
  42472. /**
  42473. * Gets the value of D-pad left
  42474. */
  42475. get dPadLeft(): number;
  42476. /**
  42477. * Sets the value of D-pad left
  42478. */
  42479. set dPadLeft(value: number);
  42480. /**
  42481. * Gets the value of D-pad right
  42482. */
  42483. get dPadRight(): number;
  42484. /**
  42485. * Sets the value of D-pad right
  42486. */
  42487. set dPadRight(value: number);
  42488. /**
  42489. * Force the gamepad to synchronize with device values
  42490. */
  42491. update(): void;
  42492. /**
  42493. * Disposes the gamepad
  42494. */
  42495. dispose(): void;
  42496. }
  42497. }
  42498. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42499. import { Observable } from "babylonjs/Misc/observable";
  42500. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42501. /**
  42502. * Defines supported buttons for DualShock compatible gamepads
  42503. */
  42504. export enum DualShockButton {
  42505. /** Cross */
  42506. Cross = 0,
  42507. /** Circle */
  42508. Circle = 1,
  42509. /** Square */
  42510. Square = 2,
  42511. /** Triangle */
  42512. Triangle = 3,
  42513. /** Options */
  42514. Options = 4,
  42515. /** Share */
  42516. Share = 5,
  42517. /** L1 */
  42518. L1 = 6,
  42519. /** R1 */
  42520. R1 = 7,
  42521. /** Left stick */
  42522. LeftStick = 8,
  42523. /** Right stick */
  42524. RightStick = 9
  42525. }
  42526. /** Defines values for DualShock DPad */
  42527. export enum DualShockDpad {
  42528. /** Up */
  42529. Up = 0,
  42530. /** Down */
  42531. Down = 1,
  42532. /** Left */
  42533. Left = 2,
  42534. /** Right */
  42535. Right = 3
  42536. }
  42537. /**
  42538. * Defines a DualShock gamepad
  42539. */
  42540. export class DualShockPad extends Gamepad {
  42541. private _leftTrigger;
  42542. private _rightTrigger;
  42543. private _onlefttriggerchanged;
  42544. private _onrighttriggerchanged;
  42545. private _onbuttondown;
  42546. private _onbuttonup;
  42547. private _ondpaddown;
  42548. private _ondpadup;
  42549. /** Observable raised when a button is pressed */
  42550. onButtonDownObservable: Observable<DualShockButton>;
  42551. /** Observable raised when a button is released */
  42552. onButtonUpObservable: Observable<DualShockButton>;
  42553. /** Observable raised when a pad is pressed */
  42554. onPadDownObservable: Observable<DualShockDpad>;
  42555. /** Observable raised when a pad is released */
  42556. onPadUpObservable: Observable<DualShockDpad>;
  42557. private _buttonCross;
  42558. private _buttonCircle;
  42559. private _buttonSquare;
  42560. private _buttonTriangle;
  42561. private _buttonShare;
  42562. private _buttonOptions;
  42563. private _buttonL1;
  42564. private _buttonR1;
  42565. private _buttonLeftStick;
  42566. private _buttonRightStick;
  42567. private _dPadUp;
  42568. private _dPadDown;
  42569. private _dPadLeft;
  42570. private _dPadRight;
  42571. /**
  42572. * Creates a new DualShock gamepad object
  42573. * @param id defines the id of this gamepad
  42574. * @param index defines its index
  42575. * @param gamepad defines the internal HTML gamepad object
  42576. */
  42577. constructor(id: string, index: number, gamepad: any);
  42578. /**
  42579. * Defines the callback to call when left trigger is pressed
  42580. * @param callback defines the callback to use
  42581. */
  42582. onlefttriggerchanged(callback: (value: number) => void): void;
  42583. /**
  42584. * Defines the callback to call when right trigger is pressed
  42585. * @param callback defines the callback to use
  42586. */
  42587. onrighttriggerchanged(callback: (value: number) => void): void;
  42588. /**
  42589. * Gets the left trigger value
  42590. */
  42591. get leftTrigger(): number;
  42592. /**
  42593. * Sets the left trigger value
  42594. */
  42595. set leftTrigger(newValue: number);
  42596. /**
  42597. * Gets the right trigger value
  42598. */
  42599. get rightTrigger(): number;
  42600. /**
  42601. * Sets the right trigger value
  42602. */
  42603. set rightTrigger(newValue: number);
  42604. /**
  42605. * Defines the callback to call when a button is pressed
  42606. * @param callback defines the callback to use
  42607. */
  42608. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42609. /**
  42610. * Defines the callback to call when a button is released
  42611. * @param callback defines the callback to use
  42612. */
  42613. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42614. /**
  42615. * Defines the callback to call when a pad is pressed
  42616. * @param callback defines the callback to use
  42617. */
  42618. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42619. /**
  42620. * Defines the callback to call when a pad is released
  42621. * @param callback defines the callback to use
  42622. */
  42623. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42624. private _setButtonValue;
  42625. private _setDPadValue;
  42626. /**
  42627. * Gets the value of the `Cross` button
  42628. */
  42629. get buttonCross(): number;
  42630. /**
  42631. * Sets the value of the `Cross` button
  42632. */
  42633. set buttonCross(value: number);
  42634. /**
  42635. * Gets the value of the `Circle` button
  42636. */
  42637. get buttonCircle(): number;
  42638. /**
  42639. * Sets the value of the `Circle` button
  42640. */
  42641. set buttonCircle(value: number);
  42642. /**
  42643. * Gets the value of the `Square` button
  42644. */
  42645. get buttonSquare(): number;
  42646. /**
  42647. * Sets the value of the `Square` button
  42648. */
  42649. set buttonSquare(value: number);
  42650. /**
  42651. * Gets the value of the `Triangle` button
  42652. */
  42653. get buttonTriangle(): number;
  42654. /**
  42655. * Sets the value of the `Triangle` button
  42656. */
  42657. set buttonTriangle(value: number);
  42658. /**
  42659. * Gets the value of the `Options` button
  42660. */
  42661. get buttonOptions(): number;
  42662. /**
  42663. * Sets the value of the `Options` button
  42664. */
  42665. set buttonOptions(value: number);
  42666. /**
  42667. * Gets the value of the `Share` button
  42668. */
  42669. get buttonShare(): number;
  42670. /**
  42671. * Sets the value of the `Share` button
  42672. */
  42673. set buttonShare(value: number);
  42674. /**
  42675. * Gets the value of the `L1` button
  42676. */
  42677. get buttonL1(): number;
  42678. /**
  42679. * Sets the value of the `L1` button
  42680. */
  42681. set buttonL1(value: number);
  42682. /**
  42683. * Gets the value of the `R1` button
  42684. */
  42685. get buttonR1(): number;
  42686. /**
  42687. * Sets the value of the `R1` button
  42688. */
  42689. set buttonR1(value: number);
  42690. /**
  42691. * Gets the value of the Left joystick
  42692. */
  42693. get buttonLeftStick(): number;
  42694. /**
  42695. * Sets the value of the Left joystick
  42696. */
  42697. set buttonLeftStick(value: number);
  42698. /**
  42699. * Gets the value of the Right joystick
  42700. */
  42701. get buttonRightStick(): number;
  42702. /**
  42703. * Sets the value of the Right joystick
  42704. */
  42705. set buttonRightStick(value: number);
  42706. /**
  42707. * Gets the value of D-pad up
  42708. */
  42709. get dPadUp(): number;
  42710. /**
  42711. * Sets the value of D-pad up
  42712. */
  42713. set dPadUp(value: number);
  42714. /**
  42715. * Gets the value of D-pad down
  42716. */
  42717. get dPadDown(): number;
  42718. /**
  42719. * Sets the value of D-pad down
  42720. */
  42721. set dPadDown(value: number);
  42722. /**
  42723. * Gets the value of D-pad left
  42724. */
  42725. get dPadLeft(): number;
  42726. /**
  42727. * Sets the value of D-pad left
  42728. */
  42729. set dPadLeft(value: number);
  42730. /**
  42731. * Gets the value of D-pad right
  42732. */
  42733. get dPadRight(): number;
  42734. /**
  42735. * Sets the value of D-pad right
  42736. */
  42737. set dPadRight(value: number);
  42738. /**
  42739. * Force the gamepad to synchronize with device values
  42740. */
  42741. update(): void;
  42742. /**
  42743. * Disposes the gamepad
  42744. */
  42745. dispose(): void;
  42746. }
  42747. }
  42748. declare module "babylonjs/Gamepads/gamepadManager" {
  42749. import { Observable } from "babylonjs/Misc/observable";
  42750. import { Nullable } from "babylonjs/types";
  42751. import { Scene } from "babylonjs/scene";
  42752. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42753. /**
  42754. * Manager for handling gamepads
  42755. */
  42756. export class GamepadManager {
  42757. private _scene?;
  42758. private _babylonGamepads;
  42759. private _oneGamepadConnected;
  42760. /** @hidden */
  42761. _isMonitoring: boolean;
  42762. private _gamepadEventSupported;
  42763. private _gamepadSupport?;
  42764. /**
  42765. * observable to be triggered when the gamepad controller has been connected
  42766. */
  42767. onGamepadConnectedObservable: Observable<Gamepad>;
  42768. /**
  42769. * observable to be triggered when the gamepad controller has been disconnected
  42770. */
  42771. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42772. private _onGamepadConnectedEvent;
  42773. private _onGamepadDisconnectedEvent;
  42774. /**
  42775. * Initializes the gamepad manager
  42776. * @param _scene BabylonJS scene
  42777. */
  42778. constructor(_scene?: Scene | undefined);
  42779. /**
  42780. * The gamepads in the game pad manager
  42781. */
  42782. get gamepads(): Gamepad[];
  42783. /**
  42784. * Get the gamepad controllers based on type
  42785. * @param type The type of gamepad controller
  42786. * @returns Nullable gamepad
  42787. */
  42788. getGamepadByType(type?: number): Nullable<Gamepad>;
  42789. /**
  42790. * Disposes the gamepad manager
  42791. */
  42792. dispose(): void;
  42793. private _addNewGamepad;
  42794. private _startMonitoringGamepads;
  42795. private _stopMonitoringGamepads;
  42796. /** @hidden */
  42797. _checkGamepadsStatus(): void;
  42798. private _updateGamepadObjects;
  42799. }
  42800. }
  42801. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42802. import { Nullable } from "babylonjs/types";
  42803. import { Scene } from "babylonjs/scene";
  42804. import { ISceneComponent } from "babylonjs/sceneComponent";
  42805. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42806. module "babylonjs/scene" {
  42807. interface Scene {
  42808. /** @hidden */
  42809. _gamepadManager: Nullable<GamepadManager>;
  42810. /**
  42811. * Gets the gamepad manager associated with the scene
  42812. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42813. */
  42814. gamepadManager: GamepadManager;
  42815. }
  42816. }
  42817. module "babylonjs/Cameras/freeCameraInputsManager" {
  42818. /**
  42819. * Interface representing a free camera inputs manager
  42820. */
  42821. interface FreeCameraInputsManager {
  42822. /**
  42823. * Adds gamepad input support to the FreeCameraInputsManager.
  42824. * @returns the FreeCameraInputsManager
  42825. */
  42826. addGamepad(): FreeCameraInputsManager;
  42827. }
  42828. }
  42829. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42830. /**
  42831. * Interface representing an arc rotate camera inputs manager
  42832. */
  42833. interface ArcRotateCameraInputsManager {
  42834. /**
  42835. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42836. * @returns the camera inputs manager
  42837. */
  42838. addGamepad(): ArcRotateCameraInputsManager;
  42839. }
  42840. }
  42841. /**
  42842. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42843. */
  42844. export class GamepadSystemSceneComponent implements ISceneComponent {
  42845. /**
  42846. * The component name helpfull to identify the component in the list of scene components.
  42847. */
  42848. readonly name: string;
  42849. /**
  42850. * The scene the component belongs to.
  42851. */
  42852. scene: Scene;
  42853. /**
  42854. * Creates a new instance of the component for the given scene
  42855. * @param scene Defines the scene to register the component in
  42856. */
  42857. constructor(scene: Scene);
  42858. /**
  42859. * Registers the component in a given scene
  42860. */
  42861. register(): void;
  42862. /**
  42863. * Rebuilds the elements related to this component in case of
  42864. * context lost for instance.
  42865. */
  42866. rebuild(): void;
  42867. /**
  42868. * Disposes the component and the associated ressources
  42869. */
  42870. dispose(): void;
  42871. private _beforeCameraUpdate;
  42872. }
  42873. }
  42874. declare module "babylonjs/Cameras/universalCamera" {
  42875. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42876. import { Scene } from "babylonjs/scene";
  42877. import { Vector3 } from "babylonjs/Maths/math.vector";
  42878. import "babylonjs/Gamepads/gamepadSceneComponent";
  42879. /**
  42880. * 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,
  42881. * which still works and will still be found in many Playgrounds.
  42882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42883. */
  42884. export class UniversalCamera extends TouchCamera {
  42885. /**
  42886. * Defines the gamepad rotation sensiblity.
  42887. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42888. */
  42889. get gamepadAngularSensibility(): number;
  42890. set gamepadAngularSensibility(value: number);
  42891. /**
  42892. * Defines the gamepad move sensiblity.
  42893. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42894. */
  42895. get gamepadMoveSensibility(): number;
  42896. set gamepadMoveSensibility(value: number);
  42897. /**
  42898. * 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,
  42899. * which still works and will still be found in many Playgrounds.
  42900. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42901. * @param name Define the name of the camera in the scene
  42902. * @param position Define the start position of the camera in the scene
  42903. * @param scene Define the scene the camera belongs to
  42904. */
  42905. constructor(name: string, position: Vector3, scene: Scene);
  42906. /**
  42907. * Gets the current object class name.
  42908. * @return the class name
  42909. */
  42910. getClassName(): string;
  42911. }
  42912. }
  42913. declare module "babylonjs/Cameras/gamepadCamera" {
  42914. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42915. import { Scene } from "babylonjs/scene";
  42916. import { Vector3 } from "babylonjs/Maths/math.vector";
  42917. /**
  42918. * This represents a FPS type of camera. This is only here for back compat purpose.
  42919. * Please use the UniversalCamera instead as both are identical.
  42920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42921. */
  42922. export class GamepadCamera extends UniversalCamera {
  42923. /**
  42924. * Instantiates a new Gamepad Camera
  42925. * This represents a FPS type of camera. This is only here for back compat purpose.
  42926. * Please use the UniversalCamera instead as both are identical.
  42927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42928. * @param name Define the name of the camera in the scene
  42929. * @param position Define the start position of the camera in the scene
  42930. * @param scene Define the scene the camera belongs to
  42931. */
  42932. constructor(name: string, position: Vector3, scene: Scene);
  42933. /**
  42934. * Gets the current object class name.
  42935. * @return the class name
  42936. */
  42937. getClassName(): string;
  42938. }
  42939. }
  42940. declare module "babylonjs/Shaders/pass.fragment" {
  42941. /** @hidden */
  42942. export var passPixelShader: {
  42943. name: string;
  42944. shader: string;
  42945. };
  42946. }
  42947. declare module "babylonjs/Shaders/passCube.fragment" {
  42948. /** @hidden */
  42949. export var passCubePixelShader: {
  42950. name: string;
  42951. shader: string;
  42952. };
  42953. }
  42954. declare module "babylonjs/PostProcesses/passPostProcess" {
  42955. import { Nullable } from "babylonjs/types";
  42956. import { Camera } from "babylonjs/Cameras/camera";
  42957. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42958. import { Engine } from "babylonjs/Engines/engine";
  42959. import "babylonjs/Shaders/pass.fragment";
  42960. import "babylonjs/Shaders/passCube.fragment";
  42961. /**
  42962. * PassPostProcess which produces an output the same as it's input
  42963. */
  42964. export class PassPostProcess extends PostProcess {
  42965. /**
  42966. * Creates the PassPostProcess
  42967. * @param name The name of the effect.
  42968. * @param options The required width/height ratio to downsize to before computing the render pass.
  42969. * @param camera The camera to apply the render pass to.
  42970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42971. * @param engine The engine which the post process will be applied. (default: current engine)
  42972. * @param reusable If the post process can be reused on the same frame. (default: false)
  42973. * @param textureType The type of texture to be used when performing the post processing.
  42974. * @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)
  42975. */
  42976. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42977. }
  42978. /**
  42979. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42980. */
  42981. export class PassCubePostProcess extends PostProcess {
  42982. private _face;
  42983. /**
  42984. * Gets or sets the cube face to display.
  42985. * * 0 is +X
  42986. * * 1 is -X
  42987. * * 2 is +Y
  42988. * * 3 is -Y
  42989. * * 4 is +Z
  42990. * * 5 is -Z
  42991. */
  42992. get face(): number;
  42993. set face(value: number);
  42994. /**
  42995. * Creates the PassCubePostProcess
  42996. * @param name The name of the effect.
  42997. * @param options The required width/height ratio to downsize to before computing the render pass.
  42998. * @param camera The camera to apply the render pass to.
  42999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43000. * @param engine The engine which the post process will be applied. (default: current engine)
  43001. * @param reusable If the post process can be reused on the same frame. (default: false)
  43002. * @param textureType The type of texture to be used when performing the post processing.
  43003. * @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)
  43004. */
  43005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43006. }
  43007. }
  43008. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43009. /** @hidden */
  43010. export var anaglyphPixelShader: {
  43011. name: string;
  43012. shader: string;
  43013. };
  43014. }
  43015. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43016. import { Engine } from "babylonjs/Engines/engine";
  43017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43018. import { Camera } from "babylonjs/Cameras/camera";
  43019. import "babylonjs/Shaders/anaglyph.fragment";
  43020. /**
  43021. * Postprocess used to generate anaglyphic rendering
  43022. */
  43023. export class AnaglyphPostProcess extends PostProcess {
  43024. private _passedProcess;
  43025. /**
  43026. * Creates a new AnaglyphPostProcess
  43027. * @param name defines postprocess name
  43028. * @param options defines creation options or target ratio scale
  43029. * @param rigCameras defines cameras using this postprocess
  43030. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43031. * @param engine defines hosting engine
  43032. * @param reusable defines if the postprocess will be reused multiple times per frame
  43033. */
  43034. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43035. }
  43036. }
  43037. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43038. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43039. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43040. import { Scene } from "babylonjs/scene";
  43041. import { Vector3 } from "babylonjs/Maths/math.vector";
  43042. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43043. /**
  43044. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43045. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43046. */
  43047. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43048. /**
  43049. * Creates a new AnaglyphArcRotateCamera
  43050. * @param name defines camera name
  43051. * @param alpha defines alpha angle (in radians)
  43052. * @param beta defines beta angle (in radians)
  43053. * @param radius defines radius
  43054. * @param target defines camera target
  43055. * @param interaxialDistance defines distance between each color axis
  43056. * @param scene defines the hosting scene
  43057. */
  43058. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43059. /**
  43060. * Gets camera class name
  43061. * @returns AnaglyphArcRotateCamera
  43062. */
  43063. getClassName(): string;
  43064. }
  43065. }
  43066. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43068. import { Scene } from "babylonjs/scene";
  43069. import { Vector3 } from "babylonjs/Maths/math.vector";
  43070. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43071. /**
  43072. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43074. */
  43075. export class AnaglyphFreeCamera extends FreeCamera {
  43076. /**
  43077. * Creates a new AnaglyphFreeCamera
  43078. * @param name defines camera name
  43079. * @param position defines initial position
  43080. * @param interaxialDistance defines distance between each color axis
  43081. * @param scene defines the hosting scene
  43082. */
  43083. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43084. /**
  43085. * Gets camera class name
  43086. * @returns AnaglyphFreeCamera
  43087. */
  43088. getClassName(): string;
  43089. }
  43090. }
  43091. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43092. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43093. import { Scene } from "babylonjs/scene";
  43094. import { Vector3 } from "babylonjs/Maths/math.vector";
  43095. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43096. /**
  43097. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43098. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43099. */
  43100. export class AnaglyphGamepadCamera extends GamepadCamera {
  43101. /**
  43102. * Creates a new AnaglyphGamepadCamera
  43103. * @param name defines camera name
  43104. * @param position defines initial position
  43105. * @param interaxialDistance defines distance between each color axis
  43106. * @param scene defines the hosting scene
  43107. */
  43108. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43109. /**
  43110. * Gets camera class name
  43111. * @returns AnaglyphGamepadCamera
  43112. */
  43113. getClassName(): string;
  43114. }
  43115. }
  43116. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43117. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43118. import { Scene } from "babylonjs/scene";
  43119. import { Vector3 } from "babylonjs/Maths/math.vector";
  43120. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43121. /**
  43122. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43123. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43124. */
  43125. export class AnaglyphUniversalCamera extends UniversalCamera {
  43126. /**
  43127. * Creates a new AnaglyphUniversalCamera
  43128. * @param name defines camera name
  43129. * @param position defines initial position
  43130. * @param interaxialDistance defines distance between each color axis
  43131. * @param scene defines the hosting scene
  43132. */
  43133. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43134. /**
  43135. * Gets camera class name
  43136. * @returns AnaglyphUniversalCamera
  43137. */
  43138. getClassName(): string;
  43139. }
  43140. }
  43141. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43142. /** @hidden */
  43143. export var stereoscopicInterlacePixelShader: {
  43144. name: string;
  43145. shader: string;
  43146. };
  43147. }
  43148. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43149. import { Camera } from "babylonjs/Cameras/camera";
  43150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43151. import { Engine } from "babylonjs/Engines/engine";
  43152. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43153. /**
  43154. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43155. */
  43156. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43157. private _stepSize;
  43158. private _passedProcess;
  43159. /**
  43160. * Initializes a StereoscopicInterlacePostProcessI
  43161. * @param name The name of the effect.
  43162. * @param rigCameras The rig cameras to be appled to the post process
  43163. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43164. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43166. * @param engine The engine which the post process will be applied. (default: current engine)
  43167. * @param reusable If the post process can be reused on the same frame. (default: false)
  43168. */
  43169. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43170. }
  43171. /**
  43172. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43173. */
  43174. export class StereoscopicInterlacePostProcess extends PostProcess {
  43175. private _stepSize;
  43176. private _passedProcess;
  43177. /**
  43178. * Initializes a StereoscopicInterlacePostProcess
  43179. * @param name The name of the effect.
  43180. * @param rigCameras The rig cameras to be appled to the post process
  43181. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43183. * @param engine The engine which the post process will be applied. (default: current engine)
  43184. * @param reusable If the post process can be reused on the same frame. (default: false)
  43185. */
  43186. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43187. }
  43188. }
  43189. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43190. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43191. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43192. import { Scene } from "babylonjs/scene";
  43193. import { Vector3 } from "babylonjs/Maths/math.vector";
  43194. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43195. /**
  43196. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43197. * @see http://doc.babylonjs.com/features/cameras
  43198. */
  43199. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43200. /**
  43201. * Creates a new StereoscopicArcRotateCamera
  43202. * @param name defines camera name
  43203. * @param alpha defines alpha angle (in radians)
  43204. * @param beta defines beta angle (in radians)
  43205. * @param radius defines radius
  43206. * @param target defines camera target
  43207. * @param interaxialDistance defines distance between each color axis
  43208. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43209. * @param scene defines the hosting scene
  43210. */
  43211. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43212. /**
  43213. * Gets camera class name
  43214. * @returns StereoscopicArcRotateCamera
  43215. */
  43216. getClassName(): string;
  43217. }
  43218. }
  43219. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43220. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43221. import { Scene } from "babylonjs/scene";
  43222. import { Vector3 } from "babylonjs/Maths/math.vector";
  43223. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43224. /**
  43225. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43226. * @see http://doc.babylonjs.com/features/cameras
  43227. */
  43228. export class StereoscopicFreeCamera extends FreeCamera {
  43229. /**
  43230. * Creates a new StereoscopicFreeCamera
  43231. * @param name defines camera name
  43232. * @param position defines initial position
  43233. * @param interaxialDistance defines distance between each color axis
  43234. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43235. * @param scene defines the hosting scene
  43236. */
  43237. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43238. /**
  43239. * Gets camera class name
  43240. * @returns StereoscopicFreeCamera
  43241. */
  43242. getClassName(): string;
  43243. }
  43244. }
  43245. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43246. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43247. import { Scene } from "babylonjs/scene";
  43248. import { Vector3 } from "babylonjs/Maths/math.vector";
  43249. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43250. /**
  43251. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43252. * @see http://doc.babylonjs.com/features/cameras
  43253. */
  43254. export class StereoscopicGamepadCamera extends GamepadCamera {
  43255. /**
  43256. * Creates a new StereoscopicGamepadCamera
  43257. * @param name defines camera name
  43258. * @param position defines initial position
  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, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43264. /**
  43265. * Gets camera class name
  43266. * @returns StereoscopicGamepadCamera
  43267. */
  43268. getClassName(): string;
  43269. }
  43270. }
  43271. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43272. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  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 UniversalCamera)
  43278. * @see http://doc.babylonjs.com/features/cameras
  43279. */
  43280. export class StereoscopicUniversalCamera extends UniversalCamera {
  43281. /**
  43282. * Creates a new StereoscopicUniversalCamera
  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 StereoscopicUniversalCamera
  43293. */
  43294. getClassName(): string;
  43295. }
  43296. }
  43297. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43298. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43299. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43300. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43301. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43302. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43303. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43304. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43305. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43306. }
  43307. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43309. import { Scene } from "babylonjs/scene";
  43310. import { Vector3 } from "babylonjs/Maths/math.vector";
  43311. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43312. /**
  43313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43314. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43315. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43316. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43317. */
  43318. export class VirtualJoysticksCamera extends FreeCamera {
  43319. /**
  43320. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43321. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43322. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43323. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43324. * @param name Define the name of the camera in the scene
  43325. * @param position Define the start position of the camera in the scene
  43326. * @param scene Define the scene the camera belongs to
  43327. */
  43328. constructor(name: string, position: Vector3, scene: Scene);
  43329. /**
  43330. * Gets the current object class name.
  43331. * @return the class name
  43332. */
  43333. getClassName(): string;
  43334. }
  43335. }
  43336. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43337. import { Matrix } from "babylonjs/Maths/math.vector";
  43338. /**
  43339. * This represents all the required metrics to create a VR camera.
  43340. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43341. */
  43342. export class VRCameraMetrics {
  43343. /**
  43344. * Define the horizontal resolution off the screen.
  43345. */
  43346. hResolution: number;
  43347. /**
  43348. * Define the vertical resolution off the screen.
  43349. */
  43350. vResolution: number;
  43351. /**
  43352. * Define the horizontal screen size.
  43353. */
  43354. hScreenSize: number;
  43355. /**
  43356. * Define the vertical screen size.
  43357. */
  43358. vScreenSize: number;
  43359. /**
  43360. * Define the vertical screen center position.
  43361. */
  43362. vScreenCenter: number;
  43363. /**
  43364. * Define the distance of the eyes to the screen.
  43365. */
  43366. eyeToScreenDistance: number;
  43367. /**
  43368. * Define the distance between both lenses
  43369. */
  43370. lensSeparationDistance: number;
  43371. /**
  43372. * Define the distance between both viewer's eyes.
  43373. */
  43374. interpupillaryDistance: number;
  43375. /**
  43376. * Define the distortion factor of the VR postprocess.
  43377. * Please, touch with care.
  43378. */
  43379. distortionK: number[];
  43380. /**
  43381. * Define the chromatic aberration correction factors for the VR post process.
  43382. */
  43383. chromaAbCorrection: number[];
  43384. /**
  43385. * Define the scale factor of the post process.
  43386. * The smaller the better but the slower.
  43387. */
  43388. postProcessScaleFactor: number;
  43389. /**
  43390. * Define an offset for the lens center.
  43391. */
  43392. lensCenterOffset: number;
  43393. /**
  43394. * Define if the current vr camera should compensate the distortion of the lense or not.
  43395. */
  43396. compensateDistortion: boolean;
  43397. /**
  43398. * Defines if multiview should be enabled when rendering (Default: false)
  43399. */
  43400. multiviewEnabled: boolean;
  43401. /**
  43402. * Gets the rendering aspect ratio based on the provided resolutions.
  43403. */
  43404. get aspectRatio(): number;
  43405. /**
  43406. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43407. */
  43408. get aspectRatioFov(): number;
  43409. /**
  43410. * @hidden
  43411. */
  43412. get leftHMatrix(): Matrix;
  43413. /**
  43414. * @hidden
  43415. */
  43416. get rightHMatrix(): Matrix;
  43417. /**
  43418. * @hidden
  43419. */
  43420. get leftPreViewMatrix(): Matrix;
  43421. /**
  43422. * @hidden
  43423. */
  43424. get rightPreViewMatrix(): Matrix;
  43425. /**
  43426. * Get the default VRMetrics based on the most generic setup.
  43427. * @returns the default vr metrics
  43428. */
  43429. static GetDefault(): VRCameraMetrics;
  43430. }
  43431. }
  43432. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43433. /** @hidden */
  43434. export var vrDistortionCorrectionPixelShader: {
  43435. name: string;
  43436. shader: string;
  43437. };
  43438. }
  43439. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43440. import { Camera } from "babylonjs/Cameras/camera";
  43441. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43442. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43443. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43444. /**
  43445. * VRDistortionCorrectionPostProcess used for mobile VR
  43446. */
  43447. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43448. private _isRightEye;
  43449. private _distortionFactors;
  43450. private _postProcessScaleFactor;
  43451. private _lensCenterOffset;
  43452. private _scaleIn;
  43453. private _scaleFactor;
  43454. private _lensCenter;
  43455. /**
  43456. * Initializes the VRDistortionCorrectionPostProcess
  43457. * @param name The name of the effect.
  43458. * @param camera The camera to apply the render pass to.
  43459. * @param isRightEye If this is for the right eye distortion
  43460. * @param vrMetrics All the required metrics for the VR camera
  43461. */
  43462. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43463. }
  43464. }
  43465. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43466. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43467. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43468. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43469. import { Scene } from "babylonjs/scene";
  43470. import { Vector3 } from "babylonjs/Maths/math.vector";
  43471. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43472. import "babylonjs/Cameras/RigModes/vrRigMode";
  43473. /**
  43474. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43475. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43476. */
  43477. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43478. /**
  43479. * Creates a new VRDeviceOrientationArcRotateCamera
  43480. * @param name defines camera name
  43481. * @param alpha defines the camera rotation along the logitudinal axis
  43482. * @param beta defines the camera rotation along the latitudinal axis
  43483. * @param radius defines the camera distance from its target
  43484. * @param target defines the camera target
  43485. * @param scene defines the scene the camera belongs to
  43486. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43487. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43488. */
  43489. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43490. /**
  43491. * Gets camera class name
  43492. * @returns VRDeviceOrientationArcRotateCamera
  43493. */
  43494. getClassName(): string;
  43495. }
  43496. }
  43497. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43498. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43499. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43500. import { Scene } from "babylonjs/scene";
  43501. import { Vector3 } from "babylonjs/Maths/math.vector";
  43502. import "babylonjs/Cameras/RigModes/vrRigMode";
  43503. /**
  43504. * Camera used to simulate VR rendering (based on FreeCamera)
  43505. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43506. */
  43507. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43508. /**
  43509. * Creates a new VRDeviceOrientationFreeCamera
  43510. * @param name defines camera name
  43511. * @param position defines the start position of the camera
  43512. * @param scene defines the scene the camera belongs to
  43513. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43514. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43515. */
  43516. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43517. /**
  43518. * Gets camera class name
  43519. * @returns VRDeviceOrientationFreeCamera
  43520. */
  43521. getClassName(): string;
  43522. }
  43523. }
  43524. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43525. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43526. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43527. import { Scene } from "babylonjs/scene";
  43528. import { Vector3 } from "babylonjs/Maths/math.vector";
  43529. import "babylonjs/Gamepads/gamepadSceneComponent";
  43530. /**
  43531. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43532. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43533. */
  43534. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43535. /**
  43536. * Creates a new VRDeviceOrientationGamepadCamera
  43537. * @param name defines camera name
  43538. * @param position defines the start position of the camera
  43539. * @param scene defines the scene the camera belongs to
  43540. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43541. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43542. */
  43543. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43544. /**
  43545. * Gets camera class name
  43546. * @returns VRDeviceOrientationGamepadCamera
  43547. */
  43548. getClassName(): string;
  43549. }
  43550. }
  43551. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43553. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43554. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43555. /** @hidden */
  43556. export var imageProcessingPixelShader: {
  43557. name: string;
  43558. shader: string;
  43559. };
  43560. }
  43561. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43562. import { Nullable } from "babylonjs/types";
  43563. import { Color4 } from "babylonjs/Maths/math.color";
  43564. import { Camera } from "babylonjs/Cameras/camera";
  43565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43566. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43567. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43568. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43569. import { Engine } from "babylonjs/Engines/engine";
  43570. import "babylonjs/Shaders/imageProcessing.fragment";
  43571. import "babylonjs/Shaders/postprocess.vertex";
  43572. /**
  43573. * ImageProcessingPostProcess
  43574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43575. */
  43576. export class ImageProcessingPostProcess extends PostProcess {
  43577. /**
  43578. * Default configuration related to image processing available in the PBR Material.
  43579. */
  43580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43581. /**
  43582. * Gets the image processing configuration used either in this material.
  43583. */
  43584. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43585. /**
  43586. * Sets the Default image processing configuration used either in the this material.
  43587. *
  43588. * If sets to null, the scene one is in use.
  43589. */
  43590. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43591. /**
  43592. * Keep track of the image processing observer to allow dispose and replace.
  43593. */
  43594. private _imageProcessingObserver;
  43595. /**
  43596. * Attaches a new image processing configuration to the PBR Material.
  43597. * @param configuration
  43598. */
  43599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43600. /**
  43601. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43602. */
  43603. get colorCurves(): Nullable<ColorCurves>;
  43604. /**
  43605. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43606. */
  43607. set colorCurves(value: Nullable<ColorCurves>);
  43608. /**
  43609. * Gets wether the color curves effect is enabled.
  43610. */
  43611. get colorCurvesEnabled(): boolean;
  43612. /**
  43613. * Sets wether the color curves effect is enabled.
  43614. */
  43615. set colorCurvesEnabled(value: boolean);
  43616. /**
  43617. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43618. */
  43619. get colorGradingTexture(): Nullable<BaseTexture>;
  43620. /**
  43621. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43622. */
  43623. set colorGradingTexture(value: Nullable<BaseTexture>);
  43624. /**
  43625. * Gets wether the color grading effect is enabled.
  43626. */
  43627. get colorGradingEnabled(): boolean;
  43628. /**
  43629. * Gets wether the color grading effect is enabled.
  43630. */
  43631. set colorGradingEnabled(value: boolean);
  43632. /**
  43633. * Gets exposure used in the effect.
  43634. */
  43635. get exposure(): number;
  43636. /**
  43637. * Sets exposure used in the effect.
  43638. */
  43639. set exposure(value: number);
  43640. /**
  43641. * Gets wether tonemapping is enabled or not.
  43642. */
  43643. get toneMappingEnabled(): boolean;
  43644. /**
  43645. * Sets wether tonemapping is enabled or not
  43646. */
  43647. set toneMappingEnabled(value: boolean);
  43648. /**
  43649. * Gets the type of tone mapping effect.
  43650. */
  43651. get toneMappingType(): number;
  43652. /**
  43653. * Sets the type of tone mapping effect.
  43654. */
  43655. set toneMappingType(value: number);
  43656. /**
  43657. * Gets contrast used in the effect.
  43658. */
  43659. get contrast(): number;
  43660. /**
  43661. * Sets contrast used in the effect.
  43662. */
  43663. set contrast(value: number);
  43664. /**
  43665. * Gets Vignette stretch size.
  43666. */
  43667. get vignetteStretch(): number;
  43668. /**
  43669. * Sets Vignette stretch size.
  43670. */
  43671. set vignetteStretch(value: number);
  43672. /**
  43673. * Gets Vignette centre X Offset.
  43674. */
  43675. get vignetteCentreX(): number;
  43676. /**
  43677. * Sets Vignette centre X Offset.
  43678. */
  43679. set vignetteCentreX(value: number);
  43680. /**
  43681. * Gets Vignette centre Y Offset.
  43682. */
  43683. get vignetteCentreY(): number;
  43684. /**
  43685. * Sets Vignette centre Y Offset.
  43686. */
  43687. set vignetteCentreY(value: number);
  43688. /**
  43689. * Gets Vignette weight or intensity of the vignette effect.
  43690. */
  43691. get vignetteWeight(): number;
  43692. /**
  43693. * Sets Vignette weight or intensity of the vignette effect.
  43694. */
  43695. set vignetteWeight(value: number);
  43696. /**
  43697. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43698. * if vignetteEnabled is set to true.
  43699. */
  43700. get vignetteColor(): Color4;
  43701. /**
  43702. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43703. * if vignetteEnabled is set to true.
  43704. */
  43705. set vignetteColor(value: Color4);
  43706. /**
  43707. * Gets Camera field of view used by the Vignette effect.
  43708. */
  43709. get vignetteCameraFov(): number;
  43710. /**
  43711. * Sets Camera field of view used by the Vignette effect.
  43712. */
  43713. set vignetteCameraFov(value: number);
  43714. /**
  43715. * Gets the vignette blend mode allowing different kind of effect.
  43716. */
  43717. get vignetteBlendMode(): number;
  43718. /**
  43719. * Sets the vignette blend mode allowing different kind of effect.
  43720. */
  43721. set vignetteBlendMode(value: number);
  43722. /**
  43723. * Gets wether the vignette effect is enabled.
  43724. */
  43725. get vignetteEnabled(): boolean;
  43726. /**
  43727. * Sets wether the vignette effect is enabled.
  43728. */
  43729. set vignetteEnabled(value: boolean);
  43730. private _fromLinearSpace;
  43731. /**
  43732. * Gets wether the input of the processing is in Gamma or Linear Space.
  43733. */
  43734. get fromLinearSpace(): boolean;
  43735. /**
  43736. * Sets wether the input of the processing is in Gamma or Linear Space.
  43737. */
  43738. set fromLinearSpace(value: boolean);
  43739. /**
  43740. * Defines cache preventing GC.
  43741. */
  43742. private _defines;
  43743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43744. /**
  43745. * "ImageProcessingPostProcess"
  43746. * @returns "ImageProcessingPostProcess"
  43747. */
  43748. getClassName(): string;
  43749. protected _updateParameters(): void;
  43750. dispose(camera?: Camera): void;
  43751. }
  43752. }
  43753. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43754. import { Scene } from "babylonjs/scene";
  43755. import { Color3 } from "babylonjs/Maths/math.color";
  43756. import { Mesh } from "babylonjs/Meshes/mesh";
  43757. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43758. import { Nullable } from "babylonjs/types";
  43759. /**
  43760. * Class containing static functions to help procedurally build meshes
  43761. */
  43762. export class GroundBuilder {
  43763. /**
  43764. * Creates a ground mesh
  43765. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43766. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43768. * @param name defines the name of the mesh
  43769. * @param options defines the options used to create the mesh
  43770. * @param scene defines the hosting scene
  43771. * @returns the ground mesh
  43772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43773. */
  43774. static CreateGround(name: string, options: {
  43775. width?: number;
  43776. height?: number;
  43777. subdivisions?: number;
  43778. subdivisionsX?: number;
  43779. subdivisionsY?: number;
  43780. updatable?: boolean;
  43781. }, scene: any): Mesh;
  43782. /**
  43783. * Creates a tiled ground mesh
  43784. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43785. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43786. * * 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
  43787. * * 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
  43788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43789. * @param name defines the name of the mesh
  43790. * @param options defines the options used to create the mesh
  43791. * @param scene defines the hosting scene
  43792. * @returns the tiled ground mesh
  43793. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43794. */
  43795. static CreateTiledGround(name: string, options: {
  43796. xmin: number;
  43797. zmin: number;
  43798. xmax: number;
  43799. zmax: number;
  43800. subdivisions?: {
  43801. w: number;
  43802. h: number;
  43803. };
  43804. precision?: {
  43805. w: number;
  43806. h: number;
  43807. };
  43808. updatable?: boolean;
  43809. }, scene?: Nullable<Scene>): Mesh;
  43810. /**
  43811. * Creates a ground mesh from a height map
  43812. * * The parameter `url` sets the URL of the height map image resource.
  43813. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43814. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43815. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43816. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43817. * * 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.
  43818. * * 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).
  43819. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43821. * @param name defines the name of the mesh
  43822. * @param url defines the url to the height map
  43823. * @param options defines the options used to create the mesh
  43824. * @param scene defines the hosting scene
  43825. * @returns the ground mesh
  43826. * @see https://doc.babylonjs.com/babylon101/height_map
  43827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43828. */
  43829. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43830. width?: number;
  43831. height?: number;
  43832. subdivisions?: number;
  43833. minHeight?: number;
  43834. maxHeight?: number;
  43835. colorFilter?: Color3;
  43836. alphaFilter?: number;
  43837. updatable?: boolean;
  43838. onReady?: (mesh: GroundMesh) => void;
  43839. }, scene?: Nullable<Scene>): GroundMesh;
  43840. }
  43841. }
  43842. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43843. import { Vector4 } from "babylonjs/Maths/math.vector";
  43844. import { Mesh } from "babylonjs/Meshes/mesh";
  43845. /**
  43846. * Class containing static functions to help procedurally build meshes
  43847. */
  43848. export class TorusBuilder {
  43849. /**
  43850. * Creates a torus mesh
  43851. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43852. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43853. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43857. * @param name defines the name of the mesh
  43858. * @param options defines the options used to create the mesh
  43859. * @param scene defines the hosting scene
  43860. * @returns the torus mesh
  43861. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43862. */
  43863. static CreateTorus(name: string, options: {
  43864. diameter?: number;
  43865. thickness?: number;
  43866. tessellation?: number;
  43867. updatable?: boolean;
  43868. sideOrientation?: number;
  43869. frontUVs?: Vector4;
  43870. backUVs?: Vector4;
  43871. }, scene: any): Mesh;
  43872. }
  43873. }
  43874. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43875. import { Vector4 } from "babylonjs/Maths/math.vector";
  43876. import { Color4 } from "babylonjs/Maths/math.color";
  43877. import { Mesh } from "babylonjs/Meshes/mesh";
  43878. /**
  43879. * Class containing static functions to help procedurally build meshes
  43880. */
  43881. export class CylinderBuilder {
  43882. /**
  43883. * Creates a cylinder or a cone mesh
  43884. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43885. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43886. * * 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.
  43887. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43888. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43889. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43890. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43891. * * 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).
  43892. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43893. * * 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).
  43894. * * 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
  43895. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43896. * * 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
  43897. * * 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.
  43898. * * If `enclose` is false, a ring surface is one element.
  43899. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43900. * * 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
  43901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43904. * @param name defines the name of the mesh
  43905. * @param options defines the options used to create the mesh
  43906. * @param scene defines the hosting scene
  43907. * @returns the cylinder mesh
  43908. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43909. */
  43910. static CreateCylinder(name: string, options: {
  43911. height?: number;
  43912. diameterTop?: number;
  43913. diameterBottom?: number;
  43914. diameter?: number;
  43915. tessellation?: number;
  43916. subdivisions?: number;
  43917. arc?: number;
  43918. faceColors?: Color4[];
  43919. faceUV?: Vector4[];
  43920. updatable?: boolean;
  43921. hasRings?: boolean;
  43922. enclose?: boolean;
  43923. cap?: number;
  43924. sideOrientation?: number;
  43925. frontUVs?: Vector4;
  43926. backUVs?: Vector4;
  43927. }, scene: any): Mesh;
  43928. }
  43929. }
  43930. declare module "babylonjs/XR/webXRTypes" {
  43931. import { Nullable } from "babylonjs/types";
  43932. import { IDisposable } from "babylonjs/scene";
  43933. /**
  43934. * States of the webXR experience
  43935. */
  43936. export enum WebXRState {
  43937. /**
  43938. * Transitioning to being in XR mode
  43939. */
  43940. ENTERING_XR = 0,
  43941. /**
  43942. * Transitioning to non XR mode
  43943. */
  43944. EXITING_XR = 1,
  43945. /**
  43946. * In XR mode and presenting
  43947. */
  43948. IN_XR = 2,
  43949. /**
  43950. * Not entered XR mode
  43951. */
  43952. NOT_IN_XR = 3
  43953. }
  43954. /**
  43955. * Abstraction of the XR render target
  43956. */
  43957. export interface WebXRRenderTarget extends IDisposable {
  43958. /**
  43959. * xrpresent context of the canvas which can be used to display/mirror xr content
  43960. */
  43961. canvasContext: WebGLRenderingContext;
  43962. /**
  43963. * xr layer for the canvas
  43964. */
  43965. xrLayer: Nullable<XRWebGLLayer>;
  43966. /**
  43967. * Initializes the xr layer for the session
  43968. * @param xrSession xr session
  43969. * @returns a promise that will resolve once the XR Layer has been created
  43970. */
  43971. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43972. }
  43973. }
  43974. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  43975. import { Nullable } from "babylonjs/types";
  43976. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43977. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  43978. /**
  43979. * COnfiguration object for WebXR output canvas
  43980. */
  43981. export class WebXRManagedOutputCanvasOptions {
  43982. /**
  43983. * An optional canvas in case you wish to create it yourself and provide it here.
  43984. * If not provided, a new canvas will be created
  43985. */
  43986. canvasElement?: HTMLCanvasElement;
  43987. /**
  43988. * Options for this XR Layer output
  43989. */
  43990. canvasOptions?: XRWebGLLayerOptions;
  43991. /**
  43992. * CSS styling for a newly created canvas (if not provided)
  43993. */
  43994. newCanvasCssStyle?: string;
  43995. /**
  43996. * Get the default values of the configuration object
  43997. * @returns default values of this configuration object
  43998. */
  43999. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44000. }
  44001. /**
  44002. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44003. */
  44004. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44005. private _options;
  44006. private _canvas;
  44007. private _engine;
  44008. /**
  44009. * Rendering context of the canvas which can be used to display/mirror xr content
  44010. */
  44011. canvasContext: WebGLRenderingContext;
  44012. /**
  44013. * xr layer for the canvas
  44014. */
  44015. xrLayer: Nullable<XRWebGLLayer>;
  44016. /**
  44017. * Initializes the canvas to be added/removed upon entering/exiting xr
  44018. * @param _xrSessionManager The XR Session manager
  44019. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44020. */
  44021. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44022. /**
  44023. * Disposes of the object
  44024. */
  44025. dispose(): void;
  44026. /**
  44027. * Initializes the xr layer for the session
  44028. * @param xrSession xr session
  44029. * @returns a promise that will resolve once the XR Layer has been created
  44030. */
  44031. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44032. private _addCanvas;
  44033. private _removeCanvas;
  44034. private _setManagedOutputCanvas;
  44035. }
  44036. }
  44037. declare module "babylonjs/XR/webXRSessionManager" {
  44038. import { Observable } from "babylonjs/Misc/observable";
  44039. import { Nullable } from "babylonjs/types";
  44040. import { IDisposable, Scene } from "babylonjs/scene";
  44041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44042. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44043. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44044. /**
  44045. * Manages an XRSession to work with Babylon's engine
  44046. * @see https://doc.babylonjs.com/how_to/webxr
  44047. */
  44048. export class WebXRSessionManager implements IDisposable {
  44049. /** The scene which the session should be created for */
  44050. scene: Scene;
  44051. private _referenceSpace;
  44052. private _rttProvider;
  44053. private _sessionEnded;
  44054. private _xrNavigator;
  44055. private baseLayer;
  44056. /**
  44057. * The base reference space from which the session started. good if you want to reset your
  44058. * reference space
  44059. */
  44060. baseReferenceSpace: XRReferenceSpace;
  44061. /**
  44062. * Current XR frame
  44063. */
  44064. currentFrame: Nullable<XRFrame>;
  44065. /** WebXR timestamp updated every frame */
  44066. currentTimestamp: number;
  44067. /**
  44068. * Used just in case of a failure to initialize an immersive session.
  44069. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44070. */
  44071. defaultHeightCompensation: number;
  44072. /**
  44073. * Fires every time a new xrFrame arrives which can be used to update the camera
  44074. */
  44075. onXRFrameObservable: Observable<XRFrame>;
  44076. /**
  44077. * Fires when the reference space changed
  44078. */
  44079. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44080. /**
  44081. * Fires when the xr session is ended either by the device or manually done
  44082. */
  44083. onXRSessionEnded: Observable<any>;
  44084. /**
  44085. * Fires when the xr session is ended either by the device or manually done
  44086. */
  44087. onXRSessionInit: Observable<XRSession>;
  44088. /**
  44089. * Underlying xr session
  44090. */
  44091. session: XRSession;
  44092. /**
  44093. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44094. * or get the offset the player is currently at.
  44095. */
  44096. viewerReferenceSpace: XRReferenceSpace;
  44097. /**
  44098. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44099. * @param scene The scene which the session should be created for
  44100. */
  44101. constructor(
  44102. /** The scene which the session should be created for */
  44103. scene: Scene);
  44104. /**
  44105. * The current reference space used in this session. This reference space can constantly change!
  44106. * It is mainly used to offset the camera's position.
  44107. */
  44108. get referenceSpace(): XRReferenceSpace;
  44109. /**
  44110. * Set a new reference space and triggers the observable
  44111. */
  44112. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44113. /**
  44114. * Disposes of the session manager
  44115. */
  44116. dispose(): void;
  44117. /**
  44118. * Stops the xrSession and restores the render loop
  44119. * @returns Promise which resolves after it exits XR
  44120. */
  44121. exitXRAsync(): Promise<void>;
  44122. /**
  44123. * Gets the correct render target texture to be rendered this frame for this eye
  44124. * @param eye the eye for which to get the render target
  44125. * @returns the render target for the specified eye
  44126. */
  44127. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44128. /**
  44129. * Creates a WebXRRenderTarget object for the XR session
  44130. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44131. * @param options optional options to provide when creating a new render target
  44132. * @returns a WebXR render target to which the session can render
  44133. */
  44134. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44135. /**
  44136. * Initializes the manager
  44137. * After initialization enterXR can be called to start an XR session
  44138. * @returns Promise which resolves after it is initialized
  44139. */
  44140. initializeAsync(): Promise<void>;
  44141. /**
  44142. * Initializes an xr session
  44143. * @param xrSessionMode mode to initialize
  44144. * @param xrSessionInit defines optional and required values to pass to the session builder
  44145. * @returns a promise which will resolve once the session has been initialized
  44146. */
  44147. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44148. /**
  44149. * Checks if a session would be supported for the creation options specified
  44150. * @param sessionMode session mode to check if supported eg. immersive-vr
  44151. * @returns A Promise that resolves to true if supported and false if not
  44152. */
  44153. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44154. /**
  44155. * Resets the reference space to the one started the session
  44156. */
  44157. resetReferenceSpace(): void;
  44158. /**
  44159. * Starts rendering to the xr layer
  44160. */
  44161. runXRRenderLoop(): void;
  44162. /**
  44163. * Sets the reference space on the xr session
  44164. * @param referenceSpaceType space to set
  44165. * @returns a promise that will resolve once the reference space has been set
  44166. */
  44167. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44168. /**
  44169. * Updates the render state of the session
  44170. * @param state state to set
  44171. * @returns a promise that resolves once the render state has been updated
  44172. */
  44173. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44174. /**
  44175. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44176. * @param sessionMode defines the session to test
  44177. * @returns a promise with boolean as final value
  44178. */
  44179. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44180. private _createRenderTargetTexture;
  44181. }
  44182. }
  44183. declare module "babylonjs/XR/webXRCamera" {
  44184. import { Scene } from "babylonjs/scene";
  44185. import { Camera } from "babylonjs/Cameras/camera";
  44186. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44187. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44188. /**
  44189. * WebXR Camera which holds the views for the xrSession
  44190. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44191. */
  44192. export class WebXRCamera extends FreeCamera {
  44193. private _xrSessionManager;
  44194. private _firstFrame;
  44195. private _referenceQuaternion;
  44196. private _referencedPosition;
  44197. private _xrInvPositionCache;
  44198. private _xrInvQuaternionCache;
  44199. /**
  44200. * Should position compensation execute on first frame.
  44201. * This is used when copying the position from a native (non XR) camera
  44202. */
  44203. compensateOnFirstFrame: boolean;
  44204. /**
  44205. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44206. * @param name the name of the camera
  44207. * @param scene the scene to add the camera to
  44208. * @param _xrSessionManager a constructed xr session manager
  44209. */
  44210. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44211. /**
  44212. * Return the user's height, unrelated to the current ground.
  44213. * This will be the y position of this camera, when ground level is 0.
  44214. */
  44215. get realWorldHeight(): number;
  44216. /** @hidden */
  44217. _updateForDualEyeDebugging(): void;
  44218. /**
  44219. * Sets this camera's transformation based on a non-vr camera
  44220. * @param otherCamera the non-vr camera to copy the transformation from
  44221. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44222. */
  44223. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44224. private _updateFromXRSession;
  44225. private _updateNumberOfRigCameras;
  44226. private _updateReferenceSpace;
  44227. private _updateReferenceSpaceOffset;
  44228. }
  44229. }
  44230. declare module "babylonjs/XR/webXRFeaturesManager" {
  44231. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44232. import { IDisposable } from "babylonjs/scene";
  44233. /**
  44234. * Defining the interface required for a (webxr) feature
  44235. */
  44236. export interface IWebXRFeature extends IDisposable {
  44237. /**
  44238. * Is this feature attached
  44239. */
  44240. attached: boolean;
  44241. /**
  44242. * Should auto-attach be disabled?
  44243. */
  44244. disableAutoAttach: boolean;
  44245. /**
  44246. * Attach the feature to the session
  44247. * Will usually be called by the features manager
  44248. *
  44249. * @param force should attachment be forced (even when already attached)
  44250. * @returns true if successful.
  44251. */
  44252. attach(force?: boolean): boolean;
  44253. /**
  44254. * Detach the feature from the session
  44255. * Will usually be called by the features manager
  44256. *
  44257. * @returns true if successful.
  44258. */
  44259. detach(): boolean;
  44260. }
  44261. /**
  44262. * A list of the currently available features without referencing them
  44263. */
  44264. export class WebXRFeatureName {
  44265. /**
  44266. * The name of the anchor system feature
  44267. */
  44268. static ANCHOR_SYSTEM: string;
  44269. /**
  44270. * The name of the background remover feature
  44271. */
  44272. static BACKGROUND_REMOVER: string;
  44273. /**
  44274. * The name of the hit test feature
  44275. */
  44276. static HIT_TEST: string;
  44277. /**
  44278. * physics impostors for xr controllers feature
  44279. */
  44280. static PHYSICS_CONTROLLERS: string;
  44281. /**
  44282. * The name of the plane detection feature
  44283. */
  44284. static PLANE_DETECTION: string;
  44285. /**
  44286. * The name of the pointer selection feature
  44287. */
  44288. static POINTER_SELECTION: string;
  44289. /**
  44290. * The name of the teleportation feature
  44291. */
  44292. static TELEPORTATION: string;
  44293. }
  44294. /**
  44295. * Defining the constructor of a feature. Used to register the modules.
  44296. */
  44297. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44298. /**
  44299. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44300. * It is mainly used in AR sessions.
  44301. *
  44302. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44303. */
  44304. export class WebXRFeaturesManager implements IDisposable {
  44305. private _xrSessionManager;
  44306. private static readonly _AvailableFeatures;
  44307. private _features;
  44308. /**
  44309. * constructs a new features manages.
  44310. *
  44311. * @param _xrSessionManager an instance of WebXRSessionManager
  44312. */
  44313. constructor(_xrSessionManager: WebXRSessionManager);
  44314. /**
  44315. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44316. * Mainly used internally.
  44317. *
  44318. * @param featureName the name of the feature to register
  44319. * @param constructorFunction the function used to construct the module
  44320. * @param version the (babylon) version of the module
  44321. * @param stable is that a stable version of this module
  44322. */
  44323. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44324. /**
  44325. * Returns a constructor of a specific feature.
  44326. *
  44327. * @param featureName the name of the feature to construct
  44328. * @param version the version of the feature to load
  44329. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44330. * @param options optional options provided to the module.
  44331. * @returns a function that, when called, will return a new instance of this feature
  44332. */
  44333. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44334. /**
  44335. * Can be used to return the list of features currently registered
  44336. *
  44337. * @returns an Array of available features
  44338. */
  44339. static GetAvailableFeatures(): string[];
  44340. /**
  44341. * Gets the versions available for a specific feature
  44342. * @param featureName the name of the feature
  44343. * @returns an array with the available versions
  44344. */
  44345. static GetAvailableVersions(featureName: string): string[];
  44346. /**
  44347. * Return the latest unstable version of this feature
  44348. * @param featureName the name of the feature to search
  44349. * @returns the version number. if not found will return -1
  44350. */
  44351. static GetLatestVersionOfFeature(featureName: string): number;
  44352. /**
  44353. * Return the latest stable version of this feature
  44354. * @param featureName the name of the feature to search
  44355. * @returns the version number. if not found will return -1
  44356. */
  44357. static GetStableVersionOfFeature(featureName: string): number;
  44358. /**
  44359. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44360. * Can be used during a session to start a feature
  44361. * @param featureName the name of feature to attach
  44362. */
  44363. attachFeature(featureName: string): void;
  44364. /**
  44365. * Can be used inside a session or when the session ends to detach a specific feature
  44366. * @param featureName the name of the feature to detach
  44367. */
  44368. detachFeature(featureName: string): void;
  44369. /**
  44370. * Used to disable an already-enabled feature
  44371. * The feature will be disposed and will be recreated once enabled.
  44372. * @param featureName the feature to disable
  44373. * @returns true if disable was successful
  44374. */
  44375. disableFeature(featureName: string | {
  44376. Name: string;
  44377. }): boolean;
  44378. /**
  44379. * dispose this features manager
  44380. */
  44381. dispose(): void;
  44382. /**
  44383. * 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.
  44384. * 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.
  44385. *
  44386. * @param featureName the name of the feature to load or the class of the feature
  44387. * @param version optional version to load. if not provided the latest version will be enabled
  44388. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44389. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44390. * @returns a new constructed feature or throws an error if feature not found.
  44391. */
  44392. enableFeature(featureName: string | {
  44393. Name: string;
  44394. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44395. /**
  44396. * get the implementation of an enabled feature.
  44397. * @param featureName the name of the feature to load
  44398. * @returns the feature class, if found
  44399. */
  44400. getEnabledFeature(featureName: string): IWebXRFeature;
  44401. /**
  44402. * Get the list of enabled features
  44403. * @returns an array of enabled features
  44404. */
  44405. getEnabledFeatures(): string[];
  44406. }
  44407. }
  44408. declare module "babylonjs/XR/webXRExperienceHelper" {
  44409. import { Observable } from "babylonjs/Misc/observable";
  44410. import { IDisposable, Scene } from "babylonjs/scene";
  44411. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44412. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44413. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44414. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44415. /**
  44416. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44417. * @see https://doc.babylonjs.com/how_to/webxr
  44418. */
  44419. export class WebXRExperienceHelper implements IDisposable {
  44420. private scene;
  44421. private _nonVRCamera;
  44422. private _originalSceneAutoClear;
  44423. private _supported;
  44424. /**
  44425. * Camera used to render xr content
  44426. */
  44427. camera: WebXRCamera;
  44428. /** A features manager for this xr session */
  44429. featuresManager: WebXRFeaturesManager;
  44430. /**
  44431. * Observers registered here will be triggered after the camera's initial transformation is set
  44432. * This can be used to set a different ground level or an extra rotation.
  44433. *
  44434. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44435. * to the position set after this observable is done executing.
  44436. */
  44437. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44438. /**
  44439. * Fires when the state of the experience helper has changed
  44440. */
  44441. onStateChangedObservable: Observable<WebXRState>;
  44442. /** Session manager used to keep track of xr session */
  44443. sessionManager: WebXRSessionManager;
  44444. /**
  44445. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44446. */
  44447. state: WebXRState;
  44448. /**
  44449. * Creates a WebXRExperienceHelper
  44450. * @param scene The scene the helper should be created in
  44451. */
  44452. private constructor();
  44453. /**
  44454. * Creates the experience helper
  44455. * @param scene the scene to attach the experience helper to
  44456. * @returns a promise for the experience helper
  44457. */
  44458. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44459. /**
  44460. * Disposes of the experience helper
  44461. */
  44462. dispose(): void;
  44463. /**
  44464. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44465. * @param sessionMode options for the XR session
  44466. * @param referenceSpaceType frame of reference of the XR session
  44467. * @param renderTarget the output canvas that will be used to enter XR mode
  44468. * @returns promise that resolves after xr mode has entered
  44469. */
  44470. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44471. /**
  44472. * Exits XR mode and returns the scene to its original state
  44473. * @returns promise that resolves after xr mode has exited
  44474. */
  44475. exitXRAsync(): Promise<void>;
  44476. private _nonXRToXRCamera;
  44477. private _setState;
  44478. }
  44479. }
  44480. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44481. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44482. import { Observable } from "babylonjs/Misc/observable";
  44483. import { IDisposable } from "babylonjs/scene";
  44484. /**
  44485. * X-Y values for axes in WebXR
  44486. */
  44487. export interface IWebXRMotionControllerAxesValue {
  44488. /**
  44489. * The value of the x axis
  44490. */
  44491. x: number;
  44492. /**
  44493. * The value of the y-axis
  44494. */
  44495. y: number;
  44496. }
  44497. /**
  44498. * changed / previous values for the values of this component
  44499. */
  44500. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44501. /**
  44502. * current (this frame) value
  44503. */
  44504. current: T;
  44505. /**
  44506. * previous (last change) value
  44507. */
  44508. previous: T;
  44509. }
  44510. /**
  44511. * Represents changes in the component between current frame and last values recorded
  44512. */
  44513. export interface IWebXRMotionControllerComponentChanges {
  44514. /**
  44515. * will be populated with previous and current values if axes changed
  44516. */
  44517. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44518. /**
  44519. * will be populated with previous and current values if pressed changed
  44520. */
  44521. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44522. /**
  44523. * will be populated with previous and current values if touched changed
  44524. */
  44525. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44526. /**
  44527. * will be populated with previous and current values if value changed
  44528. */
  44529. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44530. }
  44531. /**
  44532. * This class represents a single component (for example button or thumbstick) of a motion controller
  44533. */
  44534. export class WebXRControllerComponent implements IDisposable {
  44535. /**
  44536. * the id of this component
  44537. */
  44538. id: string;
  44539. /**
  44540. * the type of the component
  44541. */
  44542. type: MotionControllerComponentType;
  44543. private _buttonIndex;
  44544. private _axesIndices;
  44545. private _axes;
  44546. private _changes;
  44547. private _currentValue;
  44548. private _hasChanges;
  44549. private _pressed;
  44550. private _touched;
  44551. /**
  44552. * button component type
  44553. */
  44554. static BUTTON_TYPE: MotionControllerComponentType;
  44555. /**
  44556. * squeeze component type
  44557. */
  44558. static SQUEEZE_TYPE: MotionControllerComponentType;
  44559. /**
  44560. * Thumbstick component type
  44561. */
  44562. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44563. /**
  44564. * Touchpad component type
  44565. */
  44566. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44567. /**
  44568. * trigger component type
  44569. */
  44570. static TRIGGER_TYPE: MotionControllerComponentType;
  44571. /**
  44572. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44573. * the axes data changes
  44574. */
  44575. onAxisValueChangedObservable: Observable<{
  44576. x: number;
  44577. y: number;
  44578. }>;
  44579. /**
  44580. * Observers registered here will be triggered when the state of a button changes
  44581. * State change is either pressed / touched / value
  44582. */
  44583. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44584. /**
  44585. * Creates a new component for a motion controller.
  44586. * It is created by the motion controller itself
  44587. *
  44588. * @param id the id of this component
  44589. * @param type the type of the component
  44590. * @param _buttonIndex index in the buttons array of the gamepad
  44591. * @param _axesIndices indices of the values in the axes array of the gamepad
  44592. */
  44593. constructor(
  44594. /**
  44595. * the id of this component
  44596. */
  44597. id: string,
  44598. /**
  44599. * the type of the component
  44600. */
  44601. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44602. /**
  44603. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44604. */
  44605. get axes(): IWebXRMotionControllerAxesValue;
  44606. /**
  44607. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44608. */
  44609. get changes(): IWebXRMotionControllerComponentChanges;
  44610. /**
  44611. * Return whether or not the component changed the last frame
  44612. */
  44613. get hasChanges(): boolean;
  44614. /**
  44615. * is the button currently pressed
  44616. */
  44617. get pressed(): boolean;
  44618. /**
  44619. * is the button currently touched
  44620. */
  44621. get touched(): boolean;
  44622. /**
  44623. * Get the current value of this component
  44624. */
  44625. get value(): number;
  44626. /**
  44627. * Dispose this component
  44628. */
  44629. dispose(): void;
  44630. /**
  44631. * Are there axes correlating to this component
  44632. * @return true is axes data is available
  44633. */
  44634. isAxes(): boolean;
  44635. /**
  44636. * Is this component a button (hence - pressable)
  44637. * @returns true if can be pressed
  44638. */
  44639. isButton(): boolean;
  44640. /**
  44641. * update this component using the gamepad object it is in. Called on every frame
  44642. * @param nativeController the native gamepad controller object
  44643. */
  44644. update(nativeController: IMinimalMotionControllerObject): void;
  44645. }
  44646. }
  44647. declare module "babylonjs/Loading/sceneLoader" {
  44648. import { Observable } from "babylonjs/Misc/observable";
  44649. import { Nullable } from "babylonjs/types";
  44650. import { Scene } from "babylonjs/scene";
  44651. import { Engine } from "babylonjs/Engines/engine";
  44652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44653. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44654. import { AssetContainer } from "babylonjs/assetContainer";
  44655. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44656. import { Skeleton } from "babylonjs/Bones/skeleton";
  44657. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44658. import { WebRequest } from "babylonjs/Misc/webRequest";
  44659. /**
  44660. * Class used to represent data loading progression
  44661. */
  44662. export class SceneLoaderProgressEvent {
  44663. /** defines if data length to load can be evaluated */
  44664. readonly lengthComputable: boolean;
  44665. /** defines the loaded data length */
  44666. readonly loaded: number;
  44667. /** defines the data length to load */
  44668. readonly total: number;
  44669. /**
  44670. * Create a new progress event
  44671. * @param lengthComputable defines if data length to load can be evaluated
  44672. * @param loaded defines the loaded data length
  44673. * @param total defines the data length to load
  44674. */
  44675. constructor(
  44676. /** defines if data length to load can be evaluated */
  44677. lengthComputable: boolean,
  44678. /** defines the loaded data length */
  44679. loaded: number,
  44680. /** defines the data length to load */
  44681. total: number);
  44682. /**
  44683. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44684. * @param event defines the source event
  44685. * @returns a new SceneLoaderProgressEvent
  44686. */
  44687. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44688. }
  44689. /**
  44690. * Interface used by SceneLoader plugins to define supported file extensions
  44691. */
  44692. export interface ISceneLoaderPluginExtensions {
  44693. /**
  44694. * Defines the list of supported extensions
  44695. */
  44696. [extension: string]: {
  44697. isBinary: boolean;
  44698. };
  44699. }
  44700. /**
  44701. * Interface used by SceneLoader plugin factory
  44702. */
  44703. export interface ISceneLoaderPluginFactory {
  44704. /**
  44705. * Defines the name of the factory
  44706. */
  44707. name: string;
  44708. /**
  44709. * Function called to create a new plugin
  44710. * @return the new plugin
  44711. */
  44712. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44713. /**
  44714. * The callback that returns true if the data can be directly loaded.
  44715. * @param data string containing the file data
  44716. * @returns if the data can be loaded directly
  44717. */
  44718. canDirectLoad?(data: string): boolean;
  44719. }
  44720. /**
  44721. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44722. */
  44723. export interface ISceneLoaderPluginBase {
  44724. /**
  44725. * The friendly name of this plugin.
  44726. */
  44727. name: string;
  44728. /**
  44729. * The file extensions supported by this plugin.
  44730. */
  44731. extensions: string | ISceneLoaderPluginExtensions;
  44732. /**
  44733. * The callback called when loading from a url.
  44734. * @param scene scene loading this url
  44735. * @param url url to load
  44736. * @param onSuccess callback called when the file successfully loads
  44737. * @param onProgress callback called while file is loading (if the server supports this mode)
  44738. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44739. * @param onError callback called when the file fails to load
  44740. * @returns a file request object
  44741. */
  44742. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44743. /**
  44744. * The callback called when loading from a file object.
  44745. * @param scene scene loading this file
  44746. * @param file defines the file to load
  44747. * @param onSuccess defines the callback to call when data is loaded
  44748. * @param onProgress defines the callback to call during loading process
  44749. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44750. * @param onError defines the callback to call when an error occurs
  44751. * @returns a file request object
  44752. */
  44753. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44754. /**
  44755. * The callback that returns true if the data can be directly loaded.
  44756. * @param data string containing the file data
  44757. * @returns if the data can be loaded directly
  44758. */
  44759. canDirectLoad?(data: string): boolean;
  44760. /**
  44761. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44762. * @param scene scene loading this data
  44763. * @param data string containing the data
  44764. * @returns data to pass to the plugin
  44765. */
  44766. directLoad?(scene: Scene, data: string): any;
  44767. /**
  44768. * The callback that allows custom handling of the root url based on the response url.
  44769. * @param rootUrl the original root url
  44770. * @param responseURL the response url if available
  44771. * @returns the new root url
  44772. */
  44773. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44774. }
  44775. /**
  44776. * Interface used to define a SceneLoader plugin
  44777. */
  44778. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44779. /**
  44780. * Import meshes into a scene.
  44781. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44782. * @param scene The scene to import into
  44783. * @param data The data to import
  44784. * @param rootUrl The root url for scene and resources
  44785. * @param meshes The meshes array to import into
  44786. * @param particleSystems The particle systems array to import into
  44787. * @param skeletons The skeletons array to import into
  44788. * @param onError The callback when import fails
  44789. * @returns True if successful or false otherwise
  44790. */
  44791. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44792. /**
  44793. * Load into a scene.
  44794. * @param scene The scene to load into
  44795. * @param data The data to import
  44796. * @param rootUrl The root url for scene and resources
  44797. * @param onError The callback when import fails
  44798. * @returns True if successful or false otherwise
  44799. */
  44800. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44801. /**
  44802. * Load into an asset container.
  44803. * @param scene The scene to load into
  44804. * @param data The data to import
  44805. * @param rootUrl The root url for scene and resources
  44806. * @param onError The callback when import fails
  44807. * @returns The loaded asset container
  44808. */
  44809. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44810. }
  44811. /**
  44812. * Interface used to define an async SceneLoader plugin
  44813. */
  44814. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44815. /**
  44816. * Import meshes into a scene.
  44817. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44818. * @param scene The scene to import into
  44819. * @param data The data to import
  44820. * @param rootUrl The root url for scene and resources
  44821. * @param onProgress The callback when the load progresses
  44822. * @param fileName Defines the name of the file to load
  44823. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44824. */
  44825. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44826. meshes: AbstractMesh[];
  44827. particleSystems: IParticleSystem[];
  44828. skeletons: Skeleton[];
  44829. animationGroups: AnimationGroup[];
  44830. }>;
  44831. /**
  44832. * Load into a scene.
  44833. * @param scene The scene to load into
  44834. * @param data The data to import
  44835. * @param rootUrl The root url for scene and resources
  44836. * @param onProgress The callback when the load progresses
  44837. * @param fileName Defines the name of the file to load
  44838. * @returns Nothing
  44839. */
  44840. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44841. /**
  44842. * Load into an asset container.
  44843. * @param scene The scene to load into
  44844. * @param data The data to import
  44845. * @param rootUrl The root url for scene and resources
  44846. * @param onProgress The callback when the load progresses
  44847. * @param fileName Defines the name of the file to load
  44848. * @returns The loaded asset container
  44849. */
  44850. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44851. }
  44852. /**
  44853. * Mode that determines how to handle old animation groups before loading new ones.
  44854. */
  44855. export enum SceneLoaderAnimationGroupLoadingMode {
  44856. /**
  44857. * Reset all old animations to initial state then dispose them.
  44858. */
  44859. Clean = 0,
  44860. /**
  44861. * Stop all old animations.
  44862. */
  44863. Stop = 1,
  44864. /**
  44865. * Restart old animations from first frame.
  44866. */
  44867. Sync = 2,
  44868. /**
  44869. * Old animations remains untouched.
  44870. */
  44871. NoSync = 3
  44872. }
  44873. /**
  44874. * Class used to load scene from various file formats using registered plugins
  44875. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44876. */
  44877. export class SceneLoader {
  44878. /**
  44879. * No logging while loading
  44880. */
  44881. static readonly NO_LOGGING: number;
  44882. /**
  44883. * Minimal logging while loading
  44884. */
  44885. static readonly MINIMAL_LOGGING: number;
  44886. /**
  44887. * Summary logging while loading
  44888. */
  44889. static readonly SUMMARY_LOGGING: number;
  44890. /**
  44891. * Detailled logging while loading
  44892. */
  44893. static readonly DETAILED_LOGGING: number;
  44894. /**
  44895. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44896. */
  44897. static get ForceFullSceneLoadingForIncremental(): boolean;
  44898. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44899. /**
  44900. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44901. */
  44902. static get ShowLoadingScreen(): boolean;
  44903. static set ShowLoadingScreen(value: boolean);
  44904. /**
  44905. * Defines the current logging level (while loading the scene)
  44906. * @ignorenaming
  44907. */
  44908. static get loggingLevel(): number;
  44909. static set loggingLevel(value: number);
  44910. /**
  44911. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44912. */
  44913. static get CleanBoneMatrixWeights(): boolean;
  44914. static set CleanBoneMatrixWeights(value: boolean);
  44915. /**
  44916. * Event raised when a plugin is used to load a scene
  44917. */
  44918. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44919. private static _registeredPlugins;
  44920. private static _getDefaultPlugin;
  44921. private static _getPluginForExtension;
  44922. private static _getPluginForDirectLoad;
  44923. private static _getPluginForFilename;
  44924. private static _getDirectLoad;
  44925. private static _loadData;
  44926. private static _getFileInfo;
  44927. /**
  44928. * Gets a plugin that can load the given extension
  44929. * @param extension defines the extension to load
  44930. * @returns a plugin or null if none works
  44931. */
  44932. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44933. /**
  44934. * Gets a boolean indicating that the given extension can be loaded
  44935. * @param extension defines the extension to load
  44936. * @returns true if the extension is supported
  44937. */
  44938. static IsPluginForExtensionAvailable(extension: string): boolean;
  44939. /**
  44940. * Adds a new plugin to the list of registered plugins
  44941. * @param plugin defines the plugin to add
  44942. */
  44943. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44944. /**
  44945. * Import meshes into a scene
  44946. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44947. * @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)
  44948. * @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)
  44949. * @param scene the instance of BABYLON.Scene to append to
  44950. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44951. * @param onProgress a callback with a progress event for each file being loaded
  44952. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44953. * @param pluginExtension the extension used to determine the plugin
  44954. * @returns The loaded plugin
  44955. */
  44956. 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>;
  44957. /**
  44958. * Import meshes into a scene
  44959. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44960. * @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)
  44961. * @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)
  44962. * @param scene the instance of BABYLON.Scene to append to
  44963. * @param onProgress a callback with a progress event for each file being loaded
  44964. * @param pluginExtension the extension used to determine the plugin
  44965. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44966. */
  44967. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44968. meshes: AbstractMesh[];
  44969. particleSystems: IParticleSystem[];
  44970. skeletons: Skeleton[];
  44971. animationGroups: AnimationGroup[];
  44972. }>;
  44973. /**
  44974. * Load a scene
  44975. * @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)
  44976. * @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)
  44977. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44978. * @param onSuccess a callback with the scene when import succeeds
  44979. * @param onProgress a callback with a progress event for each file being loaded
  44980. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44981. * @param pluginExtension the extension used to determine the plugin
  44982. * @returns The loaded plugin
  44983. */
  44984. 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>;
  44985. /**
  44986. * Load a scene
  44987. * @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)
  44988. * @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)
  44989. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44990. * @param onProgress a callback with a progress event for each file being loaded
  44991. * @param pluginExtension the extension used to determine the plugin
  44992. * @returns The loaded scene
  44993. */
  44994. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44995. /**
  44996. * Append a scene
  44997. * @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)
  44998. * @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)
  44999. * @param scene is the instance of BABYLON.Scene to append to
  45000. * @param onSuccess a callback with the scene when import succeeds
  45001. * @param onProgress a callback with a progress event for each file being loaded
  45002. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45003. * @param pluginExtension the extension used to determine the plugin
  45004. * @returns The loaded plugin
  45005. */
  45006. 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>;
  45007. /**
  45008. * Append a scene
  45009. * @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)
  45010. * @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)
  45011. * @param scene is the instance of BABYLON.Scene to append to
  45012. * @param onProgress a callback with a progress event for each file being loaded
  45013. * @param pluginExtension the extension used to determine the plugin
  45014. * @returns The given scene
  45015. */
  45016. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45017. /**
  45018. * Load a scene into an asset container
  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 is the instance of BABYLON.Scene to append to (default: last created scene)
  45022. * @param onSuccess a callback with the scene when import succeeds
  45023. * @param onProgress a callback with a progress event for each file being loaded
  45024. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45025. * @param pluginExtension the extension used to determine the plugin
  45026. * @returns The loaded plugin
  45027. */
  45028. 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>;
  45029. /**
  45030. * Load a scene into an asset container
  45031. * @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)
  45032. * @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)
  45033. * @param scene is the instance of Scene to append to
  45034. * @param onProgress a callback with a progress event for each file being loaded
  45035. * @param pluginExtension the extension used to determine the plugin
  45036. * @returns The loaded asset container
  45037. */
  45038. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45039. /**
  45040. * Import animations from a file into a scene
  45041. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45042. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45043. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45044. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45045. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45046. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45047. * @param onSuccess a callback with the scene when import succeeds
  45048. * @param onProgress a callback with a progress event for each file being loaded
  45049. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45050. */
  45051. 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;
  45052. /**
  45053. * Import animations from a file into a scene
  45054. * @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)
  45055. * @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)
  45056. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45057. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45058. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45059. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45060. * @param onSuccess a callback with the scene when import succeeds
  45061. * @param onProgress a callback with a progress event for each file being loaded
  45062. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45063. * @returns the updated scene with imported animations
  45064. */
  45065. 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>;
  45066. }
  45067. }
  45068. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45069. import { IDisposable, Scene } from "babylonjs/scene";
  45070. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45071. import { Observable } from "babylonjs/Misc/observable";
  45072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45073. import { Nullable } from "babylonjs/types";
  45074. /**
  45075. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45076. */
  45077. export type MotionControllerHandness = "none" | "left" | "right";
  45078. /**
  45079. * The type of components available in motion controllers.
  45080. * This is not the name of the component.
  45081. */
  45082. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45083. /**
  45084. * The state of a controller component
  45085. */
  45086. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45087. /**
  45088. * The schema of motion controller layout.
  45089. * No object will be initialized using this interface
  45090. * This is used just to define the profile.
  45091. */
  45092. export interface IMotionControllerLayout {
  45093. /**
  45094. * Path to load the assets. Usually relative to the base path
  45095. */
  45096. assetPath: string;
  45097. /**
  45098. * Available components (unsorted)
  45099. */
  45100. components: {
  45101. /**
  45102. * A map of component Ids
  45103. */
  45104. [componentId: string]: {
  45105. /**
  45106. * The type of input the component outputs
  45107. */
  45108. type: MotionControllerComponentType;
  45109. /**
  45110. * The indices of this component in the gamepad object
  45111. */
  45112. gamepadIndices: {
  45113. /**
  45114. * Index of button
  45115. */
  45116. button?: number;
  45117. /**
  45118. * If available, index of x-axis
  45119. */
  45120. xAxis?: number;
  45121. /**
  45122. * If available, index of y-axis
  45123. */
  45124. yAxis?: number;
  45125. };
  45126. /**
  45127. * The mesh's root node name
  45128. */
  45129. rootNodeName: string;
  45130. /**
  45131. * Animation definitions for this model
  45132. */
  45133. visualResponses: {
  45134. [stateKey: string]: {
  45135. /**
  45136. * What property will be animated
  45137. */
  45138. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45139. /**
  45140. * What states influence this visual response
  45141. */
  45142. states: MotionControllerComponentStateType[];
  45143. /**
  45144. * Type of animation - movement or visibility
  45145. */
  45146. valueNodeProperty: "transform" | "visibility";
  45147. /**
  45148. * Base node name to move. Its position will be calculated according to the min and max nodes
  45149. */
  45150. valueNodeName?: string;
  45151. /**
  45152. * Minimum movement node
  45153. */
  45154. minNodeName?: string;
  45155. /**
  45156. * Max movement node
  45157. */
  45158. maxNodeName?: string;
  45159. };
  45160. };
  45161. /**
  45162. * If touch enabled, what is the name of node to display user feedback
  45163. */
  45164. touchPointNodeName?: string;
  45165. };
  45166. };
  45167. /**
  45168. * Is it xr standard mapping or not
  45169. */
  45170. gamepadMapping: "" | "xr-standard";
  45171. /**
  45172. * Base root node of this entire model
  45173. */
  45174. rootNodeName: string;
  45175. /**
  45176. * Defines the main button component id
  45177. */
  45178. selectComponentId: string;
  45179. }
  45180. /**
  45181. * A definition for the layout map in the input profile
  45182. */
  45183. export interface IMotionControllerLayoutMap {
  45184. /**
  45185. * Layouts with handness type as a key
  45186. */
  45187. [handness: string]: IMotionControllerLayout;
  45188. }
  45189. /**
  45190. * The XR Input profile schema
  45191. * Profiles can be found here:
  45192. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45193. */
  45194. export interface IMotionControllerProfile {
  45195. /**
  45196. * fallback profiles for this profileId
  45197. */
  45198. fallbackProfileIds: string[];
  45199. /**
  45200. * The layout map, with handness as key
  45201. */
  45202. layouts: IMotionControllerLayoutMap;
  45203. /**
  45204. * The id of this profile
  45205. * correlates to the profile(s) in the xrInput.profiles array
  45206. */
  45207. profileId: string;
  45208. }
  45209. /**
  45210. * A helper-interface for the 3 meshes needed for controller button animation
  45211. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45212. */
  45213. export interface IMotionControllerButtonMeshMap {
  45214. /**
  45215. * the mesh that defines the pressed value mesh position.
  45216. * This is used to find the max-position of this button
  45217. */
  45218. pressedMesh: AbstractMesh;
  45219. /**
  45220. * the mesh that defines the unpressed value mesh position.
  45221. * This is used to find the min (or initial) position of this button
  45222. */
  45223. unpressedMesh: AbstractMesh;
  45224. /**
  45225. * The mesh that will be changed when value changes
  45226. */
  45227. valueMesh: AbstractMesh;
  45228. }
  45229. /**
  45230. * A helper-interface for the 3 meshes needed for controller axis animation.
  45231. * This will be expanded when touchpad animations are fully supported
  45232. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45233. */
  45234. export interface IMotionControllerMeshMap {
  45235. /**
  45236. * the mesh that defines the maximum value mesh position.
  45237. */
  45238. maxMesh?: AbstractMesh;
  45239. /**
  45240. * the mesh that defines the minimum value mesh position.
  45241. */
  45242. minMesh?: AbstractMesh;
  45243. /**
  45244. * The mesh that will be changed when axis value changes
  45245. */
  45246. valueMesh: AbstractMesh;
  45247. }
  45248. /**
  45249. * The elements needed for change-detection of the gamepad objects in motion controllers
  45250. */
  45251. export interface IMinimalMotionControllerObject {
  45252. /**
  45253. * Available axes of this controller
  45254. */
  45255. axes: number[];
  45256. /**
  45257. * An array of available buttons
  45258. */
  45259. buttons: Array<{
  45260. /**
  45261. * Value of the button/trigger
  45262. */
  45263. value: number;
  45264. /**
  45265. * If the button/trigger is currently touched
  45266. */
  45267. touched: boolean;
  45268. /**
  45269. * If the button/trigger is currently pressed
  45270. */
  45271. pressed: boolean;
  45272. }>;
  45273. }
  45274. /**
  45275. * An Abstract Motion controller
  45276. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45277. * Each component has an observable to check for changes in value and state
  45278. */
  45279. export abstract class WebXRAbstractMotionController implements IDisposable {
  45280. protected scene: Scene;
  45281. protected layout: IMotionControllerLayout;
  45282. /**
  45283. * The gamepad object correlating to this controller
  45284. */
  45285. gamepadObject: IMinimalMotionControllerObject;
  45286. /**
  45287. * handness (left/right/none) of this controller
  45288. */
  45289. handness: MotionControllerHandness;
  45290. private _initComponent;
  45291. private _modelReady;
  45292. /**
  45293. * A map of components (WebXRControllerComponent) in this motion controller
  45294. * Components have a ComponentType and can also have both button and axis definitions
  45295. */
  45296. readonly components: {
  45297. [id: string]: WebXRControllerComponent;
  45298. };
  45299. /**
  45300. * Disable the model's animation. Can be set at any time.
  45301. */
  45302. disableAnimation: boolean;
  45303. /**
  45304. * Observers registered here will be triggered when the model of this controller is done loading
  45305. */
  45306. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45307. /**
  45308. * The profile id of this motion controller
  45309. */
  45310. abstract profileId: string;
  45311. /**
  45312. * The root mesh of the model. It is null if the model was not yet initialized
  45313. */
  45314. rootMesh: Nullable<AbstractMesh>;
  45315. /**
  45316. * constructs a new abstract motion controller
  45317. * @param scene the scene to which the model of the controller will be added
  45318. * @param layout The profile layout to load
  45319. * @param gamepadObject The gamepad object correlating to this controller
  45320. * @param handness handness (left/right/none) of this controller
  45321. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45322. */
  45323. constructor(scene: Scene, layout: IMotionControllerLayout,
  45324. /**
  45325. * The gamepad object correlating to this controller
  45326. */
  45327. gamepadObject: IMinimalMotionControllerObject,
  45328. /**
  45329. * handness (left/right/none) of this controller
  45330. */
  45331. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45332. /**
  45333. * Dispose this controller, the model mesh and all its components
  45334. */
  45335. dispose(): void;
  45336. /**
  45337. * Returns all components of specific type
  45338. * @param type the type to search for
  45339. * @return an array of components with this type
  45340. */
  45341. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45342. /**
  45343. * get a component based an its component id as defined in layout.components
  45344. * @param id the id of the component
  45345. * @returns the component correlates to the id or undefined if not found
  45346. */
  45347. getComponent(id: string): WebXRControllerComponent;
  45348. /**
  45349. * Get the list of components available in this motion controller
  45350. * @returns an array of strings correlating to available components
  45351. */
  45352. getComponentIds(): string[];
  45353. /**
  45354. * Get the first component of specific type
  45355. * @param type type of component to find
  45356. * @return a controller component or null if not found
  45357. */
  45358. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45359. /**
  45360. * Get the main (Select) component of this controller as defined in the layout
  45361. * @returns the main component of this controller
  45362. */
  45363. getMainComponent(): WebXRControllerComponent;
  45364. /**
  45365. * Loads the model correlating to this controller
  45366. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45367. * @returns A promise fulfilled with the result of the model loading
  45368. */
  45369. loadModel(): Promise<boolean>;
  45370. /**
  45371. * Update this model using the current XRFrame
  45372. * @param xrFrame the current xr frame to use and update the model
  45373. */
  45374. updateFromXRFrame(xrFrame: XRFrame): void;
  45375. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45376. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45377. /**
  45378. * Moves the axis on the controller mesh based on its current state
  45379. * @param axis the index of the axis
  45380. * @param axisValue the value of the axis which determines the meshes new position
  45381. * @hidden
  45382. */
  45383. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45384. /**
  45385. * Update the model itself with the current frame data
  45386. * @param xrFrame the frame to use for updating the model mesh
  45387. */
  45388. protected updateModel(xrFrame: XRFrame): void;
  45389. /**
  45390. * Get the filename and path for this controller's model
  45391. * @returns a map of filename and path
  45392. */
  45393. protected abstract _getFilenameAndPath(): {
  45394. filename: string;
  45395. path: string;
  45396. };
  45397. /**
  45398. * This function is called before the mesh is loaded. It checks for loading constraints.
  45399. * For example, this function can check if the GLB loader is available
  45400. * If this function returns false, the generic controller will be loaded instead
  45401. * @returns Is the client ready to load the mesh
  45402. */
  45403. protected abstract _getModelLoadingConstraints(): boolean;
  45404. /**
  45405. * This function will be called after the model was successfully loaded and can be used
  45406. * for mesh transformations before it is available for the user
  45407. * @param meshes the loaded meshes
  45408. */
  45409. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45410. /**
  45411. * Set the root mesh for this controller. Important for the WebXR controller class
  45412. * @param meshes the loaded meshes
  45413. */
  45414. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45415. /**
  45416. * A function executed each frame that updates the mesh (if needed)
  45417. * @param xrFrame the current xrFrame
  45418. */
  45419. protected abstract _updateModel(xrFrame: XRFrame): void;
  45420. private _getGenericFilenameAndPath;
  45421. private _getGenericParentMesh;
  45422. }
  45423. }
  45424. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45425. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45427. import { Scene } from "babylonjs/scene";
  45428. /**
  45429. * A generic trigger-only motion controller for WebXR
  45430. */
  45431. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45432. /**
  45433. * Static version of the profile id of this controller
  45434. */
  45435. static ProfileId: string;
  45436. profileId: string;
  45437. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45438. protected _getFilenameAndPath(): {
  45439. filename: string;
  45440. path: string;
  45441. };
  45442. protected _getModelLoadingConstraints(): boolean;
  45443. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45444. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45445. protected _updateModel(): void;
  45446. }
  45447. }
  45448. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45449. import { Vector4 } from "babylonjs/Maths/math.vector";
  45450. import { Mesh } from "babylonjs/Meshes/mesh";
  45451. import { Scene } from "babylonjs/scene";
  45452. import { Nullable } from "babylonjs/types";
  45453. /**
  45454. * Class containing static functions to help procedurally build meshes
  45455. */
  45456. export class SphereBuilder {
  45457. /**
  45458. * Creates a sphere mesh
  45459. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45460. * * 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`)
  45461. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45462. * * 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
  45463. * * 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)
  45464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45467. * @param name defines the name of the mesh
  45468. * @param options defines the options used to create the mesh
  45469. * @param scene defines the hosting scene
  45470. * @returns the sphere mesh
  45471. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45472. */
  45473. static CreateSphere(name: string, options: {
  45474. segments?: number;
  45475. diameter?: number;
  45476. diameterX?: number;
  45477. diameterY?: number;
  45478. diameterZ?: number;
  45479. arc?: number;
  45480. slice?: number;
  45481. sideOrientation?: number;
  45482. frontUVs?: Vector4;
  45483. backUVs?: Vector4;
  45484. updatable?: boolean;
  45485. }, scene?: Nullable<Scene>): Mesh;
  45486. }
  45487. }
  45488. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45490. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45491. import { Scene } from "babylonjs/scene";
  45492. /**
  45493. * A profiled motion controller has its profile loaded from an online repository.
  45494. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45495. */
  45496. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45497. private _repositoryUrl;
  45498. private _buttonMeshMapping;
  45499. private _touchDots;
  45500. /**
  45501. * The profile ID of this controller. Will be populated when the controller initializes.
  45502. */
  45503. profileId: string;
  45504. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45505. dispose(): void;
  45506. protected _getFilenameAndPath(): {
  45507. filename: string;
  45508. path: string;
  45509. };
  45510. protected _getModelLoadingConstraints(): boolean;
  45511. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45512. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45513. protected _updateModel(_xrFrame: XRFrame): void;
  45514. }
  45515. }
  45516. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45517. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45518. import { Scene } from "babylonjs/scene";
  45519. /**
  45520. * A construction function type to create a new controller based on an xrInput object
  45521. */
  45522. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45523. /**
  45524. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45525. *
  45526. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45527. * it should be replaced with auto-loaded controllers.
  45528. *
  45529. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45530. */
  45531. export class WebXRMotionControllerManager {
  45532. private static _AvailableControllers;
  45533. private static _Fallbacks;
  45534. private static _ProfileLoadingPromises;
  45535. private static _ProfilesList;
  45536. /**
  45537. * The base URL of the online controller repository. Can be changed at any time.
  45538. */
  45539. static BaseRepositoryUrl: string;
  45540. /**
  45541. * Which repository gets priority - local or online
  45542. */
  45543. static PrioritizeOnlineRepository: boolean;
  45544. /**
  45545. * Use the online repository, or use only locally-defined controllers
  45546. */
  45547. static UseOnlineRepository: boolean;
  45548. /**
  45549. * Clear the cache used for profile loading and reload when requested again
  45550. */
  45551. static ClearProfilesCache(): void;
  45552. /**
  45553. * Register the default fallbacks.
  45554. * This function is called automatically when this file is imported.
  45555. */
  45556. static DefaultFallbacks(): void;
  45557. /**
  45558. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45559. * @param profileId the profile to which a fallback needs to be found
  45560. * @return an array with corresponding fallback profiles
  45561. */
  45562. static FindFallbackWithProfileId(profileId: string): string[];
  45563. /**
  45564. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45565. * The order of search:
  45566. *
  45567. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45568. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45569. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45570. * 4) return the generic trigger controller if none were found
  45571. *
  45572. * @param xrInput the xrInput to which a new controller is initialized
  45573. * @param scene the scene to which the model will be added
  45574. * @param forceProfile force a certain profile for this controller
  45575. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45576. */
  45577. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45578. /**
  45579. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45580. *
  45581. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45582. *
  45583. * @param type the profile type to register
  45584. * @param constructFunction the function to be called when loading this profile
  45585. */
  45586. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45587. /**
  45588. * Register a fallback to a specific profile.
  45589. * @param profileId the profileId that will receive the fallbacks
  45590. * @param fallbacks A list of fallback profiles
  45591. */
  45592. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45593. /**
  45594. * Will update the list of profiles available in the repository
  45595. * @return a promise that resolves to a map of profiles available online
  45596. */
  45597. static UpdateProfilesList(): Promise<{
  45598. [profile: string]: string;
  45599. }>;
  45600. private static _LoadProfileFromRepository;
  45601. private static _LoadProfilesFromAvailableControllers;
  45602. }
  45603. }
  45604. declare module "babylonjs/XR/webXRInputSource" {
  45605. import { Observable } from "babylonjs/Misc/observable";
  45606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45607. import { Ray } from "babylonjs/Culling/ray";
  45608. import { Scene } from "babylonjs/scene";
  45609. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45610. /**
  45611. * Configuration options for the WebXR controller creation
  45612. */
  45613. export interface IWebXRControllerOptions {
  45614. /**
  45615. * Should the controller mesh be animated when a user interacts with it
  45616. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45617. */
  45618. disableMotionControllerAnimation?: boolean;
  45619. /**
  45620. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45621. */
  45622. doNotLoadControllerMesh?: boolean;
  45623. /**
  45624. * Force a specific controller type for this controller.
  45625. * This can be used when creating your own profile or when testing different controllers
  45626. */
  45627. forceControllerProfile?: string;
  45628. }
  45629. /**
  45630. * Represents an XR controller
  45631. */
  45632. export class WebXRInputSource {
  45633. private _scene;
  45634. /** The underlying input source for the controller */
  45635. inputSource: XRInputSource;
  45636. private _options;
  45637. private _tmpQuaternion;
  45638. private _tmpVector;
  45639. private _uniqueId;
  45640. /**
  45641. * 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
  45642. */
  45643. grip?: AbstractMesh;
  45644. /**
  45645. * If available, this is the gamepad object related to this controller.
  45646. * Using this object it is possible to get click events and trackpad changes of the
  45647. * webxr controller that is currently being used.
  45648. */
  45649. motionController?: WebXRAbstractMotionController;
  45650. /**
  45651. * Event that fires when the controller is removed/disposed.
  45652. * The object provided as event data is this controller, after associated assets were disposed.
  45653. * uniqueId is still available.
  45654. */
  45655. onDisposeObservable: Observable<WebXRInputSource>;
  45656. /**
  45657. * Will be triggered when the mesh associated with the motion controller is done loading.
  45658. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45659. * A shortened version of controller -> motion controller -> on mesh loaded.
  45660. */
  45661. onMeshLoadedObservable: Observable<AbstractMesh>;
  45662. /**
  45663. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45664. */
  45665. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45666. /**
  45667. * Pointer which can be used to select objects or attach a visible laser to
  45668. */
  45669. pointer: AbstractMesh;
  45670. /**
  45671. * Creates the controller
  45672. * @see https://doc.babylonjs.com/how_to/webxr
  45673. * @param _scene the scene which the controller should be associated to
  45674. * @param inputSource the underlying input source for the controller
  45675. * @param _options options for this controller creation
  45676. */
  45677. constructor(_scene: Scene,
  45678. /** The underlying input source for the controller */
  45679. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45680. /**
  45681. * Get this controllers unique id
  45682. */
  45683. get uniqueId(): string;
  45684. /**
  45685. * Disposes of the object
  45686. */
  45687. dispose(): void;
  45688. /**
  45689. * Gets a world space ray coming from the pointer or grip
  45690. * @param result the resulting ray
  45691. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45692. */
  45693. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45694. /**
  45695. * Updates the controller pose based on the given XRFrame
  45696. * @param xrFrame xr frame to update the pose with
  45697. * @param referenceSpace reference space to use
  45698. */
  45699. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45700. }
  45701. }
  45702. declare module "babylonjs/XR/webXRInput" {
  45703. import { Observable } from "babylonjs/Misc/observable";
  45704. import { IDisposable } from "babylonjs/scene";
  45705. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45706. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45707. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45708. /**
  45709. * The schema for initialization options of the XR Input class
  45710. */
  45711. export interface IWebXRInputOptions {
  45712. /**
  45713. * If set to true no model will be automatically loaded
  45714. */
  45715. doNotLoadControllerMeshes?: boolean;
  45716. /**
  45717. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45718. * If not found, the xr input profile data will be used.
  45719. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45720. */
  45721. forceInputProfile?: string;
  45722. /**
  45723. * Do not send a request to the controller repository to load the profile.
  45724. *
  45725. * Instead, use the controllers available in babylon itself.
  45726. */
  45727. disableOnlineControllerRepository?: boolean;
  45728. /**
  45729. * A custom URL for the controllers repository
  45730. */
  45731. customControllersRepositoryURL?: string;
  45732. /**
  45733. * Should the controller model's components not move according to the user input
  45734. */
  45735. disableControllerAnimation?: boolean;
  45736. }
  45737. /**
  45738. * XR input used to track XR inputs such as controllers/rays
  45739. */
  45740. export class WebXRInput implements IDisposable {
  45741. /**
  45742. * the xr session manager for this session
  45743. */
  45744. xrSessionManager: WebXRSessionManager;
  45745. /**
  45746. * the WebXR camera for this session. Mainly used for teleportation
  45747. */
  45748. xrCamera: WebXRCamera;
  45749. private readonly options;
  45750. /**
  45751. * XR controllers being tracked
  45752. */
  45753. controllers: Array<WebXRInputSource>;
  45754. private _frameObserver;
  45755. private _sessionEndedObserver;
  45756. private _sessionInitObserver;
  45757. /**
  45758. * Event when a controller has been connected/added
  45759. */
  45760. onControllerAddedObservable: Observable<WebXRInputSource>;
  45761. /**
  45762. * Event when a controller has been removed/disconnected
  45763. */
  45764. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45765. /**
  45766. * Initializes the WebXRInput
  45767. * @param xrSessionManager the xr session manager for this session
  45768. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45769. * @param options = initialization options for this xr input
  45770. */
  45771. constructor(
  45772. /**
  45773. * the xr session manager for this session
  45774. */
  45775. xrSessionManager: WebXRSessionManager,
  45776. /**
  45777. * the WebXR camera for this session. Mainly used for teleportation
  45778. */
  45779. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45780. private _onInputSourcesChange;
  45781. private _addAndRemoveControllers;
  45782. /**
  45783. * Disposes of the object
  45784. */
  45785. dispose(): void;
  45786. }
  45787. }
  45788. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45789. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45790. import { Observable, EventState } from "babylonjs/Misc/observable";
  45791. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45792. /**
  45793. * This is the base class for all WebXR features.
  45794. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45795. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45796. */
  45797. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45798. protected _xrSessionManager: WebXRSessionManager;
  45799. private _attached;
  45800. private _removeOnDetach;
  45801. /**
  45802. * Should auto-attach be disabled?
  45803. */
  45804. disableAutoAttach: boolean;
  45805. /**
  45806. * Construct a new (abstract) WebXR feature
  45807. * @param _xrSessionManager the xr session manager for this feature
  45808. */
  45809. constructor(_xrSessionManager: WebXRSessionManager);
  45810. /**
  45811. * Is this feature attached
  45812. */
  45813. get attached(): boolean;
  45814. /**
  45815. * attach this feature
  45816. *
  45817. * @param force should attachment be forced (even when already attached)
  45818. * @returns true if successful, false is failed or already attached
  45819. */
  45820. attach(force?: boolean): boolean;
  45821. /**
  45822. * detach this feature.
  45823. *
  45824. * @returns true if successful, false if failed or already detached
  45825. */
  45826. detach(): boolean;
  45827. /**
  45828. * Dispose this feature and all of the resources attached
  45829. */
  45830. dispose(): void;
  45831. /**
  45832. * This is used to register callbacks that will automatically be removed when detach is called.
  45833. * @param observable the observable to which the observer will be attached
  45834. * @param callback the callback to register
  45835. */
  45836. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45837. /**
  45838. * Code in this function will be executed on each xrFrame received from the browser.
  45839. * This function will not execute after the feature is detached.
  45840. * @param _xrFrame the current frame
  45841. */
  45842. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45843. }
  45844. }
  45845. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45846. import { IDisposable, Scene } from "babylonjs/scene";
  45847. import { Nullable } from "babylonjs/types";
  45848. import { Observable } from "babylonjs/Misc/observable";
  45849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45850. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45851. import { Camera } from "babylonjs/Cameras/camera";
  45852. /**
  45853. * Renders a layer on top of an existing scene
  45854. */
  45855. export class UtilityLayerRenderer implements IDisposable {
  45856. /** the original scene that will be rendered on top of */
  45857. originalScene: Scene;
  45858. private _pointerCaptures;
  45859. private _lastPointerEvents;
  45860. private static _DefaultUtilityLayer;
  45861. private static _DefaultKeepDepthUtilityLayer;
  45862. private _sharedGizmoLight;
  45863. private _renderCamera;
  45864. /**
  45865. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45866. * @returns the camera that is used when rendering the utility layer
  45867. */
  45868. getRenderCamera(): Camera;
  45869. /**
  45870. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45871. * @param cam the camera that should be used when rendering the utility layer
  45872. */
  45873. setRenderCamera(cam: Nullable<Camera>): void;
  45874. /**
  45875. * @hidden
  45876. * Light which used by gizmos to get light shading
  45877. */
  45878. _getSharedGizmoLight(): HemisphericLight;
  45879. /**
  45880. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45881. */
  45882. pickUtilitySceneFirst: boolean;
  45883. /**
  45884. * 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)
  45885. */
  45886. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45887. /**
  45888. * 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)
  45889. */
  45890. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45891. /**
  45892. * The scene that is rendered on top of the original scene
  45893. */
  45894. utilityLayerScene: Scene;
  45895. /**
  45896. * If the utility layer should automatically be rendered on top of existing scene
  45897. */
  45898. shouldRender: boolean;
  45899. /**
  45900. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45901. */
  45902. onlyCheckPointerDownEvents: boolean;
  45903. /**
  45904. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45905. */
  45906. processAllEvents: boolean;
  45907. /**
  45908. * Observable raised when the pointer move from the utility layer scene to the main scene
  45909. */
  45910. onPointerOutObservable: Observable<number>;
  45911. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45912. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45913. private _afterRenderObserver;
  45914. private _sceneDisposeObserver;
  45915. private _originalPointerObserver;
  45916. /**
  45917. * Instantiates a UtilityLayerRenderer
  45918. * @param originalScene the original scene that will be rendered on top of
  45919. * @param handleEvents boolean indicating if the utility layer should handle events
  45920. */
  45921. constructor(
  45922. /** the original scene that will be rendered on top of */
  45923. originalScene: Scene, handleEvents?: boolean);
  45924. private _notifyObservers;
  45925. /**
  45926. * Renders the utility layers scene on top of the original scene
  45927. */
  45928. render(): void;
  45929. /**
  45930. * Disposes of the renderer
  45931. */
  45932. dispose(): void;
  45933. private _updateCamera;
  45934. }
  45935. }
  45936. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45937. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45939. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45940. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45941. import { Scene } from "babylonjs/scene";
  45942. import { Nullable } from "babylonjs/types";
  45943. import { Color3 } from "babylonjs/Maths/math.color";
  45944. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45945. /**
  45946. * Options interface for the pointer selection module
  45947. */
  45948. export interface IWebXRControllerPointerSelectionOptions {
  45949. /**
  45950. * if provided, this scene will be used to render meshes.
  45951. */
  45952. customUtilityLayerScene?: Scene;
  45953. /**
  45954. * 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)
  45955. * If not disabled, the last picked point will be used to execute a pointer up event
  45956. * If disabled, pointer up event will be triggered right after the pointer down event.
  45957. * Used in screen and gaze target ray mode only
  45958. */
  45959. disablePointerUpOnTouchOut: boolean;
  45960. /**
  45961. * For gaze mode (time to select instead of press)
  45962. */
  45963. forceGazeMode: boolean;
  45964. /**
  45965. * 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
  45966. * to start a new countdown to the pointer down event.
  45967. * Defaults to 1.
  45968. */
  45969. gazeModePointerMovedFactor?: number;
  45970. /**
  45971. * Different button type to use instead of the main component
  45972. */
  45973. overrideButtonId?: string;
  45974. /**
  45975. * use this rendering group id for the meshes (optional)
  45976. */
  45977. renderingGroupId?: number;
  45978. /**
  45979. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45980. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45981. * 3000 means 3 seconds between pointing at something and selecting it
  45982. */
  45983. timeToSelect?: number;
  45984. /**
  45985. * Should meshes created here be added to a utility layer or the main scene
  45986. */
  45987. useUtilityLayer?: boolean;
  45988. /**
  45989. * the xr input to use with this pointer selection
  45990. */
  45991. xrInput: WebXRInput;
  45992. }
  45993. /**
  45994. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45995. */
  45996. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45997. private readonly _options;
  45998. private static _idCounter;
  45999. private _attachController;
  46000. private _controllers;
  46001. private _scene;
  46002. private _tmpVectorForPickCompare;
  46003. /**
  46004. * The module's name
  46005. */
  46006. static readonly Name: string;
  46007. /**
  46008. * The (Babylon) version of this module.
  46009. * This is an integer representing the implementation version.
  46010. * This number does not correspond to the WebXR specs version
  46011. */
  46012. static readonly Version: number;
  46013. /**
  46014. * Disable lighting on the laser pointer (so it will always be visible)
  46015. */
  46016. disablePointerLighting: boolean;
  46017. /**
  46018. * Disable lighting on the selection mesh (so it will always be visible)
  46019. */
  46020. disableSelectionMeshLighting: boolean;
  46021. /**
  46022. * Should the laser pointer be displayed
  46023. */
  46024. displayLaserPointer: boolean;
  46025. /**
  46026. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46027. */
  46028. displaySelectionMesh: boolean;
  46029. /**
  46030. * This color will be set to the laser pointer when selection is triggered
  46031. */
  46032. laserPointerPickedColor: Color3;
  46033. /**
  46034. * Default color of the laser pointer
  46035. */
  46036. lasterPointerDefaultColor: Color3;
  46037. /**
  46038. * default color of the selection ring
  46039. */
  46040. selectionMeshDefaultColor: Color3;
  46041. /**
  46042. * This color will be applied to the selection ring when selection is triggered
  46043. */
  46044. selectionMeshPickedColor: Color3;
  46045. /**
  46046. * constructs a new background remover module
  46047. * @param _xrSessionManager the session manager for this module
  46048. * @param _options read-only options to be used in this module
  46049. */
  46050. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46051. /**
  46052. * attach this feature
  46053. * Will usually be called by the features manager
  46054. *
  46055. * @returns true if successful.
  46056. */
  46057. attach(): boolean;
  46058. /**
  46059. * detach this feature.
  46060. * Will usually be called by the features manager
  46061. *
  46062. * @returns true if successful.
  46063. */
  46064. detach(): boolean;
  46065. /**
  46066. * Will get the mesh under a specific pointer.
  46067. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46068. * @param controllerId the controllerId to check
  46069. * @returns The mesh under pointer or null if no mesh is under the pointer
  46070. */
  46071. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46072. /**
  46073. * Get the xr controller that correlates to the pointer id in the pointer event
  46074. *
  46075. * @param id the pointer id to search for
  46076. * @returns the controller that correlates to this id or null if not found
  46077. */
  46078. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46079. protected _onXRFrame(_xrFrame: XRFrame): void;
  46080. private _attachGazeMode;
  46081. private _attachScreenRayMode;
  46082. private _attachTrackedPointerRayMode;
  46083. private _convertNormalToDirectionOfRay;
  46084. private _detachController;
  46085. private _generateNewMeshPair;
  46086. private _pickingMoved;
  46087. private _updatePointerDistance;
  46088. }
  46089. }
  46090. declare module "babylonjs/XR/webXREnterExitUI" {
  46091. import { Nullable } from "babylonjs/types";
  46092. import { Observable } from "babylonjs/Misc/observable";
  46093. import { IDisposable, Scene } from "babylonjs/scene";
  46094. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46095. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46096. /**
  46097. * Button which can be used to enter a different mode of XR
  46098. */
  46099. export class WebXREnterExitUIButton {
  46100. /** button element */
  46101. element: HTMLElement;
  46102. /** XR initialization options for the button */
  46103. sessionMode: XRSessionMode;
  46104. /** Reference space type */
  46105. referenceSpaceType: XRReferenceSpaceType;
  46106. /**
  46107. * Creates a WebXREnterExitUIButton
  46108. * @param element button element
  46109. * @param sessionMode XR initialization session mode
  46110. * @param referenceSpaceType the type of reference space to be used
  46111. */
  46112. constructor(
  46113. /** button element */
  46114. element: HTMLElement,
  46115. /** XR initialization options for the button */
  46116. sessionMode: XRSessionMode,
  46117. /** Reference space type */
  46118. referenceSpaceType: XRReferenceSpaceType);
  46119. /**
  46120. * Extendable function which can be used to update the button's visuals when the state changes
  46121. * @param activeButton the current active button in the UI
  46122. */
  46123. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46124. }
  46125. /**
  46126. * Options to create the webXR UI
  46127. */
  46128. export class WebXREnterExitUIOptions {
  46129. /**
  46130. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46131. */
  46132. customButtons?: Array<WebXREnterExitUIButton>;
  46133. /**
  46134. * A reference space type to use when creating the default button.
  46135. * Default is local-floor
  46136. */
  46137. referenceSpaceType?: XRReferenceSpaceType;
  46138. /**
  46139. * Context to enter xr with
  46140. */
  46141. renderTarget?: Nullable<WebXRRenderTarget>;
  46142. /**
  46143. * A session mode to use when creating the default button.
  46144. * Default is immersive-vr
  46145. */
  46146. sessionMode?: XRSessionMode;
  46147. }
  46148. /**
  46149. * UI to allow the user to enter/exit XR mode
  46150. */
  46151. export class WebXREnterExitUI implements IDisposable {
  46152. private scene;
  46153. /** version of the options passed to this UI */
  46154. options: WebXREnterExitUIOptions;
  46155. private _activeButton;
  46156. private _buttons;
  46157. private _overlay;
  46158. /**
  46159. * Fired every time the active button is changed.
  46160. *
  46161. * When xr is entered via a button that launches xr that button will be the callback parameter
  46162. *
  46163. * When exiting xr the callback parameter will be null)
  46164. */
  46165. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46166. /**
  46167. *
  46168. * @param scene babylon scene object to use
  46169. * @param options (read-only) version of the options passed to this UI
  46170. */
  46171. private constructor();
  46172. /**
  46173. * Creates UI to allow the user to enter/exit XR mode
  46174. * @param scene the scene to add the ui to
  46175. * @param helper the xr experience helper to enter/exit xr with
  46176. * @param options options to configure the UI
  46177. * @returns the created ui
  46178. */
  46179. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46180. /**
  46181. * Disposes of the XR UI component
  46182. */
  46183. dispose(): void;
  46184. private _updateButtons;
  46185. }
  46186. }
  46187. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46188. import { Vector3 } from "babylonjs/Maths/math.vector";
  46189. import { Color4 } from "babylonjs/Maths/math.color";
  46190. import { Nullable } from "babylonjs/types";
  46191. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46192. import { Scene } from "babylonjs/scene";
  46193. /**
  46194. * Class containing static functions to help procedurally build meshes
  46195. */
  46196. export class LinesBuilder {
  46197. /**
  46198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46199. * * 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
  46200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46205. * * 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
  46206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46209. * @param name defines the name of the new line system
  46210. * @param options defines the options used to create the line system
  46211. * @param scene defines the hosting scene
  46212. * @returns a new line system mesh
  46213. */
  46214. static CreateLineSystem(name: string, options: {
  46215. lines: Vector3[][];
  46216. updatable?: boolean;
  46217. instance?: Nullable<LinesMesh>;
  46218. colors?: Nullable<Color4[][]>;
  46219. useVertexAlpha?: boolean;
  46220. }, scene: Nullable<Scene>): LinesMesh;
  46221. /**
  46222. * Creates a line mesh
  46223. * 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
  46224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46225. * * The parameter `points` is an array successive Vector3
  46226. * * 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
  46227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46229. * * When updating an instance, remember that only point positions can change, not the number of points
  46230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46232. * @param name defines the name of the new line system
  46233. * @param options defines the options used to create the line system
  46234. * @param scene defines the hosting scene
  46235. * @returns a new line mesh
  46236. */
  46237. static CreateLines(name: string, options: {
  46238. points: Vector3[];
  46239. updatable?: boolean;
  46240. instance?: Nullable<LinesMesh>;
  46241. colors?: Color4[];
  46242. useVertexAlpha?: boolean;
  46243. }, scene?: Nullable<Scene>): LinesMesh;
  46244. /**
  46245. * Creates a dashed line mesh
  46246. * * 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
  46247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46248. * * The parameter `points` is an array successive Vector3
  46249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46252. * * 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
  46253. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46254. * * When updating an instance, remember that only point positions can change, not the number of points
  46255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46256. * @param name defines the name of the mesh
  46257. * @param options defines the options used to create the mesh
  46258. * @param scene defines the hosting scene
  46259. * @returns the dashed line mesh
  46260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46261. */
  46262. static CreateDashedLines(name: string, options: {
  46263. points: Vector3[];
  46264. dashSize?: number;
  46265. gapSize?: number;
  46266. dashNb?: number;
  46267. updatable?: boolean;
  46268. instance?: LinesMesh;
  46269. useVertexAlpha?: boolean;
  46270. }, scene?: Nullable<Scene>): LinesMesh;
  46271. }
  46272. }
  46273. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46274. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46275. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46276. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46278. import { Vector3 } from "babylonjs/Maths/math.vector";
  46279. import { Material } from "babylonjs/Materials/material";
  46280. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46281. import { Scene } from "babylonjs/scene";
  46282. /**
  46283. * The options container for the teleportation module
  46284. */
  46285. export interface IWebXRTeleportationOptions {
  46286. /**
  46287. * if provided, this scene will be used to render meshes.
  46288. */
  46289. customUtilityLayerScene?: Scene;
  46290. /**
  46291. * Values to configure the default target mesh
  46292. */
  46293. defaultTargetMeshOptions?: {
  46294. /**
  46295. * Fill color of the teleportation area
  46296. */
  46297. teleportationFillColor?: string;
  46298. /**
  46299. * Border color for the teleportation area
  46300. */
  46301. teleportationBorderColor?: string;
  46302. /**
  46303. * Disable the mesh's animation sequence
  46304. */
  46305. disableAnimation?: boolean;
  46306. /**
  46307. * Disable lighting on the material or the ring and arrow
  46308. */
  46309. disableLighting?: boolean;
  46310. /**
  46311. * Override the default material of the torus and arrow
  46312. */
  46313. torusArrowMaterial?: Material;
  46314. };
  46315. /**
  46316. * A list of meshes to use as floor meshes.
  46317. * Meshes can be added and removed after initializing the feature using the
  46318. * addFloorMesh and removeFloorMesh functions
  46319. * If empty, rotation will still work
  46320. */
  46321. floorMeshes?: AbstractMesh[];
  46322. /**
  46323. * use this rendering group id for the meshes (optional)
  46324. */
  46325. renderingGroupId?: number;
  46326. /**
  46327. * Should teleportation move only to snap points
  46328. */
  46329. snapPointsOnly?: boolean;
  46330. /**
  46331. * An array of points to which the teleportation will snap to.
  46332. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46333. */
  46334. snapPositions?: Vector3[];
  46335. /**
  46336. * How close should the teleportation ray be in order to snap to position.
  46337. * Default to 0.8 units (meters)
  46338. */
  46339. snapToPositionRadius?: number;
  46340. /**
  46341. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46342. * If you want to support rotation, make sure your mesh has a direction indicator.
  46343. *
  46344. * When left untouched, the default mesh will be initialized.
  46345. */
  46346. teleportationTargetMesh?: AbstractMesh;
  46347. /**
  46348. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46349. */
  46350. timeToTeleport?: number;
  46351. /**
  46352. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46353. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46354. */
  46355. useMainComponentOnly?: boolean;
  46356. /**
  46357. * Should meshes created here be added to a utility layer or the main scene
  46358. */
  46359. useUtilityLayer?: boolean;
  46360. /**
  46361. * Babylon XR Input class for controller
  46362. */
  46363. xrInput: WebXRInput;
  46364. }
  46365. /**
  46366. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46367. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46368. * the input of the attached controllers.
  46369. */
  46370. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46371. private _options;
  46372. private _controllers;
  46373. private _currentTeleportationControllerId;
  46374. private _floorMeshes;
  46375. private _quadraticBezierCurve;
  46376. private _selectionFeature;
  46377. private _snapToPositions;
  46378. private _snappedToPoint;
  46379. private _teleportationRingMaterial?;
  46380. private _tmpRay;
  46381. private _tmpVector;
  46382. /**
  46383. * The module's name
  46384. */
  46385. static readonly Name: string;
  46386. /**
  46387. * The (Babylon) version of this module.
  46388. * This is an integer representing the implementation version.
  46389. * This number does not correspond to the webxr specs version
  46390. */
  46391. static readonly Version: number;
  46392. /**
  46393. * Is movement backwards enabled
  46394. */
  46395. backwardsMovementEnabled: boolean;
  46396. /**
  46397. * Distance to travel when moving backwards
  46398. */
  46399. backwardsTeleportationDistance: number;
  46400. /**
  46401. * The distance from the user to the inspection point in the direction of the controller
  46402. * A higher number will allow the user to move further
  46403. * defaults to 5 (meters, in xr units)
  46404. */
  46405. parabolicCheckRadius: number;
  46406. /**
  46407. * Should the module support parabolic ray on top of direct ray
  46408. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46409. * Very helpful when moving between floors / different heights
  46410. */
  46411. parabolicRayEnabled: boolean;
  46412. /**
  46413. * How much rotation should be applied when rotating right and left
  46414. */
  46415. rotationAngle: number;
  46416. /**
  46417. * Is rotation enabled when moving forward?
  46418. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46419. */
  46420. rotationEnabled: boolean;
  46421. /**
  46422. * constructs a new anchor system
  46423. * @param _xrSessionManager an instance of WebXRSessionManager
  46424. * @param _options configuration object for this feature
  46425. */
  46426. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46427. /**
  46428. * Get the snapPointsOnly flag
  46429. */
  46430. get snapPointsOnly(): boolean;
  46431. /**
  46432. * Sets the snapPointsOnly flag
  46433. * @param snapToPoints should teleportation be exclusively to snap points
  46434. */
  46435. set snapPointsOnly(snapToPoints: boolean);
  46436. /**
  46437. * Add a new mesh to the floor meshes array
  46438. * @param mesh the mesh to use as floor mesh
  46439. */
  46440. addFloorMesh(mesh: AbstractMesh): void;
  46441. /**
  46442. * Add a new snap-to point to fix teleportation to this position
  46443. * @param newSnapPoint The new Snap-To point
  46444. */
  46445. addSnapPoint(newSnapPoint: Vector3): void;
  46446. attach(): boolean;
  46447. detach(): boolean;
  46448. dispose(): void;
  46449. /**
  46450. * Remove a mesh from the floor meshes array
  46451. * @param mesh the mesh to remove
  46452. */
  46453. removeFloorMesh(mesh: AbstractMesh): void;
  46454. /**
  46455. * Remove a mesh from the floor meshes array using its name
  46456. * @param name the mesh name to remove
  46457. */
  46458. removeFloorMeshByName(name: string): void;
  46459. /**
  46460. * 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
  46461. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46462. * @returns was the point found and removed or not
  46463. */
  46464. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46465. /**
  46466. * This function sets a selection feature that will be disabled when
  46467. * the forward ray is shown and will be reattached when hidden.
  46468. * This is used to remove the selection rays when moving.
  46469. * @param selectionFeature the feature to disable when forward movement is enabled
  46470. */
  46471. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46472. protected _onXRFrame(_xrFrame: XRFrame): void;
  46473. private _attachController;
  46474. private _createDefaultTargetMesh;
  46475. private _detachController;
  46476. private _findClosestSnapPointWithRadius;
  46477. private _setTargetMeshPosition;
  46478. private _setTargetMeshVisibility;
  46479. private _showParabolicPath;
  46480. private _teleportForward;
  46481. }
  46482. }
  46483. declare module "babylonjs/XR/webXRDefaultExperience" {
  46484. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46485. import { Scene } from "babylonjs/scene";
  46486. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46487. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46488. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46489. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46491. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46492. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46493. /**
  46494. * Options for the default xr helper
  46495. */
  46496. export class WebXRDefaultExperienceOptions {
  46497. /**
  46498. * Enable or disable default UI to enter XR
  46499. */
  46500. disableDefaultUI?: boolean;
  46501. /**
  46502. * Should teleportation not initialize. defaults to false.
  46503. */
  46504. disableTeleportation?: boolean;
  46505. /**
  46506. * Floor meshes that will be used for teleport
  46507. */
  46508. floorMeshes?: Array<AbstractMesh>;
  46509. /**
  46510. * If set to true, the first frame will not be used to reset position
  46511. * The first frame is mainly used when copying transformation from the old camera
  46512. * Mainly used in AR
  46513. */
  46514. ignoreNativeCameraTransformation?: boolean;
  46515. /**
  46516. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46517. */
  46518. inputOptions?: IWebXRInputOptions;
  46519. /**
  46520. * optional configuration for the output canvas
  46521. */
  46522. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46523. /**
  46524. * optional UI options. This can be used among other to change session mode and reference space type
  46525. */
  46526. uiOptions?: WebXREnterExitUIOptions;
  46527. /**
  46528. * When loading teleportation and pointer select, use stable versions instead of latest.
  46529. */
  46530. useStablePlugins?: boolean;
  46531. }
  46532. /**
  46533. * Default experience which provides a similar setup to the previous webVRExperience
  46534. */
  46535. export class WebXRDefaultExperience {
  46536. /**
  46537. * Base experience
  46538. */
  46539. baseExperience: WebXRExperienceHelper;
  46540. /**
  46541. * Enables ui for entering/exiting xr
  46542. */
  46543. enterExitUI: WebXREnterExitUI;
  46544. /**
  46545. * Input experience extension
  46546. */
  46547. input: WebXRInput;
  46548. /**
  46549. * Enables laser pointer and selection
  46550. */
  46551. pointerSelection: WebXRControllerPointerSelection;
  46552. /**
  46553. * Default target xr should render to
  46554. */
  46555. renderTarget: WebXRRenderTarget;
  46556. /**
  46557. * Enables teleportation
  46558. */
  46559. teleportation: WebXRMotionControllerTeleportation;
  46560. private constructor();
  46561. /**
  46562. * Creates the default xr experience
  46563. * @param scene scene
  46564. * @param options options for basic configuration
  46565. * @returns resulting WebXRDefaultExperience
  46566. */
  46567. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46568. /**
  46569. * DIsposes of the experience helper
  46570. */
  46571. dispose(): void;
  46572. }
  46573. }
  46574. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46575. import { Observable } from "babylonjs/Misc/observable";
  46576. import { Nullable } from "babylonjs/types";
  46577. import { Camera } from "babylonjs/Cameras/camera";
  46578. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46579. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46580. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46581. import { Scene } from "babylonjs/scene";
  46582. import { Vector3 } from "babylonjs/Maths/math.vector";
  46583. import { Color3 } from "babylonjs/Maths/math.color";
  46584. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46586. import { Mesh } from "babylonjs/Meshes/mesh";
  46587. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46588. import { EasingFunction } from "babylonjs/Animations/easing";
  46589. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46590. import "babylonjs/Meshes/Builders/groundBuilder";
  46591. import "babylonjs/Meshes/Builders/torusBuilder";
  46592. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46593. import "babylonjs/Gamepads/gamepadSceneComponent";
  46594. import "babylonjs/Animations/animatable";
  46595. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46596. /**
  46597. * Options to modify the vr teleportation behavior.
  46598. */
  46599. export interface VRTeleportationOptions {
  46600. /**
  46601. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46602. */
  46603. floorMeshName?: string;
  46604. /**
  46605. * A list of meshes to be used as the teleportation floor. (default: empty)
  46606. */
  46607. floorMeshes?: Mesh[];
  46608. /**
  46609. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46610. */
  46611. teleportationMode?: number;
  46612. /**
  46613. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46614. */
  46615. teleportationTime?: number;
  46616. /**
  46617. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46618. */
  46619. teleportationSpeed?: number;
  46620. /**
  46621. * The easing function used in the animation or null for Linear. (default CircleEase)
  46622. */
  46623. easingFunction?: EasingFunction;
  46624. }
  46625. /**
  46626. * Options to modify the vr experience helper's behavior.
  46627. */
  46628. export interface VRExperienceHelperOptions extends WebVROptions {
  46629. /**
  46630. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46631. */
  46632. createDeviceOrientationCamera?: boolean;
  46633. /**
  46634. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46635. */
  46636. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46637. /**
  46638. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46639. */
  46640. laserToggle?: boolean;
  46641. /**
  46642. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46643. */
  46644. floorMeshes?: Mesh[];
  46645. /**
  46646. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46647. */
  46648. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46649. /**
  46650. * Defines if WebXR should be used instead of WebVR (if available)
  46651. */
  46652. useXR?: boolean;
  46653. }
  46654. /**
  46655. * Event containing information after VR has been entered
  46656. */
  46657. export class OnAfterEnteringVRObservableEvent {
  46658. /**
  46659. * If entering vr was successful
  46660. */
  46661. success: boolean;
  46662. }
  46663. /**
  46664. * Helps to quickly add VR support to an existing scene.
  46665. * See http://doc.babylonjs.com/how_to/webvr_helper
  46666. */
  46667. export class VRExperienceHelper {
  46668. /** Options to modify the vr experience helper's behavior. */
  46669. webVROptions: VRExperienceHelperOptions;
  46670. private _scene;
  46671. private _position;
  46672. private _btnVR;
  46673. private _btnVRDisplayed;
  46674. private _webVRsupported;
  46675. private _webVRready;
  46676. private _webVRrequesting;
  46677. private _webVRpresenting;
  46678. private _hasEnteredVR;
  46679. private _fullscreenVRpresenting;
  46680. private _inputElement;
  46681. private _webVRCamera;
  46682. private _vrDeviceOrientationCamera;
  46683. private _deviceOrientationCamera;
  46684. private _existingCamera;
  46685. private _onKeyDown;
  46686. private _onVrDisplayPresentChange;
  46687. private _onVRDisplayChanged;
  46688. private _onVRRequestPresentStart;
  46689. private _onVRRequestPresentComplete;
  46690. /**
  46691. * 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)
  46692. */
  46693. enableGazeEvenWhenNoPointerLock: boolean;
  46694. /**
  46695. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46696. */
  46697. exitVROnDoubleTap: boolean;
  46698. /**
  46699. * Observable raised right before entering VR.
  46700. */
  46701. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46702. /**
  46703. * Observable raised when entering VR has completed.
  46704. */
  46705. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46706. /**
  46707. * Observable raised when exiting VR.
  46708. */
  46709. onExitingVRObservable: Observable<VRExperienceHelper>;
  46710. /**
  46711. * Observable raised when controller mesh is loaded.
  46712. */
  46713. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46714. /** Return this.onEnteringVRObservable
  46715. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46716. */
  46717. get onEnteringVR(): Observable<VRExperienceHelper>;
  46718. /** Return this.onExitingVRObservable
  46719. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46720. */
  46721. get onExitingVR(): Observable<VRExperienceHelper>;
  46722. /** Return this.onControllerMeshLoadedObservable
  46723. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46724. */
  46725. get onControllerMeshLoaded(): Observable<WebVRController>;
  46726. private _rayLength;
  46727. private _useCustomVRButton;
  46728. private _teleportationRequested;
  46729. private _teleportActive;
  46730. private _floorMeshName;
  46731. private _floorMeshesCollection;
  46732. private _teleportationMode;
  46733. private _teleportationTime;
  46734. private _teleportationSpeed;
  46735. private _teleportationEasing;
  46736. private _rotationAllowed;
  46737. private _teleportBackwardsVector;
  46738. private _teleportationTarget;
  46739. private _isDefaultTeleportationTarget;
  46740. private _postProcessMove;
  46741. private _teleportationFillColor;
  46742. private _teleportationBorderColor;
  46743. private _rotationAngle;
  46744. private _haloCenter;
  46745. private _cameraGazer;
  46746. private _padSensibilityUp;
  46747. private _padSensibilityDown;
  46748. private _leftController;
  46749. private _rightController;
  46750. private _gazeColor;
  46751. private _laserColor;
  46752. private _pickedLaserColor;
  46753. private _pickedGazeColor;
  46754. /**
  46755. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46756. */
  46757. onNewMeshSelected: Observable<AbstractMesh>;
  46758. /**
  46759. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46760. * This observable will provide the mesh and the controller used to select the mesh
  46761. */
  46762. onMeshSelectedWithController: Observable<{
  46763. mesh: AbstractMesh;
  46764. controller: WebVRController;
  46765. }>;
  46766. /**
  46767. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46768. */
  46769. onNewMeshPicked: Observable<PickingInfo>;
  46770. private _circleEase;
  46771. /**
  46772. * Observable raised before camera teleportation
  46773. */
  46774. onBeforeCameraTeleport: Observable<Vector3>;
  46775. /**
  46776. * Observable raised after camera teleportation
  46777. */
  46778. onAfterCameraTeleport: Observable<Vector3>;
  46779. /**
  46780. * Observable raised when current selected mesh gets unselected
  46781. */
  46782. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46783. private _raySelectionPredicate;
  46784. /**
  46785. * To be optionaly changed by user to define custom ray selection
  46786. */
  46787. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46788. /**
  46789. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46790. */
  46791. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46792. /**
  46793. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46794. */
  46795. teleportationEnabled: boolean;
  46796. private _defaultHeight;
  46797. private _teleportationInitialized;
  46798. private _interactionsEnabled;
  46799. private _interactionsRequested;
  46800. private _displayGaze;
  46801. private _displayLaserPointer;
  46802. /**
  46803. * The mesh used to display where the user is going to teleport.
  46804. */
  46805. get teleportationTarget(): Mesh;
  46806. /**
  46807. * Sets the mesh to be used to display where the user is going to teleport.
  46808. */
  46809. set teleportationTarget(value: Mesh);
  46810. /**
  46811. * 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
  46812. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46813. * See http://doc.babylonjs.com/resources/baking_transformations
  46814. */
  46815. get gazeTrackerMesh(): Mesh;
  46816. set gazeTrackerMesh(value: Mesh);
  46817. /**
  46818. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46819. */
  46820. updateGazeTrackerScale: boolean;
  46821. /**
  46822. * If the gaze trackers color should be updated when selecting meshes
  46823. */
  46824. updateGazeTrackerColor: boolean;
  46825. /**
  46826. * If the controller laser color should be updated when selecting meshes
  46827. */
  46828. updateControllerLaserColor: boolean;
  46829. /**
  46830. * The gaze tracking mesh corresponding to the left controller
  46831. */
  46832. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46833. /**
  46834. * The gaze tracking mesh corresponding to the right controller
  46835. */
  46836. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46837. /**
  46838. * If the ray of the gaze should be displayed.
  46839. */
  46840. get displayGaze(): boolean;
  46841. /**
  46842. * Sets if the ray of the gaze should be displayed.
  46843. */
  46844. set displayGaze(value: boolean);
  46845. /**
  46846. * If the ray of the LaserPointer should be displayed.
  46847. */
  46848. get displayLaserPointer(): boolean;
  46849. /**
  46850. * Sets if the ray of the LaserPointer should be displayed.
  46851. */
  46852. set displayLaserPointer(value: boolean);
  46853. /**
  46854. * The deviceOrientationCamera used as the camera when not in VR.
  46855. */
  46856. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46857. /**
  46858. * Based on the current WebVR support, returns the current VR camera used.
  46859. */
  46860. get currentVRCamera(): Nullable<Camera>;
  46861. /**
  46862. * The webVRCamera which is used when in VR.
  46863. */
  46864. get webVRCamera(): WebVRFreeCamera;
  46865. /**
  46866. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46867. */
  46868. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46869. /**
  46870. * The html button that is used to trigger entering into VR.
  46871. */
  46872. get vrButton(): Nullable<HTMLButtonElement>;
  46873. private get _teleportationRequestInitiated();
  46874. /**
  46875. * Defines whether or not Pointer lock should be requested when switching to
  46876. * full screen.
  46877. */
  46878. requestPointerLockOnFullScreen: boolean;
  46879. /**
  46880. * If asking to force XR, this will be populated with the default xr experience
  46881. */
  46882. xr: WebXRDefaultExperience;
  46883. /**
  46884. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46885. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46886. */
  46887. xrTestDone: boolean;
  46888. /**
  46889. * Instantiates a VRExperienceHelper.
  46890. * Helps to quickly add VR support to an existing scene.
  46891. * @param scene The scene the VRExperienceHelper belongs to.
  46892. * @param webVROptions Options to modify the vr experience helper's behavior.
  46893. */
  46894. constructor(scene: Scene,
  46895. /** Options to modify the vr experience helper's behavior. */
  46896. webVROptions?: VRExperienceHelperOptions);
  46897. private completeVRInit;
  46898. private _onDefaultMeshLoaded;
  46899. private _onResize;
  46900. private _onFullscreenChange;
  46901. /**
  46902. * Gets a value indicating if we are currently in VR mode.
  46903. */
  46904. get isInVRMode(): boolean;
  46905. private onVrDisplayPresentChange;
  46906. private onVRDisplayChanged;
  46907. private moveButtonToBottomRight;
  46908. private displayVRButton;
  46909. private updateButtonVisibility;
  46910. private _cachedAngularSensibility;
  46911. /**
  46912. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46913. * Otherwise, will use the fullscreen API.
  46914. */
  46915. enterVR(): void;
  46916. /**
  46917. * Attempt to exit VR, or fullscreen.
  46918. */
  46919. exitVR(): void;
  46920. /**
  46921. * The position of the vr experience helper.
  46922. */
  46923. get position(): Vector3;
  46924. /**
  46925. * Sets the position of the vr experience helper.
  46926. */
  46927. set position(value: Vector3);
  46928. /**
  46929. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46930. */
  46931. enableInteractions(): void;
  46932. private get _noControllerIsActive();
  46933. private beforeRender;
  46934. private _isTeleportationFloor;
  46935. /**
  46936. * Adds a floor mesh to be used for teleportation.
  46937. * @param floorMesh the mesh to be used for teleportation.
  46938. */
  46939. addFloorMesh(floorMesh: Mesh): void;
  46940. /**
  46941. * Removes a floor mesh from being used for teleportation.
  46942. * @param floorMesh the mesh to be removed.
  46943. */
  46944. removeFloorMesh(floorMesh: Mesh): void;
  46945. /**
  46946. * Enables interactions and teleportation using the VR controllers and gaze.
  46947. * @param vrTeleportationOptions options to modify teleportation behavior.
  46948. */
  46949. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46950. private _onNewGamepadConnected;
  46951. private _tryEnableInteractionOnController;
  46952. private _onNewGamepadDisconnected;
  46953. private _enableInteractionOnController;
  46954. private _checkTeleportWithRay;
  46955. private _checkRotate;
  46956. private _checkTeleportBackwards;
  46957. private _enableTeleportationOnController;
  46958. private _createTeleportationCircles;
  46959. private _displayTeleportationTarget;
  46960. private _hideTeleportationTarget;
  46961. private _rotateCamera;
  46962. private _moveTeleportationSelectorTo;
  46963. private _workingVector;
  46964. private _workingQuaternion;
  46965. private _workingMatrix;
  46966. /**
  46967. * Time Constant Teleportation Mode
  46968. */
  46969. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46970. /**
  46971. * Speed Constant Teleportation Mode
  46972. */
  46973. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46974. /**
  46975. * Teleports the users feet to the desired location
  46976. * @param location The location where the user's feet should be placed
  46977. */
  46978. teleportCamera(location: Vector3): void;
  46979. private _convertNormalToDirectionOfRay;
  46980. private _castRayAndSelectObject;
  46981. private _notifySelectedMeshUnselected;
  46982. /**
  46983. * Permanently set new colors for the laser pointer
  46984. * @param color the new laser color
  46985. * @param pickedColor the new laser color when picked mesh detected
  46986. */
  46987. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46988. /**
  46989. * Set lighting enabled / disabled on the laser pointer of both controllers
  46990. * @param enabled should the lighting be enabled on the laser pointer
  46991. */
  46992. setLaserLightingState(enabled?: boolean): void;
  46993. /**
  46994. * Permanently set new colors for the gaze pointer
  46995. * @param color the new gaze color
  46996. * @param pickedColor the new gaze color when picked mesh detected
  46997. */
  46998. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46999. /**
  47000. * Sets the color of the laser ray from the vr controllers.
  47001. * @param color new color for the ray.
  47002. */
  47003. changeLaserColor(color: Color3): void;
  47004. /**
  47005. * Sets the color of the ray from the vr headsets gaze.
  47006. * @param color new color for the ray.
  47007. */
  47008. changeGazeColor(color: Color3): void;
  47009. /**
  47010. * Exits VR and disposes of the vr experience helper
  47011. */
  47012. dispose(): void;
  47013. /**
  47014. * Gets the name of the VRExperienceHelper class
  47015. * @returns "VRExperienceHelper"
  47016. */
  47017. getClassName(): string;
  47018. }
  47019. }
  47020. declare module "babylonjs/Cameras/VR/index" {
  47021. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47022. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47023. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47024. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47025. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47026. export * from "babylonjs/Cameras/VR/webVRCamera";
  47027. }
  47028. declare module "babylonjs/Cameras/RigModes/index" {
  47029. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47030. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47031. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47032. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47033. }
  47034. declare module "babylonjs/Cameras/index" {
  47035. export * from "babylonjs/Cameras/Inputs/index";
  47036. export * from "babylonjs/Cameras/cameraInputsManager";
  47037. export * from "babylonjs/Cameras/camera";
  47038. export * from "babylonjs/Cameras/targetCamera";
  47039. export * from "babylonjs/Cameras/freeCamera";
  47040. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47041. export * from "babylonjs/Cameras/touchCamera";
  47042. export * from "babylonjs/Cameras/arcRotateCamera";
  47043. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47044. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47045. export * from "babylonjs/Cameras/flyCamera";
  47046. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47047. export * from "babylonjs/Cameras/followCamera";
  47048. export * from "babylonjs/Cameras/followCameraInputsManager";
  47049. export * from "babylonjs/Cameras/gamepadCamera";
  47050. export * from "babylonjs/Cameras/Stereoscopic/index";
  47051. export * from "babylonjs/Cameras/universalCamera";
  47052. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47053. export * from "babylonjs/Cameras/VR/index";
  47054. export * from "babylonjs/Cameras/RigModes/index";
  47055. }
  47056. declare module "babylonjs/Collisions/index" {
  47057. export * from "babylonjs/Collisions/collider";
  47058. export * from "babylonjs/Collisions/collisionCoordinator";
  47059. export * from "babylonjs/Collisions/pickingInfo";
  47060. export * from "babylonjs/Collisions/intersectionInfo";
  47061. export * from "babylonjs/Collisions/meshCollisionData";
  47062. }
  47063. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47064. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47065. import { Vector3 } from "babylonjs/Maths/math.vector";
  47066. import { Ray } from "babylonjs/Culling/ray";
  47067. import { Plane } from "babylonjs/Maths/math.plane";
  47068. /**
  47069. * Contains an array of blocks representing the octree
  47070. */
  47071. export interface IOctreeContainer<T> {
  47072. /**
  47073. * Blocks within the octree
  47074. */
  47075. blocks: Array<OctreeBlock<T>>;
  47076. }
  47077. /**
  47078. * Class used to store a cell in an octree
  47079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47080. */
  47081. export class OctreeBlock<T> {
  47082. /**
  47083. * Gets the content of the current block
  47084. */
  47085. entries: T[];
  47086. /**
  47087. * Gets the list of block children
  47088. */
  47089. blocks: Array<OctreeBlock<T>>;
  47090. private _depth;
  47091. private _maxDepth;
  47092. private _capacity;
  47093. private _minPoint;
  47094. private _maxPoint;
  47095. private _boundingVectors;
  47096. private _creationFunc;
  47097. /**
  47098. * Creates a new block
  47099. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47100. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47101. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47102. * @param depth defines the current depth of this block in the octree
  47103. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47104. * @param creationFunc defines a callback to call when an element is added to the block
  47105. */
  47106. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47107. /**
  47108. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47109. */
  47110. get capacity(): number;
  47111. /**
  47112. * Gets the minimum vector (in world space) of the block's bounding box
  47113. */
  47114. get minPoint(): Vector3;
  47115. /**
  47116. * Gets the maximum vector (in world space) of the block's bounding box
  47117. */
  47118. get maxPoint(): Vector3;
  47119. /**
  47120. * Add a new element to this block
  47121. * @param entry defines the element to add
  47122. */
  47123. addEntry(entry: T): void;
  47124. /**
  47125. * Remove an element from this block
  47126. * @param entry defines the element to remove
  47127. */
  47128. removeEntry(entry: T): void;
  47129. /**
  47130. * Add an array of elements to this block
  47131. * @param entries defines the array of elements to add
  47132. */
  47133. addEntries(entries: T[]): void;
  47134. /**
  47135. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47136. * @param frustumPlanes defines the frustum planes to test
  47137. * @param selection defines the array to store current content if selection is positive
  47138. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47139. */
  47140. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47141. /**
  47142. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47143. * @param sphereCenter defines the bounding sphere center
  47144. * @param sphereRadius defines the bounding sphere radius
  47145. * @param selection defines the array to store current content if selection is positive
  47146. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47147. */
  47148. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47149. /**
  47150. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47151. * @param ray defines the ray to test with
  47152. * @param selection defines the array to store current content if selection is positive
  47153. */
  47154. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47155. /**
  47156. * Subdivide the content into child blocks (this block will then be empty)
  47157. */
  47158. createInnerBlocks(): void;
  47159. /**
  47160. * @hidden
  47161. */
  47162. 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;
  47163. }
  47164. }
  47165. declare module "babylonjs/Culling/Octrees/octree" {
  47166. import { SmartArray } from "babylonjs/Misc/smartArray";
  47167. import { Vector3 } from "babylonjs/Maths/math.vector";
  47168. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47170. import { Ray } from "babylonjs/Culling/ray";
  47171. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47172. import { Plane } from "babylonjs/Maths/math.plane";
  47173. /**
  47174. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47175. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47176. */
  47177. export class Octree<T> {
  47178. /** 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.) */
  47179. maxDepth: number;
  47180. /**
  47181. * Blocks within the octree containing objects
  47182. */
  47183. blocks: Array<OctreeBlock<T>>;
  47184. /**
  47185. * Content stored in the octree
  47186. */
  47187. dynamicContent: T[];
  47188. private _maxBlockCapacity;
  47189. private _selectionContent;
  47190. private _creationFunc;
  47191. /**
  47192. * Creates a octree
  47193. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47194. * @param creationFunc function to be used to instatiate the octree
  47195. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47196. * @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.)
  47197. */
  47198. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47199. /** 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.) */
  47200. maxDepth?: number);
  47201. /**
  47202. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47203. * @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);
  47204. * @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);
  47205. * @param entries meshes to be added to the octree blocks
  47206. */
  47207. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47208. /**
  47209. * Adds a mesh to the octree
  47210. * @param entry Mesh to add to the octree
  47211. */
  47212. addMesh(entry: T): void;
  47213. /**
  47214. * Remove an element from the octree
  47215. * @param entry defines the element to remove
  47216. */
  47217. removeMesh(entry: T): void;
  47218. /**
  47219. * Selects an array of meshes within the frustum
  47220. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47221. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47222. * @returns array of meshes within the frustum
  47223. */
  47224. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47225. /**
  47226. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47227. * @param sphereCenter defines the bounding sphere center
  47228. * @param sphereRadius defines the bounding sphere radius
  47229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47230. * @returns an array of objects that intersect the sphere
  47231. */
  47232. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47233. /**
  47234. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47235. * @param ray defines the ray to test with
  47236. * @returns array of intersected objects
  47237. */
  47238. intersectsRay(ray: Ray): SmartArray<T>;
  47239. /**
  47240. * Adds a mesh into the octree block if it intersects the block
  47241. */
  47242. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47243. /**
  47244. * Adds a submesh into the octree block if it intersects the block
  47245. */
  47246. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47250. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47251. import { Scene } from "babylonjs/scene";
  47252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47254. import { Ray } from "babylonjs/Culling/ray";
  47255. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47256. import { Collider } from "babylonjs/Collisions/collider";
  47257. module "babylonjs/scene" {
  47258. interface Scene {
  47259. /**
  47260. * @hidden
  47261. * Backing Filed
  47262. */
  47263. _selectionOctree: Octree<AbstractMesh>;
  47264. /**
  47265. * Gets the octree used to boost mesh selection (picking)
  47266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47267. */
  47268. selectionOctree: Octree<AbstractMesh>;
  47269. /**
  47270. * Creates or updates the octree used to boost selection (picking)
  47271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47272. * @param maxCapacity defines the maximum capacity per leaf
  47273. * @param maxDepth defines the maximum depth of the octree
  47274. * @returns an octree of AbstractMesh
  47275. */
  47276. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47277. }
  47278. }
  47279. module "babylonjs/Meshes/abstractMesh" {
  47280. interface AbstractMesh {
  47281. /**
  47282. * @hidden
  47283. * Backing Field
  47284. */
  47285. _submeshesOctree: Octree<SubMesh>;
  47286. /**
  47287. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47288. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47289. * @param maxCapacity defines the maximum size of each block (64 by default)
  47290. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47291. * @returns the new octree
  47292. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47294. */
  47295. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47296. }
  47297. }
  47298. /**
  47299. * Defines the octree scene component responsible to manage any octrees
  47300. * in a given scene.
  47301. */
  47302. export class OctreeSceneComponent {
  47303. /**
  47304. * The component name help to identify the component in the list of scene components.
  47305. */
  47306. readonly name: string;
  47307. /**
  47308. * The scene the component belongs to.
  47309. */
  47310. scene: Scene;
  47311. /**
  47312. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47313. */
  47314. readonly checksIsEnabled: boolean;
  47315. /**
  47316. * Creates a new instance of the component for the given scene
  47317. * @param scene Defines the scene to register the component in
  47318. */
  47319. constructor(scene: Scene);
  47320. /**
  47321. * Registers the component in a given scene
  47322. */
  47323. register(): void;
  47324. /**
  47325. * Return the list of active meshes
  47326. * @returns the list of active meshes
  47327. */
  47328. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47329. /**
  47330. * Return the list of active sub meshes
  47331. * @param mesh The mesh to get the candidates sub meshes from
  47332. * @returns the list of active sub meshes
  47333. */
  47334. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47335. private _tempRay;
  47336. /**
  47337. * Return the list of sub meshes intersecting with a given local ray
  47338. * @param mesh defines the mesh to find the submesh for
  47339. * @param localRay defines the ray in local space
  47340. * @returns the list of intersecting sub meshes
  47341. */
  47342. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47343. /**
  47344. * Return the list of sub meshes colliding with a collider
  47345. * @param mesh defines the mesh to find the submesh for
  47346. * @param collider defines the collider to evaluate the collision against
  47347. * @returns the list of colliding sub meshes
  47348. */
  47349. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47350. /**
  47351. * Rebuilds the elements related to this component in case of
  47352. * context lost for instance.
  47353. */
  47354. rebuild(): void;
  47355. /**
  47356. * Disposes the component and the associated ressources.
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Culling/Octrees/index" {
  47362. export * from "babylonjs/Culling/Octrees/octree";
  47363. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47364. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47365. }
  47366. declare module "babylonjs/Culling/index" {
  47367. export * from "babylonjs/Culling/boundingBox";
  47368. export * from "babylonjs/Culling/boundingInfo";
  47369. export * from "babylonjs/Culling/boundingSphere";
  47370. export * from "babylonjs/Culling/Octrees/index";
  47371. export * from "babylonjs/Culling/ray";
  47372. }
  47373. declare module "babylonjs/Gizmos/gizmo" {
  47374. import { Nullable } from "babylonjs/types";
  47375. import { IDisposable } from "babylonjs/scene";
  47376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47377. import { Mesh } from "babylonjs/Meshes/mesh";
  47378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47379. /**
  47380. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47381. */
  47382. export class Gizmo implements IDisposable {
  47383. /** The utility layer the gizmo will be added to */
  47384. gizmoLayer: UtilityLayerRenderer;
  47385. /**
  47386. * The root mesh of the gizmo
  47387. */
  47388. _rootMesh: Mesh;
  47389. private _attachedMesh;
  47390. /**
  47391. * Ratio for the scale of the gizmo (Default: 1)
  47392. */
  47393. scaleRatio: number;
  47394. /**
  47395. * If a custom mesh has been set (Default: false)
  47396. */
  47397. protected _customMeshSet: boolean;
  47398. /**
  47399. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47400. * * When set, interactions will be enabled
  47401. */
  47402. get attachedMesh(): Nullable<AbstractMesh>;
  47403. set attachedMesh(value: Nullable<AbstractMesh>);
  47404. /**
  47405. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47406. * @param mesh The mesh to replace the default mesh of the gizmo
  47407. */
  47408. setCustomMesh(mesh: Mesh): void;
  47409. /**
  47410. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47411. */
  47412. updateGizmoRotationToMatchAttachedMesh: boolean;
  47413. /**
  47414. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47415. */
  47416. updateGizmoPositionToMatchAttachedMesh: boolean;
  47417. /**
  47418. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47419. */
  47420. updateScale: boolean;
  47421. protected _interactionsEnabled: boolean;
  47422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47423. private _beforeRenderObserver;
  47424. private _tempVector;
  47425. /**
  47426. * Creates a gizmo
  47427. * @param gizmoLayer The utility layer the gizmo will be added to
  47428. */
  47429. constructor(
  47430. /** The utility layer the gizmo will be added to */
  47431. gizmoLayer?: UtilityLayerRenderer);
  47432. /**
  47433. * Updates the gizmo to match the attached mesh's position/rotation
  47434. */
  47435. protected _update(): void;
  47436. /**
  47437. * Disposes of the gizmo
  47438. */
  47439. dispose(): void;
  47440. }
  47441. }
  47442. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47443. import { Observable } from "babylonjs/Misc/observable";
  47444. import { Nullable } from "babylonjs/types";
  47445. import { Vector3 } from "babylonjs/Maths/math.vector";
  47446. import { Color3 } from "babylonjs/Maths/math.color";
  47447. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47449. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47450. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47451. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47452. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47453. import { Scene } from "babylonjs/scene";
  47454. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47455. /**
  47456. * Single plane drag gizmo
  47457. */
  47458. export class PlaneDragGizmo extends Gizmo {
  47459. /**
  47460. * Drag behavior responsible for the gizmos dragging interactions
  47461. */
  47462. dragBehavior: PointerDragBehavior;
  47463. private _pointerObserver;
  47464. /**
  47465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47466. */
  47467. snapDistance: number;
  47468. /**
  47469. * Event that fires each time the gizmo snaps to a new location.
  47470. * * snapDistance is the the change in distance
  47471. */
  47472. onSnapObservable: Observable<{
  47473. snapDistance: number;
  47474. }>;
  47475. private _plane;
  47476. private _coloredMaterial;
  47477. private _hoverMaterial;
  47478. private _isEnabled;
  47479. private _parent;
  47480. /** @hidden */
  47481. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47482. /** @hidden */
  47483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47484. /**
  47485. * Creates a PlaneDragGizmo
  47486. * @param gizmoLayer The utility layer the gizmo will be added to
  47487. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47488. * @param color The color of the gizmo
  47489. */
  47490. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47492. /**
  47493. * If the gizmo is enabled
  47494. */
  47495. set isEnabled(value: boolean);
  47496. get isEnabled(): boolean;
  47497. /**
  47498. * Disposes of the gizmo
  47499. */
  47500. dispose(): void;
  47501. }
  47502. }
  47503. declare module "babylonjs/Gizmos/positionGizmo" {
  47504. import { Observable } from "babylonjs/Misc/observable";
  47505. import { Nullable } from "babylonjs/types";
  47506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47509. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47510. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47512. /**
  47513. * Gizmo that enables dragging a mesh along 3 axis
  47514. */
  47515. export class PositionGizmo extends Gizmo {
  47516. /**
  47517. * Internal gizmo used for interactions on the x axis
  47518. */
  47519. xGizmo: AxisDragGizmo;
  47520. /**
  47521. * Internal gizmo used for interactions on the y axis
  47522. */
  47523. yGizmo: AxisDragGizmo;
  47524. /**
  47525. * Internal gizmo used for interactions on the z axis
  47526. */
  47527. zGizmo: AxisDragGizmo;
  47528. /**
  47529. * Internal gizmo used for interactions on the yz plane
  47530. */
  47531. xPlaneGizmo: PlaneDragGizmo;
  47532. /**
  47533. * Internal gizmo used for interactions on the xz plane
  47534. */
  47535. yPlaneGizmo: PlaneDragGizmo;
  47536. /**
  47537. * Internal gizmo used for interactions on the xy plane
  47538. */
  47539. zPlaneGizmo: PlaneDragGizmo;
  47540. /**
  47541. * private variables
  47542. */
  47543. private _meshAttached;
  47544. private _updateGizmoRotationToMatchAttachedMesh;
  47545. private _snapDistance;
  47546. private _scaleRatio;
  47547. /** Fires an event when any of it's sub gizmos are dragged */
  47548. onDragStartObservable: Observable<unknown>;
  47549. /** Fires an event when any of it's sub gizmos are released from dragging */
  47550. onDragEndObservable: Observable<unknown>;
  47551. /**
  47552. * If set to true, planar drag is enabled
  47553. */
  47554. private _planarGizmoEnabled;
  47555. get attachedMesh(): Nullable<AbstractMesh>;
  47556. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47557. /**
  47558. * Creates a PositionGizmo
  47559. * @param gizmoLayer The utility layer the gizmo will be added to
  47560. */
  47561. constructor(gizmoLayer?: UtilityLayerRenderer);
  47562. /**
  47563. * If the planar drag gizmo is enabled
  47564. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47565. */
  47566. set planarGizmoEnabled(value: boolean);
  47567. get planarGizmoEnabled(): boolean;
  47568. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47569. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47570. /**
  47571. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47572. */
  47573. set snapDistance(value: number);
  47574. get snapDistance(): number;
  47575. /**
  47576. * Ratio for the scale of the gizmo (Default: 1)
  47577. */
  47578. set scaleRatio(value: number);
  47579. get scaleRatio(): number;
  47580. /**
  47581. * Disposes of the gizmo
  47582. */
  47583. dispose(): void;
  47584. /**
  47585. * CustomMeshes are not supported by this gizmo
  47586. * @param mesh The mesh to replace the default mesh of the gizmo
  47587. */
  47588. setCustomMesh(mesh: Mesh): void;
  47589. }
  47590. }
  47591. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47592. import { Observable } from "babylonjs/Misc/observable";
  47593. import { Nullable } from "babylonjs/types";
  47594. import { Vector3 } from "babylonjs/Maths/math.vector";
  47595. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47597. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47598. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47599. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47600. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47601. import { Scene } from "babylonjs/scene";
  47602. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47603. import { Color3 } from "babylonjs/Maths/math.color";
  47604. /**
  47605. * Single axis drag gizmo
  47606. */
  47607. export class AxisDragGizmo extends Gizmo {
  47608. /**
  47609. * Drag behavior responsible for the gizmos dragging interactions
  47610. */
  47611. dragBehavior: PointerDragBehavior;
  47612. private _pointerObserver;
  47613. /**
  47614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47615. */
  47616. snapDistance: number;
  47617. /**
  47618. * Event that fires each time the gizmo snaps to a new location.
  47619. * * snapDistance is the the change in distance
  47620. */
  47621. onSnapObservable: Observable<{
  47622. snapDistance: number;
  47623. }>;
  47624. private _isEnabled;
  47625. private _parent;
  47626. private _arrow;
  47627. private _coloredMaterial;
  47628. private _hoverMaterial;
  47629. /** @hidden */
  47630. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47631. /** @hidden */
  47632. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47633. /**
  47634. * Creates an AxisDragGizmo
  47635. * @param gizmoLayer The utility layer the gizmo will be added to
  47636. * @param dragAxis The axis which the gizmo will be able to drag on
  47637. * @param color The color of the gizmo
  47638. */
  47639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47641. /**
  47642. * If the gizmo is enabled
  47643. */
  47644. set isEnabled(value: boolean);
  47645. get isEnabled(): boolean;
  47646. /**
  47647. * Disposes of the gizmo
  47648. */
  47649. dispose(): void;
  47650. }
  47651. }
  47652. declare module "babylonjs/Debug/axesViewer" {
  47653. import { Vector3 } from "babylonjs/Maths/math.vector";
  47654. import { Nullable } from "babylonjs/types";
  47655. import { Scene } from "babylonjs/scene";
  47656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47657. /**
  47658. * The Axes viewer will show 3 axes in a specific point in space
  47659. */
  47660. export class AxesViewer {
  47661. private _xAxis;
  47662. private _yAxis;
  47663. private _zAxis;
  47664. private _scaleLinesFactor;
  47665. private _instanced;
  47666. /**
  47667. * Gets the hosting scene
  47668. */
  47669. scene: Scene;
  47670. /**
  47671. * Gets or sets a number used to scale line length
  47672. */
  47673. scaleLines: number;
  47674. /** Gets the node hierarchy used to render x-axis */
  47675. get xAxis(): TransformNode;
  47676. /** Gets the node hierarchy used to render y-axis */
  47677. get yAxis(): TransformNode;
  47678. /** Gets the node hierarchy used to render z-axis */
  47679. get zAxis(): TransformNode;
  47680. /**
  47681. * Creates a new AxesViewer
  47682. * @param scene defines the hosting scene
  47683. * @param scaleLines defines a number used to scale line length (1 by default)
  47684. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47685. * @param xAxis defines the node hierarchy used to render the x-axis
  47686. * @param yAxis defines the node hierarchy used to render the y-axis
  47687. * @param zAxis defines the node hierarchy used to render the z-axis
  47688. */
  47689. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47690. /**
  47691. * Force the viewer to update
  47692. * @param position defines the position of the viewer
  47693. * @param xaxis defines the x axis of the viewer
  47694. * @param yaxis defines the y axis of the viewer
  47695. * @param zaxis defines the z axis of the viewer
  47696. */
  47697. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47698. /**
  47699. * Creates an instance of this axes viewer.
  47700. * @returns a new axes viewer with instanced meshes
  47701. */
  47702. createInstance(): AxesViewer;
  47703. /** Releases resources */
  47704. dispose(): void;
  47705. private static _SetRenderingGroupId;
  47706. }
  47707. }
  47708. declare module "babylonjs/Debug/boneAxesViewer" {
  47709. import { Nullable } from "babylonjs/types";
  47710. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47711. import { Vector3 } from "babylonjs/Maths/math.vector";
  47712. import { Mesh } from "babylonjs/Meshes/mesh";
  47713. import { Bone } from "babylonjs/Bones/bone";
  47714. import { Scene } from "babylonjs/scene";
  47715. /**
  47716. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47717. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47718. */
  47719. export class BoneAxesViewer extends AxesViewer {
  47720. /**
  47721. * Gets or sets the target mesh where to display the axes viewer
  47722. */
  47723. mesh: Nullable<Mesh>;
  47724. /**
  47725. * Gets or sets the target bone where to display the axes viewer
  47726. */
  47727. bone: Nullable<Bone>;
  47728. /** Gets current position */
  47729. pos: Vector3;
  47730. /** Gets direction of X axis */
  47731. xaxis: Vector3;
  47732. /** Gets direction of Y axis */
  47733. yaxis: Vector3;
  47734. /** Gets direction of Z axis */
  47735. zaxis: Vector3;
  47736. /**
  47737. * Creates a new BoneAxesViewer
  47738. * @param scene defines the hosting scene
  47739. * @param bone defines the target bone
  47740. * @param mesh defines the target mesh
  47741. * @param scaleLines defines a scaling factor for line length (1 by default)
  47742. */
  47743. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47744. /**
  47745. * Force the viewer to update
  47746. */
  47747. update(): void;
  47748. /** Releases resources */
  47749. dispose(): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Debug/debugLayer" {
  47753. import { Scene } from "babylonjs/scene";
  47754. /**
  47755. * Interface used to define scene explorer extensibility option
  47756. */
  47757. export interface IExplorerExtensibilityOption {
  47758. /**
  47759. * Define the option label
  47760. */
  47761. label: string;
  47762. /**
  47763. * Defines the action to execute on click
  47764. */
  47765. action: (entity: any) => void;
  47766. }
  47767. /**
  47768. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47769. */
  47770. export interface IExplorerExtensibilityGroup {
  47771. /**
  47772. * Defines a predicate to test if a given type mut be extended
  47773. */
  47774. predicate: (entity: any) => boolean;
  47775. /**
  47776. * Gets the list of options added to a type
  47777. */
  47778. entries: IExplorerExtensibilityOption[];
  47779. }
  47780. /**
  47781. * Interface used to define the options to use to create the Inspector
  47782. */
  47783. export interface IInspectorOptions {
  47784. /**
  47785. * Display in overlay mode (default: false)
  47786. */
  47787. overlay?: boolean;
  47788. /**
  47789. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47790. */
  47791. globalRoot?: HTMLElement;
  47792. /**
  47793. * Display the Scene explorer
  47794. */
  47795. showExplorer?: boolean;
  47796. /**
  47797. * Display the property inspector
  47798. */
  47799. showInspector?: boolean;
  47800. /**
  47801. * Display in embed mode (both panes on the right)
  47802. */
  47803. embedMode?: boolean;
  47804. /**
  47805. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47806. */
  47807. handleResize?: boolean;
  47808. /**
  47809. * Allow the panes to popup (default: true)
  47810. */
  47811. enablePopup?: boolean;
  47812. /**
  47813. * Allow the panes to be closed by users (default: true)
  47814. */
  47815. enableClose?: boolean;
  47816. /**
  47817. * Optional list of extensibility entries
  47818. */
  47819. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47820. /**
  47821. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47822. */
  47823. inspectorURL?: string;
  47824. /**
  47825. * Optional initial tab (default to DebugLayerTab.Properties)
  47826. */
  47827. initialTab?: DebugLayerTab;
  47828. }
  47829. module "babylonjs/scene" {
  47830. interface Scene {
  47831. /**
  47832. * @hidden
  47833. * Backing field
  47834. */
  47835. _debugLayer: DebugLayer;
  47836. /**
  47837. * Gets the debug layer (aka Inspector) associated with the scene
  47838. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47839. */
  47840. debugLayer: DebugLayer;
  47841. }
  47842. }
  47843. /**
  47844. * Enum of inspector action tab
  47845. */
  47846. export enum DebugLayerTab {
  47847. /**
  47848. * Properties tag (default)
  47849. */
  47850. Properties = 0,
  47851. /**
  47852. * Debug tab
  47853. */
  47854. Debug = 1,
  47855. /**
  47856. * Statistics tab
  47857. */
  47858. Statistics = 2,
  47859. /**
  47860. * Tools tab
  47861. */
  47862. Tools = 3,
  47863. /**
  47864. * Settings tab
  47865. */
  47866. Settings = 4
  47867. }
  47868. /**
  47869. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47870. * what is happening in your scene
  47871. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47872. */
  47873. export class DebugLayer {
  47874. /**
  47875. * Define the url to get the inspector script from.
  47876. * By default it uses the babylonjs CDN.
  47877. * @ignoreNaming
  47878. */
  47879. static InspectorURL: string;
  47880. private _scene;
  47881. private BJSINSPECTOR;
  47882. private _onPropertyChangedObservable?;
  47883. /**
  47884. * Observable triggered when a property is changed through the inspector.
  47885. */
  47886. get onPropertyChangedObservable(): any;
  47887. /**
  47888. * Instantiates a new debug layer.
  47889. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47890. * what is happening in your scene
  47891. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47892. * @param scene Defines the scene to inspect
  47893. */
  47894. constructor(scene: Scene);
  47895. /** Creates the inspector window. */
  47896. private _createInspector;
  47897. /**
  47898. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47899. * @param entity defines the entity to select
  47900. * @param lineContainerTitle defines the specific block to highlight
  47901. */
  47902. select(entity: any, lineContainerTitle?: string): void;
  47903. /** Get the inspector from bundle or global */
  47904. private _getGlobalInspector;
  47905. /**
  47906. * Get if the inspector is visible or not.
  47907. * @returns true if visible otherwise, false
  47908. */
  47909. isVisible(): boolean;
  47910. /**
  47911. * Hide the inspector and close its window.
  47912. */
  47913. hide(): void;
  47914. /**
  47915. * Launch the debugLayer.
  47916. * @param config Define the configuration of the inspector
  47917. * @return a promise fulfilled when the debug layer is visible
  47918. */
  47919. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47920. }
  47921. }
  47922. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47923. import { Nullable } from "babylonjs/types";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Vector4 } from "babylonjs/Maths/math.vector";
  47926. import { Color4 } from "babylonjs/Maths/math.color";
  47927. import { Mesh } from "babylonjs/Meshes/mesh";
  47928. /**
  47929. * Class containing static functions to help procedurally build meshes
  47930. */
  47931. export class BoxBuilder {
  47932. /**
  47933. * Creates a box mesh
  47934. * * The parameter `size` sets the size (float) of each box side (default 1)
  47935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47936. * * 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)
  47937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47942. * @param name defines the name of the mesh
  47943. * @param options defines the options used to create the mesh
  47944. * @param scene defines the hosting scene
  47945. * @returns the box mesh
  47946. */
  47947. static CreateBox(name: string, options: {
  47948. size?: number;
  47949. width?: number;
  47950. height?: number;
  47951. depth?: number;
  47952. faceUV?: Vector4[];
  47953. faceColors?: Color4[];
  47954. sideOrientation?: number;
  47955. frontUVs?: Vector4;
  47956. backUVs?: Vector4;
  47957. wrap?: boolean;
  47958. topBaseAt?: number;
  47959. bottomBaseAt?: number;
  47960. updatable?: boolean;
  47961. }, scene?: Nullable<Scene>): Mesh;
  47962. }
  47963. }
  47964. declare module "babylonjs/Debug/physicsViewer" {
  47965. import { Nullable } from "babylonjs/types";
  47966. import { Scene } from "babylonjs/scene";
  47967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47968. import { Mesh } from "babylonjs/Meshes/mesh";
  47969. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47970. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47971. /**
  47972. * Used to show the physics impostor around the specific mesh
  47973. */
  47974. export class PhysicsViewer {
  47975. /** @hidden */
  47976. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47977. /** @hidden */
  47978. protected _meshes: Array<Nullable<AbstractMesh>>;
  47979. /** @hidden */
  47980. protected _scene: Nullable<Scene>;
  47981. /** @hidden */
  47982. protected _numMeshes: number;
  47983. /** @hidden */
  47984. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47985. private _renderFunction;
  47986. private _utilityLayer;
  47987. private _debugBoxMesh;
  47988. private _debugSphereMesh;
  47989. private _debugCylinderMesh;
  47990. private _debugMaterial;
  47991. private _debugMeshMeshes;
  47992. /**
  47993. * Creates a new PhysicsViewer
  47994. * @param scene defines the hosting scene
  47995. */
  47996. constructor(scene: Scene);
  47997. /** @hidden */
  47998. protected _updateDebugMeshes(): void;
  47999. /**
  48000. * Renders a specified physic impostor
  48001. * @param impostor defines the impostor to render
  48002. * @param targetMesh defines the mesh represented by the impostor
  48003. * @returns the new debug mesh used to render the impostor
  48004. */
  48005. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48006. /**
  48007. * Hides a specified physic impostor
  48008. * @param impostor defines the impostor to hide
  48009. */
  48010. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48011. private _getDebugMaterial;
  48012. private _getDebugBoxMesh;
  48013. private _getDebugSphereMesh;
  48014. private _getDebugCylinderMesh;
  48015. private _getDebugMeshMesh;
  48016. private _getDebugMesh;
  48017. /** Releases all resources */
  48018. dispose(): void;
  48019. }
  48020. }
  48021. declare module "babylonjs/Debug/rayHelper" {
  48022. import { Nullable } from "babylonjs/types";
  48023. import { Ray } from "babylonjs/Culling/ray";
  48024. import { Vector3 } from "babylonjs/Maths/math.vector";
  48025. import { Color3 } from "babylonjs/Maths/math.color";
  48026. import { Scene } from "babylonjs/scene";
  48027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48028. import "babylonjs/Meshes/Builders/linesBuilder";
  48029. /**
  48030. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48031. * in order to better appreciate the issue one might have.
  48032. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48033. */
  48034. export class RayHelper {
  48035. /**
  48036. * Defines the ray we are currently tryin to visualize.
  48037. */
  48038. ray: Nullable<Ray>;
  48039. private _renderPoints;
  48040. private _renderLine;
  48041. private _renderFunction;
  48042. private _scene;
  48043. private _updateToMeshFunction;
  48044. private _attachedToMesh;
  48045. private _meshSpaceDirection;
  48046. private _meshSpaceOrigin;
  48047. /**
  48048. * Helper function to create a colored helper in a scene in one line.
  48049. * @param ray Defines the ray we are currently tryin to visualize
  48050. * @param scene Defines the scene the ray is used in
  48051. * @param color Defines the color we want to see the ray in
  48052. * @returns The newly created ray helper.
  48053. */
  48054. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48055. /**
  48056. * Instantiate a new ray helper.
  48057. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48058. * in order to better appreciate the issue one might have.
  48059. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48060. * @param ray Defines the ray we are currently tryin to visualize
  48061. */
  48062. constructor(ray: Ray);
  48063. /**
  48064. * Shows the ray we are willing to debug.
  48065. * @param scene Defines the scene the ray needs to be rendered in
  48066. * @param color Defines the color the ray needs to be rendered in
  48067. */
  48068. show(scene: Scene, color?: Color3): void;
  48069. /**
  48070. * Hides the ray we are debugging.
  48071. */
  48072. hide(): void;
  48073. private _render;
  48074. /**
  48075. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48076. * @param mesh Defines the mesh we want the helper attached to
  48077. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48078. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48079. * @param length Defines the length of the ray
  48080. */
  48081. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48082. /**
  48083. * Detach the ray helper from the mesh it has previously been attached to.
  48084. */
  48085. detachFromMesh(): void;
  48086. private _updateToMesh;
  48087. /**
  48088. * Dispose the helper and release its associated resources.
  48089. */
  48090. dispose(): void;
  48091. }
  48092. }
  48093. declare module "babylonjs/Debug/skeletonViewer" {
  48094. import { Color3 } from "babylonjs/Maths/math.color";
  48095. import { Scene } from "babylonjs/scene";
  48096. import { Nullable } from "babylonjs/types";
  48097. import { Skeleton } from "babylonjs/Bones/skeleton";
  48098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48099. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48100. /**
  48101. * Class used to render a debug view of a given skeleton
  48102. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48103. */
  48104. export class SkeletonViewer {
  48105. /** defines the skeleton to render */
  48106. skeleton: Skeleton;
  48107. /** defines the mesh attached to the skeleton */
  48108. mesh: AbstractMesh;
  48109. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48110. autoUpdateBonesMatrices: boolean;
  48111. /** defines the rendering group id to use with the viewer */
  48112. renderingGroupId: number;
  48113. /** Gets or sets the color used to render the skeleton */
  48114. color: Color3;
  48115. private _scene;
  48116. private _debugLines;
  48117. private _debugMesh;
  48118. private _isEnabled;
  48119. private _renderFunction;
  48120. private _utilityLayer;
  48121. /**
  48122. * Returns the mesh used to render the bones
  48123. */
  48124. get debugMesh(): Nullable<LinesMesh>;
  48125. /**
  48126. * Creates a new SkeletonViewer
  48127. * @param skeleton defines the skeleton to render
  48128. * @param mesh defines the mesh attached to the skeleton
  48129. * @param scene defines the hosting scene
  48130. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48131. * @param renderingGroupId defines the rendering group id to use with the viewer
  48132. */
  48133. constructor(
  48134. /** defines the skeleton to render */
  48135. skeleton: Skeleton,
  48136. /** defines the mesh attached to the skeleton */
  48137. mesh: AbstractMesh, scene: Scene,
  48138. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48139. autoUpdateBonesMatrices?: boolean,
  48140. /** defines the rendering group id to use with the viewer */
  48141. renderingGroupId?: number);
  48142. /** Gets or sets a boolean indicating if the viewer is enabled */
  48143. set isEnabled(value: boolean);
  48144. get isEnabled(): boolean;
  48145. private _getBonePosition;
  48146. private _getLinesForBonesWithLength;
  48147. private _getLinesForBonesNoLength;
  48148. /** Update the viewer to sync with current skeleton state */
  48149. update(): void;
  48150. /** Release associated resources */
  48151. dispose(): void;
  48152. }
  48153. }
  48154. declare module "babylonjs/Debug/index" {
  48155. export * from "babylonjs/Debug/axesViewer";
  48156. export * from "babylonjs/Debug/boneAxesViewer";
  48157. export * from "babylonjs/Debug/debugLayer";
  48158. export * from "babylonjs/Debug/physicsViewer";
  48159. export * from "babylonjs/Debug/rayHelper";
  48160. export * from "babylonjs/Debug/skeletonViewer";
  48161. }
  48162. declare module "babylonjs/Engines/nullEngine" {
  48163. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48164. import { Engine } from "babylonjs/Engines/engine";
  48165. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48166. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48168. import { Effect } from "babylonjs/Materials/effect";
  48169. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48171. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48172. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48173. /**
  48174. * Options to create the null engine
  48175. */
  48176. export class NullEngineOptions {
  48177. /**
  48178. * Render width (Default: 512)
  48179. */
  48180. renderWidth: number;
  48181. /**
  48182. * Render height (Default: 256)
  48183. */
  48184. renderHeight: number;
  48185. /**
  48186. * Texture size (Default: 512)
  48187. */
  48188. textureSize: number;
  48189. /**
  48190. * If delta time between frames should be constant
  48191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48192. */
  48193. deterministicLockstep: boolean;
  48194. /**
  48195. * Maximum about of steps between frames (Default: 4)
  48196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48197. */
  48198. lockstepMaxSteps: number;
  48199. }
  48200. /**
  48201. * The null engine class provides support for headless version of babylon.js.
  48202. * This can be used in server side scenario or for testing purposes
  48203. */
  48204. export class NullEngine extends Engine {
  48205. private _options;
  48206. /**
  48207. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48208. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48209. * @returns true if engine is in deterministic lock step mode
  48210. */
  48211. isDeterministicLockStep(): boolean;
  48212. /**
  48213. * Gets the max steps when engine is running in deterministic lock step
  48214. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48215. * @returns the max steps
  48216. */
  48217. getLockstepMaxSteps(): number;
  48218. /**
  48219. * Gets the current hardware scaling level.
  48220. * By default the hardware scaling level is computed from the window device ratio.
  48221. * 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.
  48222. * @returns a number indicating the current hardware scaling level
  48223. */
  48224. getHardwareScalingLevel(): number;
  48225. constructor(options?: NullEngineOptions);
  48226. /**
  48227. * Creates a vertex buffer
  48228. * @param vertices the data for the vertex buffer
  48229. * @returns the new WebGL static buffer
  48230. */
  48231. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48232. /**
  48233. * Creates a new index buffer
  48234. * @param indices defines the content of the index buffer
  48235. * @param updatable defines if the index buffer must be updatable
  48236. * @returns a new webGL buffer
  48237. */
  48238. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48239. /**
  48240. * Clear the current render buffer or the current render target (if any is set up)
  48241. * @param color defines the color to use
  48242. * @param backBuffer defines if the back buffer must be cleared
  48243. * @param depth defines if the depth buffer must be cleared
  48244. * @param stencil defines if the stencil buffer must be cleared
  48245. */
  48246. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48247. /**
  48248. * Gets the current render width
  48249. * @param useScreen defines if screen size must be used (or the current render target if any)
  48250. * @returns a number defining the current render width
  48251. */
  48252. getRenderWidth(useScreen?: boolean): number;
  48253. /**
  48254. * Gets the current render height
  48255. * @param useScreen defines if screen size must be used (or the current render target if any)
  48256. * @returns a number defining the current render height
  48257. */
  48258. getRenderHeight(useScreen?: boolean): number;
  48259. /**
  48260. * Set the WebGL's viewport
  48261. * @param viewport defines the viewport element to be used
  48262. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48263. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48264. */
  48265. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48266. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48267. /**
  48268. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48269. * @param pipelineContext defines the pipeline context to use
  48270. * @param uniformsNames defines the list of uniform names
  48271. * @returns an array of webGL uniform locations
  48272. */
  48273. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48274. /**
  48275. * Gets the lsit of active attributes for a given webGL program
  48276. * @param pipelineContext defines the pipeline context to use
  48277. * @param attributesNames defines the list of attribute names to get
  48278. * @returns an array of indices indicating the offset of each attribute
  48279. */
  48280. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48281. /**
  48282. * Binds an effect to the webGL context
  48283. * @param effect defines the effect to bind
  48284. */
  48285. bindSamplers(effect: Effect): void;
  48286. /**
  48287. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48288. * @param effect defines the effect to activate
  48289. */
  48290. enableEffect(effect: Effect): void;
  48291. /**
  48292. * Set various states to the webGL context
  48293. * @param culling defines backface culling state
  48294. * @param zOffset defines the value to apply to zOffset (0 by default)
  48295. * @param force defines if states must be applied even if cache is up to date
  48296. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48297. */
  48298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48299. /**
  48300. * Set the value of an uniform to an array of int32
  48301. * @param uniform defines the webGL uniform location where to store the value
  48302. * @param array defines the array of int32 to store
  48303. */
  48304. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48305. /**
  48306. * Set the value of an uniform to an array of int32 (stored as vec2)
  48307. * @param uniform defines the webGL uniform location where to store the value
  48308. * @param array defines the array of int32 to store
  48309. */
  48310. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48311. /**
  48312. * Set the value of an uniform to an array of int32 (stored as vec3)
  48313. * @param uniform defines the webGL uniform location where to store the value
  48314. * @param array defines the array of int32 to store
  48315. */
  48316. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48317. /**
  48318. * Set the value of an uniform to an array of int32 (stored as vec4)
  48319. * @param uniform defines the webGL uniform location where to store the value
  48320. * @param array defines the array of int32 to store
  48321. */
  48322. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48323. /**
  48324. * Set the value of an uniform to an array of float32
  48325. * @param uniform defines the webGL uniform location where to store the value
  48326. * @param array defines the array of float32 to store
  48327. */
  48328. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48329. /**
  48330. * Set the value of an uniform to an array of float32 (stored as vec2)
  48331. * @param uniform defines the webGL uniform location where to store the value
  48332. * @param array defines the array of float32 to store
  48333. */
  48334. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48335. /**
  48336. * Set the value of an uniform to an array of float32 (stored as vec3)
  48337. * @param uniform defines the webGL uniform location where to store the value
  48338. * @param array defines the array of float32 to store
  48339. */
  48340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48341. /**
  48342. * Set the value of an uniform to an array of float32 (stored as vec4)
  48343. * @param uniform defines the webGL uniform location where to store the value
  48344. * @param array defines the array of float32 to store
  48345. */
  48346. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48347. /**
  48348. * Set the value of an uniform to an array of number
  48349. * @param uniform defines the webGL uniform location where to store the value
  48350. * @param array defines the array of number to store
  48351. */
  48352. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48353. /**
  48354. * Set the value of an uniform to an array of number (stored as vec2)
  48355. * @param uniform defines the webGL uniform location where to store the value
  48356. * @param array defines the array of number to store
  48357. */
  48358. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48359. /**
  48360. * Set the value of an uniform to an array of number (stored as vec3)
  48361. * @param uniform defines the webGL uniform location where to store the value
  48362. * @param array defines the array of number to store
  48363. */
  48364. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48365. /**
  48366. * Set the value of an uniform to an array of number (stored as vec4)
  48367. * @param uniform defines the webGL uniform location where to store the value
  48368. * @param array defines the array of number to store
  48369. */
  48370. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48371. /**
  48372. * Set the value of an uniform to an array of float32 (stored as matrices)
  48373. * @param uniform defines the webGL uniform location where to store the value
  48374. * @param matrices defines the array of float32 to store
  48375. */
  48376. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48377. /**
  48378. * Set the value of an uniform to a matrix (3x3)
  48379. * @param uniform defines the webGL uniform location where to store the value
  48380. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48381. */
  48382. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48383. /**
  48384. * Set the value of an uniform to a matrix (2x2)
  48385. * @param uniform defines the webGL uniform location where to store the value
  48386. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48387. */
  48388. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48389. /**
  48390. * Set the value of an uniform to a number (float)
  48391. * @param uniform defines the webGL uniform location where to store the value
  48392. * @param value defines the float number to store
  48393. */
  48394. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48395. /**
  48396. * Set the value of an uniform to a vec2
  48397. * @param uniform defines the webGL uniform location where to store the value
  48398. * @param x defines the 1st component of the value
  48399. * @param y defines the 2nd component of the value
  48400. */
  48401. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48402. /**
  48403. * Set the value of an uniform to a vec3
  48404. * @param uniform defines the webGL uniform location where to store the value
  48405. * @param x defines the 1st component of the value
  48406. * @param y defines the 2nd component of the value
  48407. * @param z defines the 3rd component of the value
  48408. */
  48409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48410. /**
  48411. * Set the value of an uniform to a boolean
  48412. * @param uniform defines the webGL uniform location where to store the value
  48413. * @param bool defines the boolean to store
  48414. */
  48415. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48416. /**
  48417. * Set the value of an uniform to a vec4
  48418. * @param uniform defines the webGL uniform location where to store the value
  48419. * @param x defines the 1st component of the value
  48420. * @param y defines the 2nd component of the value
  48421. * @param z defines the 3rd component of the value
  48422. * @param w defines the 4th component of the value
  48423. */
  48424. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48425. /**
  48426. * Sets the current alpha mode
  48427. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48428. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48430. */
  48431. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48432. /**
  48433. * Bind webGl buffers directly to the webGL context
  48434. * @param vertexBuffers defines the vertex buffer to bind
  48435. * @param indexBuffer defines the index buffer to bind
  48436. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48437. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48438. * @param effect defines the effect associated with the vertex buffer
  48439. */
  48440. bindBuffers(vertexBuffers: {
  48441. [key: string]: VertexBuffer;
  48442. }, indexBuffer: DataBuffer, effect: Effect): void;
  48443. /**
  48444. * Force the entire cache to be cleared
  48445. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48446. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48447. */
  48448. wipeCaches(bruteForce?: boolean): void;
  48449. /**
  48450. * Send a draw order
  48451. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48452. * @param indexStart defines the starting index
  48453. * @param indexCount defines the number of index to draw
  48454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48455. */
  48456. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48457. /**
  48458. * Draw a list of indexed primitives
  48459. * @param fillMode defines the primitive to use
  48460. * @param indexStart defines the starting index
  48461. * @param indexCount defines the number of index to draw
  48462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48463. */
  48464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48465. /**
  48466. * Draw a list of unindexed primitives
  48467. * @param fillMode defines the primitive to use
  48468. * @param verticesStart defines the index of first vertex to draw
  48469. * @param verticesCount defines the count of vertices to draw
  48470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48471. */
  48472. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48473. /** @hidden */
  48474. _createTexture(): WebGLTexture;
  48475. /** @hidden */
  48476. _releaseTexture(texture: InternalTexture): void;
  48477. /**
  48478. * Usually called from Texture.ts.
  48479. * Passed information to create a WebGLTexture
  48480. * @param urlArg defines a value which contains one of the following:
  48481. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48482. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48483. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48485. * @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)
  48486. * @param scene needed for loading to the correct scene
  48487. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48488. * @param onLoad optional callback to be called upon successful completion
  48489. * @param onError optional callback to be called upon failure
  48490. * @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
  48491. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48492. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48493. * @param forcedExtension defines the extension to use to pick the right loader
  48494. * @param mimeType defines an optional mime type
  48495. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48496. */
  48497. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  48498. /**
  48499. * Creates a new render target texture
  48500. * @param size defines the size of the texture
  48501. * @param options defines the options used to create the texture
  48502. * @returns a new render target texture stored in an InternalTexture
  48503. */
  48504. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48505. /**
  48506. * Update the sampling mode of a given texture
  48507. * @param samplingMode defines the required sampling mode
  48508. * @param texture defines the texture to update
  48509. */
  48510. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48511. /**
  48512. * Binds the frame buffer to the specified texture.
  48513. * @param texture The texture to render to or null for the default canvas
  48514. * @param faceIndex The face of the texture to render to in case of cube texture
  48515. * @param requiredWidth The width of the target to render to
  48516. * @param requiredHeight The height of the target to render to
  48517. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48518. * @param lodLevel defines le lod level to bind to the frame buffer
  48519. */
  48520. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48521. /**
  48522. * Unbind the current render target texture from the webGL context
  48523. * @param texture defines the render target texture to unbind
  48524. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48525. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48526. */
  48527. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48528. /**
  48529. * Creates a dynamic vertex buffer
  48530. * @param vertices the data for the dynamic vertex buffer
  48531. * @returns the new WebGL dynamic buffer
  48532. */
  48533. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48534. /**
  48535. * Update the content of a dynamic texture
  48536. * @param texture defines the texture to update
  48537. * @param canvas defines the canvas containing the source
  48538. * @param invertY defines if data must be stored with Y axis inverted
  48539. * @param premulAlpha defines if alpha is stored as premultiplied
  48540. * @param format defines the format of the data
  48541. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48542. */
  48543. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48544. /**
  48545. * Gets a boolean indicating if all created effects are ready
  48546. * @returns true if all effects are ready
  48547. */
  48548. areAllEffectsReady(): boolean;
  48549. /**
  48550. * @hidden
  48551. * Get the current error code of the webGL context
  48552. * @returns the error code
  48553. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48554. */
  48555. getError(): number;
  48556. /** @hidden */
  48557. _getUnpackAlignement(): number;
  48558. /** @hidden */
  48559. _unpackFlipY(value: boolean): void;
  48560. /**
  48561. * Update a dynamic index buffer
  48562. * @param indexBuffer defines the target index buffer
  48563. * @param indices defines the data to update
  48564. * @param offset defines the offset in the target index buffer where update should start
  48565. */
  48566. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48567. /**
  48568. * Updates a dynamic vertex buffer.
  48569. * @param vertexBuffer the vertex buffer to update
  48570. * @param vertices the data used to update the vertex buffer
  48571. * @param byteOffset the byte offset of the data (optional)
  48572. * @param byteLength the byte length of the data (optional)
  48573. */
  48574. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48575. /** @hidden */
  48576. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48577. /** @hidden */
  48578. _bindTexture(channel: number, texture: InternalTexture): void;
  48579. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48580. /**
  48581. * 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
  48582. */
  48583. releaseEffects(): void;
  48584. displayLoadingUI(): void;
  48585. hideLoadingUI(): void;
  48586. /** @hidden */
  48587. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48588. /** @hidden */
  48589. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48590. /** @hidden */
  48591. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48592. /** @hidden */
  48593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48594. }
  48595. }
  48596. declare module "babylonjs/Instrumentation/timeToken" {
  48597. import { Nullable } from "babylonjs/types";
  48598. /**
  48599. * @hidden
  48600. **/
  48601. export class _TimeToken {
  48602. _startTimeQuery: Nullable<WebGLQuery>;
  48603. _endTimeQuery: Nullable<WebGLQuery>;
  48604. _timeElapsedQuery: Nullable<WebGLQuery>;
  48605. _timeElapsedQueryEnded: boolean;
  48606. }
  48607. }
  48608. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48609. import { Nullable, int } from "babylonjs/types";
  48610. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48611. /** @hidden */
  48612. export class _OcclusionDataStorage {
  48613. /** @hidden */
  48614. occlusionInternalRetryCounter: number;
  48615. /** @hidden */
  48616. isOcclusionQueryInProgress: boolean;
  48617. /** @hidden */
  48618. isOccluded: boolean;
  48619. /** @hidden */
  48620. occlusionRetryCount: number;
  48621. /** @hidden */
  48622. occlusionType: number;
  48623. /** @hidden */
  48624. occlusionQueryAlgorithmType: number;
  48625. }
  48626. module "babylonjs/Engines/engine" {
  48627. interface Engine {
  48628. /**
  48629. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48630. * @return the new query
  48631. */
  48632. createQuery(): WebGLQuery;
  48633. /**
  48634. * Delete and release a webGL query
  48635. * @param query defines the query to delete
  48636. * @return the current engine
  48637. */
  48638. deleteQuery(query: WebGLQuery): Engine;
  48639. /**
  48640. * Check if a given query has resolved and got its value
  48641. * @param query defines the query to check
  48642. * @returns true if the query got its value
  48643. */
  48644. isQueryResultAvailable(query: WebGLQuery): boolean;
  48645. /**
  48646. * Gets the value of a given query
  48647. * @param query defines the query to check
  48648. * @returns the value of the query
  48649. */
  48650. getQueryResult(query: WebGLQuery): number;
  48651. /**
  48652. * Initiates an occlusion query
  48653. * @param algorithmType defines the algorithm to use
  48654. * @param query defines the query to use
  48655. * @returns the current engine
  48656. * @see http://doc.babylonjs.com/features/occlusionquery
  48657. */
  48658. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48659. /**
  48660. * Ends an occlusion query
  48661. * @see http://doc.babylonjs.com/features/occlusionquery
  48662. * @param algorithmType defines the algorithm to use
  48663. * @returns the current engine
  48664. */
  48665. endOcclusionQuery(algorithmType: number): Engine;
  48666. /**
  48667. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48668. * Please note that only one query can be issued at a time
  48669. * @returns a time token used to track the time span
  48670. */
  48671. startTimeQuery(): Nullable<_TimeToken>;
  48672. /**
  48673. * Ends a time query
  48674. * @param token defines the token used to measure the time span
  48675. * @returns the time spent (in ns)
  48676. */
  48677. endTimeQuery(token: _TimeToken): int;
  48678. /** @hidden */
  48679. _currentNonTimestampToken: Nullable<_TimeToken>;
  48680. /** @hidden */
  48681. _createTimeQuery(): WebGLQuery;
  48682. /** @hidden */
  48683. _deleteTimeQuery(query: WebGLQuery): void;
  48684. /** @hidden */
  48685. _getGlAlgorithmType(algorithmType: number): number;
  48686. /** @hidden */
  48687. _getTimeQueryResult(query: WebGLQuery): any;
  48688. /** @hidden */
  48689. _getTimeQueryAvailability(query: WebGLQuery): any;
  48690. }
  48691. }
  48692. module "babylonjs/Meshes/abstractMesh" {
  48693. interface AbstractMesh {
  48694. /**
  48695. * Backing filed
  48696. * @hidden
  48697. */
  48698. __occlusionDataStorage: _OcclusionDataStorage;
  48699. /**
  48700. * Access property
  48701. * @hidden
  48702. */
  48703. _occlusionDataStorage: _OcclusionDataStorage;
  48704. /**
  48705. * 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.
  48706. * The default value is -1 which means don't break the query and wait till the result
  48707. * @see http://doc.babylonjs.com/features/occlusionquery
  48708. */
  48709. occlusionRetryCount: number;
  48710. /**
  48711. * 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:
  48712. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48713. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48714. * * 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.
  48715. * @see http://doc.babylonjs.com/features/occlusionquery
  48716. */
  48717. occlusionType: number;
  48718. /**
  48719. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48720. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48721. * * 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.
  48722. * @see http://doc.babylonjs.com/features/occlusionquery
  48723. */
  48724. occlusionQueryAlgorithmType: number;
  48725. /**
  48726. * 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
  48727. * @see http://doc.babylonjs.com/features/occlusionquery
  48728. */
  48729. isOccluded: boolean;
  48730. /**
  48731. * Flag to check the progress status of the query
  48732. * @see http://doc.babylonjs.com/features/occlusionquery
  48733. */
  48734. isOcclusionQueryInProgress: boolean;
  48735. }
  48736. }
  48737. }
  48738. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48739. import { Nullable } from "babylonjs/types";
  48740. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48741. /** @hidden */
  48742. export var _forceTransformFeedbackToBundle: boolean;
  48743. module "babylonjs/Engines/engine" {
  48744. interface Engine {
  48745. /**
  48746. * Creates a webGL transform feedback object
  48747. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48748. * @returns the webGL transform feedback object
  48749. */
  48750. createTransformFeedback(): WebGLTransformFeedback;
  48751. /**
  48752. * Delete a webGL transform feedback object
  48753. * @param value defines the webGL transform feedback object to delete
  48754. */
  48755. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48756. /**
  48757. * Bind a webGL transform feedback object to the webgl context
  48758. * @param value defines the webGL transform feedback object to bind
  48759. */
  48760. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48761. /**
  48762. * Begins a transform feedback operation
  48763. * @param usePoints defines if points or triangles must be used
  48764. */
  48765. beginTransformFeedback(usePoints: boolean): void;
  48766. /**
  48767. * Ends a transform feedback operation
  48768. */
  48769. endTransformFeedback(): void;
  48770. /**
  48771. * Specify the varyings to use with transform feedback
  48772. * @param program defines the associated webGL program
  48773. * @param value defines the list of strings representing the varying names
  48774. */
  48775. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48776. /**
  48777. * Bind a webGL buffer for a transform feedback operation
  48778. * @param value defines the webGL buffer to bind
  48779. */
  48780. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48781. }
  48782. }
  48783. }
  48784. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48785. import { Scene } from "babylonjs/scene";
  48786. import { Engine } from "babylonjs/Engines/engine";
  48787. import { Texture } from "babylonjs/Materials/Textures/texture";
  48788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48789. import "babylonjs/Engines/Extensions/engine.multiRender";
  48790. /**
  48791. * Creation options of the multi render target texture.
  48792. */
  48793. export interface IMultiRenderTargetOptions {
  48794. /**
  48795. * Define if the texture needs to create mip maps after render.
  48796. */
  48797. generateMipMaps?: boolean;
  48798. /**
  48799. * Define the types of all the draw buffers we want to create
  48800. */
  48801. types?: number[];
  48802. /**
  48803. * Define the sampling modes of all the draw buffers we want to create
  48804. */
  48805. samplingModes?: number[];
  48806. /**
  48807. * Define if a depth buffer is required
  48808. */
  48809. generateDepthBuffer?: boolean;
  48810. /**
  48811. * Define if a stencil buffer is required
  48812. */
  48813. generateStencilBuffer?: boolean;
  48814. /**
  48815. * Define if a depth texture is required instead of a depth buffer
  48816. */
  48817. generateDepthTexture?: boolean;
  48818. /**
  48819. * Define the number of desired draw buffers
  48820. */
  48821. textureCount?: number;
  48822. /**
  48823. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48824. */
  48825. doNotChangeAspectRatio?: boolean;
  48826. /**
  48827. * Define the default type of the buffers we are creating
  48828. */
  48829. defaultType?: number;
  48830. }
  48831. /**
  48832. * A multi render target, like a render target provides the ability to render to a texture.
  48833. * Unlike the render target, it can render to several draw buffers in one draw.
  48834. * This is specially interesting in deferred rendering or for any effects requiring more than
  48835. * just one color from a single pass.
  48836. */
  48837. export class MultiRenderTarget extends RenderTargetTexture {
  48838. private _internalTextures;
  48839. private _textures;
  48840. private _multiRenderTargetOptions;
  48841. /**
  48842. * Get if draw buffers are currently supported by the used hardware and browser.
  48843. */
  48844. get isSupported(): boolean;
  48845. /**
  48846. * Get the list of textures generated by the multi render target.
  48847. */
  48848. get textures(): Texture[];
  48849. /**
  48850. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48851. */
  48852. get depthTexture(): Texture;
  48853. /**
  48854. * Set the wrapping mode on U of all the textures we are rendering to.
  48855. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48856. */
  48857. set wrapU(wrap: number);
  48858. /**
  48859. * Set the wrapping mode on V of all the textures we are rendering to.
  48860. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48861. */
  48862. set wrapV(wrap: number);
  48863. /**
  48864. * Instantiate a new multi render target texture.
  48865. * A multi render target, like a render target provides the ability to render to a texture.
  48866. * Unlike the render target, it can render to several draw buffers in one draw.
  48867. * This is specially interesting in deferred rendering or for any effects requiring more than
  48868. * just one color from a single pass.
  48869. * @param name Define the name of the texture
  48870. * @param size Define the size of the buffers to render to
  48871. * @param count Define the number of target we are rendering into
  48872. * @param scene Define the scene the texture belongs to
  48873. * @param options Define the options used to create the multi render target
  48874. */
  48875. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48876. /** @hidden */
  48877. _rebuild(): void;
  48878. private _createInternalTextures;
  48879. private _createTextures;
  48880. /**
  48881. * Define the number of samples used if MSAA is enabled.
  48882. */
  48883. get samples(): number;
  48884. set samples(value: number);
  48885. /**
  48886. * Resize all the textures in the multi render target.
  48887. * Be carrefull as it will recreate all the data in the new texture.
  48888. * @param size Define the new size
  48889. */
  48890. resize(size: any): void;
  48891. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48892. /**
  48893. * Dispose the render targets and their associated resources
  48894. */
  48895. dispose(): void;
  48896. /**
  48897. * Release all the underlying texture used as draw buffers.
  48898. */
  48899. releaseInternalTextures(): void;
  48900. }
  48901. }
  48902. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48904. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48905. import { Nullable } from "babylonjs/types";
  48906. module "babylonjs/Engines/thinEngine" {
  48907. interface ThinEngine {
  48908. /**
  48909. * Unbind a list of render target textures from the webGL context
  48910. * This is used only when drawBuffer extension or webGL2 are active
  48911. * @param textures defines the render target textures to unbind
  48912. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48913. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48914. */
  48915. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48916. /**
  48917. * Create a multi render target texture
  48918. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48919. * @param size defines the size of the texture
  48920. * @param options defines the creation options
  48921. * @returns the cube texture as an InternalTexture
  48922. */
  48923. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48924. /**
  48925. * Update the sample count for a given multiple render target texture
  48926. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48927. * @param textures defines the textures to update
  48928. * @param samples defines the sample count to set
  48929. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48930. */
  48931. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48932. }
  48933. }
  48934. }
  48935. declare module "babylonjs/Engines/Extensions/engine.views" {
  48936. import { Camera } from "babylonjs/Cameras/camera";
  48937. import { Nullable } from "babylonjs/types";
  48938. /**
  48939. * Class used to define an additional view for the engine
  48940. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48941. */
  48942. export class EngineView {
  48943. /** Defines the canvas where to render the view */
  48944. target: HTMLCanvasElement;
  48945. /** Defines an optional camera used to render the view (will use active camera else) */
  48946. camera?: Camera;
  48947. }
  48948. module "babylonjs/Engines/engine" {
  48949. interface Engine {
  48950. /**
  48951. * Gets or sets the HTML element to use for attaching events
  48952. */
  48953. inputElement: Nullable<HTMLElement>;
  48954. /**
  48955. * Gets the current engine view
  48956. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48957. */
  48958. activeView: Nullable<EngineView>;
  48959. /** Gets or sets the list of views */
  48960. views: EngineView[];
  48961. /**
  48962. * Register a new child canvas
  48963. * @param canvas defines the canvas to register
  48964. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48965. * @returns the associated view
  48966. */
  48967. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48968. /**
  48969. * Remove a registered child canvas
  48970. * @param canvas defines the canvas to remove
  48971. * @returns the current engine
  48972. */
  48973. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48974. }
  48975. }
  48976. }
  48977. declare module "babylonjs/Engines/Extensions/index" {
  48978. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48979. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48980. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48981. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48982. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48983. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48984. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48985. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48986. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48987. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48988. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48989. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48990. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48991. export * from "babylonjs/Engines/Extensions/engine.views";
  48992. }
  48993. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48994. import { Nullable } from "babylonjs/types";
  48995. /**
  48996. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48997. */
  48998. export interface CubeMapInfo {
  48999. /**
  49000. * The pixel array for the front face.
  49001. * This is stored in format, left to right, up to down format.
  49002. */
  49003. front: Nullable<ArrayBufferView>;
  49004. /**
  49005. * The pixel array for the back face.
  49006. * This is stored in format, left to right, up to down format.
  49007. */
  49008. back: Nullable<ArrayBufferView>;
  49009. /**
  49010. * The pixel array for the left face.
  49011. * This is stored in format, left to right, up to down format.
  49012. */
  49013. left: Nullable<ArrayBufferView>;
  49014. /**
  49015. * The pixel array for the right face.
  49016. * This is stored in format, left to right, up to down format.
  49017. */
  49018. right: Nullable<ArrayBufferView>;
  49019. /**
  49020. * The pixel array for the up face.
  49021. * This is stored in format, left to right, up to down format.
  49022. */
  49023. up: Nullable<ArrayBufferView>;
  49024. /**
  49025. * The pixel array for the down face.
  49026. * This is stored in format, left to right, up to down format.
  49027. */
  49028. down: Nullable<ArrayBufferView>;
  49029. /**
  49030. * The size of the cubemap stored.
  49031. *
  49032. * Each faces will be size * size pixels.
  49033. */
  49034. size: number;
  49035. /**
  49036. * The format of the texture.
  49037. *
  49038. * RGBA, RGB.
  49039. */
  49040. format: number;
  49041. /**
  49042. * The type of the texture data.
  49043. *
  49044. * UNSIGNED_INT, FLOAT.
  49045. */
  49046. type: number;
  49047. /**
  49048. * Specifies whether the texture is in gamma space.
  49049. */
  49050. gammaSpace: boolean;
  49051. }
  49052. /**
  49053. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49054. */
  49055. export class PanoramaToCubeMapTools {
  49056. private static FACE_FRONT;
  49057. private static FACE_BACK;
  49058. private static FACE_RIGHT;
  49059. private static FACE_LEFT;
  49060. private static FACE_DOWN;
  49061. private static FACE_UP;
  49062. /**
  49063. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49064. *
  49065. * @param float32Array The source data.
  49066. * @param inputWidth The width of the input panorama.
  49067. * @param inputHeight The height of the input panorama.
  49068. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49069. * @return The cubemap data
  49070. */
  49071. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49072. private static CreateCubemapTexture;
  49073. private static CalcProjectionSpherical;
  49074. }
  49075. }
  49076. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49077. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49079. import { Nullable } from "babylonjs/types";
  49080. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49081. /**
  49082. * Helper class dealing with the extraction of spherical polynomial dataArray
  49083. * from a cube map.
  49084. */
  49085. export class CubeMapToSphericalPolynomialTools {
  49086. private static FileFaces;
  49087. /**
  49088. * Converts a texture to the according Spherical Polynomial data.
  49089. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49090. *
  49091. * @param texture The texture to extract the information from.
  49092. * @return The Spherical Polynomial data.
  49093. */
  49094. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49095. /**
  49096. * Converts a cubemap to the according Spherical Polynomial data.
  49097. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49098. *
  49099. * @param cubeInfo The Cube map to extract the information from.
  49100. * @return The Spherical Polynomial data.
  49101. */
  49102. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49103. }
  49104. }
  49105. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49106. import { Nullable } from "babylonjs/types";
  49107. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49108. module "babylonjs/Materials/Textures/baseTexture" {
  49109. interface BaseTexture {
  49110. /**
  49111. * Get the polynomial representation of the texture data.
  49112. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49113. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49114. */
  49115. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49116. }
  49117. }
  49118. }
  49119. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49120. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49121. /** @hidden */
  49122. export var rgbdEncodePixelShader: {
  49123. name: string;
  49124. shader: string;
  49125. };
  49126. }
  49127. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49129. /** @hidden */
  49130. export var rgbdDecodePixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module "babylonjs/Misc/environmentTextureTools" {
  49136. import { Nullable } from "babylonjs/types";
  49137. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49139. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49140. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49141. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49142. import "babylonjs/Shaders/rgbdEncode.fragment";
  49143. import "babylonjs/Shaders/rgbdDecode.fragment";
  49144. /**
  49145. * Raw texture data and descriptor sufficient for WebGL texture upload
  49146. */
  49147. export interface EnvironmentTextureInfo {
  49148. /**
  49149. * Version of the environment map
  49150. */
  49151. version: number;
  49152. /**
  49153. * Width of image
  49154. */
  49155. width: number;
  49156. /**
  49157. * Irradiance information stored in the file.
  49158. */
  49159. irradiance: any;
  49160. /**
  49161. * Specular information stored in the file.
  49162. */
  49163. specular: any;
  49164. }
  49165. /**
  49166. * Defines One Image in the file. It requires only the position in the file
  49167. * as well as the length.
  49168. */
  49169. interface BufferImageData {
  49170. /**
  49171. * Length of the image data.
  49172. */
  49173. length: number;
  49174. /**
  49175. * Position of the data from the null terminator delimiting the end of the JSON.
  49176. */
  49177. position: number;
  49178. }
  49179. /**
  49180. * Defines the specular data enclosed in the file.
  49181. * This corresponds to the version 1 of the data.
  49182. */
  49183. export interface EnvironmentTextureSpecularInfoV1 {
  49184. /**
  49185. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49186. */
  49187. specularDataPosition?: number;
  49188. /**
  49189. * This contains all the images data needed to reconstruct the cubemap.
  49190. */
  49191. mipmaps: Array<BufferImageData>;
  49192. /**
  49193. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49194. */
  49195. lodGenerationScale: number;
  49196. }
  49197. /**
  49198. * Sets of helpers addressing the serialization and deserialization of environment texture
  49199. * stored in a BabylonJS env file.
  49200. * Those files are usually stored as .env files.
  49201. */
  49202. export class EnvironmentTextureTools {
  49203. /**
  49204. * Magic number identifying the env file.
  49205. */
  49206. private static _MagicBytes;
  49207. /**
  49208. * Gets the environment info from an env file.
  49209. * @param data The array buffer containing the .env bytes.
  49210. * @returns the environment file info (the json header) if successfully parsed.
  49211. */
  49212. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49213. /**
  49214. * Creates an environment texture from a loaded cube texture.
  49215. * @param texture defines the cube texture to convert in env file
  49216. * @return a promise containing the environment data if succesfull.
  49217. */
  49218. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49219. /**
  49220. * Creates a JSON representation of the spherical data.
  49221. * @param texture defines the texture containing the polynomials
  49222. * @return the JSON representation of the spherical info
  49223. */
  49224. private static _CreateEnvTextureIrradiance;
  49225. /**
  49226. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49227. * @param data the image data
  49228. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49229. * @return the views described by info providing access to the underlying buffer
  49230. */
  49231. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49232. /**
  49233. * Uploads the texture info contained in the env file to the GPU.
  49234. * @param texture defines the internal texture to upload to
  49235. * @param data defines the data to load
  49236. * @param info defines the texture info retrieved through the GetEnvInfo method
  49237. * @returns a promise
  49238. */
  49239. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49240. private static _OnImageReadyAsync;
  49241. /**
  49242. * Uploads the levels of image data to the GPU.
  49243. * @param texture defines the internal texture to upload to
  49244. * @param imageData defines the array buffer views of image data [mipmap][face]
  49245. * @returns a promise
  49246. */
  49247. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49248. /**
  49249. * Uploads spherical polynomials information to the texture.
  49250. * @param texture defines the texture we are trying to upload the information to
  49251. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49252. */
  49253. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49254. /** @hidden */
  49255. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49256. }
  49257. }
  49258. declare module "babylonjs/Maths/math.vertexFormat" {
  49259. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49260. /**
  49261. * Contains position and normal vectors for a vertex
  49262. */
  49263. export class PositionNormalVertex {
  49264. /** the position of the vertex (defaut: 0,0,0) */
  49265. position: Vector3;
  49266. /** the normal of the vertex (defaut: 0,1,0) */
  49267. normal: Vector3;
  49268. /**
  49269. * Creates a PositionNormalVertex
  49270. * @param position the position of the vertex (defaut: 0,0,0)
  49271. * @param normal the normal of the vertex (defaut: 0,1,0)
  49272. */
  49273. constructor(
  49274. /** the position of the vertex (defaut: 0,0,0) */
  49275. position?: Vector3,
  49276. /** the normal of the vertex (defaut: 0,1,0) */
  49277. normal?: Vector3);
  49278. /**
  49279. * Clones the PositionNormalVertex
  49280. * @returns the cloned PositionNormalVertex
  49281. */
  49282. clone(): PositionNormalVertex;
  49283. }
  49284. /**
  49285. * Contains position, normal and uv vectors for a vertex
  49286. */
  49287. export class PositionNormalTextureVertex {
  49288. /** the position of the vertex (defaut: 0,0,0) */
  49289. position: Vector3;
  49290. /** the normal of the vertex (defaut: 0,1,0) */
  49291. normal: Vector3;
  49292. /** the uv of the vertex (default: 0,0) */
  49293. uv: Vector2;
  49294. /**
  49295. * Creates a PositionNormalTextureVertex
  49296. * @param position the position of the vertex (defaut: 0,0,0)
  49297. * @param normal the normal of the vertex (defaut: 0,1,0)
  49298. * @param uv the uv of the vertex (default: 0,0)
  49299. */
  49300. constructor(
  49301. /** the position of the vertex (defaut: 0,0,0) */
  49302. position?: Vector3,
  49303. /** the normal of the vertex (defaut: 0,1,0) */
  49304. normal?: Vector3,
  49305. /** the uv of the vertex (default: 0,0) */
  49306. uv?: Vector2);
  49307. /**
  49308. * Clones the PositionNormalTextureVertex
  49309. * @returns the cloned PositionNormalTextureVertex
  49310. */
  49311. clone(): PositionNormalTextureVertex;
  49312. }
  49313. }
  49314. declare module "babylonjs/Maths/math" {
  49315. export * from "babylonjs/Maths/math.axis";
  49316. export * from "babylonjs/Maths/math.color";
  49317. export * from "babylonjs/Maths/math.constants";
  49318. export * from "babylonjs/Maths/math.frustum";
  49319. export * from "babylonjs/Maths/math.path";
  49320. export * from "babylonjs/Maths/math.plane";
  49321. export * from "babylonjs/Maths/math.size";
  49322. export * from "babylonjs/Maths/math.vector";
  49323. export * from "babylonjs/Maths/math.vertexFormat";
  49324. export * from "babylonjs/Maths/math.viewport";
  49325. }
  49326. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49327. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49328. /** @hidden */
  49329. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49330. private _genericAttributeLocation;
  49331. private _varyingLocationCount;
  49332. private _varyingLocationMap;
  49333. private _replacements;
  49334. private _textureCount;
  49335. private _uniforms;
  49336. lineProcessor(line: string): string;
  49337. attributeProcessor(attribute: string): string;
  49338. varyingProcessor(varying: string, isFragment: boolean): string;
  49339. uniformProcessor(uniform: string): string;
  49340. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49341. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49342. }
  49343. }
  49344. declare module "babylonjs/Engines/nativeEngine" {
  49345. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49346. import { Engine } from "babylonjs/Engines/engine";
  49347. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49350. import { Effect } from "babylonjs/Materials/effect";
  49351. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49352. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49353. import { IColor4Like } from "babylonjs/Maths/math.like";
  49354. import { Scene } from "babylonjs/scene";
  49355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49356. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49357. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49358. /**
  49359. * Container for accessors for natively-stored mesh data buffers.
  49360. */
  49361. class NativeDataBuffer extends DataBuffer {
  49362. /**
  49363. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49364. */
  49365. nativeIndexBuffer?: any;
  49366. /**
  49367. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49368. */
  49369. nativeVertexBuffer?: any;
  49370. }
  49371. /** @hidden */
  49372. class NativeTexture extends InternalTexture {
  49373. getInternalTexture(): InternalTexture;
  49374. getViewCount(): number;
  49375. }
  49376. /** @hidden */
  49377. export class NativeEngine extends Engine {
  49378. private readonly _native;
  49379. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49380. private readonly INVALID_HANDLE;
  49381. getHardwareScalingLevel(): number;
  49382. constructor();
  49383. /**
  49384. * Can be used to override the current requestAnimationFrame requester.
  49385. * @hidden
  49386. */
  49387. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49388. /**
  49389. * Override default engine behavior.
  49390. * @param color
  49391. * @param backBuffer
  49392. * @param depth
  49393. * @param stencil
  49394. */
  49395. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49396. /**
  49397. * Gets host document
  49398. * @returns the host document object
  49399. */
  49400. getHostDocument(): Nullable<Document>;
  49401. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49402. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49403. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49404. recordVertexArrayObject(vertexBuffers: {
  49405. [key: string]: VertexBuffer;
  49406. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49407. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49408. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49410. /**
  49411. * Draw a list of indexed primitives
  49412. * @param fillMode defines the primitive to use
  49413. * @param indexStart defines the starting index
  49414. * @param indexCount defines the number of index to draw
  49415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49416. */
  49417. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49418. /**
  49419. * Draw a list of unindexed primitives
  49420. * @param fillMode defines the primitive to use
  49421. * @param verticesStart defines the index of first vertex to draw
  49422. * @param verticesCount defines the count of vertices to draw
  49423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49424. */
  49425. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49426. createPipelineContext(): IPipelineContext;
  49427. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49428. /** @hidden */
  49429. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49430. /** @hidden */
  49431. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49432. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49433. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49434. protected _setProgram(program: WebGLProgram): void;
  49435. _releaseEffect(effect: Effect): void;
  49436. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49437. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49438. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49439. bindSamplers(effect: Effect): void;
  49440. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49441. getRenderWidth(useScreen?: boolean): number;
  49442. getRenderHeight(useScreen?: boolean): number;
  49443. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49444. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49445. /**
  49446. * Set the z offset to apply to current rendering
  49447. * @param value defines the offset to apply
  49448. */
  49449. setZOffset(value: number): void;
  49450. /**
  49451. * Gets the current value of the zOffset
  49452. * @returns the current zOffset state
  49453. */
  49454. getZOffset(): number;
  49455. /**
  49456. * Enable or disable depth buffering
  49457. * @param enable defines the state to set
  49458. */
  49459. setDepthBuffer(enable: boolean): void;
  49460. /**
  49461. * Gets a boolean indicating if depth writing is enabled
  49462. * @returns the current depth writing state
  49463. */
  49464. getDepthWrite(): boolean;
  49465. /**
  49466. * Enable or disable depth writing
  49467. * @param enable defines the state to set
  49468. */
  49469. setDepthWrite(enable: boolean): void;
  49470. /**
  49471. * Enable or disable color writing
  49472. * @param enable defines the state to set
  49473. */
  49474. setColorWrite(enable: boolean): void;
  49475. /**
  49476. * Gets a boolean indicating if color writing is enabled
  49477. * @returns the current color writing state
  49478. */
  49479. getColorWrite(): boolean;
  49480. /**
  49481. * Sets alpha constants used by some alpha blending modes
  49482. * @param r defines the red component
  49483. * @param g defines the green component
  49484. * @param b defines the blue component
  49485. * @param a defines the alpha component
  49486. */
  49487. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49488. /**
  49489. * Sets the current alpha mode
  49490. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49491. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49492. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49493. */
  49494. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49495. /**
  49496. * Gets the current alpha mode
  49497. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49498. * @returns the current alpha mode
  49499. */
  49500. getAlphaMode(): number;
  49501. setInt(uniform: WebGLUniformLocation, int: number): void;
  49502. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49503. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49504. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49505. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49506. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49507. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49508. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49509. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49510. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49511. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49512. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49513. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49514. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49515. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49516. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49517. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49518. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49519. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49520. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49521. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49522. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49523. wipeCaches(bruteForce?: boolean): void;
  49524. _createTexture(): WebGLTexture;
  49525. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49526. /**
  49527. * Usually called from Texture.ts.
  49528. * Passed information to create a WebGLTexture
  49529. * @param urlArg defines a value which contains one of the following:
  49530. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49531. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49532. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49534. * @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)
  49535. * @param scene needed for loading to the correct scene
  49536. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49537. * @param onLoad optional callback to be called upon successful completion
  49538. * @param onError optional callback to be called upon failure
  49539. * @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
  49540. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49541. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49542. * @param forcedExtension defines the extension to use to pick the right loader
  49543. * @param mimeType defines an optional mime type
  49544. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49545. */
  49546. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49547. /**
  49548. * Creates a cube texture
  49549. * @param rootUrl defines the url where the files to load is located
  49550. * @param scene defines the current scene
  49551. * @param files defines the list of files to load (1 per face)
  49552. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49553. * @param onLoad defines an optional callback raised when the texture is loaded
  49554. * @param onError defines an optional callback raised if there is an issue to load the texture
  49555. * @param format defines the format of the data
  49556. * @param forcedExtension defines the extension to use to pick the right loader
  49557. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49558. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49559. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49560. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49561. * @returns the cube texture as an InternalTexture
  49562. */
  49563. 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;
  49564. private _getSamplingFilter;
  49565. private static _GetNativeTextureFormat;
  49566. createRenderTargetTexture(size: number | {
  49567. width: number;
  49568. height: number;
  49569. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49570. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49571. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49572. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49573. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49574. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49575. /**
  49576. * Updates a dynamic vertex buffer.
  49577. * @param vertexBuffer the vertex buffer to update
  49578. * @param data the data used to update the vertex buffer
  49579. * @param byteOffset the byte offset of the data (optional)
  49580. * @param byteLength the byte length of the data (optional)
  49581. */
  49582. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49583. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49584. private _updateAnisotropicLevel;
  49585. private _getAddressMode;
  49586. /** @hidden */
  49587. _bindTexture(channel: number, texture: InternalTexture): void;
  49588. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49589. releaseEffects(): void;
  49590. /** @hidden */
  49591. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49592. /** @hidden */
  49593. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49594. /** @hidden */
  49595. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49596. /** @hidden */
  49597. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49598. }
  49599. }
  49600. declare module "babylonjs/Engines/index" {
  49601. export * from "babylonjs/Engines/constants";
  49602. export * from "babylonjs/Engines/engineCapabilities";
  49603. export * from "babylonjs/Engines/instancingAttributeInfo";
  49604. export * from "babylonjs/Engines/thinEngine";
  49605. export * from "babylonjs/Engines/engine";
  49606. export * from "babylonjs/Engines/engineStore";
  49607. export * from "babylonjs/Engines/nullEngine";
  49608. export * from "babylonjs/Engines/Extensions/index";
  49609. export * from "babylonjs/Engines/IPipelineContext";
  49610. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49611. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49612. export * from "babylonjs/Engines/nativeEngine";
  49613. }
  49614. declare module "babylonjs/Events/clipboardEvents" {
  49615. /**
  49616. * Gather the list of clipboard event types as constants.
  49617. */
  49618. export class ClipboardEventTypes {
  49619. /**
  49620. * The clipboard event is fired when a copy command is active (pressed).
  49621. */
  49622. static readonly COPY: number;
  49623. /**
  49624. * The clipboard event is fired when a cut command is active (pressed).
  49625. */
  49626. static readonly CUT: number;
  49627. /**
  49628. * The clipboard event is fired when a paste command is active (pressed).
  49629. */
  49630. static readonly PASTE: number;
  49631. }
  49632. /**
  49633. * This class is used to store clipboard related info for the onClipboardObservable event.
  49634. */
  49635. export class ClipboardInfo {
  49636. /**
  49637. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49638. */
  49639. type: number;
  49640. /**
  49641. * Defines the related dom event
  49642. */
  49643. event: ClipboardEvent;
  49644. /**
  49645. *Creates an instance of ClipboardInfo.
  49646. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49647. * @param event Defines the related dom event
  49648. */
  49649. constructor(
  49650. /**
  49651. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49652. */
  49653. type: number,
  49654. /**
  49655. * Defines the related dom event
  49656. */
  49657. event: ClipboardEvent);
  49658. /**
  49659. * Get the clipboard event's type from the keycode.
  49660. * @param keyCode Defines the keyCode for the current keyboard event.
  49661. * @return {number}
  49662. */
  49663. static GetTypeFromCharacter(keyCode: number): number;
  49664. }
  49665. }
  49666. declare module "babylonjs/Events/index" {
  49667. export * from "babylonjs/Events/keyboardEvents";
  49668. export * from "babylonjs/Events/pointerEvents";
  49669. export * from "babylonjs/Events/clipboardEvents";
  49670. }
  49671. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49672. import { Scene } from "babylonjs/scene";
  49673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49674. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49675. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49676. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49677. /**
  49678. * Google Daydream controller
  49679. */
  49680. export class DaydreamController extends WebVRController {
  49681. /**
  49682. * Base Url for the controller model.
  49683. */
  49684. static MODEL_BASE_URL: string;
  49685. /**
  49686. * File name for the controller model.
  49687. */
  49688. static MODEL_FILENAME: string;
  49689. /**
  49690. * Gamepad Id prefix used to identify Daydream Controller.
  49691. */
  49692. static readonly GAMEPAD_ID_PREFIX: string;
  49693. /**
  49694. * Creates a new DaydreamController from a gamepad
  49695. * @param vrGamepad the gamepad that the controller should be created from
  49696. */
  49697. constructor(vrGamepad: any);
  49698. /**
  49699. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49700. * @param scene scene in which to add meshes
  49701. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49702. */
  49703. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49704. /**
  49705. * Called once for each button that changed state since the last frame
  49706. * @param buttonIdx Which button index changed
  49707. * @param state New state of the button
  49708. * @param changes Which properties on the state changed since last frame
  49709. */
  49710. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49711. }
  49712. }
  49713. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49714. import { Scene } from "babylonjs/scene";
  49715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49716. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49717. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49718. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49719. /**
  49720. * Gear VR Controller
  49721. */
  49722. export class GearVRController extends WebVRController {
  49723. /**
  49724. * Base Url for the controller model.
  49725. */
  49726. static MODEL_BASE_URL: string;
  49727. /**
  49728. * File name for the controller model.
  49729. */
  49730. static MODEL_FILENAME: string;
  49731. /**
  49732. * Gamepad Id prefix used to identify this controller.
  49733. */
  49734. static readonly GAMEPAD_ID_PREFIX: string;
  49735. private readonly _buttonIndexToObservableNameMap;
  49736. /**
  49737. * Creates a new GearVRController from a gamepad
  49738. * @param vrGamepad the gamepad that the controller should be created from
  49739. */
  49740. constructor(vrGamepad: any);
  49741. /**
  49742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49743. * @param scene scene in which to add meshes
  49744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49745. */
  49746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49747. /**
  49748. * Called once for each button that changed state since the last frame
  49749. * @param buttonIdx Which button index changed
  49750. * @param state New state of the button
  49751. * @param changes Which properties on the state changed since last frame
  49752. */
  49753. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49754. }
  49755. }
  49756. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49757. import { Scene } from "babylonjs/scene";
  49758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49759. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49760. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49761. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49762. /**
  49763. * Generic Controller
  49764. */
  49765. export class GenericController extends WebVRController {
  49766. /**
  49767. * Base Url for the controller model.
  49768. */
  49769. static readonly MODEL_BASE_URL: string;
  49770. /**
  49771. * File name for the controller model.
  49772. */
  49773. static readonly MODEL_FILENAME: string;
  49774. /**
  49775. * Creates a new GenericController from a gamepad
  49776. * @param vrGamepad the gamepad that the controller should be created from
  49777. */
  49778. constructor(vrGamepad: any);
  49779. /**
  49780. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49781. * @param scene scene in which to add meshes
  49782. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49783. */
  49784. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49785. /**
  49786. * Called once for each button that changed state since the last frame
  49787. * @param buttonIdx Which button index changed
  49788. * @param state New state of the button
  49789. * @param changes Which properties on the state changed since last frame
  49790. */
  49791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49792. }
  49793. }
  49794. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49795. import { Observable } from "babylonjs/Misc/observable";
  49796. import { Scene } from "babylonjs/scene";
  49797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49799. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49800. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49801. /**
  49802. * Oculus Touch Controller
  49803. */
  49804. export class OculusTouchController extends WebVRController {
  49805. /**
  49806. * Base Url for the controller model.
  49807. */
  49808. static MODEL_BASE_URL: string;
  49809. /**
  49810. * File name for the left controller model.
  49811. */
  49812. static MODEL_LEFT_FILENAME: string;
  49813. /**
  49814. * File name for the right controller model.
  49815. */
  49816. static MODEL_RIGHT_FILENAME: string;
  49817. /**
  49818. * Base Url for the Quest controller model.
  49819. */
  49820. static QUEST_MODEL_BASE_URL: string;
  49821. /**
  49822. * @hidden
  49823. * If the controllers are running on a device that needs the updated Quest controller models
  49824. */
  49825. static _IsQuest: boolean;
  49826. /**
  49827. * Fired when the secondary trigger on this controller is modified
  49828. */
  49829. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49830. /**
  49831. * Fired when the thumb rest on this controller is modified
  49832. */
  49833. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49834. /**
  49835. * Creates a new OculusTouchController from a gamepad
  49836. * @param vrGamepad the gamepad that the controller should be created from
  49837. */
  49838. constructor(vrGamepad: any);
  49839. /**
  49840. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49841. * @param scene scene in which to add meshes
  49842. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49843. */
  49844. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49845. /**
  49846. * Fired when the A button on this controller is modified
  49847. */
  49848. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49849. /**
  49850. * Fired when the B button on this controller is modified
  49851. */
  49852. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49853. /**
  49854. * Fired when the X button on this controller is modified
  49855. */
  49856. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49857. /**
  49858. * Fired when the Y button on this controller is modified
  49859. */
  49860. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49861. /**
  49862. * Called once for each button that changed state since the last frame
  49863. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49864. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49865. * 2) secondary trigger (same)
  49866. * 3) A (right) X (left), touch, pressed = value
  49867. * 4) B / Y
  49868. * 5) thumb rest
  49869. * @param buttonIdx Which button index changed
  49870. * @param state New state of the button
  49871. * @param changes Which properties on the state changed since last frame
  49872. */
  49873. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49874. }
  49875. }
  49876. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49877. import { Scene } from "babylonjs/scene";
  49878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49880. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49881. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49882. import { Observable } from "babylonjs/Misc/observable";
  49883. /**
  49884. * Vive Controller
  49885. */
  49886. export class ViveController extends WebVRController {
  49887. /**
  49888. * Base Url for the controller model.
  49889. */
  49890. static MODEL_BASE_URL: string;
  49891. /**
  49892. * File name for the controller model.
  49893. */
  49894. static MODEL_FILENAME: string;
  49895. /**
  49896. * Creates a new ViveController from a gamepad
  49897. * @param vrGamepad the gamepad that the controller should be created from
  49898. */
  49899. constructor(vrGamepad: any);
  49900. /**
  49901. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49902. * @param scene scene in which to add meshes
  49903. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49904. */
  49905. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49906. /**
  49907. * Fired when the left button on this controller is modified
  49908. */
  49909. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49910. /**
  49911. * Fired when the right button on this controller is modified
  49912. */
  49913. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49914. /**
  49915. * Fired when the menu button on this controller is modified
  49916. */
  49917. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49918. /**
  49919. * Called once for each button that changed state since the last frame
  49920. * Vive mapping:
  49921. * 0: touchpad
  49922. * 1: trigger
  49923. * 2: left AND right buttons
  49924. * 3: menu button
  49925. * @param buttonIdx Which button index changed
  49926. * @param state New state of the button
  49927. * @param changes Which properties on the state changed since last frame
  49928. */
  49929. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49930. }
  49931. }
  49932. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49933. import { Observable } from "babylonjs/Misc/observable";
  49934. import { Scene } from "babylonjs/scene";
  49935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49936. import { Ray } from "babylonjs/Culling/ray";
  49937. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49938. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49939. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49940. /**
  49941. * Defines the WindowsMotionController object that the state of the windows motion controller
  49942. */
  49943. export class WindowsMotionController extends WebVRController {
  49944. /**
  49945. * The base url used to load the left and right controller models
  49946. */
  49947. static MODEL_BASE_URL: string;
  49948. /**
  49949. * The name of the left controller model file
  49950. */
  49951. static MODEL_LEFT_FILENAME: string;
  49952. /**
  49953. * The name of the right controller model file
  49954. */
  49955. static MODEL_RIGHT_FILENAME: string;
  49956. /**
  49957. * The controller name prefix for this controller type
  49958. */
  49959. static readonly GAMEPAD_ID_PREFIX: string;
  49960. /**
  49961. * The controller id pattern for this controller type
  49962. */
  49963. private static readonly GAMEPAD_ID_PATTERN;
  49964. private _loadedMeshInfo;
  49965. protected readonly _mapping: {
  49966. buttons: string[];
  49967. buttonMeshNames: {
  49968. 'trigger': string;
  49969. 'menu': string;
  49970. 'grip': string;
  49971. 'thumbstick': string;
  49972. 'trackpad': string;
  49973. };
  49974. buttonObservableNames: {
  49975. 'trigger': string;
  49976. 'menu': string;
  49977. 'grip': string;
  49978. 'thumbstick': string;
  49979. 'trackpad': string;
  49980. };
  49981. axisMeshNames: string[];
  49982. pointingPoseMeshName: string;
  49983. };
  49984. /**
  49985. * Fired when the trackpad on this controller is clicked
  49986. */
  49987. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49988. /**
  49989. * Fired when the trackpad on this controller is modified
  49990. */
  49991. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49992. /**
  49993. * The current x and y values of this controller's trackpad
  49994. */
  49995. trackpad: StickValues;
  49996. /**
  49997. * Creates a new WindowsMotionController from a gamepad
  49998. * @param vrGamepad the gamepad that the controller should be created from
  49999. */
  50000. constructor(vrGamepad: any);
  50001. /**
  50002. * Fired when the trigger on this controller is modified
  50003. */
  50004. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50005. /**
  50006. * Fired when the menu button on this controller is modified
  50007. */
  50008. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50009. /**
  50010. * Fired when the grip button on this controller is modified
  50011. */
  50012. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50013. /**
  50014. * Fired when the thumbstick button on this controller is modified
  50015. */
  50016. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50017. /**
  50018. * Fired when the touchpad button on this controller is modified
  50019. */
  50020. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50021. /**
  50022. * Fired when the touchpad values on this controller are modified
  50023. */
  50024. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50025. protected _updateTrackpad(): void;
  50026. /**
  50027. * Called once per frame by the engine.
  50028. */
  50029. update(): void;
  50030. /**
  50031. * Called once for each button that changed state since the last frame
  50032. * @param buttonIdx Which button index changed
  50033. * @param state New state of the button
  50034. * @param changes Which properties on the state changed since last frame
  50035. */
  50036. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50037. /**
  50038. * Moves the buttons on the controller mesh based on their current state
  50039. * @param buttonName the name of the button to move
  50040. * @param buttonValue the value of the button which determines the buttons new position
  50041. */
  50042. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50043. /**
  50044. * Moves the axis on the controller mesh based on its current state
  50045. * @param axis the index of the axis
  50046. * @param axisValue the value of the axis which determines the meshes new position
  50047. * @hidden
  50048. */
  50049. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50050. /**
  50051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50052. * @param scene scene in which to add meshes
  50053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50054. */
  50055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50056. /**
  50057. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50058. * can be transformed by button presses and axes values, based on this._mapping.
  50059. *
  50060. * @param scene scene in which the meshes exist
  50061. * @param meshes list of meshes that make up the controller model to process
  50062. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50063. */
  50064. private processModel;
  50065. private createMeshInfo;
  50066. /**
  50067. * Gets the ray of the controller in the direction the controller is pointing
  50068. * @param length the length the resulting ray should be
  50069. * @returns a ray in the direction the controller is pointing
  50070. */
  50071. getForwardRay(length?: number): Ray;
  50072. /**
  50073. * Disposes of the controller
  50074. */
  50075. dispose(): void;
  50076. }
  50077. /**
  50078. * This class represents a new windows motion controller in XR.
  50079. */
  50080. export class XRWindowsMotionController extends WindowsMotionController {
  50081. /**
  50082. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50083. */
  50084. protected readonly _mapping: {
  50085. buttons: string[];
  50086. buttonMeshNames: {
  50087. 'trigger': string;
  50088. 'menu': string;
  50089. 'grip': string;
  50090. 'thumbstick': string;
  50091. 'trackpad': string;
  50092. };
  50093. buttonObservableNames: {
  50094. 'trigger': string;
  50095. 'menu': string;
  50096. 'grip': string;
  50097. 'thumbstick': string;
  50098. 'trackpad': string;
  50099. };
  50100. axisMeshNames: string[];
  50101. pointingPoseMeshName: string;
  50102. };
  50103. /**
  50104. * Construct a new XR-Based windows motion controller
  50105. *
  50106. * @param gamepadInfo the gamepad object from the browser
  50107. */
  50108. constructor(gamepadInfo: any);
  50109. /**
  50110. * holds the thumbstick values (X,Y)
  50111. */
  50112. thumbstickValues: StickValues;
  50113. /**
  50114. * Fired when the thumbstick on this controller is clicked
  50115. */
  50116. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50117. /**
  50118. * Fired when the thumbstick on this controller is modified
  50119. */
  50120. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50121. /**
  50122. * Fired when the touchpad button on this controller is modified
  50123. */
  50124. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50125. /**
  50126. * Fired when the touchpad values on this controller are modified
  50127. */
  50128. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50129. /**
  50130. * Fired when the thumbstick button on this controller is modified
  50131. * here to prevent breaking changes
  50132. */
  50133. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50134. /**
  50135. * updating the thumbstick(!) and not the trackpad.
  50136. * This is named this way due to the difference between WebVR and XR and to avoid
  50137. * changing the parent class.
  50138. */
  50139. protected _updateTrackpad(): void;
  50140. /**
  50141. * Disposes the class with joy
  50142. */
  50143. dispose(): void;
  50144. }
  50145. }
  50146. declare module "babylonjs/Gamepads/Controllers/index" {
  50147. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50148. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50149. export * from "babylonjs/Gamepads/Controllers/genericController";
  50150. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50151. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50152. export * from "babylonjs/Gamepads/Controllers/viveController";
  50153. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50154. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50155. }
  50156. declare module "babylonjs/Gamepads/index" {
  50157. export * from "babylonjs/Gamepads/Controllers/index";
  50158. export * from "babylonjs/Gamepads/gamepad";
  50159. export * from "babylonjs/Gamepads/gamepadManager";
  50160. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50161. export * from "babylonjs/Gamepads/xboxGamepad";
  50162. export * from "babylonjs/Gamepads/dualShockGamepad";
  50163. }
  50164. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50165. import { Scene } from "babylonjs/scene";
  50166. import { Vector4 } from "babylonjs/Maths/math.vector";
  50167. import { Color4 } from "babylonjs/Maths/math.color";
  50168. import { Mesh } from "babylonjs/Meshes/mesh";
  50169. import { Nullable } from "babylonjs/types";
  50170. /**
  50171. * Class containing static functions to help procedurally build meshes
  50172. */
  50173. export class PolyhedronBuilder {
  50174. /**
  50175. * Creates a polyhedron mesh
  50176. * * 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
  50177. * * The parameter `size` (positive float, default 1) sets the polygon size
  50178. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50179. * * 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`
  50180. * * 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
  50181. * * 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)`)
  50182. * * 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
  50183. * * 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
  50184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50187. * @param name defines the name of the mesh
  50188. * @param options defines the options used to create the mesh
  50189. * @param scene defines the hosting scene
  50190. * @returns the polyhedron mesh
  50191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50192. */
  50193. static CreatePolyhedron(name: string, options: {
  50194. type?: number;
  50195. size?: number;
  50196. sizeX?: number;
  50197. sizeY?: number;
  50198. sizeZ?: number;
  50199. custom?: any;
  50200. faceUV?: Vector4[];
  50201. faceColors?: Color4[];
  50202. flat?: boolean;
  50203. updatable?: boolean;
  50204. sideOrientation?: number;
  50205. frontUVs?: Vector4;
  50206. backUVs?: Vector4;
  50207. }, scene?: Nullable<Scene>): Mesh;
  50208. }
  50209. }
  50210. declare module "babylonjs/Gizmos/scaleGizmo" {
  50211. import { Observable } from "babylonjs/Misc/observable";
  50212. import { Nullable } from "babylonjs/types";
  50213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50214. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50215. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50216. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50217. /**
  50218. * Gizmo that enables scaling a mesh along 3 axis
  50219. */
  50220. export class ScaleGizmo extends Gizmo {
  50221. /**
  50222. * Internal gizmo used for interactions on the x axis
  50223. */
  50224. xGizmo: AxisScaleGizmo;
  50225. /**
  50226. * Internal gizmo used for interactions on the y axis
  50227. */
  50228. yGizmo: AxisScaleGizmo;
  50229. /**
  50230. * Internal gizmo used for interactions on the z axis
  50231. */
  50232. zGizmo: AxisScaleGizmo;
  50233. /**
  50234. * Internal gizmo used to scale all axis equally
  50235. */
  50236. uniformScaleGizmo: AxisScaleGizmo;
  50237. private _meshAttached;
  50238. private _updateGizmoRotationToMatchAttachedMesh;
  50239. private _snapDistance;
  50240. private _scaleRatio;
  50241. private _uniformScalingMesh;
  50242. private _octahedron;
  50243. private _sensitivity;
  50244. /** Fires an event when any of it's sub gizmos are dragged */
  50245. onDragStartObservable: Observable<unknown>;
  50246. /** Fires an event when any of it's sub gizmos are released from dragging */
  50247. onDragEndObservable: Observable<unknown>;
  50248. get attachedMesh(): Nullable<AbstractMesh>;
  50249. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50250. /**
  50251. * Creates a ScaleGizmo
  50252. * @param gizmoLayer The utility layer the gizmo will be added to
  50253. */
  50254. constructor(gizmoLayer?: UtilityLayerRenderer);
  50255. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50256. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50257. /**
  50258. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50259. */
  50260. set snapDistance(value: number);
  50261. get snapDistance(): number;
  50262. /**
  50263. * Ratio for the scale of the gizmo (Default: 1)
  50264. */
  50265. set scaleRatio(value: number);
  50266. get scaleRatio(): number;
  50267. /**
  50268. * Sensitivity factor for dragging (Default: 1)
  50269. */
  50270. set sensitivity(value: number);
  50271. get sensitivity(): number;
  50272. /**
  50273. * Disposes of the gizmo
  50274. */
  50275. dispose(): void;
  50276. }
  50277. }
  50278. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50279. import { Observable } from "babylonjs/Misc/observable";
  50280. import { Nullable } from "babylonjs/types";
  50281. import { Vector3 } from "babylonjs/Maths/math.vector";
  50282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50283. import { Mesh } from "babylonjs/Meshes/mesh";
  50284. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50285. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50286. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50287. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50288. import { Color3 } from "babylonjs/Maths/math.color";
  50289. /**
  50290. * Single axis scale gizmo
  50291. */
  50292. export class AxisScaleGizmo extends Gizmo {
  50293. /**
  50294. * Drag behavior responsible for the gizmos dragging interactions
  50295. */
  50296. dragBehavior: PointerDragBehavior;
  50297. private _pointerObserver;
  50298. /**
  50299. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50300. */
  50301. snapDistance: number;
  50302. /**
  50303. * Event that fires each time the gizmo snaps to a new location.
  50304. * * snapDistance is the the change in distance
  50305. */
  50306. onSnapObservable: Observable<{
  50307. snapDistance: number;
  50308. }>;
  50309. /**
  50310. * If the scaling operation should be done on all axis (default: false)
  50311. */
  50312. uniformScaling: boolean;
  50313. /**
  50314. * Custom sensitivity value for the drag strength
  50315. */
  50316. sensitivity: number;
  50317. private _isEnabled;
  50318. private _parent;
  50319. private _arrow;
  50320. private _coloredMaterial;
  50321. private _hoverMaterial;
  50322. /**
  50323. * Creates an AxisScaleGizmo
  50324. * @param gizmoLayer The utility layer the gizmo will be added to
  50325. * @param dragAxis The axis which the gizmo will be able to scale on
  50326. * @param color The color of the gizmo
  50327. */
  50328. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50329. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50330. /**
  50331. * If the gizmo is enabled
  50332. */
  50333. set isEnabled(value: boolean);
  50334. get isEnabled(): boolean;
  50335. /**
  50336. * Disposes of the gizmo
  50337. */
  50338. dispose(): void;
  50339. /**
  50340. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50341. * @param mesh The mesh to replace the default mesh of the gizmo
  50342. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50343. */
  50344. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50345. }
  50346. }
  50347. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50348. import { Observable } from "babylonjs/Misc/observable";
  50349. import { Nullable } from "babylonjs/types";
  50350. import { Vector3 } from "babylonjs/Maths/math.vector";
  50351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50352. import { Mesh } from "babylonjs/Meshes/mesh";
  50353. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50354. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50355. import { Color3 } from "babylonjs/Maths/math.color";
  50356. import "babylonjs/Meshes/Builders/boxBuilder";
  50357. /**
  50358. * Bounding box gizmo
  50359. */
  50360. export class BoundingBoxGizmo extends Gizmo {
  50361. private _lineBoundingBox;
  50362. private _rotateSpheresParent;
  50363. private _scaleBoxesParent;
  50364. private _boundingDimensions;
  50365. private _renderObserver;
  50366. private _pointerObserver;
  50367. private _scaleDragSpeed;
  50368. private _tmpQuaternion;
  50369. private _tmpVector;
  50370. private _tmpRotationMatrix;
  50371. /**
  50372. * 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)
  50373. */
  50374. ignoreChildren: boolean;
  50375. /**
  50376. * 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)
  50377. */
  50378. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50379. /**
  50380. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50381. */
  50382. rotationSphereSize: number;
  50383. /**
  50384. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50385. */
  50386. scaleBoxSize: number;
  50387. /**
  50388. * 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)
  50389. */
  50390. fixedDragMeshScreenSize: boolean;
  50391. /**
  50392. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50393. */
  50394. fixedDragMeshScreenSizeDistanceFactor: number;
  50395. /**
  50396. * Fired when a rotation sphere or scale box is dragged
  50397. */
  50398. onDragStartObservable: Observable<{}>;
  50399. /**
  50400. * Fired when a scale box is dragged
  50401. */
  50402. onScaleBoxDragObservable: Observable<{}>;
  50403. /**
  50404. * Fired when a scale box drag is ended
  50405. */
  50406. onScaleBoxDragEndObservable: Observable<{}>;
  50407. /**
  50408. * Fired when a rotation sphere is dragged
  50409. */
  50410. onRotationSphereDragObservable: Observable<{}>;
  50411. /**
  50412. * Fired when a rotation sphere drag is ended
  50413. */
  50414. onRotationSphereDragEndObservable: Observable<{}>;
  50415. /**
  50416. * 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)
  50417. */
  50418. scalePivot: Nullable<Vector3>;
  50419. /**
  50420. * Mesh used as a pivot to rotate the attached mesh
  50421. */
  50422. private _anchorMesh;
  50423. private _existingMeshScale;
  50424. private _dragMesh;
  50425. private pointerDragBehavior;
  50426. private coloredMaterial;
  50427. private hoverColoredMaterial;
  50428. /**
  50429. * Sets the color of the bounding box gizmo
  50430. * @param color the color to set
  50431. */
  50432. setColor(color: Color3): void;
  50433. /**
  50434. * Creates an BoundingBoxGizmo
  50435. * @param gizmoLayer The utility layer the gizmo will be added to
  50436. * @param color The color of the gizmo
  50437. */
  50438. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50439. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50440. private _selectNode;
  50441. /**
  50442. * Updates the bounding box information for the Gizmo
  50443. */
  50444. updateBoundingBox(): void;
  50445. private _updateRotationSpheres;
  50446. private _updateScaleBoxes;
  50447. /**
  50448. * Enables rotation on the specified axis and disables rotation on the others
  50449. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50450. */
  50451. setEnabledRotationAxis(axis: string): void;
  50452. /**
  50453. * Enables/disables scaling
  50454. * @param enable if scaling should be enabled
  50455. */
  50456. setEnabledScaling(enable: boolean): void;
  50457. private _updateDummy;
  50458. /**
  50459. * Enables a pointer drag behavior on the bounding box of the gizmo
  50460. */
  50461. enableDragBehavior(): void;
  50462. /**
  50463. * Disposes of the gizmo
  50464. */
  50465. dispose(): void;
  50466. /**
  50467. * 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)
  50468. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50469. * @returns the bounding box mesh with the passed in mesh as a child
  50470. */
  50471. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50472. /**
  50473. * CustomMeshes are not supported by this gizmo
  50474. * @param mesh The mesh to replace the default mesh of the gizmo
  50475. */
  50476. setCustomMesh(mesh: Mesh): void;
  50477. }
  50478. }
  50479. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50480. import { Observable } from "babylonjs/Misc/observable";
  50481. import { Nullable } from "babylonjs/types";
  50482. import { Vector3 } from "babylonjs/Maths/math.vector";
  50483. import { Color3 } from "babylonjs/Maths/math.color";
  50484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50485. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50486. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50487. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50488. import "babylonjs/Meshes/Builders/linesBuilder";
  50489. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50490. /**
  50491. * Single plane rotation gizmo
  50492. */
  50493. export class PlaneRotationGizmo extends Gizmo {
  50494. /**
  50495. * Drag behavior responsible for the gizmos dragging interactions
  50496. */
  50497. dragBehavior: PointerDragBehavior;
  50498. private _pointerObserver;
  50499. /**
  50500. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50501. */
  50502. snapDistance: number;
  50503. /**
  50504. * Event that fires each time the gizmo snaps to a new location.
  50505. * * snapDistance is the the change in distance
  50506. */
  50507. onSnapObservable: Observable<{
  50508. snapDistance: number;
  50509. }>;
  50510. private _isEnabled;
  50511. private _parent;
  50512. /**
  50513. * Creates a PlaneRotationGizmo
  50514. * @param gizmoLayer The utility layer the gizmo will be added to
  50515. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50516. * @param color The color of the gizmo
  50517. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50518. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50519. */
  50520. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50521. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50522. /**
  50523. * If the gizmo is enabled
  50524. */
  50525. set isEnabled(value: boolean);
  50526. get isEnabled(): boolean;
  50527. /**
  50528. * Disposes of the gizmo
  50529. */
  50530. dispose(): void;
  50531. }
  50532. }
  50533. declare module "babylonjs/Gizmos/rotationGizmo" {
  50534. import { Observable } from "babylonjs/Misc/observable";
  50535. import { Nullable } from "babylonjs/types";
  50536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50537. import { Mesh } from "babylonjs/Meshes/mesh";
  50538. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50539. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50540. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50541. /**
  50542. * Gizmo that enables rotating a mesh along 3 axis
  50543. */
  50544. export class RotationGizmo extends Gizmo {
  50545. /**
  50546. * Internal gizmo used for interactions on the x axis
  50547. */
  50548. xGizmo: PlaneRotationGizmo;
  50549. /**
  50550. * Internal gizmo used for interactions on the y axis
  50551. */
  50552. yGizmo: PlaneRotationGizmo;
  50553. /**
  50554. * Internal gizmo used for interactions on the z axis
  50555. */
  50556. zGizmo: PlaneRotationGizmo;
  50557. /** Fires an event when any of it's sub gizmos are dragged */
  50558. onDragStartObservable: Observable<unknown>;
  50559. /** Fires an event when any of it's sub gizmos are released from dragging */
  50560. onDragEndObservable: Observable<unknown>;
  50561. private _meshAttached;
  50562. get attachedMesh(): Nullable<AbstractMesh>;
  50563. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50564. /**
  50565. * Creates a RotationGizmo
  50566. * @param gizmoLayer The utility layer the gizmo will be added to
  50567. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50568. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50569. */
  50570. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50571. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50572. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50573. /**
  50574. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50575. */
  50576. set snapDistance(value: number);
  50577. get snapDistance(): number;
  50578. /**
  50579. * Ratio for the scale of the gizmo (Default: 1)
  50580. */
  50581. set scaleRatio(value: number);
  50582. get scaleRatio(): number;
  50583. /**
  50584. * Disposes of the gizmo
  50585. */
  50586. dispose(): void;
  50587. /**
  50588. * CustomMeshes are not supported by this gizmo
  50589. * @param mesh The mesh to replace the default mesh of the gizmo
  50590. */
  50591. setCustomMesh(mesh: Mesh): void;
  50592. }
  50593. }
  50594. declare module "babylonjs/Gizmos/gizmoManager" {
  50595. import { Observable } from "babylonjs/Misc/observable";
  50596. import { Nullable } from "babylonjs/types";
  50597. import { Scene, IDisposable } from "babylonjs/scene";
  50598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50599. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50600. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50601. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50602. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50603. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50604. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50605. /**
  50606. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50607. */
  50608. export class GizmoManager implements IDisposable {
  50609. private scene;
  50610. /**
  50611. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50612. */
  50613. gizmos: {
  50614. positionGizmo: Nullable<PositionGizmo>;
  50615. rotationGizmo: Nullable<RotationGizmo>;
  50616. scaleGizmo: Nullable<ScaleGizmo>;
  50617. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50618. };
  50619. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50620. clearGizmoOnEmptyPointerEvent: boolean;
  50621. /** Fires an event when the manager is attached to a mesh */
  50622. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50623. private _gizmosEnabled;
  50624. private _pointerObserver;
  50625. private _attachedMesh;
  50626. private _boundingBoxColor;
  50627. private _defaultUtilityLayer;
  50628. private _defaultKeepDepthUtilityLayer;
  50629. /**
  50630. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50631. */
  50632. boundingBoxDragBehavior: SixDofDragBehavior;
  50633. /**
  50634. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50635. */
  50636. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50637. /**
  50638. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50639. */
  50640. usePointerToAttachGizmos: boolean;
  50641. /**
  50642. * Utility layer that the bounding box gizmo belongs to
  50643. */
  50644. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50645. /**
  50646. * Utility layer that all gizmos besides bounding box belong to
  50647. */
  50648. get utilityLayer(): UtilityLayerRenderer;
  50649. /**
  50650. * Instatiates a gizmo manager
  50651. * @param scene the scene to overlay the gizmos on top of
  50652. */
  50653. constructor(scene: Scene);
  50654. /**
  50655. * Attaches a set of gizmos to the specified mesh
  50656. * @param mesh The mesh the gizmo's should be attached to
  50657. */
  50658. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50659. /**
  50660. * If the position gizmo is enabled
  50661. */
  50662. set positionGizmoEnabled(value: boolean);
  50663. get positionGizmoEnabled(): boolean;
  50664. /**
  50665. * If the rotation gizmo is enabled
  50666. */
  50667. set rotationGizmoEnabled(value: boolean);
  50668. get rotationGizmoEnabled(): boolean;
  50669. /**
  50670. * If the scale gizmo is enabled
  50671. */
  50672. set scaleGizmoEnabled(value: boolean);
  50673. get scaleGizmoEnabled(): boolean;
  50674. /**
  50675. * If the boundingBox gizmo is enabled
  50676. */
  50677. set boundingBoxGizmoEnabled(value: boolean);
  50678. get boundingBoxGizmoEnabled(): boolean;
  50679. /**
  50680. * Disposes of the gizmo manager
  50681. */
  50682. dispose(): void;
  50683. }
  50684. }
  50685. declare module "babylonjs/Lights/directionalLight" {
  50686. import { Camera } from "babylonjs/Cameras/camera";
  50687. import { Scene } from "babylonjs/scene";
  50688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50690. import { Light } from "babylonjs/Lights/light";
  50691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50692. import { Effect } from "babylonjs/Materials/effect";
  50693. /**
  50694. * A directional light is defined by a direction (what a surprise!).
  50695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50696. * 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.
  50697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50698. */
  50699. export class DirectionalLight extends ShadowLight {
  50700. private _shadowFrustumSize;
  50701. /**
  50702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50703. */
  50704. get shadowFrustumSize(): number;
  50705. /**
  50706. * Specifies a fix frustum size for the shadow generation.
  50707. */
  50708. set shadowFrustumSize(value: number);
  50709. private _shadowOrthoScale;
  50710. /**
  50711. * Gets the shadow projection scale against the optimal computed one.
  50712. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50713. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50714. */
  50715. get shadowOrthoScale(): number;
  50716. /**
  50717. * Sets the shadow projection scale against the optimal computed one.
  50718. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50719. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50720. */
  50721. set shadowOrthoScale(value: number);
  50722. /**
  50723. * Automatically compute the projection matrix to best fit (including all the casters)
  50724. * on each frame.
  50725. */
  50726. autoUpdateExtends: boolean;
  50727. /**
  50728. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50729. * on each frame. autoUpdateExtends must be set to true for this to work
  50730. */
  50731. autoCalcShadowZBounds: boolean;
  50732. private _orthoLeft;
  50733. private _orthoRight;
  50734. private _orthoTop;
  50735. private _orthoBottom;
  50736. /**
  50737. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50738. * The directional light is emitted from everywhere in the given direction.
  50739. * It can cast shadows.
  50740. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50741. * @param name The friendly name of the light
  50742. * @param direction The direction of the light
  50743. * @param scene The scene the light belongs to
  50744. */
  50745. constructor(name: string, direction: Vector3, scene: Scene);
  50746. /**
  50747. * Returns the string "DirectionalLight".
  50748. * @return The class name
  50749. */
  50750. getClassName(): string;
  50751. /**
  50752. * Returns the integer 1.
  50753. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50754. */
  50755. getTypeID(): number;
  50756. /**
  50757. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50758. * Returns the DirectionalLight Shadow projection matrix.
  50759. */
  50760. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50761. /**
  50762. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50763. * Returns the DirectionalLight Shadow projection matrix.
  50764. */
  50765. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50766. /**
  50767. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50768. * Returns the DirectionalLight Shadow projection matrix.
  50769. */
  50770. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50771. protected _buildUniformLayout(): void;
  50772. /**
  50773. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50774. * @param effect The effect to update
  50775. * @param lightIndex The index of the light in the effect to update
  50776. * @returns The directional light
  50777. */
  50778. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50779. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50780. /**
  50781. * Gets the minZ used for shadow according to both the scene and the light.
  50782. *
  50783. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50784. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50785. * @param activeCamera The camera we are returning the min for
  50786. * @returns the depth min z
  50787. */
  50788. getDepthMinZ(activeCamera: Camera): number;
  50789. /**
  50790. * Gets the maxZ used for shadow according to both the scene and the light.
  50791. *
  50792. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50793. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50794. * @param activeCamera The camera we are returning the max for
  50795. * @returns the depth max z
  50796. */
  50797. getDepthMaxZ(activeCamera: Camera): number;
  50798. /**
  50799. * Prepares the list of defines specific to the light type.
  50800. * @param defines the list of defines
  50801. * @param lightIndex defines the index of the light for the effect
  50802. */
  50803. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50804. }
  50805. }
  50806. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50807. import { Mesh } from "babylonjs/Meshes/mesh";
  50808. /**
  50809. * Class containing static functions to help procedurally build meshes
  50810. */
  50811. export class HemisphereBuilder {
  50812. /**
  50813. * Creates a hemisphere mesh
  50814. * @param name defines the name of the mesh
  50815. * @param options defines the options used to create the mesh
  50816. * @param scene defines the hosting scene
  50817. * @returns the hemisphere mesh
  50818. */
  50819. static CreateHemisphere(name: string, options: {
  50820. segments?: number;
  50821. diameter?: number;
  50822. sideOrientation?: number;
  50823. }, scene: any): Mesh;
  50824. }
  50825. }
  50826. declare module "babylonjs/Lights/spotLight" {
  50827. import { Nullable } from "babylonjs/types";
  50828. import { Scene } from "babylonjs/scene";
  50829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50831. import { Effect } from "babylonjs/Materials/effect";
  50832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50833. import { Light } from "babylonjs/Lights/light";
  50834. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50835. /**
  50836. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50837. * These values define a cone of light starting from the position, emitting toward the direction.
  50838. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50839. * and the exponent defines the speed of the decay of the light with distance (reach).
  50840. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50841. */
  50842. export class SpotLight extends ShadowLight {
  50843. private _angle;
  50844. private _innerAngle;
  50845. private _cosHalfAngle;
  50846. private _lightAngleScale;
  50847. private _lightAngleOffset;
  50848. /**
  50849. * Gets the cone angle of the spot light in Radians.
  50850. */
  50851. get angle(): number;
  50852. /**
  50853. * Sets the cone angle of the spot light in Radians.
  50854. */
  50855. set angle(value: number);
  50856. /**
  50857. * Only used in gltf falloff mode, this defines the angle where
  50858. * the directional falloff will start before cutting at angle which could be seen
  50859. * as outer angle.
  50860. */
  50861. get innerAngle(): number;
  50862. /**
  50863. * Only used in gltf falloff mode, this defines the angle where
  50864. * the directional falloff will start before cutting at angle which could be seen
  50865. * as outer angle.
  50866. */
  50867. set innerAngle(value: number);
  50868. private _shadowAngleScale;
  50869. /**
  50870. * Allows scaling the angle of the light for shadow generation only.
  50871. */
  50872. get shadowAngleScale(): number;
  50873. /**
  50874. * Allows scaling the angle of the light for shadow generation only.
  50875. */
  50876. set shadowAngleScale(value: number);
  50877. /**
  50878. * The light decay speed with the distance from the emission spot.
  50879. */
  50880. exponent: number;
  50881. private _projectionTextureMatrix;
  50882. /**
  50883. * Allows reading the projecton texture
  50884. */
  50885. get projectionTextureMatrix(): Matrix;
  50886. protected _projectionTextureLightNear: number;
  50887. /**
  50888. * Gets the near clip of the Spotlight for texture projection.
  50889. */
  50890. get projectionTextureLightNear(): number;
  50891. /**
  50892. * Sets the near clip of the Spotlight for texture projection.
  50893. */
  50894. set projectionTextureLightNear(value: number);
  50895. protected _projectionTextureLightFar: number;
  50896. /**
  50897. * Gets the far clip of the Spotlight for texture projection.
  50898. */
  50899. get projectionTextureLightFar(): number;
  50900. /**
  50901. * Sets the far clip of the Spotlight for texture projection.
  50902. */
  50903. set projectionTextureLightFar(value: number);
  50904. protected _projectionTextureUpDirection: Vector3;
  50905. /**
  50906. * Gets the Up vector of the Spotlight for texture projection.
  50907. */
  50908. get projectionTextureUpDirection(): Vector3;
  50909. /**
  50910. * Sets the Up vector of the Spotlight for texture projection.
  50911. */
  50912. set projectionTextureUpDirection(value: Vector3);
  50913. private _projectionTexture;
  50914. /**
  50915. * Gets the projection texture of the light.
  50916. */
  50917. get projectionTexture(): Nullable<BaseTexture>;
  50918. /**
  50919. * Sets the projection texture of the light.
  50920. */
  50921. set projectionTexture(value: Nullable<BaseTexture>);
  50922. private _projectionTextureViewLightDirty;
  50923. private _projectionTextureProjectionLightDirty;
  50924. private _projectionTextureDirty;
  50925. private _projectionTextureViewTargetVector;
  50926. private _projectionTextureViewLightMatrix;
  50927. private _projectionTextureProjectionLightMatrix;
  50928. private _projectionTextureScalingMatrix;
  50929. /**
  50930. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50931. * It can cast shadows.
  50932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50933. * @param name The light friendly name
  50934. * @param position The position of the spot light in the scene
  50935. * @param direction The direction of the light in the scene
  50936. * @param angle The cone angle of the light in Radians
  50937. * @param exponent The light decay speed with the distance from the emission spot
  50938. * @param scene The scene the lights belongs to
  50939. */
  50940. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50941. /**
  50942. * Returns the string "SpotLight".
  50943. * @returns the class name
  50944. */
  50945. getClassName(): string;
  50946. /**
  50947. * Returns the integer 2.
  50948. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50949. */
  50950. getTypeID(): number;
  50951. /**
  50952. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50953. */
  50954. protected _setDirection(value: Vector3): void;
  50955. /**
  50956. * Overrides the position setter to recompute the projection texture view light Matrix.
  50957. */
  50958. protected _setPosition(value: Vector3): void;
  50959. /**
  50960. * 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.
  50961. * Returns the SpotLight.
  50962. */
  50963. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50964. protected _computeProjectionTextureViewLightMatrix(): void;
  50965. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50966. /**
  50967. * Main function for light texture projection matrix computing.
  50968. */
  50969. protected _computeProjectionTextureMatrix(): void;
  50970. protected _buildUniformLayout(): void;
  50971. private _computeAngleValues;
  50972. /**
  50973. * Sets the passed Effect "effect" with the Light textures.
  50974. * @param effect The effect to update
  50975. * @param lightIndex The index of the light in the effect to update
  50976. * @returns The light
  50977. */
  50978. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50979. /**
  50980. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50981. * @param effect The effect to update
  50982. * @param lightIndex The index of the light in the effect to update
  50983. * @returns The spot light
  50984. */
  50985. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50986. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50987. /**
  50988. * Disposes the light and the associated resources.
  50989. */
  50990. dispose(): void;
  50991. /**
  50992. * Prepares the list of defines specific to the light type.
  50993. * @param defines the list of defines
  50994. * @param lightIndex defines the index of the light for the effect
  50995. */
  50996. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50997. }
  50998. }
  50999. declare module "babylonjs/Gizmos/lightGizmo" {
  51000. import { Nullable } from "babylonjs/types";
  51001. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51002. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51003. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51004. import { Light } from "babylonjs/Lights/light";
  51005. /**
  51006. * Gizmo that enables viewing a light
  51007. */
  51008. export class LightGizmo extends Gizmo {
  51009. private _lightMesh;
  51010. private _material;
  51011. private _cachedPosition;
  51012. private _cachedForward;
  51013. private _attachedMeshParent;
  51014. /**
  51015. * Creates a LightGizmo
  51016. * @param gizmoLayer The utility layer the gizmo will be added to
  51017. */
  51018. constructor(gizmoLayer?: UtilityLayerRenderer);
  51019. private _light;
  51020. /**
  51021. * The light that the gizmo is attached to
  51022. */
  51023. set light(light: Nullable<Light>);
  51024. get light(): Nullable<Light>;
  51025. /**
  51026. * Gets the material used to render the light gizmo
  51027. */
  51028. get material(): StandardMaterial;
  51029. /**
  51030. * @hidden
  51031. * Updates the gizmo to match the attached mesh's position/rotation
  51032. */
  51033. protected _update(): void;
  51034. private static _Scale;
  51035. /**
  51036. * Creates the lines for a light mesh
  51037. */
  51038. private static _CreateLightLines;
  51039. /**
  51040. * Disposes of the light gizmo
  51041. */
  51042. dispose(): void;
  51043. private static _CreateHemisphericLightMesh;
  51044. private static _CreatePointLightMesh;
  51045. private static _CreateSpotLightMesh;
  51046. private static _CreateDirectionalLightMesh;
  51047. }
  51048. }
  51049. declare module "babylonjs/Gizmos/index" {
  51050. export * from "babylonjs/Gizmos/axisDragGizmo";
  51051. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51052. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51053. export * from "babylonjs/Gizmos/gizmo";
  51054. export * from "babylonjs/Gizmos/gizmoManager";
  51055. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51056. export * from "babylonjs/Gizmos/positionGizmo";
  51057. export * from "babylonjs/Gizmos/rotationGizmo";
  51058. export * from "babylonjs/Gizmos/scaleGizmo";
  51059. export * from "babylonjs/Gizmos/lightGizmo";
  51060. export * from "babylonjs/Gizmos/planeDragGizmo";
  51061. }
  51062. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51063. /** @hidden */
  51064. export var backgroundFragmentDeclaration: {
  51065. name: string;
  51066. shader: string;
  51067. };
  51068. }
  51069. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51070. /** @hidden */
  51071. export var backgroundUboDeclaration: {
  51072. name: string;
  51073. shader: string;
  51074. };
  51075. }
  51076. declare module "babylonjs/Shaders/background.fragment" {
  51077. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51078. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51079. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51080. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51081. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51082. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51083. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51084. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51085. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51086. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51087. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51088. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51090. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51091. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51092. /** @hidden */
  51093. export var backgroundPixelShader: {
  51094. name: string;
  51095. shader: string;
  51096. };
  51097. }
  51098. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51099. /** @hidden */
  51100. export var backgroundVertexDeclaration: {
  51101. name: string;
  51102. shader: string;
  51103. };
  51104. }
  51105. declare module "babylonjs/Shaders/background.vertex" {
  51106. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51107. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51109. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51110. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51111. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51113. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51114. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51115. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51116. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51117. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51118. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51119. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51120. /** @hidden */
  51121. export var backgroundVertexShader: {
  51122. name: string;
  51123. shader: string;
  51124. };
  51125. }
  51126. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51127. import { Nullable, int, float } from "babylonjs/types";
  51128. import { Scene } from "babylonjs/scene";
  51129. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51132. import { Mesh } from "babylonjs/Meshes/mesh";
  51133. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51134. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51135. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51137. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51138. import { Color3 } from "babylonjs/Maths/math.color";
  51139. import "babylonjs/Shaders/background.fragment";
  51140. import "babylonjs/Shaders/background.vertex";
  51141. /**
  51142. * Background material used to create an efficient environement around your scene.
  51143. */
  51144. export class BackgroundMaterial extends PushMaterial {
  51145. /**
  51146. * Standard reflectance value at parallel view angle.
  51147. */
  51148. static StandardReflectance0: number;
  51149. /**
  51150. * Standard reflectance value at grazing angle.
  51151. */
  51152. static StandardReflectance90: number;
  51153. protected _primaryColor: Color3;
  51154. /**
  51155. * Key light Color (multiply against the environement texture)
  51156. */
  51157. primaryColor: Color3;
  51158. protected __perceptualColor: Nullable<Color3>;
  51159. /**
  51160. * Experimental Internal Use Only.
  51161. *
  51162. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51163. * This acts as a helper to set the primary color to a more "human friendly" value.
  51164. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51165. * output color as close as possible from the chosen value.
  51166. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51167. * part of lighting setup.)
  51168. */
  51169. get _perceptualColor(): Nullable<Color3>;
  51170. set _perceptualColor(value: Nullable<Color3>);
  51171. protected _primaryColorShadowLevel: float;
  51172. /**
  51173. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51174. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51175. */
  51176. get primaryColorShadowLevel(): float;
  51177. set primaryColorShadowLevel(value: float);
  51178. protected _primaryColorHighlightLevel: float;
  51179. /**
  51180. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51181. * The primary color is used at the level chosen to define what the white area would look.
  51182. */
  51183. get primaryColorHighlightLevel(): float;
  51184. set primaryColorHighlightLevel(value: float);
  51185. protected _reflectionTexture: Nullable<BaseTexture>;
  51186. /**
  51187. * Reflection Texture used in the material.
  51188. * Should be author in a specific way for the best result (refer to the documentation).
  51189. */
  51190. reflectionTexture: Nullable<BaseTexture>;
  51191. protected _reflectionBlur: float;
  51192. /**
  51193. * Reflection Texture level of blur.
  51194. *
  51195. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51196. * texture twice.
  51197. */
  51198. reflectionBlur: float;
  51199. protected _diffuseTexture: Nullable<BaseTexture>;
  51200. /**
  51201. * Diffuse Texture used in the material.
  51202. * Should be author in a specific way for the best result (refer to the documentation).
  51203. */
  51204. diffuseTexture: Nullable<BaseTexture>;
  51205. protected _shadowLights: Nullable<IShadowLight[]>;
  51206. /**
  51207. * Specify the list of lights casting shadow on the material.
  51208. * All scene shadow lights will be included if null.
  51209. */
  51210. shadowLights: Nullable<IShadowLight[]>;
  51211. protected _shadowLevel: float;
  51212. /**
  51213. * Helps adjusting the shadow to a softer level if required.
  51214. * 0 means black shadows and 1 means no shadows.
  51215. */
  51216. shadowLevel: float;
  51217. protected _sceneCenter: Vector3;
  51218. /**
  51219. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51220. * It is usually zero but might be interesting to modify according to your setup.
  51221. */
  51222. sceneCenter: Vector3;
  51223. protected _opacityFresnel: boolean;
  51224. /**
  51225. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51226. * This helps ensuring a nice transition when the camera goes under the ground.
  51227. */
  51228. opacityFresnel: boolean;
  51229. protected _reflectionFresnel: boolean;
  51230. /**
  51231. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51232. * This helps adding a mirror texture on the ground.
  51233. */
  51234. reflectionFresnel: boolean;
  51235. protected _reflectionFalloffDistance: number;
  51236. /**
  51237. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51238. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51239. */
  51240. reflectionFalloffDistance: number;
  51241. protected _reflectionAmount: number;
  51242. /**
  51243. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51244. */
  51245. reflectionAmount: number;
  51246. protected _reflectionReflectance0: number;
  51247. /**
  51248. * This specifies the weight of the reflection at grazing angle.
  51249. */
  51250. reflectionReflectance0: number;
  51251. protected _reflectionReflectance90: number;
  51252. /**
  51253. * This specifies the weight of the reflection at a perpendicular point of view.
  51254. */
  51255. reflectionReflectance90: number;
  51256. /**
  51257. * Sets the reflection reflectance fresnel values according to the default standard
  51258. * empirically know to work well :-)
  51259. */
  51260. set reflectionStandardFresnelWeight(value: number);
  51261. protected _useRGBColor: boolean;
  51262. /**
  51263. * Helps to directly use the maps channels instead of their level.
  51264. */
  51265. useRGBColor: boolean;
  51266. protected _enableNoise: boolean;
  51267. /**
  51268. * This helps reducing the banding effect that could occur on the background.
  51269. */
  51270. enableNoise: boolean;
  51271. /**
  51272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51273. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51274. * Recommended to be keep at 1.0 except for special cases.
  51275. */
  51276. get fovMultiplier(): number;
  51277. set fovMultiplier(value: number);
  51278. private _fovMultiplier;
  51279. /**
  51280. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51281. */
  51282. useEquirectangularFOV: boolean;
  51283. private _maxSimultaneousLights;
  51284. /**
  51285. * Number of Simultaneous lights allowed on the material.
  51286. */
  51287. maxSimultaneousLights: int;
  51288. /**
  51289. * Default configuration related to image processing available in the Background Material.
  51290. */
  51291. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51292. /**
  51293. * Keep track of the image processing observer to allow dispose and replace.
  51294. */
  51295. private _imageProcessingObserver;
  51296. /**
  51297. * Attaches a new image processing configuration to the PBR Material.
  51298. * @param configuration (if null the scene configuration will be use)
  51299. */
  51300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51301. /**
  51302. * Gets the image processing configuration used either in this material.
  51303. */
  51304. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51305. /**
  51306. * Sets the Default image processing configuration used either in the this material.
  51307. *
  51308. * If sets to null, the scene one is in use.
  51309. */
  51310. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51311. /**
  51312. * Gets wether the color curves effect is enabled.
  51313. */
  51314. get cameraColorCurvesEnabled(): boolean;
  51315. /**
  51316. * Sets wether the color curves effect is enabled.
  51317. */
  51318. set cameraColorCurvesEnabled(value: boolean);
  51319. /**
  51320. * Gets wether the color grading effect is enabled.
  51321. */
  51322. get cameraColorGradingEnabled(): boolean;
  51323. /**
  51324. * Gets wether the color grading effect is enabled.
  51325. */
  51326. set cameraColorGradingEnabled(value: boolean);
  51327. /**
  51328. * Gets wether tonemapping is enabled or not.
  51329. */
  51330. get cameraToneMappingEnabled(): boolean;
  51331. /**
  51332. * Sets wether tonemapping is enabled or not
  51333. */
  51334. set cameraToneMappingEnabled(value: boolean);
  51335. /**
  51336. * The camera exposure used on this material.
  51337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51338. * This corresponds to a photographic exposure.
  51339. */
  51340. get cameraExposure(): float;
  51341. /**
  51342. * The camera exposure used on this material.
  51343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51344. * This corresponds to a photographic exposure.
  51345. */
  51346. set cameraExposure(value: float);
  51347. /**
  51348. * Gets The camera contrast used on this material.
  51349. */
  51350. get cameraContrast(): float;
  51351. /**
  51352. * Sets The camera contrast used on this material.
  51353. */
  51354. set cameraContrast(value: float);
  51355. /**
  51356. * Gets the Color Grading 2D Lookup Texture.
  51357. */
  51358. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51359. /**
  51360. * Sets the Color Grading 2D Lookup Texture.
  51361. */
  51362. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51363. /**
  51364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51366. * 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;
  51367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51368. */
  51369. get cameraColorCurves(): Nullable<ColorCurves>;
  51370. /**
  51371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51373. * 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;
  51374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51375. */
  51376. set cameraColorCurves(value: Nullable<ColorCurves>);
  51377. /**
  51378. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51379. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51380. */
  51381. switchToBGR: boolean;
  51382. private _renderTargets;
  51383. private _reflectionControls;
  51384. private _white;
  51385. private _primaryShadowColor;
  51386. private _primaryHighlightColor;
  51387. /**
  51388. * Instantiates a Background Material in the given scene
  51389. * @param name The friendly name of the material
  51390. * @param scene The scene to add the material to
  51391. */
  51392. constructor(name: string, scene: Scene);
  51393. /**
  51394. * Gets a boolean indicating that current material needs to register RTT
  51395. */
  51396. get hasRenderTargetTextures(): boolean;
  51397. /**
  51398. * The entire material has been created in order to prevent overdraw.
  51399. * @returns false
  51400. */
  51401. needAlphaTesting(): boolean;
  51402. /**
  51403. * The entire material has been created in order to prevent overdraw.
  51404. * @returns true if blending is enable
  51405. */
  51406. needAlphaBlending(): boolean;
  51407. /**
  51408. * Checks wether the material is ready to be rendered for a given mesh.
  51409. * @param mesh The mesh to render
  51410. * @param subMesh The submesh to check against
  51411. * @param useInstances Specify wether or not the material is used with instances
  51412. * @returns true if all the dependencies are ready (Textures, Effects...)
  51413. */
  51414. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51415. /**
  51416. * Compute the primary color according to the chosen perceptual color.
  51417. */
  51418. private _computePrimaryColorFromPerceptualColor;
  51419. /**
  51420. * Compute the highlights and shadow colors according to their chosen levels.
  51421. */
  51422. private _computePrimaryColors;
  51423. /**
  51424. * Build the uniform buffer used in the material.
  51425. */
  51426. buildUniformLayout(): void;
  51427. /**
  51428. * Unbind the material.
  51429. */
  51430. unbind(): void;
  51431. /**
  51432. * Bind only the world matrix to the material.
  51433. * @param world The world matrix to bind.
  51434. */
  51435. bindOnlyWorldMatrix(world: Matrix): void;
  51436. /**
  51437. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51438. * @param world The world matrix to bind.
  51439. * @param subMesh The submesh to bind for.
  51440. */
  51441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51442. /**
  51443. * Checks to see if a texture is used in the material.
  51444. * @param texture - Base texture to use.
  51445. * @returns - Boolean specifying if a texture is used in the material.
  51446. */
  51447. hasTexture(texture: BaseTexture): boolean;
  51448. /**
  51449. * Dispose the material.
  51450. * @param forceDisposeEffect Force disposal of the associated effect.
  51451. * @param forceDisposeTextures Force disposal of the associated textures.
  51452. */
  51453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51454. /**
  51455. * Clones the material.
  51456. * @param name The cloned name.
  51457. * @returns The cloned material.
  51458. */
  51459. clone(name: string): BackgroundMaterial;
  51460. /**
  51461. * Serializes the current material to its JSON representation.
  51462. * @returns The JSON representation.
  51463. */
  51464. serialize(): any;
  51465. /**
  51466. * Gets the class name of the material
  51467. * @returns "BackgroundMaterial"
  51468. */
  51469. getClassName(): string;
  51470. /**
  51471. * Parse a JSON input to create back a background material.
  51472. * @param source The JSON data to parse
  51473. * @param scene The scene to create the parsed material in
  51474. * @param rootUrl The root url of the assets the material depends upon
  51475. * @returns the instantiated BackgroundMaterial.
  51476. */
  51477. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51478. }
  51479. }
  51480. declare module "babylonjs/Helpers/environmentHelper" {
  51481. import { Observable } from "babylonjs/Misc/observable";
  51482. import { Nullable } from "babylonjs/types";
  51483. import { Scene } from "babylonjs/scene";
  51484. import { Vector3 } from "babylonjs/Maths/math.vector";
  51485. import { Color3 } from "babylonjs/Maths/math.color";
  51486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51487. import { Mesh } from "babylonjs/Meshes/mesh";
  51488. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51489. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51490. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51491. import "babylonjs/Meshes/Builders/planeBuilder";
  51492. import "babylonjs/Meshes/Builders/boxBuilder";
  51493. /**
  51494. * Represents the different options available during the creation of
  51495. * a Environment helper.
  51496. *
  51497. * This can control the default ground, skybox and image processing setup of your scene.
  51498. */
  51499. export interface IEnvironmentHelperOptions {
  51500. /**
  51501. * Specifies whether or not to create a ground.
  51502. * True by default.
  51503. */
  51504. createGround: boolean;
  51505. /**
  51506. * Specifies the ground size.
  51507. * 15 by default.
  51508. */
  51509. groundSize: number;
  51510. /**
  51511. * The texture used on the ground for the main color.
  51512. * Comes from the BabylonJS CDN by default.
  51513. *
  51514. * Remarks: Can be either a texture or a url.
  51515. */
  51516. groundTexture: string | BaseTexture;
  51517. /**
  51518. * The color mixed in the ground texture by default.
  51519. * BabylonJS clearColor by default.
  51520. */
  51521. groundColor: Color3;
  51522. /**
  51523. * Specifies the ground opacity.
  51524. * 1 by default.
  51525. */
  51526. groundOpacity: number;
  51527. /**
  51528. * Enables the ground to receive shadows.
  51529. * True by default.
  51530. */
  51531. enableGroundShadow: boolean;
  51532. /**
  51533. * Helps preventing the shadow to be fully black on the ground.
  51534. * 0.5 by default.
  51535. */
  51536. groundShadowLevel: number;
  51537. /**
  51538. * Creates a mirror texture attach to the ground.
  51539. * false by default.
  51540. */
  51541. enableGroundMirror: boolean;
  51542. /**
  51543. * Specifies the ground mirror size ratio.
  51544. * 0.3 by default as the default kernel is 64.
  51545. */
  51546. groundMirrorSizeRatio: number;
  51547. /**
  51548. * Specifies the ground mirror blur kernel size.
  51549. * 64 by default.
  51550. */
  51551. groundMirrorBlurKernel: number;
  51552. /**
  51553. * Specifies the ground mirror visibility amount.
  51554. * 1 by default
  51555. */
  51556. groundMirrorAmount: number;
  51557. /**
  51558. * Specifies the ground mirror reflectance weight.
  51559. * This uses the standard weight of the background material to setup the fresnel effect
  51560. * of the mirror.
  51561. * 1 by default.
  51562. */
  51563. groundMirrorFresnelWeight: number;
  51564. /**
  51565. * Specifies the ground mirror Falloff distance.
  51566. * This can helps reducing the size of the reflection.
  51567. * 0 by Default.
  51568. */
  51569. groundMirrorFallOffDistance: number;
  51570. /**
  51571. * Specifies the ground mirror texture type.
  51572. * Unsigned Int by Default.
  51573. */
  51574. groundMirrorTextureType: number;
  51575. /**
  51576. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51577. * the shown objects.
  51578. */
  51579. groundYBias: number;
  51580. /**
  51581. * Specifies whether or not to create a skybox.
  51582. * True by default.
  51583. */
  51584. createSkybox: boolean;
  51585. /**
  51586. * Specifies the skybox size.
  51587. * 20 by default.
  51588. */
  51589. skyboxSize: number;
  51590. /**
  51591. * The texture used on the skybox for the main color.
  51592. * Comes from the BabylonJS CDN by default.
  51593. *
  51594. * Remarks: Can be either a texture or a url.
  51595. */
  51596. skyboxTexture: string | BaseTexture;
  51597. /**
  51598. * The color mixed in the skybox texture by default.
  51599. * BabylonJS clearColor by default.
  51600. */
  51601. skyboxColor: Color3;
  51602. /**
  51603. * The background rotation around the Y axis of the scene.
  51604. * This helps aligning the key lights of your scene with the background.
  51605. * 0 by default.
  51606. */
  51607. backgroundYRotation: number;
  51608. /**
  51609. * Compute automatically the size of the elements to best fit with the scene.
  51610. */
  51611. sizeAuto: boolean;
  51612. /**
  51613. * Default position of the rootMesh if autoSize is not true.
  51614. */
  51615. rootPosition: Vector3;
  51616. /**
  51617. * Sets up the image processing in the scene.
  51618. * true by default.
  51619. */
  51620. setupImageProcessing: boolean;
  51621. /**
  51622. * The texture used as your environment texture in the scene.
  51623. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51624. *
  51625. * Remarks: Can be either a texture or a url.
  51626. */
  51627. environmentTexture: string | BaseTexture;
  51628. /**
  51629. * The value of the exposure to apply to the scene.
  51630. * 0.6 by default if setupImageProcessing is true.
  51631. */
  51632. cameraExposure: number;
  51633. /**
  51634. * The value of the contrast to apply to the scene.
  51635. * 1.6 by default if setupImageProcessing is true.
  51636. */
  51637. cameraContrast: number;
  51638. /**
  51639. * Specifies whether or not tonemapping should be enabled in the scene.
  51640. * true by default if setupImageProcessing is true.
  51641. */
  51642. toneMappingEnabled: boolean;
  51643. }
  51644. /**
  51645. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51646. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51647. * It also helps with the default setup of your imageProcessing configuration.
  51648. */
  51649. export class EnvironmentHelper {
  51650. /**
  51651. * Default ground texture URL.
  51652. */
  51653. private static _groundTextureCDNUrl;
  51654. /**
  51655. * Default skybox texture URL.
  51656. */
  51657. private static _skyboxTextureCDNUrl;
  51658. /**
  51659. * Default environment texture URL.
  51660. */
  51661. private static _environmentTextureCDNUrl;
  51662. /**
  51663. * Creates the default options for the helper.
  51664. */
  51665. private static _getDefaultOptions;
  51666. private _rootMesh;
  51667. /**
  51668. * Gets the root mesh created by the helper.
  51669. */
  51670. get rootMesh(): Mesh;
  51671. private _skybox;
  51672. /**
  51673. * Gets the skybox created by the helper.
  51674. */
  51675. get skybox(): Nullable<Mesh>;
  51676. private _skyboxTexture;
  51677. /**
  51678. * Gets the skybox texture created by the helper.
  51679. */
  51680. get skyboxTexture(): Nullable<BaseTexture>;
  51681. private _skyboxMaterial;
  51682. /**
  51683. * Gets the skybox material created by the helper.
  51684. */
  51685. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51686. private _ground;
  51687. /**
  51688. * Gets the ground mesh created by the helper.
  51689. */
  51690. get ground(): Nullable<Mesh>;
  51691. private _groundTexture;
  51692. /**
  51693. * Gets the ground texture created by the helper.
  51694. */
  51695. get groundTexture(): Nullable<BaseTexture>;
  51696. private _groundMirror;
  51697. /**
  51698. * Gets the ground mirror created by the helper.
  51699. */
  51700. get groundMirror(): Nullable<MirrorTexture>;
  51701. /**
  51702. * Gets the ground mirror render list to helps pushing the meshes
  51703. * you wish in the ground reflection.
  51704. */
  51705. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51706. private _groundMaterial;
  51707. /**
  51708. * Gets the ground material created by the helper.
  51709. */
  51710. get groundMaterial(): Nullable<BackgroundMaterial>;
  51711. /**
  51712. * Stores the creation options.
  51713. */
  51714. private readonly _scene;
  51715. private _options;
  51716. /**
  51717. * This observable will be notified with any error during the creation of the environment,
  51718. * mainly texture creation errors.
  51719. */
  51720. onErrorObservable: Observable<{
  51721. message?: string;
  51722. exception?: any;
  51723. }>;
  51724. /**
  51725. * constructor
  51726. * @param options Defines the options we want to customize the helper
  51727. * @param scene The scene to add the material to
  51728. */
  51729. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51730. /**
  51731. * Updates the background according to the new options
  51732. * @param options
  51733. */
  51734. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51735. /**
  51736. * Sets the primary color of all the available elements.
  51737. * @param color the main color to affect to the ground and the background
  51738. */
  51739. setMainColor(color: Color3): void;
  51740. /**
  51741. * Setup the image processing according to the specified options.
  51742. */
  51743. private _setupImageProcessing;
  51744. /**
  51745. * Setup the environment texture according to the specified options.
  51746. */
  51747. private _setupEnvironmentTexture;
  51748. /**
  51749. * Setup the background according to the specified options.
  51750. */
  51751. private _setupBackground;
  51752. /**
  51753. * Get the scene sizes according to the setup.
  51754. */
  51755. private _getSceneSize;
  51756. /**
  51757. * Setup the ground according to the specified options.
  51758. */
  51759. private _setupGround;
  51760. /**
  51761. * Setup the ground material according to the specified options.
  51762. */
  51763. private _setupGroundMaterial;
  51764. /**
  51765. * Setup the ground diffuse texture according to the specified options.
  51766. */
  51767. private _setupGroundDiffuseTexture;
  51768. /**
  51769. * Setup the ground mirror texture according to the specified options.
  51770. */
  51771. private _setupGroundMirrorTexture;
  51772. /**
  51773. * Setup the ground to receive the mirror texture.
  51774. */
  51775. private _setupMirrorInGroundMaterial;
  51776. /**
  51777. * Setup the skybox according to the specified options.
  51778. */
  51779. private _setupSkybox;
  51780. /**
  51781. * Setup the skybox material according to the specified options.
  51782. */
  51783. private _setupSkyboxMaterial;
  51784. /**
  51785. * Setup the skybox reflection texture according to the specified options.
  51786. */
  51787. private _setupSkyboxReflectionTexture;
  51788. private _errorHandler;
  51789. /**
  51790. * Dispose all the elements created by the Helper.
  51791. */
  51792. dispose(): void;
  51793. }
  51794. }
  51795. declare module "babylonjs/Helpers/photoDome" {
  51796. import { Observable } from "babylonjs/Misc/observable";
  51797. import { Nullable } from "babylonjs/types";
  51798. import { Scene } from "babylonjs/scene";
  51799. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51800. import { Mesh } from "babylonjs/Meshes/mesh";
  51801. import { Texture } from "babylonjs/Materials/Textures/texture";
  51802. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51803. import "babylonjs/Meshes/Builders/sphereBuilder";
  51804. /**
  51805. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51806. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51807. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51808. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51809. */
  51810. export class PhotoDome extends TransformNode {
  51811. /**
  51812. * Define the image as a Monoscopic panoramic 360 image.
  51813. */
  51814. static readonly MODE_MONOSCOPIC: number;
  51815. /**
  51816. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51817. */
  51818. static readonly MODE_TOPBOTTOM: number;
  51819. /**
  51820. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51821. */
  51822. static readonly MODE_SIDEBYSIDE: number;
  51823. private _useDirectMapping;
  51824. /**
  51825. * The texture being displayed on the sphere
  51826. */
  51827. protected _photoTexture: Texture;
  51828. /**
  51829. * Gets or sets the texture being displayed on the sphere
  51830. */
  51831. get photoTexture(): Texture;
  51832. set photoTexture(value: Texture);
  51833. /**
  51834. * Observable raised when an error occured while loading the 360 image
  51835. */
  51836. onLoadErrorObservable: Observable<string>;
  51837. /**
  51838. * The skybox material
  51839. */
  51840. protected _material: BackgroundMaterial;
  51841. /**
  51842. * The surface used for the skybox
  51843. */
  51844. protected _mesh: Mesh;
  51845. /**
  51846. * Gets the mesh used for the skybox.
  51847. */
  51848. get mesh(): Mesh;
  51849. /**
  51850. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51851. * Also see the options.resolution property.
  51852. */
  51853. get fovMultiplier(): number;
  51854. set fovMultiplier(value: number);
  51855. private _imageMode;
  51856. /**
  51857. * Gets or set the current video mode for the video. It can be:
  51858. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51859. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51860. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51861. */
  51862. get imageMode(): number;
  51863. set imageMode(value: number);
  51864. /**
  51865. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51866. * @param name Element's name, child elements will append suffixes for their own names.
  51867. * @param urlsOfPhoto defines the url of the photo to display
  51868. * @param options defines an object containing optional or exposed sub element properties
  51869. * @param onError defines a callback called when an error occured while loading the texture
  51870. */
  51871. constructor(name: string, urlOfPhoto: string, options: {
  51872. resolution?: number;
  51873. size?: number;
  51874. useDirectMapping?: boolean;
  51875. faceForward?: boolean;
  51876. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51877. private _onBeforeCameraRenderObserver;
  51878. private _changeImageMode;
  51879. /**
  51880. * Releases resources associated with this node.
  51881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51883. */
  51884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51885. }
  51886. }
  51887. declare module "babylonjs/Misc/rgbdTextureTools" {
  51888. import "babylonjs/Shaders/rgbdDecode.fragment";
  51889. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51890. import { Texture } from "babylonjs/Materials/Textures/texture";
  51891. /**
  51892. * Class used to host RGBD texture specific utilities
  51893. */
  51894. export class RGBDTextureTools {
  51895. /**
  51896. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51897. * @param texture the texture to expand.
  51898. */
  51899. static ExpandRGBDTexture(texture: Texture): void;
  51900. }
  51901. }
  51902. declare module "babylonjs/Misc/brdfTextureTools" {
  51903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51904. import { Scene } from "babylonjs/scene";
  51905. /**
  51906. * Class used to host texture specific utilities
  51907. */
  51908. export class BRDFTextureTools {
  51909. /**
  51910. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51911. * @param scene defines the hosting scene
  51912. * @returns the environment BRDF texture
  51913. */
  51914. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51915. private static _environmentBRDFBase64Texture;
  51916. }
  51917. }
  51918. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51919. import { Nullable } from "babylonjs/types";
  51920. import { Color3 } from "babylonjs/Maths/math.color";
  51921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51922. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51923. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51924. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51925. import { Engine } from "babylonjs/Engines/engine";
  51926. import { Scene } from "babylonjs/scene";
  51927. /**
  51928. * @hidden
  51929. */
  51930. export interface IMaterialClearCoatDefines {
  51931. CLEARCOAT: boolean;
  51932. CLEARCOAT_DEFAULTIOR: boolean;
  51933. CLEARCOAT_TEXTURE: boolean;
  51934. CLEARCOAT_TEXTUREDIRECTUV: number;
  51935. CLEARCOAT_BUMP: boolean;
  51936. CLEARCOAT_BUMPDIRECTUV: number;
  51937. CLEARCOAT_TINT: boolean;
  51938. CLEARCOAT_TINT_TEXTURE: boolean;
  51939. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51940. /** @hidden */
  51941. _areTexturesDirty: boolean;
  51942. }
  51943. /**
  51944. * Define the code related to the clear coat parameters of the pbr material.
  51945. */
  51946. export class PBRClearCoatConfiguration {
  51947. /**
  51948. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51949. * The default fits with a polyurethane material.
  51950. */
  51951. private static readonly _DefaultIndexOfRefraction;
  51952. private _isEnabled;
  51953. /**
  51954. * Defines if the clear coat is enabled in the material.
  51955. */
  51956. isEnabled: boolean;
  51957. /**
  51958. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51959. */
  51960. intensity: number;
  51961. /**
  51962. * Defines the clear coat layer roughness.
  51963. */
  51964. roughness: number;
  51965. private _indexOfRefraction;
  51966. /**
  51967. * Defines the index of refraction of the clear coat.
  51968. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51969. * The default fits with a polyurethane material.
  51970. * Changing the default value is more performance intensive.
  51971. */
  51972. indexOfRefraction: number;
  51973. private _texture;
  51974. /**
  51975. * Stores the clear coat values in a texture.
  51976. */
  51977. texture: Nullable<BaseTexture>;
  51978. private _bumpTexture;
  51979. /**
  51980. * Define the clear coat specific bump texture.
  51981. */
  51982. bumpTexture: Nullable<BaseTexture>;
  51983. private _isTintEnabled;
  51984. /**
  51985. * Defines if the clear coat tint is enabled in the material.
  51986. */
  51987. isTintEnabled: boolean;
  51988. /**
  51989. * Defines the clear coat tint of the material.
  51990. * This is only use if tint is enabled
  51991. */
  51992. tintColor: Color3;
  51993. /**
  51994. * Defines the distance at which the tint color should be found in the
  51995. * clear coat media.
  51996. * This is only use if tint is enabled
  51997. */
  51998. tintColorAtDistance: number;
  51999. /**
  52000. * Defines the clear coat layer thickness.
  52001. * This is only use if tint is enabled
  52002. */
  52003. tintThickness: number;
  52004. private _tintTexture;
  52005. /**
  52006. * Stores the clear tint values in a texture.
  52007. * rgb is tint
  52008. * a is a thickness factor
  52009. */
  52010. tintTexture: Nullable<BaseTexture>;
  52011. /** @hidden */
  52012. private _internalMarkAllSubMeshesAsTexturesDirty;
  52013. /** @hidden */
  52014. _markAllSubMeshesAsTexturesDirty(): void;
  52015. /**
  52016. * Instantiate a new istance of clear coat configuration.
  52017. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52018. */
  52019. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52020. /**
  52021. * Gets wehter the submesh is ready to be used or not.
  52022. * @param defines the list of "defines" to update.
  52023. * @param scene defines the scene the material belongs to.
  52024. * @param engine defines the engine the material belongs to.
  52025. * @param disableBumpMap defines wether the material disables bump or not.
  52026. * @returns - boolean indicating that the submesh is ready or not.
  52027. */
  52028. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52029. /**
  52030. * Checks to see if a texture is used in the material.
  52031. * @param defines the list of "defines" to update.
  52032. * @param scene defines the scene to the material belongs to.
  52033. */
  52034. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52035. /**
  52036. * Binds the material data.
  52037. * @param uniformBuffer defines the Uniform buffer to fill in.
  52038. * @param scene defines the scene the material belongs to.
  52039. * @param engine defines the engine the material belongs to.
  52040. * @param disableBumpMap defines wether the material disables bump or not.
  52041. * @param isFrozen defines wether the material is frozen or not.
  52042. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52043. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52044. */
  52045. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52046. /**
  52047. * Checks to see if a texture is used in the material.
  52048. * @param texture - Base texture to use.
  52049. * @returns - Boolean specifying if a texture is used in the material.
  52050. */
  52051. hasTexture(texture: BaseTexture): boolean;
  52052. /**
  52053. * Returns an array of the actively used textures.
  52054. * @param activeTextures Array of BaseTextures
  52055. */
  52056. getActiveTextures(activeTextures: BaseTexture[]): void;
  52057. /**
  52058. * Returns the animatable textures.
  52059. * @param animatables Array of animatable textures.
  52060. */
  52061. getAnimatables(animatables: IAnimatable[]): void;
  52062. /**
  52063. * Disposes the resources of the material.
  52064. * @param forceDisposeTextures - Forces the disposal of all textures.
  52065. */
  52066. dispose(forceDisposeTextures?: boolean): void;
  52067. /**
  52068. * Get the current class name of the texture useful for serialization or dynamic coding.
  52069. * @returns "PBRClearCoatConfiguration"
  52070. */
  52071. getClassName(): string;
  52072. /**
  52073. * Add fallbacks to the effect fallbacks list.
  52074. * @param defines defines the Base texture to use.
  52075. * @param fallbacks defines the current fallback list.
  52076. * @param currentRank defines the current fallback rank.
  52077. * @returns the new fallback rank.
  52078. */
  52079. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52080. /**
  52081. * Add the required uniforms to the current list.
  52082. * @param uniforms defines the current uniform list.
  52083. */
  52084. static AddUniforms(uniforms: string[]): void;
  52085. /**
  52086. * Add the required samplers to the current list.
  52087. * @param samplers defines the current sampler list.
  52088. */
  52089. static AddSamplers(samplers: string[]): void;
  52090. /**
  52091. * Add the required uniforms to the current buffer.
  52092. * @param uniformBuffer defines the current uniform buffer.
  52093. */
  52094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52095. /**
  52096. * Makes a duplicate of the current configuration into another one.
  52097. * @param clearCoatConfiguration define the config where to copy the info
  52098. */
  52099. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52100. /**
  52101. * Serializes this clear coat configuration.
  52102. * @returns - An object with the serialized config.
  52103. */
  52104. serialize(): any;
  52105. /**
  52106. * Parses a anisotropy Configuration from a serialized object.
  52107. * @param source - Serialized object.
  52108. * @param scene Defines the scene we are parsing for
  52109. * @param rootUrl Defines the rootUrl to load from
  52110. */
  52111. parse(source: any, scene: Scene, rootUrl: string): void;
  52112. }
  52113. }
  52114. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52115. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52117. import { Vector2 } from "babylonjs/Maths/math.vector";
  52118. import { Scene } from "babylonjs/scene";
  52119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52120. import { Nullable } from "babylonjs/types";
  52121. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52122. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52123. /**
  52124. * @hidden
  52125. */
  52126. export interface IMaterialAnisotropicDefines {
  52127. ANISOTROPIC: boolean;
  52128. ANISOTROPIC_TEXTURE: boolean;
  52129. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52130. MAINUV1: boolean;
  52131. _areTexturesDirty: boolean;
  52132. _needUVs: boolean;
  52133. }
  52134. /**
  52135. * Define the code related to the anisotropic parameters of the pbr material.
  52136. */
  52137. export class PBRAnisotropicConfiguration {
  52138. private _isEnabled;
  52139. /**
  52140. * Defines if the anisotropy is enabled in the material.
  52141. */
  52142. isEnabled: boolean;
  52143. /**
  52144. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52145. */
  52146. intensity: number;
  52147. /**
  52148. * Defines if the effect is along the tangents, bitangents or in between.
  52149. * By default, the effect is "strectching" the highlights along the tangents.
  52150. */
  52151. direction: Vector2;
  52152. private _texture;
  52153. /**
  52154. * Stores the anisotropy values in a texture.
  52155. * rg is direction (like normal from -1 to 1)
  52156. * b is a intensity
  52157. */
  52158. texture: Nullable<BaseTexture>;
  52159. /** @hidden */
  52160. private _internalMarkAllSubMeshesAsTexturesDirty;
  52161. /** @hidden */
  52162. _markAllSubMeshesAsTexturesDirty(): void;
  52163. /**
  52164. * Instantiate a new istance of anisotropy configuration.
  52165. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52166. */
  52167. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52168. /**
  52169. * Specifies that the submesh is ready to be used.
  52170. * @param defines the list of "defines" to update.
  52171. * @param scene defines the scene the material belongs to.
  52172. * @returns - boolean indicating that the submesh is ready or not.
  52173. */
  52174. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52175. /**
  52176. * Checks to see if a texture is used in the material.
  52177. * @param defines the list of "defines" to update.
  52178. * @param mesh the mesh we are preparing the defines for.
  52179. * @param scene defines the scene the material belongs to.
  52180. */
  52181. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52182. /**
  52183. * Binds the material data.
  52184. * @param uniformBuffer defines the Uniform buffer to fill in.
  52185. * @param scene defines the scene the material belongs to.
  52186. * @param isFrozen defines wether the material is frozen or not.
  52187. */
  52188. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52189. /**
  52190. * Checks to see if a texture is used in the material.
  52191. * @param texture - Base texture to use.
  52192. * @returns - Boolean specifying if a texture is used in the material.
  52193. */
  52194. hasTexture(texture: BaseTexture): boolean;
  52195. /**
  52196. * Returns an array of the actively used textures.
  52197. * @param activeTextures Array of BaseTextures
  52198. */
  52199. getActiveTextures(activeTextures: BaseTexture[]): void;
  52200. /**
  52201. * Returns the animatable textures.
  52202. * @param animatables Array of animatable textures.
  52203. */
  52204. getAnimatables(animatables: IAnimatable[]): void;
  52205. /**
  52206. * Disposes the resources of the material.
  52207. * @param forceDisposeTextures - Forces the disposal of all textures.
  52208. */
  52209. dispose(forceDisposeTextures?: boolean): void;
  52210. /**
  52211. * Get the current class name of the texture useful for serialization or dynamic coding.
  52212. * @returns "PBRAnisotropicConfiguration"
  52213. */
  52214. getClassName(): string;
  52215. /**
  52216. * Add fallbacks to the effect fallbacks list.
  52217. * @param defines defines the Base texture to use.
  52218. * @param fallbacks defines the current fallback list.
  52219. * @param currentRank defines the current fallback rank.
  52220. * @returns the new fallback rank.
  52221. */
  52222. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52223. /**
  52224. * Add the required uniforms to the current list.
  52225. * @param uniforms defines the current uniform list.
  52226. */
  52227. static AddUniforms(uniforms: string[]): void;
  52228. /**
  52229. * Add the required uniforms to the current buffer.
  52230. * @param uniformBuffer defines the current uniform buffer.
  52231. */
  52232. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52233. /**
  52234. * Add the required samplers to the current list.
  52235. * @param samplers defines the current sampler list.
  52236. */
  52237. static AddSamplers(samplers: string[]): void;
  52238. /**
  52239. * Makes a duplicate of the current configuration into another one.
  52240. * @param anisotropicConfiguration define the config where to copy the info
  52241. */
  52242. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52243. /**
  52244. * Serializes this anisotropy configuration.
  52245. * @returns - An object with the serialized config.
  52246. */
  52247. serialize(): any;
  52248. /**
  52249. * Parses a anisotropy Configuration from a serialized object.
  52250. * @param source - Serialized object.
  52251. * @param scene Defines the scene we are parsing for
  52252. * @param rootUrl Defines the rootUrl to load from
  52253. */
  52254. parse(source: any, scene: Scene, rootUrl: string): void;
  52255. }
  52256. }
  52257. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52258. import { Scene } from "babylonjs/scene";
  52259. /**
  52260. * @hidden
  52261. */
  52262. export interface IMaterialBRDFDefines {
  52263. BRDF_V_HEIGHT_CORRELATED: boolean;
  52264. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52265. SPHERICAL_HARMONICS: boolean;
  52266. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52267. /** @hidden */
  52268. _areMiscDirty: boolean;
  52269. }
  52270. /**
  52271. * Define the code related to the BRDF parameters of the pbr material.
  52272. */
  52273. export class PBRBRDFConfiguration {
  52274. /**
  52275. * Default value used for the energy conservation.
  52276. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52277. */
  52278. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52279. /**
  52280. * Default value used for the Smith Visibility Height Correlated mode.
  52281. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52282. */
  52283. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52284. /**
  52285. * Default value used for the IBL diffuse part.
  52286. * This can help switching back to the polynomials mode globally which is a tiny bit
  52287. * less GPU intensive at the drawback of a lower quality.
  52288. */
  52289. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52290. /**
  52291. * Default value used for activating energy conservation for the specular workflow.
  52292. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52293. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52294. */
  52295. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52296. private _useEnergyConservation;
  52297. /**
  52298. * Defines if the material uses energy conservation.
  52299. */
  52300. useEnergyConservation: boolean;
  52301. private _useSmithVisibilityHeightCorrelated;
  52302. /**
  52303. * LEGACY Mode set to false
  52304. * Defines if the material uses height smith correlated visibility term.
  52305. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52306. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52307. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52308. * Not relying on height correlated will also disable energy conservation.
  52309. */
  52310. useSmithVisibilityHeightCorrelated: boolean;
  52311. private _useSphericalHarmonics;
  52312. /**
  52313. * LEGACY Mode set to false
  52314. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52315. * diffuse part of the IBL.
  52316. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52317. * to the ground truth.
  52318. */
  52319. useSphericalHarmonics: boolean;
  52320. private _useSpecularGlossinessInputEnergyConservation;
  52321. /**
  52322. * Defines if the material uses energy conservation, when the specular workflow is active.
  52323. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52324. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52325. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52326. */
  52327. useSpecularGlossinessInputEnergyConservation: boolean;
  52328. /** @hidden */
  52329. private _internalMarkAllSubMeshesAsMiscDirty;
  52330. /** @hidden */
  52331. _markAllSubMeshesAsMiscDirty(): void;
  52332. /**
  52333. * Instantiate a new istance of clear coat configuration.
  52334. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52335. */
  52336. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52337. /**
  52338. * Checks to see if a texture is used in the material.
  52339. * @param defines the list of "defines" to update.
  52340. */
  52341. prepareDefines(defines: IMaterialBRDFDefines): void;
  52342. /**
  52343. * Get the current class name of the texture useful for serialization or dynamic coding.
  52344. * @returns "PBRClearCoatConfiguration"
  52345. */
  52346. getClassName(): string;
  52347. /**
  52348. * Makes a duplicate of the current configuration into another one.
  52349. * @param brdfConfiguration define the config where to copy the info
  52350. */
  52351. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52352. /**
  52353. * Serializes this BRDF configuration.
  52354. * @returns - An object with the serialized config.
  52355. */
  52356. serialize(): any;
  52357. /**
  52358. * Parses a anisotropy Configuration from a serialized object.
  52359. * @param source - Serialized object.
  52360. * @param scene Defines the scene we are parsing for
  52361. * @param rootUrl Defines the rootUrl to load from
  52362. */
  52363. parse(source: any, scene: Scene, rootUrl: string): void;
  52364. }
  52365. }
  52366. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52367. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52368. import { Color3 } from "babylonjs/Maths/math.color";
  52369. import { Scene } from "babylonjs/scene";
  52370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52371. import { Nullable } from "babylonjs/types";
  52372. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52373. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52374. /**
  52375. * @hidden
  52376. */
  52377. export interface IMaterialSheenDefines {
  52378. SHEEN: boolean;
  52379. SHEEN_TEXTURE: boolean;
  52380. SHEEN_TEXTUREDIRECTUV: number;
  52381. SHEEN_LINKWITHALBEDO: boolean;
  52382. /** @hidden */
  52383. _areTexturesDirty: boolean;
  52384. }
  52385. /**
  52386. * Define the code related to the Sheen parameters of the pbr material.
  52387. */
  52388. export class PBRSheenConfiguration {
  52389. private _isEnabled;
  52390. /**
  52391. * Defines if the material uses sheen.
  52392. */
  52393. isEnabled: boolean;
  52394. private _linkSheenWithAlbedo;
  52395. /**
  52396. * Defines if the sheen is linked to the sheen color.
  52397. */
  52398. linkSheenWithAlbedo: boolean;
  52399. /**
  52400. * Defines the sheen intensity.
  52401. */
  52402. intensity: number;
  52403. /**
  52404. * Defines the sheen color.
  52405. */
  52406. color: Color3;
  52407. private _texture;
  52408. /**
  52409. * Stores the sheen tint values in a texture.
  52410. * rgb is tint
  52411. * a is a intensity
  52412. */
  52413. texture: Nullable<BaseTexture>;
  52414. /** @hidden */
  52415. private _internalMarkAllSubMeshesAsTexturesDirty;
  52416. /** @hidden */
  52417. _markAllSubMeshesAsTexturesDirty(): void;
  52418. /**
  52419. * Instantiate a new istance of clear coat configuration.
  52420. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52421. */
  52422. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52423. /**
  52424. * Specifies that the submesh is ready to be used.
  52425. * @param defines the list of "defines" to update.
  52426. * @param scene defines the scene the material belongs to.
  52427. * @returns - boolean indicating that the submesh is ready or not.
  52428. */
  52429. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52430. /**
  52431. * Checks to see if a texture is used in the material.
  52432. * @param defines the list of "defines" to update.
  52433. * @param scene defines the scene the material belongs to.
  52434. */
  52435. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52436. /**
  52437. * Binds the material data.
  52438. * @param uniformBuffer defines the Uniform buffer to fill in.
  52439. * @param scene defines the scene the material belongs to.
  52440. * @param isFrozen defines wether the material is frozen or not.
  52441. */
  52442. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52443. /**
  52444. * Checks to see if a texture is used in the material.
  52445. * @param texture - Base texture to use.
  52446. * @returns - Boolean specifying if a texture is used in the material.
  52447. */
  52448. hasTexture(texture: BaseTexture): boolean;
  52449. /**
  52450. * Returns an array of the actively used textures.
  52451. * @param activeTextures Array of BaseTextures
  52452. */
  52453. getActiveTextures(activeTextures: BaseTexture[]): void;
  52454. /**
  52455. * Returns the animatable textures.
  52456. * @param animatables Array of animatable textures.
  52457. */
  52458. getAnimatables(animatables: IAnimatable[]): void;
  52459. /**
  52460. * Disposes the resources of the material.
  52461. * @param forceDisposeTextures - Forces the disposal of all textures.
  52462. */
  52463. dispose(forceDisposeTextures?: boolean): void;
  52464. /**
  52465. * Get the current class name of the texture useful for serialization or dynamic coding.
  52466. * @returns "PBRSheenConfiguration"
  52467. */
  52468. getClassName(): string;
  52469. /**
  52470. * Add fallbacks to the effect fallbacks list.
  52471. * @param defines defines the Base texture to use.
  52472. * @param fallbacks defines the current fallback list.
  52473. * @param currentRank defines the current fallback rank.
  52474. * @returns the new fallback rank.
  52475. */
  52476. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52477. /**
  52478. * Add the required uniforms to the current list.
  52479. * @param uniforms defines the current uniform list.
  52480. */
  52481. static AddUniforms(uniforms: string[]): void;
  52482. /**
  52483. * Add the required uniforms to the current buffer.
  52484. * @param uniformBuffer defines the current uniform buffer.
  52485. */
  52486. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52487. /**
  52488. * Add the required samplers to the current list.
  52489. * @param samplers defines the current sampler list.
  52490. */
  52491. static AddSamplers(samplers: string[]): void;
  52492. /**
  52493. * Makes a duplicate of the current configuration into another one.
  52494. * @param sheenConfiguration define the config where to copy the info
  52495. */
  52496. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52497. /**
  52498. * Serializes this BRDF configuration.
  52499. * @returns - An object with the serialized config.
  52500. */
  52501. serialize(): any;
  52502. /**
  52503. * Parses a anisotropy Configuration from a serialized object.
  52504. * @param source - Serialized object.
  52505. * @param scene Defines the scene we are parsing for
  52506. * @param rootUrl Defines the rootUrl to load from
  52507. */
  52508. parse(source: any, scene: Scene, rootUrl: string): void;
  52509. }
  52510. }
  52511. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52512. import { Nullable } from "babylonjs/types";
  52513. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52514. import { Color3 } from "babylonjs/Maths/math.color";
  52515. import { SmartArray } from "babylonjs/Misc/smartArray";
  52516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52517. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52518. import { Effect } from "babylonjs/Materials/effect";
  52519. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52520. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52521. import { Engine } from "babylonjs/Engines/engine";
  52522. import { Scene } from "babylonjs/scene";
  52523. /**
  52524. * @hidden
  52525. */
  52526. export interface IMaterialSubSurfaceDefines {
  52527. SUBSURFACE: boolean;
  52528. SS_REFRACTION: boolean;
  52529. SS_TRANSLUCENCY: boolean;
  52530. SS_SCATERRING: boolean;
  52531. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52532. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52533. SS_REFRACTIONMAP_3D: boolean;
  52534. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52535. SS_LODINREFRACTIONALPHA: boolean;
  52536. SS_GAMMAREFRACTION: boolean;
  52537. SS_RGBDREFRACTION: boolean;
  52538. SS_LINEARSPECULARREFRACTION: boolean;
  52539. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52540. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52541. /** @hidden */
  52542. _areTexturesDirty: boolean;
  52543. }
  52544. /**
  52545. * Define the code related to the sub surface parameters of the pbr material.
  52546. */
  52547. export class PBRSubSurfaceConfiguration {
  52548. private _isRefractionEnabled;
  52549. /**
  52550. * Defines if the refraction is enabled in the material.
  52551. */
  52552. isRefractionEnabled: boolean;
  52553. private _isTranslucencyEnabled;
  52554. /**
  52555. * Defines if the translucency is enabled in the material.
  52556. */
  52557. isTranslucencyEnabled: boolean;
  52558. private _isScatteringEnabled;
  52559. /**
  52560. * Defines the refraction intensity of the material.
  52561. * The refraction when enabled replaces the Diffuse part of the material.
  52562. * The intensity helps transitionning between diffuse and refraction.
  52563. */
  52564. refractionIntensity: number;
  52565. /**
  52566. * Defines the translucency intensity of the material.
  52567. * When translucency has been enabled, this defines how much of the "translucency"
  52568. * is addded to the diffuse part of the material.
  52569. */
  52570. translucencyIntensity: number;
  52571. /**
  52572. * Defines the scattering intensity of the material.
  52573. * When scattering has been enabled, this defines how much of the "scattered light"
  52574. * is addded to the diffuse part of the material.
  52575. */
  52576. scatteringIntensity: number;
  52577. private _thicknessTexture;
  52578. /**
  52579. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52580. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52581. * 0 would mean minimumThickness
  52582. * 1 would mean maximumThickness
  52583. * The other channels might be use as a mask to vary the different effects intensity.
  52584. */
  52585. thicknessTexture: Nullable<BaseTexture>;
  52586. private _refractionTexture;
  52587. /**
  52588. * Defines the texture to use for refraction.
  52589. */
  52590. refractionTexture: Nullable<BaseTexture>;
  52591. private _indexOfRefraction;
  52592. /**
  52593. * Defines the index of refraction used in the material.
  52594. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52595. */
  52596. indexOfRefraction: number;
  52597. private _invertRefractionY;
  52598. /**
  52599. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52600. */
  52601. invertRefractionY: boolean;
  52602. private _linkRefractionWithTransparency;
  52603. /**
  52604. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52605. * Materials half opaque for instance using refraction could benefit from this control.
  52606. */
  52607. linkRefractionWithTransparency: boolean;
  52608. /**
  52609. * Defines the minimum thickness stored in the thickness map.
  52610. * If no thickness map is defined, this value will be used to simulate thickness.
  52611. */
  52612. minimumThickness: number;
  52613. /**
  52614. * Defines the maximum thickness stored in the thickness map.
  52615. */
  52616. maximumThickness: number;
  52617. /**
  52618. * Defines the volume tint of the material.
  52619. * This is used for both translucency and scattering.
  52620. */
  52621. tintColor: Color3;
  52622. /**
  52623. * Defines the distance at which the tint color should be found in the media.
  52624. * This is used for refraction only.
  52625. */
  52626. tintColorAtDistance: number;
  52627. /**
  52628. * Defines how far each channel transmit through the media.
  52629. * It is defined as a color to simplify it selection.
  52630. */
  52631. diffusionDistance: Color3;
  52632. private _useMaskFromThicknessTexture;
  52633. /**
  52634. * Stores the intensity of the different subsurface effects in the thickness texture.
  52635. * * the green channel is the translucency intensity.
  52636. * * the blue channel is the scattering intensity.
  52637. * * the alpha channel is the refraction intensity.
  52638. */
  52639. useMaskFromThicknessTexture: boolean;
  52640. /** @hidden */
  52641. private _internalMarkAllSubMeshesAsTexturesDirty;
  52642. /** @hidden */
  52643. _markAllSubMeshesAsTexturesDirty(): void;
  52644. /**
  52645. * Instantiate a new istance of sub surface configuration.
  52646. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52647. */
  52648. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52649. /**
  52650. * Gets wehter the submesh is ready to be used or not.
  52651. * @param defines the list of "defines" to update.
  52652. * @param scene defines the scene the material belongs to.
  52653. * @returns - boolean indicating that the submesh is ready or not.
  52654. */
  52655. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52656. /**
  52657. * Checks to see if a texture is used in the material.
  52658. * @param defines the list of "defines" to update.
  52659. * @param scene defines the scene to the material belongs to.
  52660. */
  52661. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52662. /**
  52663. * Binds the material data.
  52664. * @param uniformBuffer defines the Uniform buffer to fill in.
  52665. * @param scene defines the scene the material belongs to.
  52666. * @param engine defines the engine the material belongs to.
  52667. * @param isFrozen defines wether the material is frozen or not.
  52668. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52669. */
  52670. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52671. /**
  52672. * Unbinds the material from the mesh.
  52673. * @param activeEffect defines the effect that should be unbound from.
  52674. * @returns true if unbound, otherwise false
  52675. */
  52676. unbind(activeEffect: Effect): boolean;
  52677. /**
  52678. * Returns the texture used for refraction or null if none is used.
  52679. * @param scene defines the scene the material belongs to.
  52680. * @returns - Refraction texture if present. If no refraction texture and refraction
  52681. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52682. */
  52683. private _getRefractionTexture;
  52684. /**
  52685. * Returns true if alpha blending should be disabled.
  52686. */
  52687. get disableAlphaBlending(): boolean;
  52688. /**
  52689. * Fills the list of render target textures.
  52690. * @param renderTargets the list of render targets to update
  52691. */
  52692. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52693. /**
  52694. * Checks to see if a texture is used in the material.
  52695. * @param texture - Base texture to use.
  52696. * @returns - Boolean specifying if a texture is used in the material.
  52697. */
  52698. hasTexture(texture: BaseTexture): boolean;
  52699. /**
  52700. * Gets a boolean indicating that current material needs to register RTT
  52701. * @returns true if this uses a render target otherwise false.
  52702. */
  52703. hasRenderTargetTextures(): boolean;
  52704. /**
  52705. * Returns an array of the actively used textures.
  52706. * @param activeTextures Array of BaseTextures
  52707. */
  52708. getActiveTextures(activeTextures: BaseTexture[]): void;
  52709. /**
  52710. * Returns the animatable textures.
  52711. * @param animatables Array of animatable textures.
  52712. */
  52713. getAnimatables(animatables: IAnimatable[]): void;
  52714. /**
  52715. * Disposes the resources of the material.
  52716. * @param forceDisposeTextures - Forces the disposal of all textures.
  52717. */
  52718. dispose(forceDisposeTextures?: boolean): void;
  52719. /**
  52720. * Get the current class name of the texture useful for serialization or dynamic coding.
  52721. * @returns "PBRSubSurfaceConfiguration"
  52722. */
  52723. getClassName(): string;
  52724. /**
  52725. * Add fallbacks to the effect fallbacks list.
  52726. * @param defines defines the Base texture to use.
  52727. * @param fallbacks defines the current fallback list.
  52728. * @param currentRank defines the current fallback rank.
  52729. * @returns the new fallback rank.
  52730. */
  52731. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52732. /**
  52733. * Add the required uniforms to the current list.
  52734. * @param uniforms defines the current uniform list.
  52735. */
  52736. static AddUniforms(uniforms: string[]): void;
  52737. /**
  52738. * Add the required samplers to the current list.
  52739. * @param samplers defines the current sampler list.
  52740. */
  52741. static AddSamplers(samplers: string[]): void;
  52742. /**
  52743. * Add the required uniforms to the current buffer.
  52744. * @param uniformBuffer defines the current uniform buffer.
  52745. */
  52746. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52747. /**
  52748. * Makes a duplicate of the current configuration into another one.
  52749. * @param configuration define the config where to copy the info
  52750. */
  52751. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52752. /**
  52753. * Serializes this Sub Surface configuration.
  52754. * @returns - An object with the serialized config.
  52755. */
  52756. serialize(): any;
  52757. /**
  52758. * Parses a anisotropy Configuration from a serialized object.
  52759. * @param source - Serialized object.
  52760. * @param scene Defines the scene we are parsing for
  52761. * @param rootUrl Defines the rootUrl to load from
  52762. */
  52763. parse(source: any, scene: Scene, rootUrl: string): void;
  52764. }
  52765. }
  52766. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52767. /** @hidden */
  52768. export var pbrFragmentDeclaration: {
  52769. name: string;
  52770. shader: string;
  52771. };
  52772. }
  52773. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52774. /** @hidden */
  52775. export var pbrUboDeclaration: {
  52776. name: string;
  52777. shader: string;
  52778. };
  52779. }
  52780. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52781. /** @hidden */
  52782. export var pbrFragmentExtraDeclaration: {
  52783. name: string;
  52784. shader: string;
  52785. };
  52786. }
  52787. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52788. /** @hidden */
  52789. export var pbrFragmentSamplersDeclaration: {
  52790. name: string;
  52791. shader: string;
  52792. };
  52793. }
  52794. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52795. /** @hidden */
  52796. export var pbrHelperFunctions: {
  52797. name: string;
  52798. shader: string;
  52799. };
  52800. }
  52801. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52802. /** @hidden */
  52803. export var harmonicsFunctions: {
  52804. name: string;
  52805. shader: string;
  52806. };
  52807. }
  52808. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52809. /** @hidden */
  52810. export var pbrDirectLightingSetupFunctions: {
  52811. name: string;
  52812. shader: string;
  52813. };
  52814. }
  52815. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52816. /** @hidden */
  52817. export var pbrDirectLightingFalloffFunctions: {
  52818. name: string;
  52819. shader: string;
  52820. };
  52821. }
  52822. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52823. /** @hidden */
  52824. export var pbrBRDFFunctions: {
  52825. name: string;
  52826. shader: string;
  52827. };
  52828. }
  52829. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52830. /** @hidden */
  52831. export var pbrDirectLightingFunctions: {
  52832. name: string;
  52833. shader: string;
  52834. };
  52835. }
  52836. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52837. /** @hidden */
  52838. export var pbrIBLFunctions: {
  52839. name: string;
  52840. shader: string;
  52841. };
  52842. }
  52843. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52844. /** @hidden */
  52845. export var pbrDebug: {
  52846. name: string;
  52847. shader: string;
  52848. };
  52849. }
  52850. declare module "babylonjs/Shaders/pbr.fragment" {
  52851. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52852. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52853. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52856. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52857. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52858. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52859. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52860. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52861. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52862. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52863. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52864. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52865. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52866. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52867. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52868. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52869. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52870. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52871. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52872. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52874. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52875. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52876. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52877. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52878. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52879. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52880. /** @hidden */
  52881. export var pbrPixelShader: {
  52882. name: string;
  52883. shader: string;
  52884. };
  52885. }
  52886. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52887. /** @hidden */
  52888. export var pbrVertexDeclaration: {
  52889. name: string;
  52890. shader: string;
  52891. };
  52892. }
  52893. declare module "babylonjs/Shaders/pbr.vertex" {
  52894. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52895. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52896. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52897. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52900. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52907. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52909. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52910. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52911. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52912. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52913. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52914. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52915. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52916. /** @hidden */
  52917. export var pbrVertexShader: {
  52918. name: string;
  52919. shader: string;
  52920. };
  52921. }
  52922. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52923. import { Nullable } from "babylonjs/types";
  52924. import { Scene } from "babylonjs/scene";
  52925. import { Matrix } from "babylonjs/Maths/math.vector";
  52926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52928. import { Mesh } from "babylonjs/Meshes/mesh";
  52929. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52930. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52931. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52932. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52933. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52934. import { Color3 } from "babylonjs/Maths/math.color";
  52935. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52936. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52937. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52938. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52941. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52942. import "babylonjs/Shaders/pbr.fragment";
  52943. import "babylonjs/Shaders/pbr.vertex";
  52944. /**
  52945. * Manages the defines for the PBR Material.
  52946. * @hidden
  52947. */
  52948. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52949. PBR: boolean;
  52950. MAINUV1: boolean;
  52951. MAINUV2: boolean;
  52952. UV1: boolean;
  52953. UV2: boolean;
  52954. ALBEDO: boolean;
  52955. GAMMAALBEDO: boolean;
  52956. ALBEDODIRECTUV: number;
  52957. VERTEXCOLOR: boolean;
  52958. AMBIENT: boolean;
  52959. AMBIENTDIRECTUV: number;
  52960. AMBIENTINGRAYSCALE: boolean;
  52961. OPACITY: boolean;
  52962. VERTEXALPHA: boolean;
  52963. OPACITYDIRECTUV: number;
  52964. OPACITYRGB: boolean;
  52965. ALPHATEST: boolean;
  52966. DEPTHPREPASS: boolean;
  52967. ALPHABLEND: boolean;
  52968. ALPHAFROMALBEDO: boolean;
  52969. ALPHATESTVALUE: string;
  52970. SPECULAROVERALPHA: boolean;
  52971. RADIANCEOVERALPHA: boolean;
  52972. ALPHAFRESNEL: boolean;
  52973. LINEARALPHAFRESNEL: boolean;
  52974. PREMULTIPLYALPHA: boolean;
  52975. EMISSIVE: boolean;
  52976. EMISSIVEDIRECTUV: number;
  52977. REFLECTIVITY: boolean;
  52978. REFLECTIVITYDIRECTUV: number;
  52979. SPECULARTERM: boolean;
  52980. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52981. MICROSURFACEAUTOMATIC: boolean;
  52982. LODBASEDMICROSFURACE: boolean;
  52983. MICROSURFACEMAP: boolean;
  52984. MICROSURFACEMAPDIRECTUV: number;
  52985. METALLICWORKFLOW: boolean;
  52986. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52987. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52988. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52989. AOSTOREINMETALMAPRED: boolean;
  52990. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52991. ENVIRONMENTBRDF: boolean;
  52992. ENVIRONMENTBRDF_RGBD: boolean;
  52993. NORMAL: boolean;
  52994. TANGENT: boolean;
  52995. BUMP: boolean;
  52996. BUMPDIRECTUV: number;
  52997. OBJECTSPACE_NORMALMAP: boolean;
  52998. PARALLAX: boolean;
  52999. PARALLAXOCCLUSION: boolean;
  53000. NORMALXYSCALE: boolean;
  53001. LIGHTMAP: boolean;
  53002. LIGHTMAPDIRECTUV: number;
  53003. USELIGHTMAPASSHADOWMAP: boolean;
  53004. GAMMALIGHTMAP: boolean;
  53005. RGBDLIGHTMAP: boolean;
  53006. REFLECTION: boolean;
  53007. REFLECTIONMAP_3D: boolean;
  53008. REFLECTIONMAP_SPHERICAL: boolean;
  53009. REFLECTIONMAP_PLANAR: boolean;
  53010. REFLECTIONMAP_CUBIC: boolean;
  53011. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53012. REFLECTIONMAP_PROJECTION: boolean;
  53013. REFLECTIONMAP_SKYBOX: boolean;
  53014. REFLECTIONMAP_EXPLICIT: boolean;
  53015. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53016. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53017. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53018. INVERTCUBICMAP: boolean;
  53019. USESPHERICALFROMREFLECTIONMAP: boolean;
  53020. USEIRRADIANCEMAP: boolean;
  53021. SPHERICAL_HARMONICS: boolean;
  53022. USESPHERICALINVERTEX: boolean;
  53023. REFLECTIONMAP_OPPOSITEZ: boolean;
  53024. LODINREFLECTIONALPHA: boolean;
  53025. GAMMAREFLECTION: boolean;
  53026. RGBDREFLECTION: boolean;
  53027. LINEARSPECULARREFLECTION: boolean;
  53028. RADIANCEOCCLUSION: boolean;
  53029. HORIZONOCCLUSION: boolean;
  53030. INSTANCES: boolean;
  53031. NUM_BONE_INFLUENCERS: number;
  53032. BonesPerMesh: number;
  53033. BONETEXTURE: boolean;
  53034. NONUNIFORMSCALING: boolean;
  53035. MORPHTARGETS: boolean;
  53036. MORPHTARGETS_NORMAL: boolean;
  53037. MORPHTARGETS_TANGENT: boolean;
  53038. MORPHTARGETS_UV: boolean;
  53039. NUM_MORPH_INFLUENCERS: number;
  53040. IMAGEPROCESSING: boolean;
  53041. VIGNETTE: boolean;
  53042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53043. VIGNETTEBLENDMODEOPAQUE: boolean;
  53044. TONEMAPPING: boolean;
  53045. TONEMAPPING_ACES: boolean;
  53046. CONTRAST: boolean;
  53047. COLORCURVES: boolean;
  53048. COLORGRADING: boolean;
  53049. COLORGRADING3D: boolean;
  53050. SAMPLER3DGREENDEPTH: boolean;
  53051. SAMPLER3DBGRMAP: boolean;
  53052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53053. EXPOSURE: boolean;
  53054. MULTIVIEW: boolean;
  53055. USEPHYSICALLIGHTFALLOFF: boolean;
  53056. USEGLTFLIGHTFALLOFF: boolean;
  53057. TWOSIDEDLIGHTING: boolean;
  53058. SHADOWFLOAT: boolean;
  53059. CLIPPLANE: boolean;
  53060. CLIPPLANE2: boolean;
  53061. CLIPPLANE3: boolean;
  53062. CLIPPLANE4: boolean;
  53063. CLIPPLANE5: boolean;
  53064. CLIPPLANE6: boolean;
  53065. POINTSIZE: boolean;
  53066. FOG: boolean;
  53067. LOGARITHMICDEPTH: boolean;
  53068. FORCENORMALFORWARD: boolean;
  53069. SPECULARAA: boolean;
  53070. CLEARCOAT: boolean;
  53071. CLEARCOAT_DEFAULTIOR: boolean;
  53072. CLEARCOAT_TEXTURE: boolean;
  53073. CLEARCOAT_TEXTUREDIRECTUV: number;
  53074. CLEARCOAT_BUMP: boolean;
  53075. CLEARCOAT_BUMPDIRECTUV: number;
  53076. CLEARCOAT_TINT: boolean;
  53077. CLEARCOAT_TINT_TEXTURE: boolean;
  53078. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53079. ANISOTROPIC: boolean;
  53080. ANISOTROPIC_TEXTURE: boolean;
  53081. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53082. BRDF_V_HEIGHT_CORRELATED: boolean;
  53083. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53084. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53085. SHEEN: boolean;
  53086. SHEEN_TEXTURE: boolean;
  53087. SHEEN_TEXTUREDIRECTUV: number;
  53088. SHEEN_LINKWITHALBEDO: boolean;
  53089. SUBSURFACE: boolean;
  53090. SS_REFRACTION: boolean;
  53091. SS_TRANSLUCENCY: boolean;
  53092. SS_SCATERRING: boolean;
  53093. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53094. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53095. SS_REFRACTIONMAP_3D: boolean;
  53096. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53097. SS_LODINREFRACTIONALPHA: boolean;
  53098. SS_GAMMAREFRACTION: boolean;
  53099. SS_RGBDREFRACTION: boolean;
  53100. SS_LINEARSPECULARREFRACTION: boolean;
  53101. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53102. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53103. UNLIT: boolean;
  53104. DEBUGMODE: number;
  53105. /**
  53106. * Initializes the PBR Material defines.
  53107. */
  53108. constructor();
  53109. /**
  53110. * Resets the PBR Material defines.
  53111. */
  53112. reset(): void;
  53113. }
  53114. /**
  53115. * The Physically based material base class of BJS.
  53116. *
  53117. * This offers the main features of a standard PBR material.
  53118. * For more information, please refer to the documentation :
  53119. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53120. */
  53121. export abstract class PBRBaseMaterial extends PushMaterial {
  53122. /**
  53123. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53124. */
  53125. static readonly PBRMATERIAL_OPAQUE: number;
  53126. /**
  53127. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53128. */
  53129. static readonly PBRMATERIAL_ALPHATEST: number;
  53130. /**
  53131. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53132. */
  53133. static readonly PBRMATERIAL_ALPHABLEND: number;
  53134. /**
  53135. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53136. * They are also discarded below the alpha cutoff threshold to improve performances.
  53137. */
  53138. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53139. /**
  53140. * Defines the default value of how much AO map is occluding the analytical lights
  53141. * (point spot...).
  53142. */
  53143. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53144. /**
  53145. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53146. */
  53147. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53148. /**
  53149. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53150. * to enhance interoperability with other engines.
  53151. */
  53152. static readonly LIGHTFALLOFF_GLTF: number;
  53153. /**
  53154. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53155. * to enhance interoperability with other materials.
  53156. */
  53157. static readonly LIGHTFALLOFF_STANDARD: number;
  53158. /**
  53159. * Intensity of the direct lights e.g. the four lights available in your scene.
  53160. * This impacts both the direct diffuse and specular highlights.
  53161. */
  53162. protected _directIntensity: number;
  53163. /**
  53164. * Intensity of the emissive part of the material.
  53165. * This helps controlling the emissive effect without modifying the emissive color.
  53166. */
  53167. protected _emissiveIntensity: number;
  53168. /**
  53169. * Intensity of the environment e.g. how much the environment will light the object
  53170. * either through harmonics for rough material or through the refelction for shiny ones.
  53171. */
  53172. protected _environmentIntensity: number;
  53173. /**
  53174. * This is a special control allowing the reduction of the specular highlights coming from the
  53175. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53176. */
  53177. protected _specularIntensity: number;
  53178. /**
  53179. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53180. */
  53181. private _lightingInfos;
  53182. /**
  53183. * Debug Control allowing disabling the bump map on this material.
  53184. */
  53185. protected _disableBumpMap: boolean;
  53186. /**
  53187. * AKA Diffuse Texture in standard nomenclature.
  53188. */
  53189. protected _albedoTexture: Nullable<BaseTexture>;
  53190. /**
  53191. * AKA Occlusion Texture in other nomenclature.
  53192. */
  53193. protected _ambientTexture: Nullable<BaseTexture>;
  53194. /**
  53195. * AKA Occlusion Texture Intensity in other nomenclature.
  53196. */
  53197. protected _ambientTextureStrength: number;
  53198. /**
  53199. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53200. * 1 means it completely occludes it
  53201. * 0 mean it has no impact
  53202. */
  53203. protected _ambientTextureImpactOnAnalyticalLights: number;
  53204. /**
  53205. * Stores the alpha values in a texture.
  53206. */
  53207. protected _opacityTexture: Nullable<BaseTexture>;
  53208. /**
  53209. * Stores the reflection values in a texture.
  53210. */
  53211. protected _reflectionTexture: Nullable<BaseTexture>;
  53212. /**
  53213. * Stores the emissive values in a texture.
  53214. */
  53215. protected _emissiveTexture: Nullable<BaseTexture>;
  53216. /**
  53217. * AKA Specular texture in other nomenclature.
  53218. */
  53219. protected _reflectivityTexture: Nullable<BaseTexture>;
  53220. /**
  53221. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53222. */
  53223. protected _metallicTexture: Nullable<BaseTexture>;
  53224. /**
  53225. * Specifies the metallic scalar of the metallic/roughness workflow.
  53226. * Can also be used to scale the metalness values of the metallic texture.
  53227. */
  53228. protected _metallic: Nullable<number>;
  53229. /**
  53230. * Specifies the roughness scalar of the metallic/roughness workflow.
  53231. * Can also be used to scale the roughness values of the metallic texture.
  53232. */
  53233. protected _roughness: Nullable<number>;
  53234. /**
  53235. * Specifies the an F0 factor to help configuring the material F0.
  53236. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53237. * to 0.5 the previously hard coded value stays the same.
  53238. * Can also be used to scale the F0 values of the metallic texture.
  53239. */
  53240. protected _metallicF0Factor: number;
  53241. /**
  53242. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53243. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53244. * your expectation as it multiplies with the texture data.
  53245. */
  53246. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53247. /**
  53248. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53249. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53250. */
  53251. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53252. /**
  53253. * Stores surface normal data used to displace a mesh in a texture.
  53254. */
  53255. protected _bumpTexture: Nullable<BaseTexture>;
  53256. /**
  53257. * Stores the pre-calculated light information of a mesh in a texture.
  53258. */
  53259. protected _lightmapTexture: Nullable<BaseTexture>;
  53260. /**
  53261. * The color of a material in ambient lighting.
  53262. */
  53263. protected _ambientColor: Color3;
  53264. /**
  53265. * AKA Diffuse Color in other nomenclature.
  53266. */
  53267. protected _albedoColor: Color3;
  53268. /**
  53269. * AKA Specular Color in other nomenclature.
  53270. */
  53271. protected _reflectivityColor: Color3;
  53272. /**
  53273. * The color applied when light is reflected from a material.
  53274. */
  53275. protected _reflectionColor: Color3;
  53276. /**
  53277. * The color applied when light is emitted from a material.
  53278. */
  53279. protected _emissiveColor: Color3;
  53280. /**
  53281. * AKA Glossiness in other nomenclature.
  53282. */
  53283. protected _microSurface: number;
  53284. /**
  53285. * Specifies that the material will use the light map as a show map.
  53286. */
  53287. protected _useLightmapAsShadowmap: boolean;
  53288. /**
  53289. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53290. * makes the reflect vector face the model (under horizon).
  53291. */
  53292. protected _useHorizonOcclusion: boolean;
  53293. /**
  53294. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53295. * too much the area relying on ambient texture to define their ambient occlusion.
  53296. */
  53297. protected _useRadianceOcclusion: boolean;
  53298. /**
  53299. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53300. */
  53301. protected _useAlphaFromAlbedoTexture: boolean;
  53302. /**
  53303. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53304. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53305. */
  53306. protected _useSpecularOverAlpha: boolean;
  53307. /**
  53308. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53309. */
  53310. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53311. /**
  53312. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53313. */
  53314. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53315. /**
  53316. * Specifies if the metallic texture contains the roughness information in its green channel.
  53317. */
  53318. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53319. /**
  53320. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53321. */
  53322. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53323. /**
  53324. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53325. */
  53326. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53327. /**
  53328. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53329. */
  53330. protected _useAmbientInGrayScale: boolean;
  53331. /**
  53332. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53333. * The material will try to infer what glossiness each pixel should be.
  53334. */
  53335. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53336. /**
  53337. * Defines the falloff type used in this material.
  53338. * It by default is Physical.
  53339. */
  53340. protected _lightFalloff: number;
  53341. /**
  53342. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53343. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53344. */
  53345. protected _useRadianceOverAlpha: boolean;
  53346. /**
  53347. * Allows using an object space normal map (instead of tangent space).
  53348. */
  53349. protected _useObjectSpaceNormalMap: boolean;
  53350. /**
  53351. * Allows using the bump map in parallax mode.
  53352. */
  53353. protected _useParallax: boolean;
  53354. /**
  53355. * Allows using the bump map in parallax occlusion mode.
  53356. */
  53357. protected _useParallaxOcclusion: boolean;
  53358. /**
  53359. * Controls the scale bias of the parallax mode.
  53360. */
  53361. protected _parallaxScaleBias: number;
  53362. /**
  53363. * If sets to true, disables all the lights affecting the material.
  53364. */
  53365. protected _disableLighting: boolean;
  53366. /**
  53367. * Number of Simultaneous lights allowed on the material.
  53368. */
  53369. protected _maxSimultaneousLights: number;
  53370. /**
  53371. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53372. */
  53373. protected _invertNormalMapX: boolean;
  53374. /**
  53375. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53376. */
  53377. protected _invertNormalMapY: boolean;
  53378. /**
  53379. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53380. */
  53381. protected _twoSidedLighting: boolean;
  53382. /**
  53383. * Defines the alpha limits in alpha test mode.
  53384. */
  53385. protected _alphaCutOff: number;
  53386. /**
  53387. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53388. */
  53389. protected _forceAlphaTest: boolean;
  53390. /**
  53391. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53392. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53393. */
  53394. protected _useAlphaFresnel: boolean;
  53395. /**
  53396. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53397. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53398. */
  53399. protected _useLinearAlphaFresnel: boolean;
  53400. /**
  53401. * The transparency mode of the material.
  53402. */
  53403. protected _transparencyMode: Nullable<number>;
  53404. /**
  53405. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53406. * from cos thetav and roughness:
  53407. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53408. */
  53409. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53410. /**
  53411. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53412. */
  53413. protected _forceIrradianceInFragment: boolean;
  53414. /**
  53415. * Force normal to face away from face.
  53416. */
  53417. protected _forceNormalForward: boolean;
  53418. /**
  53419. * Enables specular anti aliasing in the PBR shader.
  53420. * It will both interacts on the Geometry for analytical and IBL lighting.
  53421. * It also prefilter the roughness map based on the bump values.
  53422. */
  53423. protected _enableSpecularAntiAliasing: boolean;
  53424. /**
  53425. * Default configuration related to image processing available in the PBR Material.
  53426. */
  53427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53428. /**
  53429. * Keep track of the image processing observer to allow dispose and replace.
  53430. */
  53431. private _imageProcessingObserver;
  53432. /**
  53433. * Attaches a new image processing configuration to the PBR Material.
  53434. * @param configuration
  53435. */
  53436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53437. /**
  53438. * Stores the available render targets.
  53439. */
  53440. private _renderTargets;
  53441. /**
  53442. * Sets the global ambient color for the material used in lighting calculations.
  53443. */
  53444. private _globalAmbientColor;
  53445. /**
  53446. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53447. */
  53448. private _useLogarithmicDepth;
  53449. /**
  53450. * If set to true, no lighting calculations will be applied.
  53451. */
  53452. private _unlit;
  53453. private _debugMode;
  53454. /**
  53455. * @hidden
  53456. * This is reserved for the inspector.
  53457. * Defines the material debug mode.
  53458. * It helps seeing only some components of the material while troubleshooting.
  53459. */
  53460. debugMode: number;
  53461. /**
  53462. * @hidden
  53463. * This is reserved for the inspector.
  53464. * Specify from where on screen the debug mode should start.
  53465. * The value goes from -1 (full screen) to 1 (not visible)
  53466. * It helps with side by side comparison against the final render
  53467. * This defaults to -1
  53468. */
  53469. private debugLimit;
  53470. /**
  53471. * @hidden
  53472. * This is reserved for the inspector.
  53473. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53474. * You can use the factor to better multiply the final value.
  53475. */
  53476. private debugFactor;
  53477. /**
  53478. * Defines the clear coat layer parameters for the material.
  53479. */
  53480. readonly clearCoat: PBRClearCoatConfiguration;
  53481. /**
  53482. * Defines the anisotropic parameters for the material.
  53483. */
  53484. readonly anisotropy: PBRAnisotropicConfiguration;
  53485. /**
  53486. * Defines the BRDF parameters for the material.
  53487. */
  53488. readonly brdf: PBRBRDFConfiguration;
  53489. /**
  53490. * Defines the Sheen parameters for the material.
  53491. */
  53492. readonly sheen: PBRSheenConfiguration;
  53493. /**
  53494. * Defines the SubSurface parameters for the material.
  53495. */
  53496. readonly subSurface: PBRSubSurfaceConfiguration;
  53497. /**
  53498. * Custom callback helping to override the default shader used in the material.
  53499. */
  53500. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53501. protected _rebuildInParallel: boolean;
  53502. /**
  53503. * Instantiates a new PBRMaterial instance.
  53504. *
  53505. * @param name The material name
  53506. * @param scene The scene the material will be use in.
  53507. */
  53508. constructor(name: string, scene: Scene);
  53509. /**
  53510. * Gets a boolean indicating that current material needs to register RTT
  53511. */
  53512. get hasRenderTargetTextures(): boolean;
  53513. /**
  53514. * Gets the name of the material class.
  53515. */
  53516. getClassName(): string;
  53517. /**
  53518. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53519. */
  53520. get useLogarithmicDepth(): boolean;
  53521. /**
  53522. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53523. */
  53524. set useLogarithmicDepth(value: boolean);
  53525. /**
  53526. * Gets the current transparency mode.
  53527. */
  53528. get transparencyMode(): Nullable<number>;
  53529. /**
  53530. * Sets the transparency mode of the material.
  53531. *
  53532. * | Value | Type | Description |
  53533. * | ----- | ----------------------------------- | ----------- |
  53534. * | 0 | OPAQUE | |
  53535. * | 1 | ALPHATEST | |
  53536. * | 2 | ALPHABLEND | |
  53537. * | 3 | ALPHATESTANDBLEND | |
  53538. *
  53539. */
  53540. set transparencyMode(value: Nullable<number>);
  53541. /**
  53542. * Returns true if alpha blending should be disabled.
  53543. */
  53544. private get _disableAlphaBlending();
  53545. /**
  53546. * Specifies whether or not this material should be rendered in alpha blend mode.
  53547. */
  53548. needAlphaBlending(): boolean;
  53549. /**
  53550. * Specifies if the mesh will require alpha blending.
  53551. * @param mesh - BJS mesh.
  53552. */
  53553. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53554. /**
  53555. * Specifies whether or not this material should be rendered in alpha test mode.
  53556. */
  53557. needAlphaTesting(): boolean;
  53558. /**
  53559. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53560. */
  53561. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53562. /**
  53563. * Gets the texture used for the alpha test.
  53564. */
  53565. getAlphaTestTexture(): Nullable<BaseTexture>;
  53566. /**
  53567. * Specifies that the submesh is ready to be used.
  53568. * @param mesh - BJS mesh.
  53569. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53570. * @param useInstances - Specifies that instances should be used.
  53571. * @returns - boolean indicating that the submesh is ready or not.
  53572. */
  53573. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53574. /**
  53575. * Specifies if the material uses metallic roughness workflow.
  53576. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53577. */
  53578. isMetallicWorkflow(): boolean;
  53579. private _prepareEffect;
  53580. private _prepareDefines;
  53581. /**
  53582. * Force shader compilation
  53583. */
  53584. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53585. /**
  53586. * Initializes the uniform buffer layout for the shader.
  53587. */
  53588. buildUniformLayout(): void;
  53589. /**
  53590. * Unbinds the material from the mesh
  53591. */
  53592. unbind(): void;
  53593. /**
  53594. * Binds the submesh data.
  53595. * @param world - The world matrix.
  53596. * @param mesh - The BJS mesh.
  53597. * @param subMesh - A submesh of the BJS mesh.
  53598. */
  53599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53600. /**
  53601. * Returns the animatable textures.
  53602. * @returns - Array of animatable textures.
  53603. */
  53604. getAnimatables(): IAnimatable[];
  53605. /**
  53606. * Returns the texture used for reflections.
  53607. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53608. */
  53609. private _getReflectionTexture;
  53610. /**
  53611. * Returns an array of the actively used textures.
  53612. * @returns - Array of BaseTextures
  53613. */
  53614. getActiveTextures(): BaseTexture[];
  53615. /**
  53616. * Checks to see if a texture is used in the material.
  53617. * @param texture - Base texture to use.
  53618. * @returns - Boolean specifying if a texture is used in the material.
  53619. */
  53620. hasTexture(texture: BaseTexture): boolean;
  53621. /**
  53622. * Disposes the resources of the material.
  53623. * @param forceDisposeEffect - Forces the disposal of effects.
  53624. * @param forceDisposeTextures - Forces the disposal of all textures.
  53625. */
  53626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53627. }
  53628. }
  53629. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53630. import { Nullable } from "babylonjs/types";
  53631. import { Scene } from "babylonjs/scene";
  53632. import { Color3 } from "babylonjs/Maths/math.color";
  53633. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53634. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53636. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53637. /**
  53638. * The Physically based material of BJS.
  53639. *
  53640. * This offers the main features of a standard PBR material.
  53641. * For more information, please refer to the documentation :
  53642. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53643. */
  53644. export class PBRMaterial extends PBRBaseMaterial {
  53645. /**
  53646. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53647. */
  53648. static readonly PBRMATERIAL_OPAQUE: number;
  53649. /**
  53650. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53651. */
  53652. static readonly PBRMATERIAL_ALPHATEST: number;
  53653. /**
  53654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53655. */
  53656. static readonly PBRMATERIAL_ALPHABLEND: number;
  53657. /**
  53658. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53659. * They are also discarded below the alpha cutoff threshold to improve performances.
  53660. */
  53661. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53662. /**
  53663. * Defines the default value of how much AO map is occluding the analytical lights
  53664. * (point spot...).
  53665. */
  53666. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53667. /**
  53668. * Intensity of the direct lights e.g. the four lights available in your scene.
  53669. * This impacts both the direct diffuse and specular highlights.
  53670. */
  53671. directIntensity: number;
  53672. /**
  53673. * Intensity of the emissive part of the material.
  53674. * This helps controlling the emissive effect without modifying the emissive color.
  53675. */
  53676. emissiveIntensity: number;
  53677. /**
  53678. * Intensity of the environment e.g. how much the environment will light the object
  53679. * either through harmonics for rough material or through the refelction for shiny ones.
  53680. */
  53681. environmentIntensity: number;
  53682. /**
  53683. * This is a special control allowing the reduction of the specular highlights coming from the
  53684. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53685. */
  53686. specularIntensity: number;
  53687. /**
  53688. * Debug Control allowing disabling the bump map on this material.
  53689. */
  53690. disableBumpMap: boolean;
  53691. /**
  53692. * AKA Diffuse Texture in standard nomenclature.
  53693. */
  53694. albedoTexture: BaseTexture;
  53695. /**
  53696. * AKA Occlusion Texture in other nomenclature.
  53697. */
  53698. ambientTexture: BaseTexture;
  53699. /**
  53700. * AKA Occlusion Texture Intensity in other nomenclature.
  53701. */
  53702. ambientTextureStrength: number;
  53703. /**
  53704. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53705. * 1 means it completely occludes it
  53706. * 0 mean it has no impact
  53707. */
  53708. ambientTextureImpactOnAnalyticalLights: number;
  53709. /**
  53710. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53711. */
  53712. opacityTexture: BaseTexture;
  53713. /**
  53714. * Stores the reflection values in a texture.
  53715. */
  53716. reflectionTexture: Nullable<BaseTexture>;
  53717. /**
  53718. * Stores the emissive values in a texture.
  53719. */
  53720. emissiveTexture: BaseTexture;
  53721. /**
  53722. * AKA Specular texture in other nomenclature.
  53723. */
  53724. reflectivityTexture: BaseTexture;
  53725. /**
  53726. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53727. */
  53728. metallicTexture: BaseTexture;
  53729. /**
  53730. * Specifies the metallic scalar of the metallic/roughness workflow.
  53731. * Can also be used to scale the metalness values of the metallic texture.
  53732. */
  53733. metallic: Nullable<number>;
  53734. /**
  53735. * Specifies the roughness scalar of the metallic/roughness workflow.
  53736. * Can also be used to scale the roughness values of the metallic texture.
  53737. */
  53738. roughness: Nullable<number>;
  53739. /**
  53740. * Specifies the an F0 factor to help configuring the material F0.
  53741. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53742. * to 0.5 the previously hard coded value stays the same.
  53743. * Can also be used to scale the F0 values of the metallic texture.
  53744. */
  53745. metallicF0Factor: number;
  53746. /**
  53747. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53748. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53749. * your expectation as it multiplies with the texture data.
  53750. */
  53751. useMetallicF0FactorFromMetallicTexture: boolean;
  53752. /**
  53753. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53754. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53755. */
  53756. microSurfaceTexture: BaseTexture;
  53757. /**
  53758. * Stores surface normal data used to displace a mesh in a texture.
  53759. */
  53760. bumpTexture: BaseTexture;
  53761. /**
  53762. * Stores the pre-calculated light information of a mesh in a texture.
  53763. */
  53764. lightmapTexture: BaseTexture;
  53765. /**
  53766. * Stores the refracted light information in a texture.
  53767. */
  53768. get refractionTexture(): Nullable<BaseTexture>;
  53769. set refractionTexture(value: Nullable<BaseTexture>);
  53770. /**
  53771. * The color of a material in ambient lighting.
  53772. */
  53773. ambientColor: Color3;
  53774. /**
  53775. * AKA Diffuse Color in other nomenclature.
  53776. */
  53777. albedoColor: Color3;
  53778. /**
  53779. * AKA Specular Color in other nomenclature.
  53780. */
  53781. reflectivityColor: Color3;
  53782. /**
  53783. * The color reflected from the material.
  53784. */
  53785. reflectionColor: Color3;
  53786. /**
  53787. * The color emitted from the material.
  53788. */
  53789. emissiveColor: Color3;
  53790. /**
  53791. * AKA Glossiness in other nomenclature.
  53792. */
  53793. microSurface: number;
  53794. /**
  53795. * source material index of refraction (IOR)' / 'destination material IOR.
  53796. */
  53797. get indexOfRefraction(): number;
  53798. set indexOfRefraction(value: number);
  53799. /**
  53800. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53801. */
  53802. get invertRefractionY(): boolean;
  53803. set invertRefractionY(value: boolean);
  53804. /**
  53805. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53806. * Materials half opaque for instance using refraction could benefit from this control.
  53807. */
  53808. get linkRefractionWithTransparency(): boolean;
  53809. set linkRefractionWithTransparency(value: boolean);
  53810. /**
  53811. * If true, the light map contains occlusion information instead of lighting info.
  53812. */
  53813. useLightmapAsShadowmap: boolean;
  53814. /**
  53815. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53816. */
  53817. useAlphaFromAlbedoTexture: boolean;
  53818. /**
  53819. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53820. */
  53821. forceAlphaTest: boolean;
  53822. /**
  53823. * Defines the alpha limits in alpha test mode.
  53824. */
  53825. alphaCutOff: number;
  53826. /**
  53827. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53828. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53829. */
  53830. useSpecularOverAlpha: boolean;
  53831. /**
  53832. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53833. */
  53834. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53835. /**
  53836. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53837. */
  53838. useRoughnessFromMetallicTextureAlpha: boolean;
  53839. /**
  53840. * Specifies if the metallic texture contains the roughness information in its green channel.
  53841. */
  53842. useRoughnessFromMetallicTextureGreen: boolean;
  53843. /**
  53844. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53845. */
  53846. useMetallnessFromMetallicTextureBlue: boolean;
  53847. /**
  53848. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53849. */
  53850. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53851. /**
  53852. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53853. */
  53854. useAmbientInGrayScale: boolean;
  53855. /**
  53856. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53857. * The material will try to infer what glossiness each pixel should be.
  53858. */
  53859. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53860. /**
  53861. * BJS is using an harcoded light falloff based on a manually sets up range.
  53862. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53863. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53864. */
  53865. get usePhysicalLightFalloff(): boolean;
  53866. /**
  53867. * BJS is using an harcoded light falloff based on a manually sets up range.
  53868. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53869. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53870. */
  53871. set usePhysicalLightFalloff(value: boolean);
  53872. /**
  53873. * In order to support the falloff compatibility with gltf, a special mode has been added
  53874. * to reproduce the gltf light falloff.
  53875. */
  53876. get useGLTFLightFalloff(): boolean;
  53877. /**
  53878. * In order to support the falloff compatibility with gltf, a special mode has been added
  53879. * to reproduce the gltf light falloff.
  53880. */
  53881. set useGLTFLightFalloff(value: boolean);
  53882. /**
  53883. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53884. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53885. */
  53886. useRadianceOverAlpha: boolean;
  53887. /**
  53888. * Allows using an object space normal map (instead of tangent space).
  53889. */
  53890. useObjectSpaceNormalMap: boolean;
  53891. /**
  53892. * Allows using the bump map in parallax mode.
  53893. */
  53894. useParallax: boolean;
  53895. /**
  53896. * Allows using the bump map in parallax occlusion mode.
  53897. */
  53898. useParallaxOcclusion: boolean;
  53899. /**
  53900. * Controls the scale bias of the parallax mode.
  53901. */
  53902. parallaxScaleBias: number;
  53903. /**
  53904. * If sets to true, disables all the lights affecting the material.
  53905. */
  53906. disableLighting: boolean;
  53907. /**
  53908. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53909. */
  53910. forceIrradianceInFragment: boolean;
  53911. /**
  53912. * Number of Simultaneous lights allowed on the material.
  53913. */
  53914. maxSimultaneousLights: number;
  53915. /**
  53916. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53917. */
  53918. invertNormalMapX: boolean;
  53919. /**
  53920. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53921. */
  53922. invertNormalMapY: boolean;
  53923. /**
  53924. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53925. */
  53926. twoSidedLighting: boolean;
  53927. /**
  53928. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53929. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53930. */
  53931. useAlphaFresnel: boolean;
  53932. /**
  53933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53934. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53935. */
  53936. useLinearAlphaFresnel: boolean;
  53937. /**
  53938. * Let user defines the brdf lookup texture used for IBL.
  53939. * A default 8bit version is embedded but you could point at :
  53940. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53941. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53942. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53943. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53944. */
  53945. environmentBRDFTexture: Nullable<BaseTexture>;
  53946. /**
  53947. * Force normal to face away from face.
  53948. */
  53949. forceNormalForward: boolean;
  53950. /**
  53951. * Enables specular anti aliasing in the PBR shader.
  53952. * It will both interacts on the Geometry for analytical and IBL lighting.
  53953. * It also prefilter the roughness map based on the bump values.
  53954. */
  53955. enableSpecularAntiAliasing: boolean;
  53956. /**
  53957. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53958. * makes the reflect vector face the model (under horizon).
  53959. */
  53960. useHorizonOcclusion: boolean;
  53961. /**
  53962. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53963. * too much the area relying on ambient texture to define their ambient occlusion.
  53964. */
  53965. useRadianceOcclusion: boolean;
  53966. /**
  53967. * If set to true, no lighting calculations will be applied.
  53968. */
  53969. unlit: boolean;
  53970. /**
  53971. * Gets the image processing configuration used either in this material.
  53972. */
  53973. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53974. /**
  53975. * Sets the Default image processing configuration used either in the this material.
  53976. *
  53977. * If sets to null, the scene one is in use.
  53978. */
  53979. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53980. /**
  53981. * Gets wether the color curves effect is enabled.
  53982. */
  53983. get cameraColorCurvesEnabled(): boolean;
  53984. /**
  53985. * Sets wether the color curves effect is enabled.
  53986. */
  53987. set cameraColorCurvesEnabled(value: boolean);
  53988. /**
  53989. * Gets wether the color grading effect is enabled.
  53990. */
  53991. get cameraColorGradingEnabled(): boolean;
  53992. /**
  53993. * Gets wether the color grading effect is enabled.
  53994. */
  53995. set cameraColorGradingEnabled(value: boolean);
  53996. /**
  53997. * Gets wether tonemapping is enabled or not.
  53998. */
  53999. get cameraToneMappingEnabled(): boolean;
  54000. /**
  54001. * Sets wether tonemapping is enabled or not
  54002. */
  54003. set cameraToneMappingEnabled(value: boolean);
  54004. /**
  54005. * The camera exposure used on this material.
  54006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54007. * This corresponds to a photographic exposure.
  54008. */
  54009. get cameraExposure(): number;
  54010. /**
  54011. * The camera exposure used on this material.
  54012. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54013. * This corresponds to a photographic exposure.
  54014. */
  54015. set cameraExposure(value: number);
  54016. /**
  54017. * Gets The camera contrast used on this material.
  54018. */
  54019. get cameraContrast(): number;
  54020. /**
  54021. * Sets The camera contrast used on this material.
  54022. */
  54023. set cameraContrast(value: number);
  54024. /**
  54025. * Gets the Color Grading 2D Lookup Texture.
  54026. */
  54027. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54028. /**
  54029. * Sets the Color Grading 2D Lookup Texture.
  54030. */
  54031. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54032. /**
  54033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54035. * 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;
  54036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54037. */
  54038. get cameraColorCurves(): Nullable<ColorCurves>;
  54039. /**
  54040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54042. * 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;
  54043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54044. */
  54045. set cameraColorCurves(value: Nullable<ColorCurves>);
  54046. /**
  54047. * Instantiates a new PBRMaterial instance.
  54048. *
  54049. * @param name The material name
  54050. * @param scene The scene the material will be use in.
  54051. */
  54052. constructor(name: string, scene: Scene);
  54053. /**
  54054. * Returns the name of this material class.
  54055. */
  54056. getClassName(): string;
  54057. /**
  54058. * Makes a duplicate of the current material.
  54059. * @param name - name to use for the new material.
  54060. */
  54061. clone(name: string): PBRMaterial;
  54062. /**
  54063. * Serializes this PBR Material.
  54064. * @returns - An object with the serialized material.
  54065. */
  54066. serialize(): any;
  54067. /**
  54068. * Parses a PBR Material from a serialized object.
  54069. * @param source - Serialized object.
  54070. * @param scene - BJS scene instance.
  54071. * @param rootUrl - url for the scene object
  54072. * @returns - PBRMaterial
  54073. */
  54074. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54075. }
  54076. }
  54077. declare module "babylonjs/Misc/dds" {
  54078. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54080. import { Nullable } from "babylonjs/types";
  54081. import { Scene } from "babylonjs/scene";
  54082. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54083. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54084. /**
  54085. * Direct draw surface info
  54086. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54087. */
  54088. export interface DDSInfo {
  54089. /**
  54090. * Width of the texture
  54091. */
  54092. width: number;
  54093. /**
  54094. * Width of the texture
  54095. */
  54096. height: number;
  54097. /**
  54098. * Number of Mipmaps for the texture
  54099. * @see https://en.wikipedia.org/wiki/Mipmap
  54100. */
  54101. mipmapCount: number;
  54102. /**
  54103. * If the textures format is a known fourCC format
  54104. * @see https://www.fourcc.org/
  54105. */
  54106. isFourCC: boolean;
  54107. /**
  54108. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54109. */
  54110. isRGB: boolean;
  54111. /**
  54112. * If the texture is a lumincance format
  54113. */
  54114. isLuminance: boolean;
  54115. /**
  54116. * If this is a cube texture
  54117. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54118. */
  54119. isCube: boolean;
  54120. /**
  54121. * If the texture is a compressed format eg. FOURCC_DXT1
  54122. */
  54123. isCompressed: boolean;
  54124. /**
  54125. * The dxgiFormat of the texture
  54126. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54127. */
  54128. dxgiFormat: number;
  54129. /**
  54130. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54131. */
  54132. textureType: number;
  54133. /**
  54134. * Sphericle polynomial created for the dds texture
  54135. */
  54136. sphericalPolynomial?: SphericalPolynomial;
  54137. }
  54138. /**
  54139. * Class used to provide DDS decompression tools
  54140. */
  54141. export class DDSTools {
  54142. /**
  54143. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54144. */
  54145. static StoreLODInAlphaChannel: boolean;
  54146. /**
  54147. * Gets DDS information from an array buffer
  54148. * @param data defines the array buffer view to read data from
  54149. * @returns the DDS information
  54150. */
  54151. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54152. private static _FloatView;
  54153. private static _Int32View;
  54154. private static _ToHalfFloat;
  54155. private static _FromHalfFloat;
  54156. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54157. private static _GetHalfFloatRGBAArrayBuffer;
  54158. private static _GetFloatRGBAArrayBuffer;
  54159. private static _GetFloatAsUIntRGBAArrayBuffer;
  54160. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54161. private static _GetRGBAArrayBuffer;
  54162. private static _ExtractLongWordOrder;
  54163. private static _GetRGBArrayBuffer;
  54164. private static _GetLuminanceArrayBuffer;
  54165. /**
  54166. * Uploads DDS Levels to a Babylon Texture
  54167. * @hidden
  54168. */
  54169. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54170. }
  54171. module "babylonjs/Engines/thinEngine" {
  54172. interface ThinEngine {
  54173. /**
  54174. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54175. * @param rootUrl defines the url where the file to load is located
  54176. * @param scene defines the current scene
  54177. * @param lodScale defines scale to apply to the mip map selection
  54178. * @param lodOffset defines offset to apply to the mip map selection
  54179. * @param onLoad defines an optional callback raised when the texture is loaded
  54180. * @param onError defines an optional callback raised if there is an issue to load the texture
  54181. * @param format defines the format of the data
  54182. * @param forcedExtension defines the extension to use to pick the right loader
  54183. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54184. * @returns the cube texture as an InternalTexture
  54185. */
  54186. 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;
  54187. }
  54188. }
  54189. }
  54190. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54191. import { Nullable } from "babylonjs/types";
  54192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54193. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54194. /**
  54195. * Implementation of the DDS Texture Loader.
  54196. * @hidden
  54197. */
  54198. export class _DDSTextureLoader implements IInternalTextureLoader {
  54199. /**
  54200. * Defines wether the loader supports cascade loading the different faces.
  54201. */
  54202. readonly supportCascades: boolean;
  54203. /**
  54204. * This returns if the loader support the current file information.
  54205. * @param extension defines the file extension of the file being loaded
  54206. * @returns true if the loader can load the specified file
  54207. */
  54208. canLoad(extension: string): boolean;
  54209. /**
  54210. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54211. * @param data contains the texture data
  54212. * @param texture defines the BabylonJS internal texture
  54213. * @param createPolynomials will be true if polynomials have been requested
  54214. * @param onLoad defines the callback to trigger once the texture is ready
  54215. * @param onError defines the callback to trigger in case of error
  54216. */
  54217. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54218. /**
  54219. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54220. * @param data contains the texture data
  54221. * @param texture defines the BabylonJS internal texture
  54222. * @param callback defines the method to call once ready to upload
  54223. */
  54224. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54228. import { Nullable } from "babylonjs/types";
  54229. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54230. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54231. /**
  54232. * Implementation of the ENV Texture Loader.
  54233. * @hidden
  54234. */
  54235. export class _ENVTextureLoader implements IInternalTextureLoader {
  54236. /**
  54237. * Defines wether the loader supports cascade loading the different faces.
  54238. */
  54239. readonly supportCascades: boolean;
  54240. /**
  54241. * This returns if the loader support the current file information.
  54242. * @param extension defines the file extension of the file being loaded
  54243. * @returns true if the loader can load the specified file
  54244. */
  54245. canLoad(extension: string): boolean;
  54246. /**
  54247. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54248. * @param data contains the texture data
  54249. * @param texture defines the BabylonJS internal texture
  54250. * @param createPolynomials will be true if polynomials have been requested
  54251. * @param onLoad defines the callback to trigger once the texture is ready
  54252. * @param onError defines the callback to trigger in case of error
  54253. */
  54254. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54255. /**
  54256. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54257. * @param data contains the texture data
  54258. * @param texture defines the BabylonJS internal texture
  54259. * @param callback defines the method to call once ready to upload
  54260. */
  54261. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54262. }
  54263. }
  54264. declare module "babylonjs/Misc/khronosTextureContainer" {
  54265. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54266. /**
  54267. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54268. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54269. */
  54270. export class KhronosTextureContainer {
  54271. /** contents of the KTX container file */
  54272. data: ArrayBufferView;
  54273. private static HEADER_LEN;
  54274. private static COMPRESSED_2D;
  54275. private static COMPRESSED_3D;
  54276. private static TEX_2D;
  54277. private static TEX_3D;
  54278. /**
  54279. * Gets the openGL type
  54280. */
  54281. glType: number;
  54282. /**
  54283. * Gets the openGL type size
  54284. */
  54285. glTypeSize: number;
  54286. /**
  54287. * Gets the openGL format
  54288. */
  54289. glFormat: number;
  54290. /**
  54291. * Gets the openGL internal format
  54292. */
  54293. glInternalFormat: number;
  54294. /**
  54295. * Gets the base internal format
  54296. */
  54297. glBaseInternalFormat: number;
  54298. /**
  54299. * Gets image width in pixel
  54300. */
  54301. pixelWidth: number;
  54302. /**
  54303. * Gets image height in pixel
  54304. */
  54305. pixelHeight: number;
  54306. /**
  54307. * Gets image depth in pixels
  54308. */
  54309. pixelDepth: number;
  54310. /**
  54311. * Gets the number of array elements
  54312. */
  54313. numberOfArrayElements: number;
  54314. /**
  54315. * Gets the number of faces
  54316. */
  54317. numberOfFaces: number;
  54318. /**
  54319. * Gets the number of mipmap levels
  54320. */
  54321. numberOfMipmapLevels: number;
  54322. /**
  54323. * Gets the bytes of key value data
  54324. */
  54325. bytesOfKeyValueData: number;
  54326. /**
  54327. * Gets the load type
  54328. */
  54329. loadType: number;
  54330. /**
  54331. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54332. */
  54333. isInvalid: boolean;
  54334. /**
  54335. * Creates a new KhronosTextureContainer
  54336. * @param data contents of the KTX container file
  54337. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54338. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54339. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54340. */
  54341. constructor(
  54342. /** contents of the KTX container file */
  54343. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54344. /**
  54345. * Uploads KTX content to a Babylon Texture.
  54346. * It is assumed that the texture has already been created & is currently bound
  54347. * @hidden
  54348. */
  54349. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54350. private _upload2DCompressedLevels;
  54351. /**
  54352. * Checks if the given data starts with a KTX file identifier.
  54353. * @param data the data to check
  54354. * @returns true if the data is a KTX file or false otherwise
  54355. */
  54356. static IsValid(data: ArrayBufferView): boolean;
  54357. }
  54358. }
  54359. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54361. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54362. /**
  54363. * Class for loading KTX2 files
  54364. * !!! Experimental Extension Subject to Changes !!!
  54365. * @hidden
  54366. */
  54367. export class KhronosTextureContainer2 {
  54368. private static _ModulePromise;
  54369. private static _TranscodeFormat;
  54370. constructor(engine: ThinEngine);
  54371. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54372. private _determineTranscodeFormat;
  54373. /**
  54374. * Checks if the given data starts with a KTX2 file identifier.
  54375. * @param data the data to check
  54376. * @returns true if the data is a KTX2 file or false otherwise
  54377. */
  54378. static IsValid(data: ArrayBufferView): boolean;
  54379. }
  54380. }
  54381. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54382. import { Nullable } from "babylonjs/types";
  54383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54384. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54385. /**
  54386. * Implementation of the KTX Texture Loader.
  54387. * @hidden
  54388. */
  54389. export class _KTXTextureLoader implements IInternalTextureLoader {
  54390. /**
  54391. * Defines wether the loader supports cascade loading the different faces.
  54392. */
  54393. readonly supportCascades: boolean;
  54394. /**
  54395. * This returns if the loader support the current file information.
  54396. * @param extension defines the file extension of the file being loaded
  54397. * @returns true if the loader can load the specified file
  54398. */
  54399. canLoad(extension: string): boolean;
  54400. /**
  54401. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54402. * @param data contains the texture data
  54403. * @param texture defines the BabylonJS internal texture
  54404. * @param createPolynomials will be true if polynomials have been requested
  54405. * @param onLoad defines the callback to trigger once the texture is ready
  54406. * @param onError defines the callback to trigger in case of error
  54407. */
  54408. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54409. /**
  54410. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54411. * @param data contains the texture data
  54412. * @param texture defines the BabylonJS internal texture
  54413. * @param callback defines the method to call once ready to upload
  54414. */
  54415. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54416. }
  54417. }
  54418. declare module "babylonjs/Helpers/sceneHelpers" {
  54419. import { Nullable } from "babylonjs/types";
  54420. import { Mesh } from "babylonjs/Meshes/mesh";
  54421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54422. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54423. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54424. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54425. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54426. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54427. import "babylonjs/Meshes/Builders/boxBuilder";
  54428. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54429. /** @hidden */
  54430. export var _forceSceneHelpersToBundle: boolean;
  54431. module "babylonjs/scene" {
  54432. interface Scene {
  54433. /**
  54434. * Creates a default light for the scene.
  54435. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54436. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54437. */
  54438. createDefaultLight(replace?: boolean): void;
  54439. /**
  54440. * Creates a default camera for the scene.
  54441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54442. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54443. * @param replace has default false, when true replaces the active camera in the scene
  54444. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54445. */
  54446. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54447. /**
  54448. * Creates a default camera and a default light.
  54449. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54450. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54451. * @param replace has the default false, when true replaces the active camera/light in the scene
  54452. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54453. */
  54454. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54455. /**
  54456. * Creates a new sky box
  54457. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54458. * @param environmentTexture defines the texture to use as environment texture
  54459. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54460. * @param scale defines the overall scale of the skybox
  54461. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54462. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54463. * @returns a new mesh holding the sky box
  54464. */
  54465. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54466. /**
  54467. * Creates a new environment
  54468. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54469. * @param options defines the options you can use to configure the environment
  54470. * @returns the new EnvironmentHelper
  54471. */
  54472. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54473. /**
  54474. * Creates a new VREXperienceHelper
  54475. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54476. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54477. * @returns a new VREXperienceHelper
  54478. */
  54479. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54480. /**
  54481. * Creates a new WebXRDefaultExperience
  54482. * @see http://doc.babylonjs.com/how_to/webxr
  54483. * @param options experience options
  54484. * @returns a promise for a new WebXRDefaultExperience
  54485. */
  54486. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54487. }
  54488. }
  54489. }
  54490. declare module "babylonjs/Helpers/videoDome" {
  54491. import { Scene } from "babylonjs/scene";
  54492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54493. import { Mesh } from "babylonjs/Meshes/mesh";
  54494. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54495. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54496. import "babylonjs/Meshes/Builders/sphereBuilder";
  54497. /**
  54498. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54499. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54500. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54501. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54502. */
  54503. export class VideoDome extends TransformNode {
  54504. /**
  54505. * Define the video source as a Monoscopic panoramic 360 video.
  54506. */
  54507. static readonly MODE_MONOSCOPIC: number;
  54508. /**
  54509. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54510. */
  54511. static readonly MODE_TOPBOTTOM: number;
  54512. /**
  54513. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54514. */
  54515. static readonly MODE_SIDEBYSIDE: number;
  54516. private _halfDome;
  54517. private _useDirectMapping;
  54518. /**
  54519. * The video texture being displayed on the sphere
  54520. */
  54521. protected _videoTexture: VideoTexture;
  54522. /**
  54523. * Gets the video texture being displayed on the sphere
  54524. */
  54525. get videoTexture(): VideoTexture;
  54526. /**
  54527. * The skybox material
  54528. */
  54529. protected _material: BackgroundMaterial;
  54530. /**
  54531. * The surface used for the skybox
  54532. */
  54533. protected _mesh: Mesh;
  54534. /**
  54535. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54536. */
  54537. private _halfDomeMask;
  54538. /**
  54539. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54540. * Also see the options.resolution property.
  54541. */
  54542. get fovMultiplier(): number;
  54543. set fovMultiplier(value: number);
  54544. private _videoMode;
  54545. /**
  54546. * Gets or set the current video mode for the video. It can be:
  54547. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54548. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54549. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54550. */
  54551. get videoMode(): number;
  54552. set videoMode(value: number);
  54553. /**
  54554. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54555. *
  54556. */
  54557. get halfDome(): boolean;
  54558. /**
  54559. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54560. */
  54561. set halfDome(enabled: boolean);
  54562. /**
  54563. * Oberserver used in Stereoscopic VR Mode.
  54564. */
  54565. private _onBeforeCameraRenderObserver;
  54566. /**
  54567. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54568. * @param name Element's name, child elements will append suffixes for their own names.
  54569. * @param urlsOrVideo defines the url(s) or the video element to use
  54570. * @param options An object containing optional or exposed sub element properties
  54571. */
  54572. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54573. resolution?: number;
  54574. clickToPlay?: boolean;
  54575. autoPlay?: boolean;
  54576. loop?: boolean;
  54577. size?: number;
  54578. poster?: string;
  54579. faceForward?: boolean;
  54580. useDirectMapping?: boolean;
  54581. halfDomeMode?: boolean;
  54582. }, scene: Scene);
  54583. private _changeVideoMode;
  54584. /**
  54585. * Releases resources associated with this node.
  54586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54588. */
  54589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54590. }
  54591. }
  54592. declare module "babylonjs/Helpers/index" {
  54593. export * from "babylonjs/Helpers/environmentHelper";
  54594. export * from "babylonjs/Helpers/photoDome";
  54595. export * from "babylonjs/Helpers/sceneHelpers";
  54596. export * from "babylonjs/Helpers/videoDome";
  54597. }
  54598. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54599. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54600. import { IDisposable } from "babylonjs/scene";
  54601. import { Engine } from "babylonjs/Engines/engine";
  54602. /**
  54603. * This class can be used to get instrumentation data from a Babylon engine
  54604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54605. */
  54606. export class EngineInstrumentation implements IDisposable {
  54607. /**
  54608. * Define the instrumented engine.
  54609. */
  54610. engine: Engine;
  54611. private _captureGPUFrameTime;
  54612. private _gpuFrameTimeToken;
  54613. private _gpuFrameTime;
  54614. private _captureShaderCompilationTime;
  54615. private _shaderCompilationTime;
  54616. private _onBeginFrameObserver;
  54617. private _onEndFrameObserver;
  54618. private _onBeforeShaderCompilationObserver;
  54619. private _onAfterShaderCompilationObserver;
  54620. /**
  54621. * Gets the perf counter used for GPU frame time
  54622. */
  54623. get gpuFrameTimeCounter(): PerfCounter;
  54624. /**
  54625. * Gets the GPU frame time capture status
  54626. */
  54627. get captureGPUFrameTime(): boolean;
  54628. /**
  54629. * Enable or disable the GPU frame time capture
  54630. */
  54631. set captureGPUFrameTime(value: boolean);
  54632. /**
  54633. * Gets the perf counter used for shader compilation time
  54634. */
  54635. get shaderCompilationTimeCounter(): PerfCounter;
  54636. /**
  54637. * Gets the shader compilation time capture status
  54638. */
  54639. get captureShaderCompilationTime(): boolean;
  54640. /**
  54641. * Enable or disable the shader compilation time capture
  54642. */
  54643. set captureShaderCompilationTime(value: boolean);
  54644. /**
  54645. * Instantiates a new engine instrumentation.
  54646. * This class can be used to get instrumentation data from a Babylon engine
  54647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54648. * @param engine Defines the engine to instrument
  54649. */
  54650. constructor(
  54651. /**
  54652. * Define the instrumented engine.
  54653. */
  54654. engine: Engine);
  54655. /**
  54656. * Dispose and release associated resources.
  54657. */
  54658. dispose(): void;
  54659. }
  54660. }
  54661. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54662. import { Scene, IDisposable } from "babylonjs/scene";
  54663. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54664. /**
  54665. * This class can be used to get instrumentation data from a Babylon engine
  54666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54667. */
  54668. export class SceneInstrumentation implements IDisposable {
  54669. /**
  54670. * Defines the scene to instrument
  54671. */
  54672. scene: Scene;
  54673. private _captureActiveMeshesEvaluationTime;
  54674. private _activeMeshesEvaluationTime;
  54675. private _captureRenderTargetsRenderTime;
  54676. private _renderTargetsRenderTime;
  54677. private _captureFrameTime;
  54678. private _frameTime;
  54679. private _captureRenderTime;
  54680. private _renderTime;
  54681. private _captureInterFrameTime;
  54682. private _interFrameTime;
  54683. private _captureParticlesRenderTime;
  54684. private _particlesRenderTime;
  54685. private _captureSpritesRenderTime;
  54686. private _spritesRenderTime;
  54687. private _capturePhysicsTime;
  54688. private _physicsTime;
  54689. private _captureAnimationsTime;
  54690. private _animationsTime;
  54691. private _captureCameraRenderTime;
  54692. private _cameraRenderTime;
  54693. private _onBeforeActiveMeshesEvaluationObserver;
  54694. private _onAfterActiveMeshesEvaluationObserver;
  54695. private _onBeforeRenderTargetsRenderObserver;
  54696. private _onAfterRenderTargetsRenderObserver;
  54697. private _onAfterRenderObserver;
  54698. private _onBeforeDrawPhaseObserver;
  54699. private _onAfterDrawPhaseObserver;
  54700. private _onBeforeAnimationsObserver;
  54701. private _onBeforeParticlesRenderingObserver;
  54702. private _onAfterParticlesRenderingObserver;
  54703. private _onBeforeSpritesRenderingObserver;
  54704. private _onAfterSpritesRenderingObserver;
  54705. private _onBeforePhysicsObserver;
  54706. private _onAfterPhysicsObserver;
  54707. private _onAfterAnimationsObserver;
  54708. private _onBeforeCameraRenderObserver;
  54709. private _onAfterCameraRenderObserver;
  54710. /**
  54711. * Gets the perf counter used for active meshes evaluation time
  54712. */
  54713. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54714. /**
  54715. * Gets the active meshes evaluation time capture status
  54716. */
  54717. get captureActiveMeshesEvaluationTime(): boolean;
  54718. /**
  54719. * Enable or disable the active meshes evaluation time capture
  54720. */
  54721. set captureActiveMeshesEvaluationTime(value: boolean);
  54722. /**
  54723. * Gets the perf counter used for render targets render time
  54724. */
  54725. get renderTargetsRenderTimeCounter(): PerfCounter;
  54726. /**
  54727. * Gets the render targets render time capture status
  54728. */
  54729. get captureRenderTargetsRenderTime(): boolean;
  54730. /**
  54731. * Enable or disable the render targets render time capture
  54732. */
  54733. set captureRenderTargetsRenderTime(value: boolean);
  54734. /**
  54735. * Gets the perf counter used for particles render time
  54736. */
  54737. get particlesRenderTimeCounter(): PerfCounter;
  54738. /**
  54739. * Gets the particles render time capture status
  54740. */
  54741. get captureParticlesRenderTime(): boolean;
  54742. /**
  54743. * Enable or disable the particles render time capture
  54744. */
  54745. set captureParticlesRenderTime(value: boolean);
  54746. /**
  54747. * Gets the perf counter used for sprites render time
  54748. */
  54749. get spritesRenderTimeCounter(): PerfCounter;
  54750. /**
  54751. * Gets the sprites render time capture status
  54752. */
  54753. get captureSpritesRenderTime(): boolean;
  54754. /**
  54755. * Enable or disable the sprites render time capture
  54756. */
  54757. set captureSpritesRenderTime(value: boolean);
  54758. /**
  54759. * Gets the perf counter used for physics time
  54760. */
  54761. get physicsTimeCounter(): PerfCounter;
  54762. /**
  54763. * Gets the physics time capture status
  54764. */
  54765. get capturePhysicsTime(): boolean;
  54766. /**
  54767. * Enable or disable the physics time capture
  54768. */
  54769. set capturePhysicsTime(value: boolean);
  54770. /**
  54771. * Gets the perf counter used for animations time
  54772. */
  54773. get animationsTimeCounter(): PerfCounter;
  54774. /**
  54775. * Gets the animations time capture status
  54776. */
  54777. get captureAnimationsTime(): boolean;
  54778. /**
  54779. * Enable or disable the animations time capture
  54780. */
  54781. set captureAnimationsTime(value: boolean);
  54782. /**
  54783. * Gets the perf counter used for frame time capture
  54784. */
  54785. get frameTimeCounter(): PerfCounter;
  54786. /**
  54787. * Gets the frame time capture status
  54788. */
  54789. get captureFrameTime(): boolean;
  54790. /**
  54791. * Enable or disable the frame time capture
  54792. */
  54793. set captureFrameTime(value: boolean);
  54794. /**
  54795. * Gets the perf counter used for inter-frames time capture
  54796. */
  54797. get interFrameTimeCounter(): PerfCounter;
  54798. /**
  54799. * Gets the inter-frames time capture status
  54800. */
  54801. get captureInterFrameTime(): boolean;
  54802. /**
  54803. * Enable or disable the inter-frames time capture
  54804. */
  54805. set captureInterFrameTime(value: boolean);
  54806. /**
  54807. * Gets the perf counter used for render time capture
  54808. */
  54809. get renderTimeCounter(): PerfCounter;
  54810. /**
  54811. * Gets the render time capture status
  54812. */
  54813. get captureRenderTime(): boolean;
  54814. /**
  54815. * Enable or disable the render time capture
  54816. */
  54817. set captureRenderTime(value: boolean);
  54818. /**
  54819. * Gets the perf counter used for camera render time capture
  54820. */
  54821. get cameraRenderTimeCounter(): PerfCounter;
  54822. /**
  54823. * Gets the camera render time capture status
  54824. */
  54825. get captureCameraRenderTime(): boolean;
  54826. /**
  54827. * Enable or disable the camera render time capture
  54828. */
  54829. set captureCameraRenderTime(value: boolean);
  54830. /**
  54831. * Gets the perf counter used for draw calls
  54832. */
  54833. get drawCallsCounter(): PerfCounter;
  54834. /**
  54835. * Instantiates a new scene instrumentation.
  54836. * This class can be used to get instrumentation data from a Babylon engine
  54837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54838. * @param scene Defines the scene to instrument
  54839. */
  54840. constructor(
  54841. /**
  54842. * Defines the scene to instrument
  54843. */
  54844. scene: Scene);
  54845. /**
  54846. * Dispose and release associated resources.
  54847. */
  54848. dispose(): void;
  54849. }
  54850. }
  54851. declare module "babylonjs/Instrumentation/index" {
  54852. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54853. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54854. export * from "babylonjs/Instrumentation/timeToken";
  54855. }
  54856. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54857. /** @hidden */
  54858. export var glowMapGenerationPixelShader: {
  54859. name: string;
  54860. shader: string;
  54861. };
  54862. }
  54863. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54864. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54867. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54868. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54869. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54871. /** @hidden */
  54872. export var glowMapGenerationVertexShader: {
  54873. name: string;
  54874. shader: string;
  54875. };
  54876. }
  54877. declare module "babylonjs/Layers/effectLayer" {
  54878. import { Observable } from "babylonjs/Misc/observable";
  54879. import { Nullable } from "babylonjs/types";
  54880. import { Camera } from "babylonjs/Cameras/camera";
  54881. import { Scene } from "babylonjs/scene";
  54882. import { ISize } from "babylonjs/Maths/math.size";
  54883. import { Color4 } from "babylonjs/Maths/math.color";
  54884. import { Engine } from "babylonjs/Engines/engine";
  54885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54887. import { Mesh } from "babylonjs/Meshes/mesh";
  54888. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54891. import { Effect } from "babylonjs/Materials/effect";
  54892. import { Material } from "babylonjs/Materials/material";
  54893. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54894. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54895. /**
  54896. * Effect layer options. This helps customizing the behaviour
  54897. * of the effect layer.
  54898. */
  54899. export interface IEffectLayerOptions {
  54900. /**
  54901. * Multiplication factor apply to the canvas size to compute the render target size
  54902. * used to generated the objects (the smaller the faster).
  54903. */
  54904. mainTextureRatio: number;
  54905. /**
  54906. * Enforces a fixed size texture to ensure effect stability across devices.
  54907. */
  54908. mainTextureFixedSize?: number;
  54909. /**
  54910. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54911. */
  54912. alphaBlendingMode: number;
  54913. /**
  54914. * The camera attached to the layer.
  54915. */
  54916. camera: Nullable<Camera>;
  54917. /**
  54918. * The rendering group to draw the layer in.
  54919. */
  54920. renderingGroupId: number;
  54921. }
  54922. /**
  54923. * The effect layer Helps adding post process effect blended with the main pass.
  54924. *
  54925. * This can be for instance use to generate glow or higlight effects on the scene.
  54926. *
  54927. * The effect layer class can not be used directly and is intented to inherited from to be
  54928. * customized per effects.
  54929. */
  54930. export abstract class EffectLayer {
  54931. private _vertexBuffers;
  54932. private _indexBuffer;
  54933. private _cachedDefines;
  54934. private _effectLayerMapGenerationEffect;
  54935. private _effectLayerOptions;
  54936. private _mergeEffect;
  54937. protected _scene: Scene;
  54938. protected _engine: Engine;
  54939. protected _maxSize: number;
  54940. protected _mainTextureDesiredSize: ISize;
  54941. protected _mainTexture: RenderTargetTexture;
  54942. protected _shouldRender: boolean;
  54943. protected _postProcesses: PostProcess[];
  54944. protected _textures: BaseTexture[];
  54945. protected _emissiveTextureAndColor: {
  54946. texture: Nullable<BaseTexture>;
  54947. color: Color4;
  54948. };
  54949. /**
  54950. * The name of the layer
  54951. */
  54952. name: string;
  54953. /**
  54954. * The clear color of the texture used to generate the glow map.
  54955. */
  54956. neutralColor: Color4;
  54957. /**
  54958. * Specifies whether the highlight layer is enabled or not.
  54959. */
  54960. isEnabled: boolean;
  54961. /**
  54962. * Gets the camera attached to the layer.
  54963. */
  54964. get camera(): Nullable<Camera>;
  54965. /**
  54966. * Gets the rendering group id the layer should render in.
  54967. */
  54968. get renderingGroupId(): number;
  54969. set renderingGroupId(renderingGroupId: number);
  54970. /**
  54971. * An event triggered when the effect layer has been disposed.
  54972. */
  54973. onDisposeObservable: Observable<EffectLayer>;
  54974. /**
  54975. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54976. */
  54977. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54978. /**
  54979. * An event triggered when the generated texture is being merged in the scene.
  54980. */
  54981. onBeforeComposeObservable: Observable<EffectLayer>;
  54982. /**
  54983. * An event triggered when the mesh is rendered into the effect render target.
  54984. */
  54985. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54986. /**
  54987. * An event triggered after the mesh has been rendered into the effect render target.
  54988. */
  54989. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54990. /**
  54991. * An event triggered when the generated texture has been merged in the scene.
  54992. */
  54993. onAfterComposeObservable: Observable<EffectLayer>;
  54994. /**
  54995. * An event triggered when the efffect layer changes its size.
  54996. */
  54997. onSizeChangedObservable: Observable<EffectLayer>;
  54998. /** @hidden */
  54999. static _SceneComponentInitialization: (scene: Scene) => void;
  55000. /**
  55001. * Instantiates a new effect Layer and references it in the scene.
  55002. * @param name The name of the layer
  55003. * @param scene The scene to use the layer in
  55004. */
  55005. constructor(
  55006. /** The Friendly of the effect in the scene */
  55007. name: string, scene: Scene);
  55008. /**
  55009. * Get the effect name of the layer.
  55010. * @return The effect name
  55011. */
  55012. abstract getEffectName(): string;
  55013. /**
  55014. * Checks for the readiness of the element composing the layer.
  55015. * @param subMesh the mesh to check for
  55016. * @param useInstances specify whether or not to use instances to render the mesh
  55017. * @return true if ready otherwise, false
  55018. */
  55019. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55020. /**
  55021. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55022. * @returns true if the effect requires stencil during the main canvas render pass.
  55023. */
  55024. abstract needStencil(): boolean;
  55025. /**
  55026. * Create the merge effect. This is the shader use to blit the information back
  55027. * to the main canvas at the end of the scene rendering.
  55028. * @returns The effect containing the shader used to merge the effect on the main canvas
  55029. */
  55030. protected abstract _createMergeEffect(): Effect;
  55031. /**
  55032. * Creates the render target textures and post processes used in the effect layer.
  55033. */
  55034. protected abstract _createTextureAndPostProcesses(): void;
  55035. /**
  55036. * Implementation specific of rendering the generating effect on the main canvas.
  55037. * @param effect The effect used to render through
  55038. */
  55039. protected abstract _internalRender(effect: Effect): void;
  55040. /**
  55041. * Sets the required values for both the emissive texture and and the main color.
  55042. */
  55043. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55044. /**
  55045. * Free any resources and references associated to a mesh.
  55046. * Internal use
  55047. * @param mesh The mesh to free.
  55048. */
  55049. abstract _disposeMesh(mesh: Mesh): void;
  55050. /**
  55051. * Serializes this layer (Glow or Highlight for example)
  55052. * @returns a serialized layer object
  55053. */
  55054. abstract serialize?(): any;
  55055. /**
  55056. * Initializes the effect layer with the required options.
  55057. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55058. */
  55059. protected _init(options: Partial<IEffectLayerOptions>): void;
  55060. /**
  55061. * Generates the index buffer of the full screen quad blending to the main canvas.
  55062. */
  55063. private _generateIndexBuffer;
  55064. /**
  55065. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55066. */
  55067. private _generateVertexBuffer;
  55068. /**
  55069. * Sets the main texture desired size which is the closest power of two
  55070. * of the engine canvas size.
  55071. */
  55072. private _setMainTextureSize;
  55073. /**
  55074. * Creates the main texture for the effect layer.
  55075. */
  55076. protected _createMainTexture(): void;
  55077. /**
  55078. * Adds specific effects defines.
  55079. * @param defines The defines to add specifics to.
  55080. */
  55081. protected _addCustomEffectDefines(defines: string[]): void;
  55082. /**
  55083. * Checks for the readiness of the element composing the layer.
  55084. * @param subMesh the mesh to check for
  55085. * @param useInstances specify whether or not to use instances to render the mesh
  55086. * @param emissiveTexture the associated emissive texture used to generate the glow
  55087. * @return true if ready otherwise, false
  55088. */
  55089. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55090. /**
  55091. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55092. */
  55093. render(): void;
  55094. /**
  55095. * Determine if a given mesh will be used in the current effect.
  55096. * @param mesh mesh to test
  55097. * @returns true if the mesh will be used
  55098. */
  55099. hasMesh(mesh: AbstractMesh): boolean;
  55100. /**
  55101. * Returns true if the layer contains information to display, otherwise false.
  55102. * @returns true if the glow layer should be rendered
  55103. */
  55104. shouldRender(): boolean;
  55105. /**
  55106. * Returns true if the mesh should render, otherwise false.
  55107. * @param mesh The mesh to render
  55108. * @returns true if it should render otherwise false
  55109. */
  55110. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55111. /**
  55112. * Returns true if the mesh can be rendered, otherwise false.
  55113. * @param mesh The mesh to render
  55114. * @param material The material used on the mesh
  55115. * @returns true if it can be rendered otherwise false
  55116. */
  55117. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55118. /**
  55119. * Returns true if the mesh should render, otherwise false.
  55120. * @param mesh The mesh to render
  55121. * @returns true if it should render otherwise false
  55122. */
  55123. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55124. /**
  55125. * Renders the submesh passed in parameter to the generation map.
  55126. */
  55127. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55128. /**
  55129. * Defines whether the current material of the mesh should be use to render the effect.
  55130. * @param mesh defines the current mesh to render
  55131. */
  55132. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55133. /**
  55134. * Rebuild the required buffers.
  55135. * @hidden Internal use only.
  55136. */
  55137. _rebuild(): void;
  55138. /**
  55139. * Dispose only the render target textures and post process.
  55140. */
  55141. private _disposeTextureAndPostProcesses;
  55142. /**
  55143. * Dispose the highlight layer and free resources.
  55144. */
  55145. dispose(): void;
  55146. /**
  55147. * Gets the class name of the effect layer
  55148. * @returns the string with the class name of the effect layer
  55149. */
  55150. getClassName(): string;
  55151. /**
  55152. * Creates an effect layer from parsed effect layer data
  55153. * @param parsedEffectLayer defines effect layer data
  55154. * @param scene defines the current scene
  55155. * @param rootUrl defines the root URL containing the effect layer information
  55156. * @returns a parsed effect Layer
  55157. */
  55158. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55159. }
  55160. }
  55161. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55162. import { Scene } from "babylonjs/scene";
  55163. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55164. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55165. import { AbstractScene } from "babylonjs/abstractScene";
  55166. module "babylonjs/abstractScene" {
  55167. interface AbstractScene {
  55168. /**
  55169. * The list of effect layers (highlights/glow) added to the scene
  55170. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55171. * @see http://doc.babylonjs.com/how_to/glow_layer
  55172. */
  55173. effectLayers: Array<EffectLayer>;
  55174. /**
  55175. * Removes the given effect layer from this scene.
  55176. * @param toRemove defines the effect layer to remove
  55177. * @returns the index of the removed effect layer
  55178. */
  55179. removeEffectLayer(toRemove: EffectLayer): number;
  55180. /**
  55181. * Adds the given effect layer to this scene
  55182. * @param newEffectLayer defines the effect layer to add
  55183. */
  55184. addEffectLayer(newEffectLayer: EffectLayer): void;
  55185. }
  55186. }
  55187. /**
  55188. * Defines the layer scene component responsible to manage any effect layers
  55189. * in a given scene.
  55190. */
  55191. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55192. /**
  55193. * The component name helpfull to identify the component in the list of scene components.
  55194. */
  55195. readonly name: string;
  55196. /**
  55197. * The scene the component belongs to.
  55198. */
  55199. scene: Scene;
  55200. private _engine;
  55201. private _renderEffects;
  55202. private _needStencil;
  55203. private _previousStencilState;
  55204. /**
  55205. * Creates a new instance of the component for the given scene
  55206. * @param scene Defines the scene to register the component in
  55207. */
  55208. constructor(scene: Scene);
  55209. /**
  55210. * Registers the component in a given scene
  55211. */
  55212. register(): void;
  55213. /**
  55214. * Rebuilds the elements related to this component in case of
  55215. * context lost for instance.
  55216. */
  55217. rebuild(): void;
  55218. /**
  55219. * Serializes the component data to the specified json object
  55220. * @param serializationObject The object to serialize to
  55221. */
  55222. serialize(serializationObject: any): void;
  55223. /**
  55224. * Adds all the elements from the container to the scene
  55225. * @param container the container holding the elements
  55226. */
  55227. addFromContainer(container: AbstractScene): void;
  55228. /**
  55229. * Removes all the elements in the container from the scene
  55230. * @param container contains the elements to remove
  55231. * @param dispose if the removed element should be disposed (default: false)
  55232. */
  55233. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55234. /**
  55235. * Disposes the component and the associated ressources.
  55236. */
  55237. dispose(): void;
  55238. private _isReadyForMesh;
  55239. private _renderMainTexture;
  55240. private _setStencil;
  55241. private _setStencilBack;
  55242. private _draw;
  55243. private _drawCamera;
  55244. private _drawRenderingGroup;
  55245. }
  55246. }
  55247. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55248. /** @hidden */
  55249. export var glowMapMergePixelShader: {
  55250. name: string;
  55251. shader: string;
  55252. };
  55253. }
  55254. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55255. /** @hidden */
  55256. export var glowMapMergeVertexShader: {
  55257. name: string;
  55258. shader: string;
  55259. };
  55260. }
  55261. declare module "babylonjs/Layers/glowLayer" {
  55262. import { Nullable } from "babylonjs/types";
  55263. import { Camera } from "babylonjs/Cameras/camera";
  55264. import { Scene } from "babylonjs/scene";
  55265. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55267. import { Mesh } from "babylonjs/Meshes/mesh";
  55268. import { Texture } from "babylonjs/Materials/Textures/texture";
  55269. import { Effect } from "babylonjs/Materials/effect";
  55270. import { Material } from "babylonjs/Materials/material";
  55271. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55272. import { Color4 } from "babylonjs/Maths/math.color";
  55273. import "babylonjs/Shaders/glowMapMerge.fragment";
  55274. import "babylonjs/Shaders/glowMapMerge.vertex";
  55275. import "babylonjs/Layers/effectLayerSceneComponent";
  55276. module "babylonjs/abstractScene" {
  55277. interface AbstractScene {
  55278. /**
  55279. * Return a the first highlight layer of the scene with a given name.
  55280. * @param name The name of the highlight layer to look for.
  55281. * @return The highlight layer if found otherwise null.
  55282. */
  55283. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55284. }
  55285. }
  55286. /**
  55287. * Glow layer options. This helps customizing the behaviour
  55288. * of the glow layer.
  55289. */
  55290. export interface IGlowLayerOptions {
  55291. /**
  55292. * Multiplication factor apply to the canvas size to compute the render target size
  55293. * used to generated the glowing objects (the smaller the faster).
  55294. */
  55295. mainTextureRatio: number;
  55296. /**
  55297. * Enforces a fixed size texture to ensure resize independant blur.
  55298. */
  55299. mainTextureFixedSize?: number;
  55300. /**
  55301. * How big is the kernel of the blur texture.
  55302. */
  55303. blurKernelSize: number;
  55304. /**
  55305. * The camera attached to the layer.
  55306. */
  55307. camera: Nullable<Camera>;
  55308. /**
  55309. * Enable MSAA by chosing the number of samples.
  55310. */
  55311. mainTextureSamples?: number;
  55312. /**
  55313. * The rendering group to draw the layer in.
  55314. */
  55315. renderingGroupId: number;
  55316. }
  55317. /**
  55318. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55319. *
  55320. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55321. *
  55322. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55323. */
  55324. export class GlowLayer extends EffectLayer {
  55325. /**
  55326. * Effect Name of the layer.
  55327. */
  55328. static readonly EffectName: string;
  55329. /**
  55330. * The default blur kernel size used for the glow.
  55331. */
  55332. static DefaultBlurKernelSize: number;
  55333. /**
  55334. * The default texture size ratio used for the glow.
  55335. */
  55336. static DefaultTextureRatio: number;
  55337. /**
  55338. * Sets the kernel size of the blur.
  55339. */
  55340. set blurKernelSize(value: number);
  55341. /**
  55342. * Gets the kernel size of the blur.
  55343. */
  55344. get blurKernelSize(): number;
  55345. /**
  55346. * Sets the glow intensity.
  55347. */
  55348. set intensity(value: number);
  55349. /**
  55350. * Gets the glow intensity.
  55351. */
  55352. get intensity(): number;
  55353. private _options;
  55354. private _intensity;
  55355. private _horizontalBlurPostprocess1;
  55356. private _verticalBlurPostprocess1;
  55357. private _horizontalBlurPostprocess2;
  55358. private _verticalBlurPostprocess2;
  55359. private _blurTexture1;
  55360. private _blurTexture2;
  55361. private _postProcesses1;
  55362. private _postProcesses2;
  55363. private _includedOnlyMeshes;
  55364. private _excludedMeshes;
  55365. private _meshesUsingTheirOwnMaterials;
  55366. /**
  55367. * Callback used to let the user override the color selection on a per mesh basis
  55368. */
  55369. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55370. /**
  55371. * Callback used to let the user override the texture selection on a per mesh basis
  55372. */
  55373. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55374. /**
  55375. * Instantiates a new glow Layer and references it to the scene.
  55376. * @param name The name of the layer
  55377. * @param scene The scene to use the layer in
  55378. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55379. */
  55380. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55381. /**
  55382. * Get the effect name of the layer.
  55383. * @return The effect name
  55384. */
  55385. getEffectName(): string;
  55386. /**
  55387. * Create the merge effect. This is the shader use to blit the information back
  55388. * to the main canvas at the end of the scene rendering.
  55389. */
  55390. protected _createMergeEffect(): Effect;
  55391. /**
  55392. * Creates the render target textures and post processes used in the glow layer.
  55393. */
  55394. protected _createTextureAndPostProcesses(): void;
  55395. /**
  55396. * Checks for the readiness of the element composing the layer.
  55397. * @param subMesh the mesh to check for
  55398. * @param useInstances specify wether or not to use instances to render the mesh
  55399. * @param emissiveTexture the associated emissive texture used to generate the glow
  55400. * @return true if ready otherwise, false
  55401. */
  55402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55403. /**
  55404. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55405. */
  55406. needStencil(): boolean;
  55407. /**
  55408. * Returns true if the mesh can be rendered, otherwise false.
  55409. * @param mesh The mesh to render
  55410. * @param material The material used on the mesh
  55411. * @returns true if it can be rendered otherwise false
  55412. */
  55413. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55414. /**
  55415. * Implementation specific of rendering the generating effect on the main canvas.
  55416. * @param effect The effect used to render through
  55417. */
  55418. protected _internalRender(effect: Effect): void;
  55419. /**
  55420. * Sets the required values for both the emissive texture and and the main color.
  55421. */
  55422. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55423. /**
  55424. * Returns true if the mesh should render, otherwise false.
  55425. * @param mesh The mesh to render
  55426. * @returns true if it should render otherwise false
  55427. */
  55428. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55429. /**
  55430. * Adds specific effects defines.
  55431. * @param defines The defines to add specifics to.
  55432. */
  55433. protected _addCustomEffectDefines(defines: string[]): void;
  55434. /**
  55435. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55436. * @param mesh The mesh to exclude from the glow layer
  55437. */
  55438. addExcludedMesh(mesh: Mesh): void;
  55439. /**
  55440. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55441. * @param mesh The mesh to remove
  55442. */
  55443. removeExcludedMesh(mesh: Mesh): void;
  55444. /**
  55445. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55446. * @param mesh The mesh to include in the glow layer
  55447. */
  55448. addIncludedOnlyMesh(mesh: Mesh): void;
  55449. /**
  55450. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55451. * @param mesh The mesh to remove
  55452. */
  55453. removeIncludedOnlyMesh(mesh: Mesh): void;
  55454. /**
  55455. * Determine if a given mesh will be used in the glow layer
  55456. * @param mesh The mesh to test
  55457. * @returns true if the mesh will be highlighted by the current glow layer
  55458. */
  55459. hasMesh(mesh: AbstractMesh): boolean;
  55460. /**
  55461. * Defines whether the current material of the mesh should be use to render the effect.
  55462. * @param mesh defines the current mesh to render
  55463. */
  55464. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55465. /**
  55466. * Add a mesh to be rendered through its own material and not with emissive only.
  55467. * @param mesh The mesh for which we need to use its material
  55468. */
  55469. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55470. /**
  55471. * Remove a mesh from being rendered through its own material and not with emissive only.
  55472. * @param mesh The mesh for which we need to not use its material
  55473. */
  55474. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55475. /**
  55476. * Free any resources and references associated to a mesh.
  55477. * Internal use
  55478. * @param mesh The mesh to free.
  55479. * @hidden
  55480. */
  55481. _disposeMesh(mesh: Mesh): void;
  55482. /**
  55483. * Gets the class name of the effect layer
  55484. * @returns the string with the class name of the effect layer
  55485. */
  55486. getClassName(): string;
  55487. /**
  55488. * Serializes this glow layer
  55489. * @returns a serialized glow layer object
  55490. */
  55491. serialize(): any;
  55492. /**
  55493. * Creates a Glow Layer from parsed glow layer data
  55494. * @param parsedGlowLayer defines glow layer data
  55495. * @param scene defines the current scene
  55496. * @param rootUrl defines the root URL containing the glow layer information
  55497. * @returns a parsed Glow Layer
  55498. */
  55499. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55500. }
  55501. }
  55502. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55503. /** @hidden */
  55504. export var glowBlurPostProcessPixelShader: {
  55505. name: string;
  55506. shader: string;
  55507. };
  55508. }
  55509. declare module "babylonjs/Layers/highlightLayer" {
  55510. import { Observable } from "babylonjs/Misc/observable";
  55511. import { Nullable } from "babylonjs/types";
  55512. import { Camera } from "babylonjs/Cameras/camera";
  55513. import { Scene } from "babylonjs/scene";
  55514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55516. import { Mesh } from "babylonjs/Meshes/mesh";
  55517. import { Effect } from "babylonjs/Materials/effect";
  55518. import { Material } from "babylonjs/Materials/material";
  55519. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55520. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55521. import "babylonjs/Shaders/glowMapMerge.fragment";
  55522. import "babylonjs/Shaders/glowMapMerge.vertex";
  55523. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55524. module "babylonjs/abstractScene" {
  55525. interface AbstractScene {
  55526. /**
  55527. * Return a the first highlight layer of the scene with a given name.
  55528. * @param name The name of the highlight layer to look for.
  55529. * @return The highlight layer if found otherwise null.
  55530. */
  55531. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55532. }
  55533. }
  55534. /**
  55535. * Highlight layer options. This helps customizing the behaviour
  55536. * of the highlight layer.
  55537. */
  55538. export interface IHighlightLayerOptions {
  55539. /**
  55540. * Multiplication factor apply to the canvas size to compute the render target size
  55541. * used to generated the glowing objects (the smaller the faster).
  55542. */
  55543. mainTextureRatio: number;
  55544. /**
  55545. * Enforces a fixed size texture to ensure resize independant blur.
  55546. */
  55547. mainTextureFixedSize?: number;
  55548. /**
  55549. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55550. * of the picture to blur (the smaller the faster).
  55551. */
  55552. blurTextureSizeRatio: number;
  55553. /**
  55554. * How big in texel of the blur texture is the vertical blur.
  55555. */
  55556. blurVerticalSize: number;
  55557. /**
  55558. * How big in texel of the blur texture is the horizontal blur.
  55559. */
  55560. blurHorizontalSize: number;
  55561. /**
  55562. * Alpha blending mode used to apply the blur. Default is combine.
  55563. */
  55564. alphaBlendingMode: number;
  55565. /**
  55566. * The camera attached to the layer.
  55567. */
  55568. camera: Nullable<Camera>;
  55569. /**
  55570. * Should we display highlight as a solid stroke?
  55571. */
  55572. isStroke?: boolean;
  55573. /**
  55574. * The rendering group to draw the layer in.
  55575. */
  55576. renderingGroupId: number;
  55577. }
  55578. /**
  55579. * The highlight layer Helps adding a glow effect around a mesh.
  55580. *
  55581. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55582. * glowy meshes to your scene.
  55583. *
  55584. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55585. */
  55586. export class HighlightLayer extends EffectLayer {
  55587. name: string;
  55588. /**
  55589. * Effect Name of the highlight layer.
  55590. */
  55591. static readonly EffectName: string;
  55592. /**
  55593. * The neutral color used during the preparation of the glow effect.
  55594. * This is black by default as the blend operation is a blend operation.
  55595. */
  55596. static NeutralColor: Color4;
  55597. /**
  55598. * Stencil value used for glowing meshes.
  55599. */
  55600. static GlowingMeshStencilReference: number;
  55601. /**
  55602. * Stencil value used for the other meshes in the scene.
  55603. */
  55604. static NormalMeshStencilReference: number;
  55605. /**
  55606. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55607. */
  55608. innerGlow: boolean;
  55609. /**
  55610. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55611. */
  55612. outerGlow: boolean;
  55613. /**
  55614. * Specifies the horizontal size of the blur.
  55615. */
  55616. set blurHorizontalSize(value: number);
  55617. /**
  55618. * Specifies the vertical size of the blur.
  55619. */
  55620. set blurVerticalSize(value: number);
  55621. /**
  55622. * Gets the horizontal size of the blur.
  55623. */
  55624. get blurHorizontalSize(): number;
  55625. /**
  55626. * Gets the vertical size of the blur.
  55627. */
  55628. get blurVerticalSize(): number;
  55629. /**
  55630. * An event triggered when the highlight layer is being blurred.
  55631. */
  55632. onBeforeBlurObservable: Observable<HighlightLayer>;
  55633. /**
  55634. * An event triggered when the highlight layer has been blurred.
  55635. */
  55636. onAfterBlurObservable: Observable<HighlightLayer>;
  55637. private _instanceGlowingMeshStencilReference;
  55638. private _options;
  55639. private _downSamplePostprocess;
  55640. private _horizontalBlurPostprocess;
  55641. private _verticalBlurPostprocess;
  55642. private _blurTexture;
  55643. private _meshes;
  55644. private _excludedMeshes;
  55645. /**
  55646. * Instantiates a new highlight Layer and references it to the scene..
  55647. * @param name The name of the layer
  55648. * @param scene The scene to use the layer in
  55649. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55650. */
  55651. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55652. /**
  55653. * Get the effect name of the layer.
  55654. * @return The effect name
  55655. */
  55656. getEffectName(): string;
  55657. /**
  55658. * Create the merge effect. This is the shader use to blit the information back
  55659. * to the main canvas at the end of the scene rendering.
  55660. */
  55661. protected _createMergeEffect(): Effect;
  55662. /**
  55663. * Creates the render target textures and post processes used in the highlight layer.
  55664. */
  55665. protected _createTextureAndPostProcesses(): void;
  55666. /**
  55667. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55668. */
  55669. needStencil(): boolean;
  55670. /**
  55671. * Checks for the readiness of the element composing the layer.
  55672. * @param subMesh the mesh to check for
  55673. * @param useInstances specify wether or not to use instances to render the mesh
  55674. * @param emissiveTexture the associated emissive texture used to generate the glow
  55675. * @return true if ready otherwise, false
  55676. */
  55677. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55678. /**
  55679. * Implementation specific of rendering the generating effect on the main canvas.
  55680. * @param effect The effect used to render through
  55681. */
  55682. protected _internalRender(effect: Effect): void;
  55683. /**
  55684. * Returns true if the layer contains information to display, otherwise false.
  55685. */
  55686. shouldRender(): boolean;
  55687. /**
  55688. * Returns true if the mesh should render, otherwise false.
  55689. * @param mesh The mesh to render
  55690. * @returns true if it should render otherwise false
  55691. */
  55692. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55693. /**
  55694. * Sets the required values for both the emissive texture and and the main color.
  55695. */
  55696. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55697. /**
  55698. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55699. * @param mesh The mesh to exclude from the highlight layer
  55700. */
  55701. addExcludedMesh(mesh: Mesh): void;
  55702. /**
  55703. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55704. * @param mesh The mesh to highlight
  55705. */
  55706. removeExcludedMesh(mesh: Mesh): void;
  55707. /**
  55708. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55709. * @param mesh mesh to test
  55710. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55711. */
  55712. hasMesh(mesh: AbstractMesh): boolean;
  55713. /**
  55714. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55715. * @param mesh The mesh to highlight
  55716. * @param color The color of the highlight
  55717. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55718. */
  55719. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55720. /**
  55721. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55722. * @param mesh The mesh to highlight
  55723. */
  55724. removeMesh(mesh: Mesh): void;
  55725. /**
  55726. * Remove all the meshes currently referenced in the highlight layer
  55727. */
  55728. removeAllMeshes(): void;
  55729. /**
  55730. * Force the stencil to the normal expected value for none glowing parts
  55731. */
  55732. private _defaultStencilReference;
  55733. /**
  55734. * Free any resources and references associated to a mesh.
  55735. * Internal use
  55736. * @param mesh The mesh to free.
  55737. * @hidden
  55738. */
  55739. _disposeMesh(mesh: Mesh): void;
  55740. /**
  55741. * Dispose the highlight layer and free resources.
  55742. */
  55743. dispose(): void;
  55744. /**
  55745. * Gets the class name of the effect layer
  55746. * @returns the string with the class name of the effect layer
  55747. */
  55748. getClassName(): string;
  55749. /**
  55750. * Serializes this Highlight layer
  55751. * @returns a serialized Highlight layer object
  55752. */
  55753. serialize(): any;
  55754. /**
  55755. * Creates a Highlight layer from parsed Highlight layer data
  55756. * @param parsedHightlightLayer defines the Highlight layer data
  55757. * @param scene defines the current scene
  55758. * @param rootUrl defines the root URL containing the Highlight layer information
  55759. * @returns a parsed Highlight layer
  55760. */
  55761. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55762. }
  55763. }
  55764. declare module "babylonjs/Layers/layerSceneComponent" {
  55765. import { Scene } from "babylonjs/scene";
  55766. import { ISceneComponent } from "babylonjs/sceneComponent";
  55767. import { Layer } from "babylonjs/Layers/layer";
  55768. import { AbstractScene } from "babylonjs/abstractScene";
  55769. module "babylonjs/abstractScene" {
  55770. interface AbstractScene {
  55771. /**
  55772. * The list of layers (background and foreground) of the scene
  55773. */
  55774. layers: Array<Layer>;
  55775. }
  55776. }
  55777. /**
  55778. * Defines the layer scene component responsible to manage any layers
  55779. * in a given scene.
  55780. */
  55781. export class LayerSceneComponent implements ISceneComponent {
  55782. /**
  55783. * The component name helpfull to identify the component in the list of scene components.
  55784. */
  55785. readonly name: string;
  55786. /**
  55787. * The scene the component belongs to.
  55788. */
  55789. scene: Scene;
  55790. private _engine;
  55791. /**
  55792. * Creates a new instance of the component for the given scene
  55793. * @param scene Defines the scene to register the component in
  55794. */
  55795. constructor(scene: Scene);
  55796. /**
  55797. * Registers the component in a given scene
  55798. */
  55799. register(): void;
  55800. /**
  55801. * Rebuilds the elements related to this component in case of
  55802. * context lost for instance.
  55803. */
  55804. rebuild(): void;
  55805. /**
  55806. * Disposes the component and the associated ressources.
  55807. */
  55808. dispose(): void;
  55809. private _draw;
  55810. private _drawCameraPredicate;
  55811. private _drawCameraBackground;
  55812. private _drawCameraForeground;
  55813. private _drawRenderTargetPredicate;
  55814. private _drawRenderTargetBackground;
  55815. private _drawRenderTargetForeground;
  55816. /**
  55817. * Adds all the elements from the container to the scene
  55818. * @param container the container holding the elements
  55819. */
  55820. addFromContainer(container: AbstractScene): void;
  55821. /**
  55822. * Removes all the elements in the container from the scene
  55823. * @param container contains the elements to remove
  55824. * @param dispose if the removed element should be disposed (default: false)
  55825. */
  55826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55827. }
  55828. }
  55829. declare module "babylonjs/Shaders/layer.fragment" {
  55830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55831. /** @hidden */
  55832. export var layerPixelShader: {
  55833. name: string;
  55834. shader: string;
  55835. };
  55836. }
  55837. declare module "babylonjs/Shaders/layer.vertex" {
  55838. /** @hidden */
  55839. export var layerVertexShader: {
  55840. name: string;
  55841. shader: string;
  55842. };
  55843. }
  55844. declare module "babylonjs/Layers/layer" {
  55845. import { Observable } from "babylonjs/Misc/observable";
  55846. import { Nullable } from "babylonjs/types";
  55847. import { Scene } from "babylonjs/scene";
  55848. import { Vector2 } from "babylonjs/Maths/math.vector";
  55849. import { Color4 } from "babylonjs/Maths/math.color";
  55850. import { Texture } from "babylonjs/Materials/Textures/texture";
  55851. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55852. import "babylonjs/Shaders/layer.fragment";
  55853. import "babylonjs/Shaders/layer.vertex";
  55854. /**
  55855. * This represents a full screen 2d layer.
  55856. * This can be useful to display a picture in the background of your scene for instance.
  55857. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55858. */
  55859. export class Layer {
  55860. /**
  55861. * Define the name of the layer.
  55862. */
  55863. name: string;
  55864. /**
  55865. * Define the texture the layer should display.
  55866. */
  55867. texture: Nullable<Texture>;
  55868. /**
  55869. * Is the layer in background or foreground.
  55870. */
  55871. isBackground: boolean;
  55872. /**
  55873. * Define the color of the layer (instead of texture).
  55874. */
  55875. color: Color4;
  55876. /**
  55877. * Define the scale of the layer in order to zoom in out of the texture.
  55878. */
  55879. scale: Vector2;
  55880. /**
  55881. * Define an offset for the layer in order to shift the texture.
  55882. */
  55883. offset: Vector2;
  55884. /**
  55885. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55886. */
  55887. alphaBlendingMode: number;
  55888. /**
  55889. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55890. * Alpha test will not mix with the background color in case of transparency.
  55891. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55892. */
  55893. alphaTest: boolean;
  55894. /**
  55895. * Define a mask to restrict the layer to only some of the scene cameras.
  55896. */
  55897. layerMask: number;
  55898. /**
  55899. * Define the list of render target the layer is visible into.
  55900. */
  55901. renderTargetTextures: RenderTargetTexture[];
  55902. /**
  55903. * Define if the layer is only used in renderTarget or if it also
  55904. * renders in the main frame buffer of the canvas.
  55905. */
  55906. renderOnlyInRenderTargetTextures: boolean;
  55907. private _scene;
  55908. private _vertexBuffers;
  55909. private _indexBuffer;
  55910. private _effect;
  55911. private _previousDefines;
  55912. /**
  55913. * An event triggered when the layer is disposed.
  55914. */
  55915. onDisposeObservable: Observable<Layer>;
  55916. private _onDisposeObserver;
  55917. /**
  55918. * Back compatibility with callback before the onDisposeObservable existed.
  55919. * The set callback will be triggered when the layer has been disposed.
  55920. */
  55921. set onDispose(callback: () => void);
  55922. /**
  55923. * An event triggered before rendering the scene
  55924. */
  55925. onBeforeRenderObservable: Observable<Layer>;
  55926. private _onBeforeRenderObserver;
  55927. /**
  55928. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55929. * The set callback will be triggered just before rendering the layer.
  55930. */
  55931. set onBeforeRender(callback: () => void);
  55932. /**
  55933. * An event triggered after rendering the scene
  55934. */
  55935. onAfterRenderObservable: Observable<Layer>;
  55936. private _onAfterRenderObserver;
  55937. /**
  55938. * Back compatibility with callback before the onAfterRenderObservable existed.
  55939. * The set callback will be triggered just after rendering the layer.
  55940. */
  55941. set onAfterRender(callback: () => void);
  55942. /**
  55943. * Instantiates a new layer.
  55944. * This represents a full screen 2d layer.
  55945. * This can be useful to display a picture in the background of your scene for instance.
  55946. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55947. * @param name Define the name of the layer in the scene
  55948. * @param imgUrl Define the url of the texture to display in the layer
  55949. * @param scene Define the scene the layer belongs to
  55950. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55951. * @param color Defines a color for the layer
  55952. */
  55953. constructor(
  55954. /**
  55955. * Define the name of the layer.
  55956. */
  55957. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55958. private _createIndexBuffer;
  55959. /** @hidden */
  55960. _rebuild(): void;
  55961. /**
  55962. * Renders the layer in the scene.
  55963. */
  55964. render(): void;
  55965. /**
  55966. * Disposes and releases the associated ressources.
  55967. */
  55968. dispose(): void;
  55969. }
  55970. }
  55971. declare module "babylonjs/Layers/index" {
  55972. export * from "babylonjs/Layers/effectLayer";
  55973. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55974. export * from "babylonjs/Layers/glowLayer";
  55975. export * from "babylonjs/Layers/highlightLayer";
  55976. export * from "babylonjs/Layers/layer";
  55977. export * from "babylonjs/Layers/layerSceneComponent";
  55978. }
  55979. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55980. /** @hidden */
  55981. export var lensFlarePixelShader: {
  55982. name: string;
  55983. shader: string;
  55984. };
  55985. }
  55986. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55987. /** @hidden */
  55988. export var lensFlareVertexShader: {
  55989. name: string;
  55990. shader: string;
  55991. };
  55992. }
  55993. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55994. import { Scene } from "babylonjs/scene";
  55995. import { Vector3 } from "babylonjs/Maths/math.vector";
  55996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55997. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55998. import "babylonjs/Shaders/lensFlare.fragment";
  55999. import "babylonjs/Shaders/lensFlare.vertex";
  56000. import { Viewport } from "babylonjs/Maths/math.viewport";
  56001. /**
  56002. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56003. * It is usually composed of several `lensFlare`.
  56004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56005. */
  56006. export class LensFlareSystem {
  56007. /**
  56008. * Define the name of the lens flare system
  56009. */
  56010. name: string;
  56011. /**
  56012. * List of lens flares used in this system.
  56013. */
  56014. lensFlares: LensFlare[];
  56015. /**
  56016. * Define a limit from the border the lens flare can be visible.
  56017. */
  56018. borderLimit: number;
  56019. /**
  56020. * Define a viewport border we do not want to see the lens flare in.
  56021. */
  56022. viewportBorder: number;
  56023. /**
  56024. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56025. */
  56026. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56027. /**
  56028. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56029. */
  56030. layerMask: number;
  56031. /**
  56032. * Define the id of the lens flare system in the scene.
  56033. * (equal to name by default)
  56034. */
  56035. id: string;
  56036. private _scene;
  56037. private _emitter;
  56038. private _vertexBuffers;
  56039. private _indexBuffer;
  56040. private _effect;
  56041. private _positionX;
  56042. private _positionY;
  56043. private _isEnabled;
  56044. /** @hidden */
  56045. static _SceneComponentInitialization: (scene: Scene) => void;
  56046. /**
  56047. * Instantiates a lens flare system.
  56048. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56049. * It is usually composed of several `lensFlare`.
  56050. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56051. * @param name Define the name of the lens flare system in the scene
  56052. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56053. * @param scene Define the scene the lens flare system belongs to
  56054. */
  56055. constructor(
  56056. /**
  56057. * Define the name of the lens flare system
  56058. */
  56059. name: string, emitter: any, scene: Scene);
  56060. /**
  56061. * Define if the lens flare system is enabled.
  56062. */
  56063. get isEnabled(): boolean;
  56064. set isEnabled(value: boolean);
  56065. /**
  56066. * Get the scene the effects belongs to.
  56067. * @returns the scene holding the lens flare system
  56068. */
  56069. getScene(): Scene;
  56070. /**
  56071. * Get the emitter of the lens flare system.
  56072. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56073. * @returns the emitter of the lens flare system
  56074. */
  56075. getEmitter(): any;
  56076. /**
  56077. * Set the emitter of the lens flare system.
  56078. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56079. * @param newEmitter Define the new emitter of the system
  56080. */
  56081. setEmitter(newEmitter: any): void;
  56082. /**
  56083. * Get the lens flare system emitter position.
  56084. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56085. * @returns the position
  56086. */
  56087. getEmitterPosition(): Vector3;
  56088. /**
  56089. * @hidden
  56090. */
  56091. computeEffectivePosition(globalViewport: Viewport): boolean;
  56092. /** @hidden */
  56093. _isVisible(): boolean;
  56094. /**
  56095. * @hidden
  56096. */
  56097. render(): boolean;
  56098. /**
  56099. * Dispose and release the lens flare with its associated resources.
  56100. */
  56101. dispose(): void;
  56102. /**
  56103. * Parse a lens flare system from a JSON repressentation
  56104. * @param parsedLensFlareSystem Define the JSON to parse
  56105. * @param scene Define the scene the parsed system should be instantiated in
  56106. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56107. * @returns the parsed system
  56108. */
  56109. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56110. /**
  56111. * Serialize the current Lens Flare System into a JSON representation.
  56112. * @returns the serialized JSON
  56113. */
  56114. serialize(): any;
  56115. }
  56116. }
  56117. declare module "babylonjs/LensFlares/lensFlare" {
  56118. import { Nullable } from "babylonjs/types";
  56119. import { Color3 } from "babylonjs/Maths/math.color";
  56120. import { Texture } from "babylonjs/Materials/Textures/texture";
  56121. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56122. /**
  56123. * This represents one of the lens effect in a `lensFlareSystem`.
  56124. * It controls one of the indiviual texture used in the effect.
  56125. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56126. */
  56127. export class LensFlare {
  56128. /**
  56129. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56130. */
  56131. size: number;
  56132. /**
  56133. * 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.
  56134. */
  56135. position: number;
  56136. /**
  56137. * Define the lens color.
  56138. */
  56139. color: Color3;
  56140. /**
  56141. * Define the lens texture.
  56142. */
  56143. texture: Nullable<Texture>;
  56144. /**
  56145. * Define the alpha mode to render this particular lens.
  56146. */
  56147. alphaMode: number;
  56148. private _system;
  56149. /**
  56150. * Creates a new Lens Flare.
  56151. * This represents one of the lens effect in a `lensFlareSystem`.
  56152. * It controls one of the indiviual texture used in the effect.
  56153. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56154. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56155. * @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.
  56156. * @param color Define the lens color
  56157. * @param imgUrl Define the lens texture url
  56158. * @param system Define the `lensFlareSystem` this flare is part of
  56159. * @returns The newly created Lens Flare
  56160. */
  56161. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56162. /**
  56163. * Instantiates a new Lens Flare.
  56164. * This represents one of the lens effect in a `lensFlareSystem`.
  56165. * It controls one of the indiviual texture used in the effect.
  56166. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56167. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56168. * @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.
  56169. * @param color Define the lens color
  56170. * @param imgUrl Define the lens texture url
  56171. * @param system Define the `lensFlareSystem` this flare is part of
  56172. */
  56173. constructor(
  56174. /**
  56175. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56176. */
  56177. size: number,
  56178. /**
  56179. * 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.
  56180. */
  56181. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56182. /**
  56183. * Dispose and release the lens flare with its associated resources.
  56184. */
  56185. dispose(): void;
  56186. }
  56187. }
  56188. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56189. import { Nullable } from "babylonjs/types";
  56190. import { Scene } from "babylonjs/scene";
  56191. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56192. import { AbstractScene } from "babylonjs/abstractScene";
  56193. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56194. module "babylonjs/abstractScene" {
  56195. interface AbstractScene {
  56196. /**
  56197. * The list of lens flare system added to the scene
  56198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56199. */
  56200. lensFlareSystems: Array<LensFlareSystem>;
  56201. /**
  56202. * Removes the given lens flare system from this scene.
  56203. * @param toRemove The lens flare system to remove
  56204. * @returns The index of the removed lens flare system
  56205. */
  56206. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56207. /**
  56208. * Adds the given lens flare system to this scene
  56209. * @param newLensFlareSystem The lens flare system to add
  56210. */
  56211. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56212. /**
  56213. * Gets a lens flare system using its name
  56214. * @param name defines the name to look for
  56215. * @returns the lens flare system or null if not found
  56216. */
  56217. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56218. /**
  56219. * Gets a lens flare system using its id
  56220. * @param id defines the id to look for
  56221. * @returns the lens flare system or null if not found
  56222. */
  56223. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56224. }
  56225. }
  56226. /**
  56227. * Defines the lens flare scene component responsible to manage any lens flares
  56228. * in a given scene.
  56229. */
  56230. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56231. /**
  56232. * The component name helpfull to identify the component in the list of scene components.
  56233. */
  56234. readonly name: string;
  56235. /**
  56236. * The scene the component belongs to.
  56237. */
  56238. scene: Scene;
  56239. /**
  56240. * Creates a new instance of the component for the given scene
  56241. * @param scene Defines the scene to register the component in
  56242. */
  56243. constructor(scene: Scene);
  56244. /**
  56245. * Registers the component in a given scene
  56246. */
  56247. register(): void;
  56248. /**
  56249. * Rebuilds the elements related to this component in case of
  56250. * context lost for instance.
  56251. */
  56252. rebuild(): void;
  56253. /**
  56254. * Adds all the elements from the container to the scene
  56255. * @param container the container holding the elements
  56256. */
  56257. addFromContainer(container: AbstractScene): void;
  56258. /**
  56259. * Removes all the elements in the container from the scene
  56260. * @param container contains the elements to remove
  56261. * @param dispose if the removed element should be disposed (default: false)
  56262. */
  56263. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56264. /**
  56265. * Serializes the component data to the specified json object
  56266. * @param serializationObject The object to serialize to
  56267. */
  56268. serialize(serializationObject: any): void;
  56269. /**
  56270. * Disposes the component and the associated ressources.
  56271. */
  56272. dispose(): void;
  56273. private _draw;
  56274. }
  56275. }
  56276. declare module "babylonjs/LensFlares/index" {
  56277. export * from "babylonjs/LensFlares/lensFlare";
  56278. export * from "babylonjs/LensFlares/lensFlareSystem";
  56279. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56280. }
  56281. declare module "babylonjs/Shaders/depth.fragment" {
  56282. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56283. /** @hidden */
  56284. export var depthPixelShader: {
  56285. name: string;
  56286. shader: string;
  56287. };
  56288. }
  56289. declare module "babylonjs/Shaders/depth.vertex" {
  56290. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56291. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56292. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56293. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56294. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56295. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56296. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56297. /** @hidden */
  56298. export var depthVertexShader: {
  56299. name: string;
  56300. shader: string;
  56301. };
  56302. }
  56303. declare module "babylonjs/Rendering/depthRenderer" {
  56304. import { Nullable } from "babylonjs/types";
  56305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56306. import { Scene } from "babylonjs/scene";
  56307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56308. import { Camera } from "babylonjs/Cameras/camera";
  56309. import "babylonjs/Shaders/depth.fragment";
  56310. import "babylonjs/Shaders/depth.vertex";
  56311. /**
  56312. * This represents a depth renderer in Babylon.
  56313. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56314. */
  56315. export class DepthRenderer {
  56316. private _scene;
  56317. private _depthMap;
  56318. private _effect;
  56319. private readonly _storeNonLinearDepth;
  56320. private readonly _clearColor;
  56321. /** Get if the depth renderer is using packed depth or not */
  56322. readonly isPacked: boolean;
  56323. private _cachedDefines;
  56324. private _camera;
  56325. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56326. enabled: boolean;
  56327. /**
  56328. * Specifiess that the depth renderer will only be used within
  56329. * the camera it is created for.
  56330. * This can help forcing its rendering during the camera processing.
  56331. */
  56332. useOnlyInActiveCamera: boolean;
  56333. /** @hidden */
  56334. static _SceneComponentInitialization: (scene: Scene) => void;
  56335. /**
  56336. * Instantiates a depth renderer
  56337. * @param scene The scene the renderer belongs to
  56338. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56339. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56340. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56341. */
  56342. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56343. /**
  56344. * Creates the depth rendering effect and checks if the effect is ready.
  56345. * @param subMesh The submesh to be used to render the depth map of
  56346. * @param useInstances If multiple world instances should be used
  56347. * @returns if the depth renderer is ready to render the depth map
  56348. */
  56349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56350. /**
  56351. * Gets the texture which the depth map will be written to.
  56352. * @returns The depth map texture
  56353. */
  56354. getDepthMap(): RenderTargetTexture;
  56355. /**
  56356. * Disposes of the depth renderer.
  56357. */
  56358. dispose(): void;
  56359. }
  56360. }
  56361. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56362. /** @hidden */
  56363. export var minmaxReduxPixelShader: {
  56364. name: string;
  56365. shader: string;
  56366. };
  56367. }
  56368. declare module "babylonjs/Misc/minMaxReducer" {
  56369. import { Nullable } from "babylonjs/types";
  56370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56371. import { Camera } from "babylonjs/Cameras/camera";
  56372. import { Observer } from "babylonjs/Misc/observable";
  56373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56374. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56375. import { Observable } from "babylonjs/Misc/observable";
  56376. import "babylonjs/Shaders/minmaxRedux.fragment";
  56377. /**
  56378. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56379. * and maximum values from all values of the texture.
  56380. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56381. * The source values are read from the red channel of the texture.
  56382. */
  56383. export class MinMaxReducer {
  56384. /**
  56385. * Observable triggered when the computation has been performed
  56386. */
  56387. onAfterReductionPerformed: Observable<{
  56388. min: number;
  56389. max: number;
  56390. }>;
  56391. protected _camera: Camera;
  56392. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56393. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56394. protected _postProcessManager: PostProcessManager;
  56395. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56396. protected _forceFullscreenViewport: boolean;
  56397. /**
  56398. * Creates a min/max reducer
  56399. * @param camera The camera to use for the post processes
  56400. */
  56401. constructor(camera: Camera);
  56402. /**
  56403. * Gets the texture used to read the values from.
  56404. */
  56405. get sourceTexture(): Nullable<RenderTargetTexture>;
  56406. /**
  56407. * Sets the source texture to read the values from.
  56408. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56409. * because in such textures '1' value must not be taken into account to compute the maximum
  56410. * as this value is used to clear the texture.
  56411. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56412. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56413. * @param depthRedux Indicates if the texture is a depth texture or not
  56414. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56415. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56416. */
  56417. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56418. /**
  56419. * Defines the refresh rate of the computation.
  56420. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56421. */
  56422. get refreshRate(): number;
  56423. set refreshRate(value: number);
  56424. protected _activated: boolean;
  56425. /**
  56426. * Gets the activation status of the reducer
  56427. */
  56428. get activated(): boolean;
  56429. /**
  56430. * Activates the reduction computation.
  56431. * When activated, the observers registered in onAfterReductionPerformed are
  56432. * called after the compuation is performed
  56433. */
  56434. activate(): void;
  56435. /**
  56436. * Deactivates the reduction computation.
  56437. */
  56438. deactivate(): void;
  56439. /**
  56440. * Disposes the min/max reducer
  56441. * @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.
  56442. */
  56443. dispose(disposeAll?: boolean): void;
  56444. }
  56445. }
  56446. declare module "babylonjs/Misc/depthReducer" {
  56447. import { Nullable } from "babylonjs/types";
  56448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56449. import { Camera } from "babylonjs/Cameras/camera";
  56450. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56451. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56452. /**
  56453. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56454. */
  56455. export class DepthReducer extends MinMaxReducer {
  56456. private _depthRenderer;
  56457. private _depthRendererId;
  56458. /**
  56459. * Gets the depth renderer used for the computation.
  56460. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56461. */
  56462. get depthRenderer(): Nullable<DepthRenderer>;
  56463. /**
  56464. * Creates a depth reducer
  56465. * @param camera The camera used to render the depth texture
  56466. */
  56467. constructor(camera: Camera);
  56468. /**
  56469. * Sets the depth renderer to use to generate the depth map
  56470. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56471. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56472. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56473. */
  56474. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56475. /** @hidden */
  56476. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56477. /**
  56478. * Activates the reduction computation.
  56479. * When activated, the observers registered in onAfterReductionPerformed are
  56480. * called after the compuation is performed
  56481. */
  56482. activate(): void;
  56483. /**
  56484. * Deactivates the reduction computation.
  56485. */
  56486. deactivate(): void;
  56487. /**
  56488. * Disposes the depth reducer
  56489. * @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.
  56490. */
  56491. dispose(disposeAll?: boolean): void;
  56492. }
  56493. }
  56494. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56495. import { Nullable } from "babylonjs/types";
  56496. import { Scene } from "babylonjs/scene";
  56497. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56499. import { Effect } from "babylonjs/Materials/effect";
  56500. import "babylonjs/Shaders/shadowMap.fragment";
  56501. import "babylonjs/Shaders/shadowMap.vertex";
  56502. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56503. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56504. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56505. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56506. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56507. /**
  56508. * A CSM implementation allowing casting shadows on large scenes.
  56509. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56510. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56511. */
  56512. export class CascadedShadowGenerator extends ShadowGenerator {
  56513. private static readonly frustumCornersNDCSpace;
  56514. /**
  56515. * Name of the CSM class
  56516. */
  56517. static CLASSNAME: string;
  56518. /**
  56519. * Defines the default number of cascades used by the CSM.
  56520. */
  56521. static readonly DEFAULT_CASCADES_COUNT: number;
  56522. /**
  56523. * Defines the minimum number of cascades used by the CSM.
  56524. */
  56525. static readonly MIN_CASCADES_COUNT: number;
  56526. /**
  56527. * Defines the maximum number of cascades used by the CSM.
  56528. */
  56529. static readonly MAX_CASCADES_COUNT: number;
  56530. protected _validateFilter(filter: number): number;
  56531. /**
  56532. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56533. */
  56534. penumbraDarkness: number;
  56535. private _numCascades;
  56536. /**
  56537. * Gets or set the number of cascades used by the CSM.
  56538. */
  56539. get numCascades(): number;
  56540. set numCascades(value: number);
  56541. /**
  56542. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56543. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56544. */
  56545. stabilizeCascades: boolean;
  56546. private _freezeShadowCastersBoundingInfo;
  56547. private _freezeShadowCastersBoundingInfoObservable;
  56548. /**
  56549. * Enables or disables the shadow casters bounding info computation.
  56550. * If your shadow casters don't move, you can disable this feature.
  56551. * If it is enabled, the bounding box computation is done every frame.
  56552. */
  56553. get freezeShadowCastersBoundingInfo(): boolean;
  56554. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56555. private _scbiMin;
  56556. private _scbiMax;
  56557. protected _computeShadowCastersBoundingInfo(): void;
  56558. protected _shadowCastersBoundingInfo: BoundingInfo;
  56559. /**
  56560. * Gets or sets the shadow casters bounding info.
  56561. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56562. * so that the system won't overwrite the bounds you provide
  56563. */
  56564. get shadowCastersBoundingInfo(): BoundingInfo;
  56565. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56566. protected _breaksAreDirty: boolean;
  56567. protected _minDistance: number;
  56568. protected _maxDistance: number;
  56569. /**
  56570. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56571. *
  56572. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56573. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56574. * @param min minimal distance for the breaks (default to 0.)
  56575. * @param max maximal distance for the breaks (default to 1.)
  56576. */
  56577. setMinMaxDistance(min: number, max: number): void;
  56578. /** Gets the minimal distance used in the cascade break computation */
  56579. get minDistance(): number;
  56580. /** Gets the maximal distance used in the cascade break computation */
  56581. get maxDistance(): number;
  56582. /**
  56583. * Gets the class name of that object
  56584. * @returns "CascadedShadowGenerator"
  56585. */
  56586. getClassName(): string;
  56587. private _cascadeMinExtents;
  56588. private _cascadeMaxExtents;
  56589. /**
  56590. * Gets a cascade minimum extents
  56591. * @param cascadeIndex index of the cascade
  56592. * @returns the minimum cascade extents
  56593. */
  56594. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56595. /**
  56596. * Gets a cascade maximum extents
  56597. * @param cascadeIndex index of the cascade
  56598. * @returns the maximum cascade extents
  56599. */
  56600. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56601. private _cascades;
  56602. private _currentLayer;
  56603. private _viewSpaceFrustumsZ;
  56604. private _viewMatrices;
  56605. private _projectionMatrices;
  56606. private _transformMatrices;
  56607. private _transformMatricesAsArray;
  56608. private _frustumLengths;
  56609. private _lightSizeUVCorrection;
  56610. private _depthCorrection;
  56611. private _frustumCornersWorldSpace;
  56612. private _frustumCenter;
  56613. private _shadowCameraPos;
  56614. private _shadowMaxZ;
  56615. /**
  56616. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56617. * It defaults to camera.maxZ
  56618. */
  56619. get shadowMaxZ(): number;
  56620. /**
  56621. * Sets the shadow max z distance.
  56622. */
  56623. set shadowMaxZ(value: number);
  56624. protected _debug: boolean;
  56625. /**
  56626. * Gets or sets the debug flag.
  56627. * When enabled, the cascades are materialized by different colors on the screen.
  56628. */
  56629. get debug(): boolean;
  56630. set debug(dbg: boolean);
  56631. private _depthClamp;
  56632. /**
  56633. * Gets or sets the depth clamping value.
  56634. *
  56635. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56636. * to account for the shadow casters far away.
  56637. *
  56638. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56639. */
  56640. get depthClamp(): boolean;
  56641. set depthClamp(value: boolean);
  56642. private _cascadeBlendPercentage;
  56643. /**
  56644. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56645. * It defaults to 0.1 (10% blending).
  56646. */
  56647. get cascadeBlendPercentage(): number;
  56648. set cascadeBlendPercentage(value: number);
  56649. private _lambda;
  56650. /**
  56651. * Gets or set the lambda parameter.
  56652. * This parameter is used to split the camera frustum and create the cascades.
  56653. * 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.
  56654. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56655. */
  56656. get lambda(): number;
  56657. set lambda(value: number);
  56658. /**
  56659. * Gets the view matrix corresponding to a given cascade
  56660. * @param cascadeNum cascade to retrieve the view matrix from
  56661. * @returns the cascade view matrix
  56662. */
  56663. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56664. /**
  56665. * Gets the projection matrix corresponding to a given cascade
  56666. * @param cascadeNum cascade to retrieve the projection matrix from
  56667. * @returns the cascade projection matrix
  56668. */
  56669. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56670. /**
  56671. * Gets the transformation matrix corresponding to a given cascade
  56672. * @param cascadeNum cascade to retrieve the transformation matrix from
  56673. * @returns the cascade transformation matrix
  56674. */
  56675. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56676. private _depthRenderer;
  56677. /**
  56678. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56679. *
  56680. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56681. *
  56682. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56683. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56684. * @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
  56685. */
  56686. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56687. private _depthReducer;
  56688. private _autoCalcDepthBounds;
  56689. /**
  56690. * Gets or sets the autoCalcDepthBounds property.
  56691. *
  56692. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56693. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56694. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56695. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56696. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56697. */
  56698. get autoCalcDepthBounds(): boolean;
  56699. set autoCalcDepthBounds(value: boolean);
  56700. /**
  56701. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56702. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56703. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56704. * for setting the refresh rate on the renderer yourself!
  56705. */
  56706. get autoCalcDepthBoundsRefreshRate(): number;
  56707. set autoCalcDepthBoundsRefreshRate(value: number);
  56708. /**
  56709. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56710. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56711. * you change the camera near/far planes!
  56712. */
  56713. splitFrustum(): void;
  56714. private _splitFrustum;
  56715. private _computeMatrices;
  56716. private _computeFrustumInWorldSpace;
  56717. private _computeCascadeFrustum;
  56718. /** @hidden */
  56719. static _SceneComponentInitialization: (scene: Scene) => void;
  56720. /**
  56721. * Creates a Cascaded Shadow Generator object.
  56722. * A ShadowGenerator is the required tool to use the shadows.
  56723. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56724. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56725. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56726. * @param light The directional light object generating the shadows.
  56727. * @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.
  56728. */
  56729. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56730. protected _initializeGenerator(): void;
  56731. protected _createTargetRenderTexture(): void;
  56732. protected _initializeShadowMap(): void;
  56733. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56734. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56735. /**
  56736. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56737. * @param defines Defines of the material we want to update
  56738. * @param lightIndex Index of the light in the enabled light list of the material
  56739. */
  56740. prepareDefines(defines: any, lightIndex: number): void;
  56741. /**
  56742. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56743. * defined in the generator but impacting the effect).
  56744. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56745. * @param effect The effect we are binfing the information for
  56746. */
  56747. bindShadowLight(lightIndex: string, effect: Effect): void;
  56748. /**
  56749. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56750. * (eq to view projection * shadow projection matrices)
  56751. * @returns The transform matrix used to create the shadow map
  56752. */
  56753. getTransformMatrix(): Matrix;
  56754. /**
  56755. * Disposes the ShadowGenerator.
  56756. * Returns nothing.
  56757. */
  56758. dispose(): void;
  56759. /**
  56760. * Serializes the shadow generator setup to a json object.
  56761. * @returns The serialized JSON object
  56762. */
  56763. serialize(): any;
  56764. /**
  56765. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56766. * @param parsedShadowGenerator The JSON object to parse
  56767. * @param scene The scene to create the shadow map for
  56768. * @returns The parsed shadow generator
  56769. */
  56770. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56771. }
  56772. }
  56773. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56774. import { Scene } from "babylonjs/scene";
  56775. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56776. import { AbstractScene } from "babylonjs/abstractScene";
  56777. /**
  56778. * Defines the shadow generator component responsible to manage any shadow generators
  56779. * in a given scene.
  56780. */
  56781. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56782. /**
  56783. * The component name helpfull to identify the component in the list of scene components.
  56784. */
  56785. readonly name: string;
  56786. /**
  56787. * The scene the component belongs to.
  56788. */
  56789. scene: Scene;
  56790. /**
  56791. * Creates a new instance of the component for the given scene
  56792. * @param scene Defines the scene to register the component in
  56793. */
  56794. constructor(scene: Scene);
  56795. /**
  56796. * Registers the component in a given scene
  56797. */
  56798. register(): void;
  56799. /**
  56800. * Rebuilds the elements related to this component in case of
  56801. * context lost for instance.
  56802. */
  56803. rebuild(): void;
  56804. /**
  56805. * Serializes the component data to the specified json object
  56806. * @param serializationObject The object to serialize to
  56807. */
  56808. serialize(serializationObject: any): void;
  56809. /**
  56810. * Adds all the elements from the container to the scene
  56811. * @param container the container holding the elements
  56812. */
  56813. addFromContainer(container: AbstractScene): void;
  56814. /**
  56815. * Removes all the elements in the container from the scene
  56816. * @param container contains the elements to remove
  56817. * @param dispose if the removed element should be disposed (default: false)
  56818. */
  56819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56820. /**
  56821. * Rebuilds the elements related to this component in case of
  56822. * context lost for instance.
  56823. */
  56824. dispose(): void;
  56825. private _gatherRenderTargets;
  56826. }
  56827. }
  56828. declare module "babylonjs/Lights/Shadows/index" {
  56829. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56830. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56831. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56832. }
  56833. declare module "babylonjs/Lights/pointLight" {
  56834. import { Scene } from "babylonjs/scene";
  56835. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56837. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56838. import { Effect } from "babylonjs/Materials/effect";
  56839. /**
  56840. * A point light is a light defined by an unique point in world space.
  56841. * The light is emitted in every direction from this point.
  56842. * A good example of a point light is a standard light bulb.
  56843. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56844. */
  56845. export class PointLight extends ShadowLight {
  56846. private _shadowAngle;
  56847. /**
  56848. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56849. * This specifies what angle the shadow will use to be created.
  56850. *
  56851. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56852. */
  56853. get shadowAngle(): number;
  56854. /**
  56855. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56856. * This specifies what angle the shadow will use to be created.
  56857. *
  56858. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56859. */
  56860. set shadowAngle(value: number);
  56861. /**
  56862. * Gets the direction if it has been set.
  56863. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56864. */
  56865. get direction(): Vector3;
  56866. /**
  56867. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56868. */
  56869. set direction(value: Vector3);
  56870. /**
  56871. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56872. * A PointLight emits the light in every direction.
  56873. * It can cast shadows.
  56874. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56875. * ```javascript
  56876. * var pointLight = new PointLight("pl", camera.position, scene);
  56877. * ```
  56878. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56879. * @param name The light friendly name
  56880. * @param position The position of the point light in the scene
  56881. * @param scene The scene the lights belongs to
  56882. */
  56883. constructor(name: string, position: Vector3, scene: Scene);
  56884. /**
  56885. * Returns the string "PointLight"
  56886. * @returns the class name
  56887. */
  56888. getClassName(): string;
  56889. /**
  56890. * Returns the integer 0.
  56891. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56892. */
  56893. getTypeID(): number;
  56894. /**
  56895. * Specifies wether or not the shadowmap should be a cube texture.
  56896. * @returns true if the shadowmap needs to be a cube texture.
  56897. */
  56898. needCube(): boolean;
  56899. /**
  56900. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56901. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56902. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56903. */
  56904. getShadowDirection(faceIndex?: number): Vector3;
  56905. /**
  56906. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56907. * - fov = PI / 2
  56908. * - aspect ratio : 1.0
  56909. * - z-near and far equal to the active camera minZ and maxZ.
  56910. * Returns the PointLight.
  56911. */
  56912. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56913. protected _buildUniformLayout(): void;
  56914. /**
  56915. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56916. * @param effect The effect to update
  56917. * @param lightIndex The index of the light in the effect to update
  56918. * @returns The point light
  56919. */
  56920. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56921. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56922. /**
  56923. * Prepares the list of defines specific to the light type.
  56924. * @param defines the list of defines
  56925. * @param lightIndex defines the index of the light for the effect
  56926. */
  56927. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56928. }
  56929. }
  56930. declare module "babylonjs/Lights/index" {
  56931. export * from "babylonjs/Lights/light";
  56932. export * from "babylonjs/Lights/shadowLight";
  56933. export * from "babylonjs/Lights/Shadows/index";
  56934. export * from "babylonjs/Lights/directionalLight";
  56935. export * from "babylonjs/Lights/hemisphericLight";
  56936. export * from "babylonjs/Lights/pointLight";
  56937. export * from "babylonjs/Lights/spotLight";
  56938. }
  56939. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56940. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56941. /**
  56942. * Header information of HDR texture files.
  56943. */
  56944. export interface HDRInfo {
  56945. /**
  56946. * The height of the texture in pixels.
  56947. */
  56948. height: number;
  56949. /**
  56950. * The width of the texture in pixels.
  56951. */
  56952. width: number;
  56953. /**
  56954. * The index of the beginning of the data in the binary file.
  56955. */
  56956. dataPosition: number;
  56957. }
  56958. /**
  56959. * This groups tools to convert HDR texture to native colors array.
  56960. */
  56961. export class HDRTools {
  56962. private static Ldexp;
  56963. private static Rgbe2float;
  56964. private static readStringLine;
  56965. /**
  56966. * Reads header information from an RGBE texture stored in a native array.
  56967. * More information on this format are available here:
  56968. * https://en.wikipedia.org/wiki/RGBE_image_format
  56969. *
  56970. * @param uint8array The binary file stored in native array.
  56971. * @return The header information.
  56972. */
  56973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56974. /**
  56975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56976. * This RGBE texture needs to store the information as a panorama.
  56977. *
  56978. * More information on this format are available here:
  56979. * https://en.wikipedia.org/wiki/RGBE_image_format
  56980. *
  56981. * @param buffer The binary file stored in an array buffer.
  56982. * @param size The expected size of the extracted cubemap.
  56983. * @return The Cube Map information.
  56984. */
  56985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56986. /**
  56987. * Returns the pixels data extracted from an RGBE texture.
  56988. * This pixels will be stored left to right up to down in the R G B order in one array.
  56989. *
  56990. * More information on this format are available here:
  56991. * https://en.wikipedia.org/wiki/RGBE_image_format
  56992. *
  56993. * @param uint8array The binary file stored in an array buffer.
  56994. * @param hdrInfo The header information of the file.
  56995. * @return The pixels data in RGB right to left up to down order.
  56996. */
  56997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56998. private static RGBE_ReadPixels_RLE;
  56999. }
  57000. }
  57001. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57002. import { Nullable } from "babylonjs/types";
  57003. import { Scene } from "babylonjs/scene";
  57004. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57006. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57007. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57008. /**
  57009. * This represents a texture coming from an HDR input.
  57010. *
  57011. * The only supported format is currently panorama picture stored in RGBE format.
  57012. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57013. */
  57014. export class HDRCubeTexture extends BaseTexture {
  57015. private static _facesMapping;
  57016. private _generateHarmonics;
  57017. private _noMipmap;
  57018. private _textureMatrix;
  57019. private _size;
  57020. private _onLoad;
  57021. private _onError;
  57022. /**
  57023. * The texture URL.
  57024. */
  57025. url: string;
  57026. /**
  57027. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57028. */
  57029. coordinatesMode: number;
  57030. protected _isBlocking: boolean;
  57031. /**
  57032. * Sets wether or not the texture is blocking during loading.
  57033. */
  57034. set isBlocking(value: boolean);
  57035. /**
  57036. * Gets wether or not the texture is blocking during loading.
  57037. */
  57038. get isBlocking(): boolean;
  57039. protected _rotationY: number;
  57040. /**
  57041. * Sets texture matrix rotation angle around Y axis in radians.
  57042. */
  57043. set rotationY(value: number);
  57044. /**
  57045. * Gets texture matrix rotation angle around Y axis radians.
  57046. */
  57047. get rotationY(): number;
  57048. /**
  57049. * Gets or sets the center of the bounding box associated with the cube texture
  57050. * It must define where the camera used to render the texture was set
  57051. */
  57052. boundingBoxPosition: Vector3;
  57053. private _boundingBoxSize;
  57054. /**
  57055. * Gets or sets the size of the bounding box associated with the cube texture
  57056. * When defined, the cubemap will switch to local mode
  57057. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57058. * @example https://www.babylonjs-playground.com/#RNASML
  57059. */
  57060. set boundingBoxSize(value: Vector3);
  57061. get boundingBoxSize(): Vector3;
  57062. /**
  57063. * Instantiates an HDRTexture from the following parameters.
  57064. *
  57065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57066. * @param scene The scene the texture will be used in
  57067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57068. * @param noMipmap Forces to not generate the mipmap if true
  57069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57070. * @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)
  57071. * @param reserved Reserved flag for internal use.
  57072. */
  57073. 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>);
  57074. /**
  57075. * Get the current class name of the texture useful for serialization or dynamic coding.
  57076. * @returns "HDRCubeTexture"
  57077. */
  57078. getClassName(): string;
  57079. /**
  57080. * Occurs when the file is raw .hdr file.
  57081. */
  57082. private loadTexture;
  57083. clone(): HDRCubeTexture;
  57084. delayLoad(): void;
  57085. /**
  57086. * Get the texture reflection matrix used to rotate/transform the reflection.
  57087. * @returns the reflection matrix
  57088. */
  57089. getReflectionTextureMatrix(): Matrix;
  57090. /**
  57091. * Set the texture reflection matrix used to rotate/transform the reflection.
  57092. * @param value Define the reflection matrix to set
  57093. */
  57094. setReflectionTextureMatrix(value: Matrix): void;
  57095. /**
  57096. * Parses a JSON representation of an HDR Texture in order to create the texture
  57097. * @param parsedTexture Define the JSON representation
  57098. * @param scene Define the scene the texture should be created in
  57099. * @param rootUrl Define the root url in case we need to load relative dependencies
  57100. * @returns the newly created texture after parsing
  57101. */
  57102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57103. serialize(): any;
  57104. }
  57105. }
  57106. declare module "babylonjs/Physics/physicsEngine" {
  57107. import { Nullable } from "babylonjs/types";
  57108. import { Vector3 } from "babylonjs/Maths/math.vector";
  57109. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57110. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57111. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57112. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57113. /**
  57114. * Class used to control physics engine
  57115. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57116. */
  57117. export class PhysicsEngine implements IPhysicsEngine {
  57118. private _physicsPlugin;
  57119. /**
  57120. * Global value used to control the smallest number supported by the simulation
  57121. */
  57122. static Epsilon: number;
  57123. private _impostors;
  57124. private _joints;
  57125. private _subTimeStep;
  57126. /**
  57127. * Gets the gravity vector used by the simulation
  57128. */
  57129. gravity: Vector3;
  57130. /**
  57131. * Factory used to create the default physics plugin.
  57132. * @returns The default physics plugin
  57133. */
  57134. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57135. /**
  57136. * Creates a new Physics Engine
  57137. * @param gravity defines the gravity vector used by the simulation
  57138. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57139. */
  57140. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57141. /**
  57142. * Sets the gravity vector used by the simulation
  57143. * @param gravity defines the gravity vector to use
  57144. */
  57145. setGravity(gravity: Vector3): void;
  57146. /**
  57147. * Set the time step of the physics engine.
  57148. * Default is 1/60.
  57149. * To slow it down, enter 1/600 for example.
  57150. * To speed it up, 1/30
  57151. * @param newTimeStep defines the new timestep to apply to this world.
  57152. */
  57153. setTimeStep(newTimeStep?: number): void;
  57154. /**
  57155. * Get the time step of the physics engine.
  57156. * @returns the current time step
  57157. */
  57158. getTimeStep(): number;
  57159. /**
  57160. * Set the sub time step of the physics engine.
  57161. * Default is 0 meaning there is no sub steps
  57162. * To increase physics resolution precision, set a small value (like 1 ms)
  57163. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57164. */
  57165. setSubTimeStep(subTimeStep?: number): void;
  57166. /**
  57167. * Get the sub time step of the physics engine.
  57168. * @returns the current sub time step
  57169. */
  57170. getSubTimeStep(): number;
  57171. /**
  57172. * Release all resources
  57173. */
  57174. dispose(): void;
  57175. /**
  57176. * Gets the name of the current physics plugin
  57177. * @returns the name of the plugin
  57178. */
  57179. getPhysicsPluginName(): string;
  57180. /**
  57181. * Adding a new impostor for the impostor tracking.
  57182. * This will be done by the impostor itself.
  57183. * @param impostor the impostor to add
  57184. */
  57185. addImpostor(impostor: PhysicsImpostor): void;
  57186. /**
  57187. * Remove an impostor from the engine.
  57188. * This impostor and its mesh will not longer be updated by the physics engine.
  57189. * @param impostor the impostor to remove
  57190. */
  57191. removeImpostor(impostor: PhysicsImpostor): void;
  57192. /**
  57193. * Add a joint to the physics engine
  57194. * @param mainImpostor defines the main impostor to which the joint is added.
  57195. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57196. * @param joint defines the joint that will connect both impostors.
  57197. */
  57198. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57199. /**
  57200. * Removes a joint from the simulation
  57201. * @param mainImpostor defines the impostor used with the joint
  57202. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57203. * @param joint defines the joint to remove
  57204. */
  57205. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57206. /**
  57207. * Called by the scene. No need to call it.
  57208. * @param delta defines the timespam between frames
  57209. */
  57210. _step(delta: number): void;
  57211. /**
  57212. * Gets the current plugin used to run the simulation
  57213. * @returns current plugin
  57214. */
  57215. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57216. /**
  57217. * Gets the list of physic impostors
  57218. * @returns an array of PhysicsImpostor
  57219. */
  57220. getImpostors(): Array<PhysicsImpostor>;
  57221. /**
  57222. * Gets the impostor for a physics enabled object
  57223. * @param object defines the object impersonated by the impostor
  57224. * @returns the PhysicsImpostor or null if not found
  57225. */
  57226. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57227. /**
  57228. * Gets the impostor for a physics body object
  57229. * @param body defines physics body used by the impostor
  57230. * @returns the PhysicsImpostor or null if not found
  57231. */
  57232. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57233. /**
  57234. * Does a raycast in the physics world
  57235. * @param from when should the ray start?
  57236. * @param to when should the ray end?
  57237. * @returns PhysicsRaycastResult
  57238. */
  57239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57240. }
  57241. }
  57242. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57243. import { Nullable } from "babylonjs/types";
  57244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57246. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57247. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57248. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57249. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57250. /** @hidden */
  57251. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57252. private _useDeltaForWorldStep;
  57253. world: any;
  57254. name: string;
  57255. private _physicsMaterials;
  57256. private _fixedTimeStep;
  57257. private _cannonRaycastResult;
  57258. private _raycastResult;
  57259. private _physicsBodysToRemoveAfterStep;
  57260. BJSCANNON: any;
  57261. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57262. setGravity(gravity: Vector3): void;
  57263. setTimeStep(timeStep: number): void;
  57264. getTimeStep(): number;
  57265. executeStep(delta: number): void;
  57266. private _removeMarkedPhysicsBodiesFromWorld;
  57267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57269. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57270. private _processChildMeshes;
  57271. removePhysicsBody(impostor: PhysicsImpostor): void;
  57272. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57273. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57274. private _addMaterial;
  57275. private _checkWithEpsilon;
  57276. private _createShape;
  57277. private _createHeightmap;
  57278. private _minus90X;
  57279. private _plus90X;
  57280. private _tmpPosition;
  57281. private _tmpDeltaPosition;
  57282. private _tmpUnityRotation;
  57283. private _updatePhysicsBodyTransformation;
  57284. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57285. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57286. isSupported(): boolean;
  57287. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57288. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57289. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57291. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57292. getBodyMass(impostor: PhysicsImpostor): number;
  57293. getBodyFriction(impostor: PhysicsImpostor): number;
  57294. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57295. getBodyRestitution(impostor: PhysicsImpostor): number;
  57296. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57297. sleepBody(impostor: PhysicsImpostor): void;
  57298. wakeUpBody(impostor: PhysicsImpostor): void;
  57299. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57300. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57301. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57302. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57303. getRadius(impostor: PhysicsImpostor): number;
  57304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57305. dispose(): void;
  57306. private _extendNamespace;
  57307. /**
  57308. * Does a raycast in the physics world
  57309. * @param from when should the ray start?
  57310. * @param to when should the ray end?
  57311. * @returns PhysicsRaycastResult
  57312. */
  57313. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57314. }
  57315. }
  57316. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57317. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57318. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57319. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57321. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57322. import { Nullable } from "babylonjs/types";
  57323. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57324. /** @hidden */
  57325. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57326. world: any;
  57327. name: string;
  57328. BJSOIMO: any;
  57329. private _raycastResult;
  57330. constructor(iterations?: number, oimoInjection?: any);
  57331. setGravity(gravity: Vector3): void;
  57332. setTimeStep(timeStep: number): void;
  57333. getTimeStep(): number;
  57334. private _tmpImpostorsArray;
  57335. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57339. private _tmpPositionVector;
  57340. removePhysicsBody(impostor: PhysicsImpostor): void;
  57341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57343. isSupported(): boolean;
  57344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57351. getBodyMass(impostor: PhysicsImpostor): number;
  57352. getBodyFriction(impostor: PhysicsImpostor): number;
  57353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57354. getBodyRestitution(impostor: PhysicsImpostor): number;
  57355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57356. sleepBody(impostor: PhysicsImpostor): void;
  57357. wakeUpBody(impostor: PhysicsImpostor): void;
  57358. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57359. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57360. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57361. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57362. getRadius(impostor: PhysicsImpostor): number;
  57363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57364. dispose(): void;
  57365. /**
  57366. * Does a raycast in the physics world
  57367. * @param from when should the ray start?
  57368. * @param to when should the ray end?
  57369. * @returns PhysicsRaycastResult
  57370. */
  57371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57372. }
  57373. }
  57374. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57375. import { Nullable } from "babylonjs/types";
  57376. import { Scene } from "babylonjs/scene";
  57377. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57378. import { Color4 } from "babylonjs/Maths/math.color";
  57379. import { Mesh } from "babylonjs/Meshes/mesh";
  57380. /**
  57381. * Class containing static functions to help procedurally build meshes
  57382. */
  57383. export class RibbonBuilder {
  57384. /**
  57385. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57386. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57387. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57388. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57389. * * 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
  57390. * * 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
  57391. * * 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
  57392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57395. * * 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
  57396. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57397. * * 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
  57398. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57400. * @param name defines the name of the mesh
  57401. * @param options defines the options used to create the mesh
  57402. * @param scene defines the hosting scene
  57403. * @returns the ribbon mesh
  57404. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57406. */
  57407. static CreateRibbon(name: string, options: {
  57408. pathArray: Vector3[][];
  57409. closeArray?: boolean;
  57410. closePath?: boolean;
  57411. offset?: number;
  57412. updatable?: boolean;
  57413. sideOrientation?: number;
  57414. frontUVs?: Vector4;
  57415. backUVs?: Vector4;
  57416. instance?: Mesh;
  57417. invertUV?: boolean;
  57418. uvs?: Vector2[];
  57419. colors?: Color4[];
  57420. }, scene?: Nullable<Scene>): Mesh;
  57421. }
  57422. }
  57423. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57424. import { Nullable } from "babylonjs/types";
  57425. import { Scene } from "babylonjs/scene";
  57426. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57427. import { Mesh } from "babylonjs/Meshes/mesh";
  57428. /**
  57429. * Class containing static functions to help procedurally build meshes
  57430. */
  57431. export class ShapeBuilder {
  57432. /**
  57433. * 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.
  57434. * * 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.
  57435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57436. * * 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.
  57437. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57438. * * 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
  57439. * * 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
  57440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57445. * @param name defines the name of the mesh
  57446. * @param options defines the options used to create the mesh
  57447. * @param scene defines the hosting scene
  57448. * @returns the extruded shape mesh
  57449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57451. */
  57452. static ExtrudeShape(name: string, options: {
  57453. shape: Vector3[];
  57454. path: Vector3[];
  57455. scale?: number;
  57456. rotation?: number;
  57457. cap?: number;
  57458. updatable?: boolean;
  57459. sideOrientation?: number;
  57460. frontUVs?: Vector4;
  57461. backUVs?: Vector4;
  57462. instance?: Mesh;
  57463. invertUV?: boolean;
  57464. }, scene?: Nullable<Scene>): Mesh;
  57465. /**
  57466. * Creates an custom extruded shape mesh.
  57467. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57468. * * 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.
  57469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57470. * * 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
  57471. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57472. * * 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
  57473. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57474. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57475. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57476. * * 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
  57477. * * 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
  57478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57483. * @param name defines the name of the mesh
  57484. * @param options defines the options used to create the mesh
  57485. * @param scene defines the hosting scene
  57486. * @returns the custom extruded shape mesh
  57487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57490. */
  57491. static ExtrudeShapeCustom(name: string, options: {
  57492. shape: Vector3[];
  57493. path: Vector3[];
  57494. scaleFunction?: any;
  57495. rotationFunction?: any;
  57496. ribbonCloseArray?: boolean;
  57497. ribbonClosePath?: boolean;
  57498. cap?: number;
  57499. updatable?: boolean;
  57500. sideOrientation?: number;
  57501. frontUVs?: Vector4;
  57502. backUVs?: Vector4;
  57503. instance?: Mesh;
  57504. invertUV?: boolean;
  57505. }, scene?: Nullable<Scene>): Mesh;
  57506. private static _ExtrudeShapeGeneric;
  57507. }
  57508. }
  57509. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57510. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57511. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57513. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57514. import { Nullable } from "babylonjs/types";
  57515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57516. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57517. /**
  57518. * AmmoJS Physics plugin
  57519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57520. * @see https://github.com/kripken/ammo.js/
  57521. */
  57522. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57523. private _useDeltaForWorldStep;
  57524. /**
  57525. * Reference to the Ammo library
  57526. */
  57527. bjsAMMO: any;
  57528. /**
  57529. * Created ammoJS world which physics bodies are added to
  57530. */
  57531. world: any;
  57532. /**
  57533. * Name of the plugin
  57534. */
  57535. name: string;
  57536. private _timeStep;
  57537. private _fixedTimeStep;
  57538. private _maxSteps;
  57539. private _tmpQuaternion;
  57540. private _tmpAmmoTransform;
  57541. private _tmpAmmoQuaternion;
  57542. private _tmpAmmoConcreteContactResultCallback;
  57543. private _collisionConfiguration;
  57544. private _dispatcher;
  57545. private _overlappingPairCache;
  57546. private _solver;
  57547. private _softBodySolver;
  57548. private _tmpAmmoVectorA;
  57549. private _tmpAmmoVectorB;
  57550. private _tmpAmmoVectorC;
  57551. private _tmpAmmoVectorD;
  57552. private _tmpContactCallbackResult;
  57553. private _tmpAmmoVectorRCA;
  57554. private _tmpAmmoVectorRCB;
  57555. private _raycastResult;
  57556. private static readonly DISABLE_COLLISION_FLAG;
  57557. private static readonly KINEMATIC_FLAG;
  57558. private static readonly DISABLE_DEACTIVATION_FLAG;
  57559. /**
  57560. * Initializes the ammoJS plugin
  57561. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57562. * @param ammoInjection can be used to inject your own ammo reference
  57563. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57564. */
  57565. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57566. /**
  57567. * Sets the gravity of the physics world (m/(s^2))
  57568. * @param gravity Gravity to set
  57569. */
  57570. setGravity(gravity: Vector3): void;
  57571. /**
  57572. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57573. * @param timeStep timestep to use in seconds
  57574. */
  57575. setTimeStep(timeStep: number): void;
  57576. /**
  57577. * 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)
  57578. * @param fixedTimeStep fixedTimeStep to use in seconds
  57579. */
  57580. setFixedTimeStep(fixedTimeStep: number): void;
  57581. /**
  57582. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57583. * @param maxSteps the maximum number of steps by the physics engine per frame
  57584. */
  57585. setMaxSteps(maxSteps: number): void;
  57586. /**
  57587. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57588. * @returns the current timestep in seconds
  57589. */
  57590. getTimeStep(): number;
  57591. /**
  57592. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57593. */
  57594. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57595. private _isImpostorInContact;
  57596. private _isImpostorPairInContact;
  57597. private _stepSimulation;
  57598. /**
  57599. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57600. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57601. * After the step the babylon meshes are set to the position of the physics imposters
  57602. * @param delta amount of time to step forward
  57603. * @param impostors array of imposters to update before/after the step
  57604. */
  57605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57606. /**
  57607. * Update babylon mesh to match physics world object
  57608. * @param impostor imposter to match
  57609. */
  57610. private _afterSoftStep;
  57611. /**
  57612. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57613. * @param impostor imposter to match
  57614. */
  57615. private _ropeStep;
  57616. /**
  57617. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57618. * @param impostor imposter to match
  57619. */
  57620. private _softbodyOrClothStep;
  57621. private _tmpVector;
  57622. private _tmpMatrix;
  57623. /**
  57624. * Applies an impulse on the imposter
  57625. * @param impostor imposter to apply impulse to
  57626. * @param force amount of force to be applied to the imposter
  57627. * @param contactPoint the location to apply the impulse on the imposter
  57628. */
  57629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57630. /**
  57631. * Applies a force on the imposter
  57632. * @param impostor imposter to apply force
  57633. * @param force amount of force to be applied to the imposter
  57634. * @param contactPoint the location to apply the force on the imposter
  57635. */
  57636. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57637. /**
  57638. * Creates a physics body using the plugin
  57639. * @param impostor the imposter to create the physics body on
  57640. */
  57641. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57642. /**
  57643. * Removes the physics body from the imposter and disposes of the body's memory
  57644. * @param impostor imposter to remove the physics body from
  57645. */
  57646. removePhysicsBody(impostor: PhysicsImpostor): void;
  57647. /**
  57648. * Generates a joint
  57649. * @param impostorJoint the imposter joint to create the joint with
  57650. */
  57651. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57652. /**
  57653. * Removes a joint
  57654. * @param impostorJoint the imposter joint to remove the joint from
  57655. */
  57656. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57657. private _addMeshVerts;
  57658. /**
  57659. * Initialise the soft body vertices to match its object's (mesh) vertices
  57660. * Softbody vertices (nodes) are in world space and to match this
  57661. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57662. * @param impostor to create the softbody for
  57663. */
  57664. private _softVertexData;
  57665. /**
  57666. * Create an impostor's soft body
  57667. * @param impostor to create the softbody for
  57668. */
  57669. private _createSoftbody;
  57670. /**
  57671. * Create cloth for an impostor
  57672. * @param impostor to create the softbody for
  57673. */
  57674. private _createCloth;
  57675. /**
  57676. * Create rope for an impostor
  57677. * @param impostor to create the softbody for
  57678. */
  57679. private _createRope;
  57680. /**
  57681. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57682. * @param impostor to create the custom physics shape for
  57683. */
  57684. private _createCustom;
  57685. private _addHullVerts;
  57686. private _createShape;
  57687. /**
  57688. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57689. * @param impostor imposter containing the physics body and babylon object
  57690. */
  57691. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57692. /**
  57693. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57694. * @param impostor imposter containing the physics body and babylon object
  57695. * @param newPosition new position
  57696. * @param newRotation new rotation
  57697. */
  57698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57699. /**
  57700. * If this plugin is supported
  57701. * @returns true if its supported
  57702. */
  57703. isSupported(): boolean;
  57704. /**
  57705. * Sets the linear velocity of the physics body
  57706. * @param impostor imposter to set the velocity on
  57707. * @param velocity velocity to set
  57708. */
  57709. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57710. /**
  57711. * Sets the angular velocity of the physics body
  57712. * @param impostor imposter to set the velocity on
  57713. * @param velocity velocity to set
  57714. */
  57715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57716. /**
  57717. * gets the linear velocity
  57718. * @param impostor imposter to get linear velocity from
  57719. * @returns linear velocity
  57720. */
  57721. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57722. /**
  57723. * gets the angular velocity
  57724. * @param impostor imposter to get angular velocity from
  57725. * @returns angular velocity
  57726. */
  57727. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57728. /**
  57729. * Sets the mass of physics body
  57730. * @param impostor imposter to set the mass on
  57731. * @param mass mass to set
  57732. */
  57733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57734. /**
  57735. * Gets the mass of the physics body
  57736. * @param impostor imposter to get the mass from
  57737. * @returns mass
  57738. */
  57739. getBodyMass(impostor: PhysicsImpostor): number;
  57740. /**
  57741. * Gets friction of the impostor
  57742. * @param impostor impostor to get friction from
  57743. * @returns friction value
  57744. */
  57745. getBodyFriction(impostor: PhysicsImpostor): number;
  57746. /**
  57747. * Sets friction of the impostor
  57748. * @param impostor impostor to set friction on
  57749. * @param friction friction value
  57750. */
  57751. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57752. /**
  57753. * Gets restitution of the impostor
  57754. * @param impostor impostor to get restitution from
  57755. * @returns restitution value
  57756. */
  57757. getBodyRestitution(impostor: PhysicsImpostor): number;
  57758. /**
  57759. * Sets resitution of the impostor
  57760. * @param impostor impostor to set resitution on
  57761. * @param restitution resitution value
  57762. */
  57763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57764. /**
  57765. * Gets pressure inside the impostor
  57766. * @param impostor impostor to get pressure from
  57767. * @returns pressure value
  57768. */
  57769. getBodyPressure(impostor: PhysicsImpostor): number;
  57770. /**
  57771. * Sets pressure inside a soft body impostor
  57772. * Cloth and rope must remain 0 pressure
  57773. * @param impostor impostor to set pressure on
  57774. * @param pressure pressure value
  57775. */
  57776. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57777. /**
  57778. * Gets stiffness of the impostor
  57779. * @param impostor impostor to get stiffness from
  57780. * @returns pressure value
  57781. */
  57782. getBodyStiffness(impostor: PhysicsImpostor): number;
  57783. /**
  57784. * Sets stiffness of the impostor
  57785. * @param impostor impostor to set stiffness on
  57786. * @param stiffness stiffness value from 0 to 1
  57787. */
  57788. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57789. /**
  57790. * Gets velocityIterations of the impostor
  57791. * @param impostor impostor to get velocity iterations from
  57792. * @returns velocityIterations value
  57793. */
  57794. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57795. /**
  57796. * Sets velocityIterations of the impostor
  57797. * @param impostor impostor to set velocity iterations on
  57798. * @param velocityIterations velocityIterations value
  57799. */
  57800. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57801. /**
  57802. * Gets positionIterations of the impostor
  57803. * @param impostor impostor to get position iterations from
  57804. * @returns positionIterations value
  57805. */
  57806. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57807. /**
  57808. * Sets positionIterations of the impostor
  57809. * @param impostor impostor to set position on
  57810. * @param positionIterations positionIterations value
  57811. */
  57812. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57813. /**
  57814. * Append an anchor to a cloth object
  57815. * @param impostor is the cloth impostor to add anchor to
  57816. * @param otherImpostor is the rigid impostor to anchor to
  57817. * @param width ratio across width from 0 to 1
  57818. * @param height ratio up height from 0 to 1
  57819. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57820. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57821. */
  57822. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57823. /**
  57824. * Append an hook to a rope object
  57825. * @param impostor is the rope impostor to add hook to
  57826. * @param otherImpostor is the rigid impostor to hook to
  57827. * @param length ratio along the rope from 0 to 1
  57828. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57829. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57830. */
  57831. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57832. /**
  57833. * Sleeps the physics body and stops it from being active
  57834. * @param impostor impostor to sleep
  57835. */
  57836. sleepBody(impostor: PhysicsImpostor): void;
  57837. /**
  57838. * Activates the physics body
  57839. * @param impostor impostor to activate
  57840. */
  57841. wakeUpBody(impostor: PhysicsImpostor): void;
  57842. /**
  57843. * Updates the distance parameters of the joint
  57844. * @param joint joint to update
  57845. * @param maxDistance maximum distance of the joint
  57846. * @param minDistance minimum distance of the joint
  57847. */
  57848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57849. /**
  57850. * Sets a motor on the joint
  57851. * @param joint joint to set motor on
  57852. * @param speed speed of the motor
  57853. * @param maxForce maximum force of the motor
  57854. * @param motorIndex index of the motor
  57855. */
  57856. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57857. /**
  57858. * Sets the motors limit
  57859. * @param joint joint to set limit on
  57860. * @param upperLimit upper limit
  57861. * @param lowerLimit lower limit
  57862. */
  57863. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57864. /**
  57865. * Syncs the position and rotation of a mesh with the impostor
  57866. * @param mesh mesh to sync
  57867. * @param impostor impostor to update the mesh with
  57868. */
  57869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57870. /**
  57871. * Gets the radius of the impostor
  57872. * @param impostor impostor to get radius from
  57873. * @returns the radius
  57874. */
  57875. getRadius(impostor: PhysicsImpostor): number;
  57876. /**
  57877. * Gets the box size of the impostor
  57878. * @param impostor impostor to get box size from
  57879. * @param result the resulting box size
  57880. */
  57881. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57882. /**
  57883. * Disposes of the impostor
  57884. */
  57885. dispose(): void;
  57886. /**
  57887. * Does a raycast in the physics world
  57888. * @param from when should the ray start?
  57889. * @param to when should the ray end?
  57890. * @returns PhysicsRaycastResult
  57891. */
  57892. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57893. }
  57894. }
  57895. declare module "babylonjs/Probes/reflectionProbe" {
  57896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57897. import { Vector3 } from "babylonjs/Maths/math.vector";
  57898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57899. import { Nullable } from "babylonjs/types";
  57900. import { Scene } from "babylonjs/scene";
  57901. module "babylonjs/abstractScene" {
  57902. interface AbstractScene {
  57903. /**
  57904. * The list of reflection probes added to the scene
  57905. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57906. */
  57907. reflectionProbes: Array<ReflectionProbe>;
  57908. /**
  57909. * Removes the given reflection probe from this scene.
  57910. * @param toRemove The reflection probe to remove
  57911. * @returns The index of the removed reflection probe
  57912. */
  57913. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57914. /**
  57915. * Adds the given reflection probe to this scene.
  57916. * @param newReflectionProbe The reflection probe to add
  57917. */
  57918. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57919. }
  57920. }
  57921. /**
  57922. * Class used to generate realtime reflection / refraction cube textures
  57923. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57924. */
  57925. export class ReflectionProbe {
  57926. /** defines the name of the probe */
  57927. name: string;
  57928. private _scene;
  57929. private _renderTargetTexture;
  57930. private _projectionMatrix;
  57931. private _viewMatrix;
  57932. private _target;
  57933. private _add;
  57934. private _attachedMesh;
  57935. private _invertYAxis;
  57936. /** Gets or sets probe position (center of the cube map) */
  57937. position: Vector3;
  57938. /**
  57939. * Creates a new reflection probe
  57940. * @param name defines the name of the probe
  57941. * @param size defines the texture resolution (for each face)
  57942. * @param scene defines the hosting scene
  57943. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57944. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57945. */
  57946. constructor(
  57947. /** defines the name of the probe */
  57948. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57949. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57950. get samples(): number;
  57951. set samples(value: number);
  57952. /** Gets or sets the refresh rate to use (on every frame by default) */
  57953. get refreshRate(): number;
  57954. set refreshRate(value: number);
  57955. /**
  57956. * Gets the hosting scene
  57957. * @returns a Scene
  57958. */
  57959. getScene(): Scene;
  57960. /** Gets the internal CubeTexture used to render to */
  57961. get cubeTexture(): RenderTargetTexture;
  57962. /** Gets the list of meshes to render */
  57963. get renderList(): Nullable<AbstractMesh[]>;
  57964. /**
  57965. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57966. * @param mesh defines the mesh to attach to
  57967. */
  57968. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57969. /**
  57970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57971. * @param renderingGroupId The rendering group id corresponding to its index
  57972. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57973. */
  57974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57975. /**
  57976. * Clean all associated resources
  57977. */
  57978. dispose(): void;
  57979. /**
  57980. * Converts the reflection probe information to a readable string for debug purpose.
  57981. * @param fullDetails Supports for multiple levels of logging within scene loading
  57982. * @returns the human readable reflection probe info
  57983. */
  57984. toString(fullDetails?: boolean): string;
  57985. /**
  57986. * Get the class name of the relfection probe.
  57987. * @returns "ReflectionProbe"
  57988. */
  57989. getClassName(): string;
  57990. /**
  57991. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57992. * @returns The JSON representation of the texture
  57993. */
  57994. serialize(): any;
  57995. /**
  57996. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57997. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57998. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57999. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58000. * @returns The parsed reflection probe if successful
  58001. */
  58002. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58003. }
  58004. }
  58005. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58006. /** @hidden */
  58007. export var _BabylonLoaderRegistered: boolean;
  58008. /**
  58009. * Helps setting up some configuration for the babylon file loader.
  58010. */
  58011. export class BabylonFileLoaderConfiguration {
  58012. /**
  58013. * The loader does not allow injecting custom physix engine into the plugins.
  58014. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58015. * So you could set this variable to your engine import to make it work.
  58016. */
  58017. static LoaderInjectedPhysicsEngine: any;
  58018. }
  58019. }
  58020. declare module "babylonjs/Loading/Plugins/index" {
  58021. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58022. }
  58023. declare module "babylonjs/Loading/index" {
  58024. export * from "babylonjs/Loading/loadingScreen";
  58025. export * from "babylonjs/Loading/Plugins/index";
  58026. export * from "babylonjs/Loading/sceneLoader";
  58027. export * from "babylonjs/Loading/sceneLoaderFlags";
  58028. }
  58029. declare module "babylonjs/Materials/Background/index" {
  58030. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58031. }
  58032. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58033. import { Scene } from "babylonjs/scene";
  58034. import { Color3 } from "babylonjs/Maths/math.color";
  58035. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58037. /**
  58038. * The Physically based simple base material of BJS.
  58039. *
  58040. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58041. * It is used as the base class for both the specGloss and metalRough conventions.
  58042. */
  58043. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58044. /**
  58045. * Number of Simultaneous lights allowed on the material.
  58046. */
  58047. maxSimultaneousLights: number;
  58048. /**
  58049. * If sets to true, disables all the lights affecting the material.
  58050. */
  58051. disableLighting: boolean;
  58052. /**
  58053. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58054. */
  58055. environmentTexture: BaseTexture;
  58056. /**
  58057. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58058. */
  58059. invertNormalMapX: boolean;
  58060. /**
  58061. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58062. */
  58063. invertNormalMapY: boolean;
  58064. /**
  58065. * Normal map used in the model.
  58066. */
  58067. normalTexture: BaseTexture;
  58068. /**
  58069. * Emissivie color used to self-illuminate the model.
  58070. */
  58071. emissiveColor: Color3;
  58072. /**
  58073. * Emissivie texture used to self-illuminate the model.
  58074. */
  58075. emissiveTexture: BaseTexture;
  58076. /**
  58077. * Occlusion Channel Strenght.
  58078. */
  58079. occlusionStrength: number;
  58080. /**
  58081. * Occlusion Texture of the material (adding extra occlusion effects).
  58082. */
  58083. occlusionTexture: BaseTexture;
  58084. /**
  58085. * Defines the alpha limits in alpha test mode.
  58086. */
  58087. alphaCutOff: number;
  58088. /**
  58089. * Gets the current double sided mode.
  58090. */
  58091. get doubleSided(): boolean;
  58092. /**
  58093. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58094. */
  58095. set doubleSided(value: boolean);
  58096. /**
  58097. * Stores the pre-calculated light information of a mesh in a texture.
  58098. */
  58099. lightmapTexture: BaseTexture;
  58100. /**
  58101. * If true, the light map contains occlusion information instead of lighting info.
  58102. */
  58103. useLightmapAsShadowmap: boolean;
  58104. /**
  58105. * Instantiates a new PBRMaterial instance.
  58106. *
  58107. * @param name The material name
  58108. * @param scene The scene the material will be use in.
  58109. */
  58110. constructor(name: string, scene: Scene);
  58111. getClassName(): string;
  58112. }
  58113. }
  58114. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58115. import { Scene } from "babylonjs/scene";
  58116. import { Color3 } from "babylonjs/Maths/math.color";
  58117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58118. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58119. /**
  58120. * The PBR material of BJS following the metal roughness convention.
  58121. *
  58122. * This fits to the PBR convention in the GLTF definition:
  58123. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58124. */
  58125. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58126. /**
  58127. * The base color has two different interpretations depending on the value of metalness.
  58128. * When the material is a metal, the base color is the specific measured reflectance value
  58129. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58130. * of the material.
  58131. */
  58132. baseColor: Color3;
  58133. /**
  58134. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58135. * well as opacity information in the alpha channel.
  58136. */
  58137. baseTexture: BaseTexture;
  58138. /**
  58139. * Specifies the metallic scalar value of the material.
  58140. * Can also be used to scale the metalness values of the metallic texture.
  58141. */
  58142. metallic: number;
  58143. /**
  58144. * Specifies the roughness scalar value of the material.
  58145. * Can also be used to scale the roughness values of the metallic texture.
  58146. */
  58147. roughness: number;
  58148. /**
  58149. * Texture containing both the metallic value in the B channel and the
  58150. * roughness value in the G channel to keep better precision.
  58151. */
  58152. metallicRoughnessTexture: BaseTexture;
  58153. /**
  58154. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58155. *
  58156. * @param name The material name
  58157. * @param scene The scene the material will be use in.
  58158. */
  58159. constructor(name: string, scene: Scene);
  58160. /**
  58161. * Return the currrent class name of the material.
  58162. */
  58163. getClassName(): string;
  58164. /**
  58165. * Makes a duplicate of the current material.
  58166. * @param name - name to use for the new material.
  58167. */
  58168. clone(name: string): PBRMetallicRoughnessMaterial;
  58169. /**
  58170. * Serialize the material to a parsable JSON object.
  58171. */
  58172. serialize(): any;
  58173. /**
  58174. * Parses a JSON object correponding to the serialize function.
  58175. */
  58176. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58177. }
  58178. }
  58179. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58180. import { Scene } from "babylonjs/scene";
  58181. import { Color3 } from "babylonjs/Maths/math.color";
  58182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58183. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58184. /**
  58185. * The PBR material of BJS following the specular glossiness convention.
  58186. *
  58187. * This fits to the PBR convention in the GLTF definition:
  58188. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58189. */
  58190. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58191. /**
  58192. * Specifies the diffuse color of the material.
  58193. */
  58194. diffuseColor: Color3;
  58195. /**
  58196. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58197. * channel.
  58198. */
  58199. diffuseTexture: BaseTexture;
  58200. /**
  58201. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58202. */
  58203. specularColor: Color3;
  58204. /**
  58205. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58206. */
  58207. glossiness: number;
  58208. /**
  58209. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58210. */
  58211. specularGlossinessTexture: BaseTexture;
  58212. /**
  58213. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58214. *
  58215. * @param name The material name
  58216. * @param scene The scene the material will be use in.
  58217. */
  58218. constructor(name: string, scene: Scene);
  58219. /**
  58220. * Return the currrent class name of the material.
  58221. */
  58222. getClassName(): string;
  58223. /**
  58224. * Makes a duplicate of the current material.
  58225. * @param name - name to use for the new material.
  58226. */
  58227. clone(name: string): PBRSpecularGlossinessMaterial;
  58228. /**
  58229. * Serialize the material to a parsable JSON object.
  58230. */
  58231. serialize(): any;
  58232. /**
  58233. * Parses a JSON object correponding to the serialize function.
  58234. */
  58235. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58236. }
  58237. }
  58238. declare module "babylonjs/Materials/PBR/index" {
  58239. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58240. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58241. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58242. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58243. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58244. }
  58245. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58246. import { Nullable } from "babylonjs/types";
  58247. import { Scene } from "babylonjs/scene";
  58248. import { Matrix } from "babylonjs/Maths/math.vector";
  58249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58250. /**
  58251. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58252. * It can help converting any input color in a desired output one. This can then be used to create effects
  58253. * from sepia, black and white to sixties or futuristic rendering...
  58254. *
  58255. * The only supported format is currently 3dl.
  58256. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58257. */
  58258. export class ColorGradingTexture extends BaseTexture {
  58259. /**
  58260. * The current texture matrix. (will always be identity in color grading texture)
  58261. */
  58262. private _textureMatrix;
  58263. /**
  58264. * The texture URL.
  58265. */
  58266. url: string;
  58267. /**
  58268. * Empty line regex stored for GC.
  58269. */
  58270. private static _noneEmptyLineRegex;
  58271. private _engine;
  58272. /**
  58273. * Instantiates a ColorGradingTexture from the following parameters.
  58274. *
  58275. * @param url The location of the color gradind data (currently only supporting 3dl)
  58276. * @param scene The scene the texture will be used in
  58277. */
  58278. constructor(url: string, scene: Scene);
  58279. /**
  58280. * Returns the texture matrix used in most of the material.
  58281. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58282. */
  58283. getTextureMatrix(): Matrix;
  58284. /**
  58285. * Occurs when the file being loaded is a .3dl LUT file.
  58286. */
  58287. private load3dlTexture;
  58288. /**
  58289. * Starts the loading process of the texture.
  58290. */
  58291. private loadTexture;
  58292. /**
  58293. * Clones the color gradind texture.
  58294. */
  58295. clone(): ColorGradingTexture;
  58296. /**
  58297. * Called during delayed load for textures.
  58298. */
  58299. delayLoad(): void;
  58300. /**
  58301. * Parses a color grading texture serialized by Babylon.
  58302. * @param parsedTexture The texture information being parsedTexture
  58303. * @param scene The scene to load the texture in
  58304. * @param rootUrl The root url of the data assets to load
  58305. * @return A color gradind texture
  58306. */
  58307. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58308. /**
  58309. * Serializes the LUT texture to json format.
  58310. */
  58311. serialize(): any;
  58312. }
  58313. }
  58314. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58316. import { Scene } from "babylonjs/scene";
  58317. import { Nullable } from "babylonjs/types";
  58318. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58319. /**
  58320. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58321. */
  58322. export class EquiRectangularCubeTexture extends BaseTexture {
  58323. /** The six faces of the cube. */
  58324. private static _FacesMapping;
  58325. private _noMipmap;
  58326. private _onLoad;
  58327. private _onError;
  58328. /** The size of the cubemap. */
  58329. private _size;
  58330. /** The buffer of the image. */
  58331. private _buffer;
  58332. /** The width of the input image. */
  58333. private _width;
  58334. /** The height of the input image. */
  58335. private _height;
  58336. /** The URL to the image. */
  58337. url: string;
  58338. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58339. coordinatesMode: number;
  58340. /**
  58341. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58342. * @param url The location of the image
  58343. * @param scene The scene the texture will be used in
  58344. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58345. * @param noMipmap Forces to not generate the mipmap if true
  58346. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58347. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58348. * @param onLoad — defines a callback called when texture is loaded
  58349. * @param onError — defines a callback called if there is an error
  58350. */
  58351. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58352. /**
  58353. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58354. */
  58355. private loadImage;
  58356. /**
  58357. * Convert the image buffer into a cubemap and create a CubeTexture.
  58358. */
  58359. private loadTexture;
  58360. /**
  58361. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58362. * @param buffer The ArrayBuffer that should be converted.
  58363. * @returns The buffer as Float32Array.
  58364. */
  58365. private getFloat32ArrayFromArrayBuffer;
  58366. /**
  58367. * Get the current class name of the texture useful for serialization or dynamic coding.
  58368. * @returns "EquiRectangularCubeTexture"
  58369. */
  58370. getClassName(): string;
  58371. /**
  58372. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58373. * @returns A clone of the current EquiRectangularCubeTexture.
  58374. */
  58375. clone(): EquiRectangularCubeTexture;
  58376. }
  58377. }
  58378. declare module "babylonjs/Misc/tga" {
  58379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58380. /**
  58381. * Based on jsTGALoader - Javascript loader for TGA file
  58382. * By Vincent Thibault
  58383. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58384. */
  58385. export class TGATools {
  58386. private static _TYPE_INDEXED;
  58387. private static _TYPE_RGB;
  58388. private static _TYPE_GREY;
  58389. private static _TYPE_RLE_INDEXED;
  58390. private static _TYPE_RLE_RGB;
  58391. private static _TYPE_RLE_GREY;
  58392. private static _ORIGIN_MASK;
  58393. private static _ORIGIN_SHIFT;
  58394. private static _ORIGIN_BL;
  58395. private static _ORIGIN_BR;
  58396. private static _ORIGIN_UL;
  58397. private static _ORIGIN_UR;
  58398. /**
  58399. * Gets the header of a TGA file
  58400. * @param data defines the TGA data
  58401. * @returns the header
  58402. */
  58403. static GetTGAHeader(data: Uint8Array): any;
  58404. /**
  58405. * Uploads TGA content to a Babylon Texture
  58406. * @hidden
  58407. */
  58408. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58409. /** @hidden */
  58410. 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;
  58411. /** @hidden */
  58412. 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;
  58413. /** @hidden */
  58414. 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;
  58415. /** @hidden */
  58416. 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;
  58417. /** @hidden */
  58418. 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;
  58419. /** @hidden */
  58420. 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;
  58421. }
  58422. }
  58423. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58424. import { Nullable } from "babylonjs/types";
  58425. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58426. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58427. /**
  58428. * Implementation of the TGA Texture Loader.
  58429. * @hidden
  58430. */
  58431. export class _TGATextureLoader implements IInternalTextureLoader {
  58432. /**
  58433. * Defines wether the loader supports cascade loading the different faces.
  58434. */
  58435. readonly supportCascades: boolean;
  58436. /**
  58437. * This returns if the loader support the current file information.
  58438. * @param extension defines the file extension of the file being loaded
  58439. * @returns true if the loader can load the specified file
  58440. */
  58441. canLoad(extension: string): boolean;
  58442. /**
  58443. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58444. * @param data contains the texture data
  58445. * @param texture defines the BabylonJS internal texture
  58446. * @param createPolynomials will be true if polynomials have been requested
  58447. * @param onLoad defines the callback to trigger once the texture is ready
  58448. * @param onError defines the callback to trigger in case of error
  58449. */
  58450. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58451. /**
  58452. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58453. * @param data contains the texture data
  58454. * @param texture defines the BabylonJS internal texture
  58455. * @param callback defines the method to call once ready to upload
  58456. */
  58457. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58458. }
  58459. }
  58460. declare module "babylonjs/Misc/basis" {
  58461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58462. /**
  58463. * Info about the .basis files
  58464. */
  58465. class BasisFileInfo {
  58466. /**
  58467. * If the file has alpha
  58468. */
  58469. hasAlpha: boolean;
  58470. /**
  58471. * Info about each image of the basis file
  58472. */
  58473. images: Array<{
  58474. levels: Array<{
  58475. width: number;
  58476. height: number;
  58477. transcodedPixels: ArrayBufferView;
  58478. }>;
  58479. }>;
  58480. }
  58481. /**
  58482. * Result of transcoding a basis file
  58483. */
  58484. class TranscodeResult {
  58485. /**
  58486. * Info about the .basis file
  58487. */
  58488. fileInfo: BasisFileInfo;
  58489. /**
  58490. * Format to use when loading the file
  58491. */
  58492. format: number;
  58493. }
  58494. /**
  58495. * Configuration options for the Basis transcoder
  58496. */
  58497. export class BasisTranscodeConfiguration {
  58498. /**
  58499. * Supported compression formats used to determine the supported output format of the transcoder
  58500. */
  58501. supportedCompressionFormats?: {
  58502. /**
  58503. * etc1 compression format
  58504. */
  58505. etc1?: boolean;
  58506. /**
  58507. * s3tc compression format
  58508. */
  58509. s3tc?: boolean;
  58510. /**
  58511. * pvrtc compression format
  58512. */
  58513. pvrtc?: boolean;
  58514. /**
  58515. * etc2 compression format
  58516. */
  58517. etc2?: boolean;
  58518. };
  58519. /**
  58520. * If mipmap levels should be loaded for transcoded images (Default: true)
  58521. */
  58522. loadMipmapLevels?: boolean;
  58523. /**
  58524. * Index of a single image to load (Default: all images)
  58525. */
  58526. loadSingleImage?: number;
  58527. }
  58528. /**
  58529. * Used to load .Basis files
  58530. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58531. */
  58532. export class BasisTools {
  58533. private static _IgnoreSupportedFormats;
  58534. /**
  58535. * URL to use when loading the basis transcoder
  58536. */
  58537. static JSModuleURL: string;
  58538. /**
  58539. * URL to use when loading the wasm module for the transcoder
  58540. */
  58541. static WasmModuleURL: string;
  58542. /**
  58543. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58544. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58545. * @returns internal format corresponding to the Basis format
  58546. */
  58547. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58548. private static _WorkerPromise;
  58549. private static _Worker;
  58550. private static _actionId;
  58551. private static _CreateWorkerAsync;
  58552. /**
  58553. * Transcodes a loaded image file to compressed pixel data
  58554. * @param data image data to transcode
  58555. * @param config configuration options for the transcoding
  58556. * @returns a promise resulting in the transcoded image
  58557. */
  58558. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58559. /**
  58560. * Loads a texture from the transcode result
  58561. * @param texture texture load to
  58562. * @param transcodeResult the result of transcoding the basis file to load from
  58563. */
  58564. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58565. }
  58566. }
  58567. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58568. import { Nullable } from "babylonjs/types";
  58569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58570. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58571. /**
  58572. * Loader for .basis file format
  58573. */
  58574. export class _BasisTextureLoader implements IInternalTextureLoader {
  58575. /**
  58576. * Defines whether the loader supports cascade loading the different faces.
  58577. */
  58578. readonly supportCascades: boolean;
  58579. /**
  58580. * This returns if the loader support the current file information.
  58581. * @param extension defines the file extension of the file being loaded
  58582. * @returns true if the loader can load the specified file
  58583. */
  58584. canLoad(extension: string): boolean;
  58585. /**
  58586. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58587. * @param data contains the texture data
  58588. * @param texture defines the BabylonJS internal texture
  58589. * @param createPolynomials will be true if polynomials have been requested
  58590. * @param onLoad defines the callback to trigger once the texture is ready
  58591. * @param onError defines the callback to trigger in case of error
  58592. */
  58593. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58594. /**
  58595. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58596. * @param data contains the texture data
  58597. * @param texture defines the BabylonJS internal texture
  58598. * @param callback defines the method to call once ready to upload
  58599. */
  58600. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58601. }
  58602. }
  58603. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58604. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58605. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58606. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58607. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58608. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58609. }
  58610. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58611. import { Scene } from "babylonjs/scene";
  58612. import { Texture } from "babylonjs/Materials/Textures/texture";
  58613. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58614. /**
  58615. * 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.
  58616. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58617. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58618. */
  58619. export class CustomProceduralTexture extends ProceduralTexture {
  58620. private _animate;
  58621. private _time;
  58622. private _config;
  58623. private _texturePath;
  58624. /**
  58625. * Instantiates a new Custom Procedural Texture.
  58626. * 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.
  58627. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58629. * @param name Define the name of the texture
  58630. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58631. * @param size Define the size of the texture to create
  58632. * @param scene Define the scene the texture belongs to
  58633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58634. * @param generateMipMaps Define if the texture should creates mip maps or not
  58635. */
  58636. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58637. private _loadJson;
  58638. /**
  58639. * Is the texture ready to be used ? (rendered at least once)
  58640. * @returns true if ready, otherwise, false.
  58641. */
  58642. isReady(): boolean;
  58643. /**
  58644. * Render the texture to its associated render target.
  58645. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58646. */
  58647. render(useCameraPostProcess?: boolean): void;
  58648. /**
  58649. * Update the list of dependant textures samplers in the shader.
  58650. */
  58651. updateTextures(): void;
  58652. /**
  58653. * Update the uniform values of the procedural texture in the shader.
  58654. */
  58655. updateShaderUniforms(): void;
  58656. /**
  58657. * Define if the texture animates or not.
  58658. */
  58659. get animate(): boolean;
  58660. set animate(value: boolean);
  58661. }
  58662. }
  58663. declare module "babylonjs/Shaders/noise.fragment" {
  58664. /** @hidden */
  58665. export var noisePixelShader: {
  58666. name: string;
  58667. shader: string;
  58668. };
  58669. }
  58670. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58671. import { Nullable } from "babylonjs/types";
  58672. import { Scene } from "babylonjs/scene";
  58673. import { Texture } from "babylonjs/Materials/Textures/texture";
  58674. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58675. import "babylonjs/Shaders/noise.fragment";
  58676. /**
  58677. * Class used to generate noise procedural textures
  58678. */
  58679. export class NoiseProceduralTexture extends ProceduralTexture {
  58680. private _time;
  58681. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58682. brightness: number;
  58683. /** Defines the number of octaves to process */
  58684. octaves: number;
  58685. /** Defines the level of persistence (0.8 by default) */
  58686. persistence: number;
  58687. /** Gets or sets animation speed factor (default is 1) */
  58688. animationSpeedFactor: number;
  58689. /**
  58690. * Creates a new NoiseProceduralTexture
  58691. * @param name defines the name fo the texture
  58692. * @param size defines the size of the texture (default is 256)
  58693. * @param scene defines the hosting scene
  58694. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58695. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58696. */
  58697. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58698. private _updateShaderUniforms;
  58699. protected _getDefines(): string;
  58700. /** Generate the current state of the procedural texture */
  58701. render(useCameraPostProcess?: boolean): void;
  58702. /**
  58703. * Serializes this noise procedural texture
  58704. * @returns a serialized noise procedural texture object
  58705. */
  58706. serialize(): any;
  58707. /**
  58708. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58709. * @param parsedTexture defines parsed texture data
  58710. * @param scene defines the current scene
  58711. * @param rootUrl defines the root URL containing noise procedural texture information
  58712. * @returns a parsed NoiseProceduralTexture
  58713. */
  58714. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58715. }
  58716. }
  58717. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58718. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58719. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58720. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58721. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58722. }
  58723. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58724. import { Nullable } from "babylonjs/types";
  58725. import { Scene } from "babylonjs/scene";
  58726. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58728. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58729. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58730. /**
  58731. * Raw cube texture where the raw buffers are passed in
  58732. */
  58733. export class RawCubeTexture extends CubeTexture {
  58734. /**
  58735. * Creates a cube texture where the raw buffers are passed in.
  58736. * @param scene defines the scene the texture is attached to
  58737. * @param data defines the array of data to use to create each face
  58738. * @param size defines the size of the textures
  58739. * @param format defines the format of the data
  58740. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58741. * @param generateMipMaps defines if the engine should generate the mip levels
  58742. * @param invertY defines if data must be stored with Y axis inverted
  58743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58744. * @param compression defines the compression used (null by default)
  58745. */
  58746. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58747. /**
  58748. * Updates the raw cube texture.
  58749. * @param data defines the data to store
  58750. * @param format defines the data format
  58751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58752. * @param invertY defines if data must be stored with Y axis inverted
  58753. * @param compression defines the compression used (null by default)
  58754. * @param level defines which level of the texture to update
  58755. */
  58756. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58757. /**
  58758. * Updates a raw cube texture with RGBD encoded data.
  58759. * @param data defines the array of data [mipmap][face] to use to create each face
  58760. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58761. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58762. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58763. * @returns a promsie that resolves when the operation is complete
  58764. */
  58765. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58766. /**
  58767. * Clones the raw cube texture.
  58768. * @return a new cube texture
  58769. */
  58770. clone(): CubeTexture;
  58771. /** @hidden */
  58772. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58773. }
  58774. }
  58775. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58776. import { Scene } from "babylonjs/scene";
  58777. import { Texture } from "babylonjs/Materials/Textures/texture";
  58778. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58779. /**
  58780. * Class used to store 3D textures containing user data
  58781. */
  58782. export class RawTexture3D extends Texture {
  58783. /** Gets or sets the texture format to use */
  58784. format: number;
  58785. private _engine;
  58786. /**
  58787. * Create a new RawTexture3D
  58788. * @param data defines the data of the texture
  58789. * @param width defines the width of the texture
  58790. * @param height defines the height of the texture
  58791. * @param depth defines the depth of the texture
  58792. * @param format defines the texture format to use
  58793. * @param scene defines the hosting scene
  58794. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58795. * @param invertY defines if texture must be stored with Y axis inverted
  58796. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58797. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58798. */
  58799. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58800. /** Gets or sets the texture format to use */
  58801. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58802. /**
  58803. * Update the texture with new data
  58804. * @param data defines the data to store in the texture
  58805. */
  58806. update(data: ArrayBufferView): void;
  58807. }
  58808. }
  58809. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58810. import { Scene } from "babylonjs/scene";
  58811. import { Texture } from "babylonjs/Materials/Textures/texture";
  58812. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58813. /**
  58814. * Class used to store 2D array textures containing user data
  58815. */
  58816. export class RawTexture2DArray extends Texture {
  58817. /** Gets or sets the texture format to use */
  58818. format: number;
  58819. private _engine;
  58820. /**
  58821. * Create a new RawTexture2DArray
  58822. * @param data defines the data of the texture
  58823. * @param width defines the width of the texture
  58824. * @param height defines the height of the texture
  58825. * @param depth defines the number of layers of the texture
  58826. * @param format defines the texture format to use
  58827. * @param scene defines the hosting scene
  58828. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58829. * @param invertY defines if texture must be stored with Y axis inverted
  58830. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58831. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58832. */
  58833. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58834. /** Gets or sets the texture format to use */
  58835. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58836. /**
  58837. * Update the texture with new data
  58838. * @param data defines the data to store in the texture
  58839. */
  58840. update(data: ArrayBufferView): void;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58844. import { Scene } from "babylonjs/scene";
  58845. import { Plane } from "babylonjs/Maths/math.plane";
  58846. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58847. /**
  58848. * Creates a refraction texture used by refraction channel of the standard material.
  58849. * It is like a mirror but to see through a material.
  58850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58851. */
  58852. export class RefractionTexture extends RenderTargetTexture {
  58853. /**
  58854. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58855. * 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.
  58856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58857. */
  58858. refractionPlane: Plane;
  58859. /**
  58860. * Define how deep under the surface we should see.
  58861. */
  58862. depth: number;
  58863. /**
  58864. * Creates a refraction texture used by refraction channel of the standard material.
  58865. * It is like a mirror but to see through a material.
  58866. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58867. * @param name Define the texture name
  58868. * @param size Define the size of the underlying texture
  58869. * @param scene Define the scene the refraction belongs to
  58870. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58871. */
  58872. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58873. /**
  58874. * Clone the refraction texture.
  58875. * @returns the cloned texture
  58876. */
  58877. clone(): RefractionTexture;
  58878. /**
  58879. * Serialize the texture to a JSON representation you could use in Parse later on
  58880. * @returns the serialized JSON representation
  58881. */
  58882. serialize(): any;
  58883. }
  58884. }
  58885. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58886. import { Nullable } from "babylonjs/types";
  58887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58888. import { Matrix } from "babylonjs/Maths/math.vector";
  58889. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58890. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58891. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58892. import { Scene } from "babylonjs/scene";
  58893. /**
  58894. * Defines the options related to the creation of an HtmlElementTexture
  58895. */
  58896. export interface IHtmlElementTextureOptions {
  58897. /**
  58898. * Defines wether mip maps should be created or not.
  58899. */
  58900. generateMipMaps?: boolean;
  58901. /**
  58902. * Defines the sampling mode of the texture.
  58903. */
  58904. samplingMode?: number;
  58905. /**
  58906. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58907. */
  58908. engine: Nullable<ThinEngine>;
  58909. /**
  58910. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58911. */
  58912. scene: Nullable<Scene>;
  58913. }
  58914. /**
  58915. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58916. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58917. * is automatically managed.
  58918. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58919. * in your application.
  58920. *
  58921. * As the update is not automatic, you need to call them manually.
  58922. */
  58923. export class HtmlElementTexture extends BaseTexture {
  58924. /**
  58925. * The texture URL.
  58926. */
  58927. element: HTMLVideoElement | HTMLCanvasElement;
  58928. private static readonly DefaultOptions;
  58929. private _textureMatrix;
  58930. private _engine;
  58931. private _isVideo;
  58932. private _generateMipMaps;
  58933. private _samplingMode;
  58934. /**
  58935. * Instantiates a HtmlElementTexture from the following parameters.
  58936. *
  58937. * @param name Defines the name of the texture
  58938. * @param element Defines the video or canvas the texture is filled with
  58939. * @param options Defines the other none mandatory texture creation options
  58940. */
  58941. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58942. private _createInternalTexture;
  58943. /**
  58944. * Returns the texture matrix used in most of the material.
  58945. */
  58946. getTextureMatrix(): Matrix;
  58947. /**
  58948. * Updates the content of the texture.
  58949. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58950. */
  58951. update(invertY?: Nullable<boolean>): void;
  58952. }
  58953. }
  58954. declare module "babylonjs/Materials/Textures/Packer/frame" {
  58955. import { Vector2 } from "babylonjs/Maths/math.vector";
  58956. /**
  58957. * Defines the basic options interface of a TexturePacker Frame
  58958. */
  58959. export interface ITexturePackerFrame {
  58960. /**
  58961. * The frame ID
  58962. */
  58963. id: number;
  58964. /**
  58965. * The frames Scale
  58966. */
  58967. scale: Vector2;
  58968. /**
  58969. * The Frames offset
  58970. */
  58971. offset: Vector2;
  58972. }
  58973. /**
  58974. * This is a support class for frame Data on texture packer sets.
  58975. */
  58976. export class TexturePackerFrame implements ITexturePackerFrame {
  58977. /**
  58978. * The frame ID
  58979. */
  58980. id: number;
  58981. /**
  58982. * The frames Scale
  58983. */
  58984. scale: Vector2;
  58985. /**
  58986. * The Frames offset
  58987. */
  58988. offset: Vector2;
  58989. /**
  58990. * Initializes a texture package frame.
  58991. * @param id The numerical frame identifier
  58992. * @param scale Scalar Vector2 for UV frame
  58993. * @param offset Vector2 for the frame position in UV units.
  58994. * @returns TexturePackerFrame
  58995. */
  58996. constructor(id: number, scale: Vector2, offset: Vector2);
  58997. }
  58998. }
  58999. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59001. import { Scene } from "babylonjs/scene";
  59002. import { Nullable } from "babylonjs/types";
  59003. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59004. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59005. /**
  59006. * Defines the basic options interface of a TexturePacker
  59007. */
  59008. export interface ITexturePackerOptions {
  59009. /**
  59010. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59011. */
  59012. map?: string[];
  59013. /**
  59014. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59015. */
  59016. uvsIn?: string;
  59017. /**
  59018. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59019. */
  59020. uvsOut?: string;
  59021. /**
  59022. * number representing the layout style. Defaults to LAYOUT_STRIP
  59023. */
  59024. layout?: number;
  59025. /**
  59026. * number of columns if using custom column count layout(2). This defaults to 4.
  59027. */
  59028. colnum?: number;
  59029. /**
  59030. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59031. */
  59032. updateInputMeshes?: boolean;
  59033. /**
  59034. * boolean flag to dispose all the source textures. Defaults to true.
  59035. */
  59036. disposeSources?: boolean;
  59037. /**
  59038. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59039. */
  59040. fillBlanks?: boolean;
  59041. /**
  59042. * string value representing the context fill style color. Defaults to 'black'.
  59043. */
  59044. customFillColor?: string;
  59045. /**
  59046. * Width and Height Value of each Frame in the TexturePacker Sets
  59047. */
  59048. frameSize?: number;
  59049. /**
  59050. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59051. */
  59052. paddingRatio?: number;
  59053. /**
  59054. * Number that declares the fill method for the padding gutter.
  59055. */
  59056. paddingMode?: number;
  59057. /**
  59058. * If in SUBUV_COLOR padding mode what color to use.
  59059. */
  59060. paddingColor?: Color3 | Color4;
  59061. }
  59062. /**
  59063. * Defines the basic interface of a TexturePacker JSON File
  59064. */
  59065. export interface ITexturePackerJSON {
  59066. /**
  59067. * The frame ID
  59068. */
  59069. name: string;
  59070. /**
  59071. * The base64 channel data
  59072. */
  59073. sets: any;
  59074. /**
  59075. * The options of the Packer
  59076. */
  59077. options: ITexturePackerOptions;
  59078. /**
  59079. * The frame data of the Packer
  59080. */
  59081. frames: Array<number>;
  59082. }
  59083. /**
  59084. * This is a support class that generates a series of packed texture sets.
  59085. * @see https://doc.babylonjs.com/babylon101/materials
  59086. */
  59087. export class TexturePacker {
  59088. /** Packer Layout Constant 0 */
  59089. static readonly LAYOUT_STRIP: number;
  59090. /** Packer Layout Constant 1 */
  59091. static readonly LAYOUT_POWER2: number;
  59092. /** Packer Layout Constant 2 */
  59093. static readonly LAYOUT_COLNUM: number;
  59094. /** Packer Layout Constant 0 */
  59095. static readonly SUBUV_WRAP: number;
  59096. /** Packer Layout Constant 1 */
  59097. static readonly SUBUV_EXTEND: number;
  59098. /** Packer Layout Constant 2 */
  59099. static readonly SUBUV_COLOR: number;
  59100. /** The Name of the Texture Package */
  59101. name: string;
  59102. /** The scene scope of the TexturePacker */
  59103. scene: Scene;
  59104. /** The Meshes to target */
  59105. meshes: AbstractMesh[];
  59106. /** Arguments passed with the Constructor */
  59107. options: ITexturePackerOptions;
  59108. /** The promise that is started upon initialization */
  59109. promise: Nullable<Promise<TexturePacker | string>>;
  59110. /** The Container object for the channel sets that are generated */
  59111. sets: object;
  59112. /** The Container array for the frames that are generated */
  59113. frames: TexturePackerFrame[];
  59114. /** The expected number of textures the system is parsing. */
  59115. private _expecting;
  59116. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59117. private _paddingValue;
  59118. /**
  59119. * Initializes a texture package series from an array of meshes or a single mesh.
  59120. * @param name The name of the package
  59121. * @param meshes The target meshes to compose the package from
  59122. * @param options The arguments that texture packer should follow while building.
  59123. * @param scene The scene which the textures are scoped to.
  59124. * @returns TexturePacker
  59125. */
  59126. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59127. /**
  59128. * Starts the package process
  59129. * @param resolve The promises resolution function
  59130. * @returns TexturePacker
  59131. */
  59132. private _createFrames;
  59133. /**
  59134. * Calculates the Size of the Channel Sets
  59135. * @returns Vector2
  59136. */
  59137. private _calculateSize;
  59138. /**
  59139. * Calculates the UV data for the frames.
  59140. * @param baseSize the base frameSize
  59141. * @param padding the base frame padding
  59142. * @param dtSize size of the Dynamic Texture for that channel
  59143. * @param dtUnits is 1/dtSize
  59144. * @param update flag to update the input meshes
  59145. */
  59146. private _calculateMeshUVFrames;
  59147. /**
  59148. * Calculates the frames Offset.
  59149. * @param index of the frame
  59150. * @returns Vector2
  59151. */
  59152. private _getFrameOffset;
  59153. /**
  59154. * Updates a Mesh to the frame data
  59155. * @param mesh that is the target
  59156. * @param frameID or the frame index
  59157. */
  59158. private _updateMeshUV;
  59159. /**
  59160. * Updates a Meshes materials to use the texture packer channels
  59161. * @param m is the mesh to target
  59162. * @param force all channels on the packer to be set.
  59163. */
  59164. private _updateTextureReferences;
  59165. /**
  59166. * Public method to set a Mesh to a frame
  59167. * @param m that is the target
  59168. * @param frameID or the frame index
  59169. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59170. */
  59171. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59172. /**
  59173. * Starts the async promise to compile the texture packer.
  59174. * @returns Promise<void>
  59175. */
  59176. processAsync(): Promise<void>;
  59177. /**
  59178. * Disposes all textures associated with this packer
  59179. */
  59180. dispose(): void;
  59181. /**
  59182. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59183. * @param imageType is the image type to use.
  59184. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59185. */
  59186. download(imageType?: string, quality?: number): void;
  59187. /**
  59188. * Public method to load a texturePacker JSON file.
  59189. * @param data of the JSON file in string format.
  59190. */
  59191. updateFromJSON(data: string): void;
  59192. }
  59193. }
  59194. declare module "babylonjs/Materials/Textures/Packer/index" {
  59195. export * from "babylonjs/Materials/Textures/Packer/packer";
  59196. export * from "babylonjs/Materials/Textures/Packer/frame";
  59197. }
  59198. declare module "babylonjs/Materials/Textures/index" {
  59199. export * from "babylonjs/Materials/Textures/baseTexture";
  59200. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59201. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59202. export * from "babylonjs/Materials/Textures/cubeTexture";
  59203. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59204. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59205. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59206. export * from "babylonjs/Materials/Textures/internalTexture";
  59207. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59208. export * from "babylonjs/Materials/Textures/Loaders/index";
  59209. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59210. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59211. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59212. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59213. export * from "babylonjs/Materials/Textures/rawTexture";
  59214. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59215. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59216. export * from "babylonjs/Materials/Textures/refractionTexture";
  59217. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59218. export * from "babylonjs/Materials/Textures/texture";
  59219. export * from "babylonjs/Materials/Textures/videoTexture";
  59220. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59221. export * from "babylonjs/Materials/Textures/Packer/index";
  59222. }
  59223. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59224. /**
  59225. * Enum used to define the target of a block
  59226. */
  59227. export enum NodeMaterialBlockTargets {
  59228. /** Vertex shader */
  59229. Vertex = 1,
  59230. /** Fragment shader */
  59231. Fragment = 2,
  59232. /** Neutral */
  59233. Neutral = 4,
  59234. /** Vertex and Fragment */
  59235. VertexAndFragment = 3
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59239. /**
  59240. * Defines the kind of connection point for node based material
  59241. */
  59242. export enum NodeMaterialBlockConnectionPointTypes {
  59243. /** Float */
  59244. Float = 1,
  59245. /** Int */
  59246. Int = 2,
  59247. /** Vector2 */
  59248. Vector2 = 4,
  59249. /** Vector3 */
  59250. Vector3 = 8,
  59251. /** Vector4 */
  59252. Vector4 = 16,
  59253. /** Color3 */
  59254. Color3 = 32,
  59255. /** Color4 */
  59256. Color4 = 64,
  59257. /** Matrix */
  59258. Matrix = 128,
  59259. /** Detect type based on connection */
  59260. AutoDetect = 1024,
  59261. /** Output type that will be defined by input type */
  59262. BasedOnInput = 2048
  59263. }
  59264. }
  59265. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59266. /**
  59267. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59268. */
  59269. export enum NodeMaterialBlockConnectionPointMode {
  59270. /** Value is an uniform */
  59271. Uniform = 0,
  59272. /** Value is a mesh attribute */
  59273. Attribute = 1,
  59274. /** Value is a varying between vertex and fragment shaders */
  59275. Varying = 2,
  59276. /** Mode is undefined */
  59277. Undefined = 3
  59278. }
  59279. }
  59280. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59281. /**
  59282. * Enum used to define system values e.g. values automatically provided by the system
  59283. */
  59284. export enum NodeMaterialSystemValues {
  59285. /** World */
  59286. World = 1,
  59287. /** View */
  59288. View = 2,
  59289. /** Projection */
  59290. Projection = 3,
  59291. /** ViewProjection */
  59292. ViewProjection = 4,
  59293. /** WorldView */
  59294. WorldView = 5,
  59295. /** WorldViewProjection */
  59296. WorldViewProjection = 6,
  59297. /** CameraPosition */
  59298. CameraPosition = 7,
  59299. /** Fog Color */
  59300. FogColor = 8,
  59301. /** Delta time */
  59302. DeltaTime = 9
  59303. }
  59304. }
  59305. declare module "babylonjs/Materials/Node/Enums/index" {
  59306. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59307. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59308. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59309. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59310. }
  59311. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59313. /**
  59314. * Root class for all node material optimizers
  59315. */
  59316. export class NodeMaterialOptimizer {
  59317. /**
  59318. * Function used to optimize a NodeMaterial graph
  59319. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59320. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59321. */
  59322. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59323. }
  59324. }
  59325. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59329. import { Scene } from "babylonjs/scene";
  59330. /**
  59331. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59332. */
  59333. export class TransformBlock extends NodeMaterialBlock {
  59334. /**
  59335. * Defines the value to use to complement W value to transform it to a Vector4
  59336. */
  59337. complementW: number;
  59338. /**
  59339. * Defines the value to use to complement z value to transform it to a Vector4
  59340. */
  59341. complementZ: number;
  59342. /**
  59343. * Creates a new TransformBlock
  59344. * @param name defines the block name
  59345. */
  59346. constructor(name: string);
  59347. /**
  59348. * Gets the current class name
  59349. * @returns the class name
  59350. */
  59351. getClassName(): string;
  59352. /**
  59353. * Gets the vector input
  59354. */
  59355. get vector(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. get output(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the xyz output component
  59362. */
  59363. get xyz(): NodeMaterialConnectionPoint;
  59364. /**
  59365. * Gets the matrix transform input
  59366. */
  59367. get transform(): NodeMaterialConnectionPoint;
  59368. protected _buildBlock(state: NodeMaterialBuildState): this;
  59369. serialize(): any;
  59370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59371. protected _dumpPropertiesCode(): string;
  59372. }
  59373. }
  59374. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59378. /**
  59379. * Block used to output the vertex position
  59380. */
  59381. export class VertexOutputBlock extends NodeMaterialBlock {
  59382. /**
  59383. * Creates a new VertexOutputBlock
  59384. * @param name defines the block name
  59385. */
  59386. constructor(name: string);
  59387. /**
  59388. * Gets the current class name
  59389. * @returns the class name
  59390. */
  59391. getClassName(): string;
  59392. /**
  59393. * Gets the vector input component
  59394. */
  59395. get vector(): NodeMaterialConnectionPoint;
  59396. protected _buildBlock(state: NodeMaterialBuildState): this;
  59397. }
  59398. }
  59399. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59403. /**
  59404. * Block used to output the final color
  59405. */
  59406. export class FragmentOutputBlock extends NodeMaterialBlock {
  59407. /**
  59408. * Create a new FragmentOutputBlock
  59409. * @param name defines the block name
  59410. */
  59411. constructor(name: string);
  59412. /**
  59413. * Gets the current class name
  59414. * @returns the class name
  59415. */
  59416. getClassName(): string;
  59417. /**
  59418. * Gets the rgba input component
  59419. */
  59420. get rgba(): NodeMaterialConnectionPoint;
  59421. /**
  59422. * Gets the rgb input component
  59423. */
  59424. get rgb(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the a input component
  59427. */
  59428. get a(): NodeMaterialConnectionPoint;
  59429. protected _buildBlock(state: NodeMaterialBuildState): this;
  59430. }
  59431. }
  59432. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59438. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59439. import { Effect } from "babylonjs/Materials/effect";
  59440. import { Mesh } from "babylonjs/Meshes/mesh";
  59441. import { Nullable } from "babylonjs/types";
  59442. import { Scene } from "babylonjs/scene";
  59443. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59444. /**
  59445. * Block used to read a reflection texture from a sampler
  59446. */
  59447. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59448. private _define3DName;
  59449. private _defineCubicName;
  59450. private _defineExplicitName;
  59451. private _defineProjectionName;
  59452. private _defineLocalCubicName;
  59453. private _defineSphericalName;
  59454. private _definePlanarName;
  59455. private _defineEquirectangularName;
  59456. private _defineMirroredEquirectangularFixedName;
  59457. private _defineEquirectangularFixedName;
  59458. private _defineSkyboxName;
  59459. private _cubeSamplerName;
  59460. private _2DSamplerName;
  59461. private _positionUVWName;
  59462. private _directionWName;
  59463. private _reflectionCoordsName;
  59464. private _reflection2DCoordsName;
  59465. private _reflectionColorName;
  59466. private _reflectionMatrixName;
  59467. /**
  59468. * Gets or sets the texture associated with the node
  59469. */
  59470. texture: Nullable<BaseTexture>;
  59471. /**
  59472. * Create a new TextureBlock
  59473. * @param name defines the block name
  59474. */
  59475. constructor(name: string);
  59476. /**
  59477. * Gets the current class name
  59478. * @returns the class name
  59479. */
  59480. getClassName(): string;
  59481. /**
  59482. * Gets the world position input component
  59483. */
  59484. get position(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the world position input component
  59487. */
  59488. get worldPosition(): NodeMaterialConnectionPoint;
  59489. /**
  59490. * Gets the world normal input component
  59491. */
  59492. get worldNormal(): NodeMaterialConnectionPoint;
  59493. /**
  59494. * Gets the world input component
  59495. */
  59496. get world(): NodeMaterialConnectionPoint;
  59497. /**
  59498. * Gets the camera (or eye) position component
  59499. */
  59500. get cameraPosition(): NodeMaterialConnectionPoint;
  59501. /**
  59502. * Gets the view input component
  59503. */
  59504. get view(): NodeMaterialConnectionPoint;
  59505. /**
  59506. * Gets the rgb output component
  59507. */
  59508. get rgb(): NodeMaterialConnectionPoint;
  59509. /**
  59510. * Gets the r output component
  59511. */
  59512. get r(): NodeMaterialConnectionPoint;
  59513. /**
  59514. * Gets the g output component
  59515. */
  59516. get g(): NodeMaterialConnectionPoint;
  59517. /**
  59518. * Gets the b output component
  59519. */
  59520. get b(): NodeMaterialConnectionPoint;
  59521. autoConfigure(material: NodeMaterial): void;
  59522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59523. isReady(): boolean;
  59524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59525. private _injectVertexCode;
  59526. private _writeOutput;
  59527. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59528. protected _dumpPropertiesCode(): string;
  59529. serialize(): any;
  59530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59531. }
  59532. }
  59533. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59535. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59536. import { Scene } from "babylonjs/scene";
  59537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59538. import { Matrix } from "babylonjs/Maths/math.vector";
  59539. import { Mesh } from "babylonjs/Meshes/mesh";
  59540. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59541. import { Observable } from "babylonjs/Misc/observable";
  59542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59543. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59544. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59545. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59546. import { Nullable } from "babylonjs/types";
  59547. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59548. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59549. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59550. /**
  59551. * Interface used to configure the node material editor
  59552. */
  59553. export interface INodeMaterialEditorOptions {
  59554. /** Define the URl to load node editor script */
  59555. editorURL?: string;
  59556. }
  59557. /** @hidden */
  59558. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59559. NORMAL: boolean;
  59560. TANGENT: boolean;
  59561. UV1: boolean;
  59562. /** BONES */
  59563. NUM_BONE_INFLUENCERS: number;
  59564. BonesPerMesh: number;
  59565. BONETEXTURE: boolean;
  59566. /** MORPH TARGETS */
  59567. MORPHTARGETS: boolean;
  59568. MORPHTARGETS_NORMAL: boolean;
  59569. MORPHTARGETS_TANGENT: boolean;
  59570. MORPHTARGETS_UV: boolean;
  59571. NUM_MORPH_INFLUENCERS: number;
  59572. /** IMAGE PROCESSING */
  59573. IMAGEPROCESSING: boolean;
  59574. VIGNETTE: boolean;
  59575. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59576. VIGNETTEBLENDMODEOPAQUE: boolean;
  59577. TONEMAPPING: boolean;
  59578. TONEMAPPING_ACES: boolean;
  59579. CONTRAST: boolean;
  59580. EXPOSURE: boolean;
  59581. COLORCURVES: boolean;
  59582. COLORGRADING: boolean;
  59583. COLORGRADING3D: boolean;
  59584. SAMPLER3DGREENDEPTH: boolean;
  59585. SAMPLER3DBGRMAP: boolean;
  59586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59587. /** MISC. */
  59588. BUMPDIRECTUV: number;
  59589. constructor();
  59590. setValue(name: string, value: boolean): void;
  59591. }
  59592. /**
  59593. * Class used to configure NodeMaterial
  59594. */
  59595. export interface INodeMaterialOptions {
  59596. /**
  59597. * Defines if blocks should emit comments
  59598. */
  59599. emitComments: boolean;
  59600. }
  59601. /**
  59602. * Class used to create a node based material built by assembling shader blocks
  59603. */
  59604. export class NodeMaterial extends PushMaterial {
  59605. private static _BuildIdGenerator;
  59606. private _options;
  59607. private _vertexCompilationState;
  59608. private _fragmentCompilationState;
  59609. private _sharedData;
  59610. private _buildId;
  59611. private _buildWasSuccessful;
  59612. private _cachedWorldViewMatrix;
  59613. private _cachedWorldViewProjectionMatrix;
  59614. private _optimizers;
  59615. private _animationFrame;
  59616. /** Define the Url to load node editor script */
  59617. static EditorURL: string;
  59618. /** Define the Url to load snippets */
  59619. static SnippetUrl: string;
  59620. private BJSNODEMATERIALEDITOR;
  59621. /** Get the inspector from bundle or global */
  59622. private _getGlobalNodeMaterialEditor;
  59623. /**
  59624. * Gets or sets data used by visual editor
  59625. * @see https://nme.babylonjs.com
  59626. */
  59627. editorData: any;
  59628. /**
  59629. * 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)
  59630. */
  59631. ignoreAlpha: boolean;
  59632. /**
  59633. * Defines the maximum number of lights that can be used in the material
  59634. */
  59635. maxSimultaneousLights: number;
  59636. /**
  59637. * Observable raised when the material is built
  59638. */
  59639. onBuildObservable: Observable<NodeMaterial>;
  59640. /**
  59641. * Gets or sets the root nodes of the material vertex shader
  59642. */
  59643. _vertexOutputNodes: NodeMaterialBlock[];
  59644. /**
  59645. * Gets or sets the root nodes of the material fragment (pixel) shader
  59646. */
  59647. _fragmentOutputNodes: NodeMaterialBlock[];
  59648. /** Gets or sets options to control the node material overall behavior */
  59649. get options(): INodeMaterialOptions;
  59650. set options(options: INodeMaterialOptions);
  59651. /**
  59652. * Default configuration related to image processing available in the standard Material.
  59653. */
  59654. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59655. /**
  59656. * Gets the image processing configuration used either in this material.
  59657. */
  59658. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59659. /**
  59660. * Sets the Default image processing configuration used either in the this material.
  59661. *
  59662. * If sets to null, the scene one is in use.
  59663. */
  59664. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59665. /**
  59666. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59667. */
  59668. attachedBlocks: NodeMaterialBlock[];
  59669. /**
  59670. * Create a new node based material
  59671. * @param name defines the material name
  59672. * @param scene defines the hosting scene
  59673. * @param options defines creation option
  59674. */
  59675. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59676. /**
  59677. * Gets the current class name of the material e.g. "NodeMaterial"
  59678. * @returns the class name
  59679. */
  59680. getClassName(): string;
  59681. /**
  59682. * Keep track of the image processing observer to allow dispose and replace.
  59683. */
  59684. private _imageProcessingObserver;
  59685. /**
  59686. * Attaches a new image processing configuration to the Standard Material.
  59687. * @param configuration
  59688. */
  59689. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59690. /**
  59691. * Get a block by its name
  59692. * @param name defines the name of the block to retrieve
  59693. * @returns the required block or null if not found
  59694. */
  59695. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59696. /**
  59697. * Get a block by its name
  59698. * @param predicate defines the predicate used to find the good candidate
  59699. * @returns the required block or null if not found
  59700. */
  59701. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59702. /**
  59703. * Get an input block by its name
  59704. * @param predicate defines the predicate used to find the good candidate
  59705. * @returns the required input block or null if not found
  59706. */
  59707. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59708. /**
  59709. * Gets the list of input blocks attached to this material
  59710. * @returns an array of InputBlocks
  59711. */
  59712. getInputBlocks(): InputBlock[];
  59713. /**
  59714. * Adds a new optimizer to the list of optimizers
  59715. * @param optimizer defines the optimizers to add
  59716. * @returns the current material
  59717. */
  59718. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59719. /**
  59720. * Remove an optimizer from the list of optimizers
  59721. * @param optimizer defines the optimizers to remove
  59722. * @returns the current material
  59723. */
  59724. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59725. /**
  59726. * Add a new block to the list of output nodes
  59727. * @param node defines the node to add
  59728. * @returns the current material
  59729. */
  59730. addOutputNode(node: NodeMaterialBlock): this;
  59731. /**
  59732. * Remove a block from the list of root nodes
  59733. * @param node defines the node to remove
  59734. * @returns the current material
  59735. */
  59736. removeOutputNode(node: NodeMaterialBlock): this;
  59737. private _addVertexOutputNode;
  59738. private _removeVertexOutputNode;
  59739. private _addFragmentOutputNode;
  59740. private _removeFragmentOutputNode;
  59741. /**
  59742. * Specifies if the material will require alpha blending
  59743. * @returns a boolean specifying if alpha blending is needed
  59744. */
  59745. needAlphaBlending(): boolean;
  59746. /**
  59747. * Specifies if this material should be rendered in alpha test mode
  59748. * @returns a boolean specifying if an alpha test is needed.
  59749. */
  59750. needAlphaTesting(): boolean;
  59751. private _initializeBlock;
  59752. private _resetDualBlocks;
  59753. /**
  59754. * Remove a block from the current node material
  59755. * @param block defines the block to remove
  59756. */
  59757. removeBlock(block: NodeMaterialBlock): void;
  59758. /**
  59759. * Build the material and generates the inner effect
  59760. * @param verbose defines if the build should log activity
  59761. */
  59762. build(verbose?: boolean): void;
  59763. /**
  59764. * Runs an otpimization phase to try to improve the shader code
  59765. */
  59766. optimize(): void;
  59767. private _prepareDefinesForAttributes;
  59768. /**
  59769. * Get if the submesh is ready to be used and all its information available.
  59770. * Child classes can use it to update shaders
  59771. * @param mesh defines the mesh to check
  59772. * @param subMesh defines which submesh to check
  59773. * @param useInstances specifies that instances should be used
  59774. * @returns a boolean indicating that the submesh is ready or not
  59775. */
  59776. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59777. /**
  59778. * Get a string representing the shaders built by the current node graph
  59779. */
  59780. get compiledShaders(): string;
  59781. /**
  59782. * Binds the world matrix to the material
  59783. * @param world defines the world transformation matrix
  59784. */
  59785. bindOnlyWorldMatrix(world: Matrix): void;
  59786. /**
  59787. * Binds the submesh to this material by preparing the effect and shader to draw
  59788. * @param world defines the world transformation matrix
  59789. * @param mesh defines the mesh containing the submesh
  59790. * @param subMesh defines the submesh to bind the material to
  59791. */
  59792. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59793. /**
  59794. * Gets the active textures from the material
  59795. * @returns an array of textures
  59796. */
  59797. getActiveTextures(): BaseTexture[];
  59798. /**
  59799. * Gets the list of texture blocks
  59800. * @returns an array of texture blocks
  59801. */
  59802. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59803. /**
  59804. * Specifies if the material uses a texture
  59805. * @param texture defines the texture to check against the material
  59806. * @returns a boolean specifying if the material uses the texture
  59807. */
  59808. hasTexture(texture: BaseTexture): boolean;
  59809. /**
  59810. * Disposes the material
  59811. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59812. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59813. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59814. */
  59815. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59816. /** Creates the node editor window. */
  59817. private _createNodeEditor;
  59818. /**
  59819. * Launch the node material editor
  59820. * @param config Define the configuration of the editor
  59821. * @return a promise fulfilled when the node editor is visible
  59822. */
  59823. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59824. /**
  59825. * Clear the current material
  59826. */
  59827. clear(): void;
  59828. /**
  59829. * Clear the current material and set it to a default state
  59830. */
  59831. setToDefault(): void;
  59832. /**
  59833. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59834. * @param url defines the url to load from
  59835. * @returns a promise that will fullfil when the material is fully loaded
  59836. */
  59837. loadAsync(url: string): Promise<void>;
  59838. private _gatherBlocks;
  59839. /**
  59840. * Generate a string containing the code declaration required to create an equivalent of this material
  59841. * @returns a string
  59842. */
  59843. generateCode(): string;
  59844. /**
  59845. * Serializes this material in a JSON representation
  59846. * @returns the serialized material object
  59847. */
  59848. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59849. private _restoreConnections;
  59850. /**
  59851. * Clear the current graph and load a new one from a serialization object
  59852. * @param source defines the JSON representation of the material
  59853. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59854. */
  59855. loadFromSerialization(source: any, rootUrl?: string): void;
  59856. /**
  59857. * Creates a node material from parsed material data
  59858. * @param source defines the JSON representation of the material
  59859. * @param scene defines the hosting scene
  59860. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59861. * @returns a new node material
  59862. */
  59863. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59864. /**
  59865. * Creates a node material from a snippet saved in a remote file
  59866. * @param name defines the name of the material to create
  59867. * @param url defines the url to load from
  59868. * @param scene defines the hosting scene
  59869. * @returns a promise that will resolve to the new node material
  59870. */
  59871. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59872. /**
  59873. * Creates a node material from a snippet saved by the node material editor
  59874. * @param snippetId defines the snippet to load
  59875. * @param scene defines the hosting scene
  59876. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59877. * @returns a promise that will resolve to the new node material
  59878. */
  59879. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59880. /**
  59881. * Creates a new node material set to default basic configuration
  59882. * @param name defines the name of the material
  59883. * @param scene defines the hosting scene
  59884. * @returns a new NodeMaterial
  59885. */
  59886. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59887. }
  59888. }
  59889. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59892. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59895. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59896. import { Effect } from "babylonjs/Materials/effect";
  59897. import { Mesh } from "babylonjs/Meshes/mesh";
  59898. import { Nullable } from "babylonjs/types";
  59899. import { Texture } from "babylonjs/Materials/Textures/texture";
  59900. import { Scene } from "babylonjs/scene";
  59901. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59902. /**
  59903. * Block used to read a texture from a sampler
  59904. */
  59905. export class TextureBlock extends NodeMaterialBlock {
  59906. private _defineName;
  59907. private _linearDefineName;
  59908. private _tempTextureRead;
  59909. private _samplerName;
  59910. private _transformedUVName;
  59911. private _textureTransformName;
  59912. private _textureInfoName;
  59913. private _mainUVName;
  59914. private _mainUVDefineName;
  59915. /**
  59916. * Gets or sets the texture associated with the node
  59917. */
  59918. texture: Nullable<Texture>;
  59919. /**
  59920. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59921. */
  59922. convertToGammaSpace: boolean;
  59923. /**
  59924. * Create a new TextureBlock
  59925. * @param name defines the block name
  59926. */
  59927. constructor(name: string);
  59928. /**
  59929. * Gets the current class name
  59930. * @returns the class name
  59931. */
  59932. getClassName(): string;
  59933. /**
  59934. * Gets the uv input component
  59935. */
  59936. get uv(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the rgba output component
  59939. */
  59940. get rgba(): NodeMaterialConnectionPoint;
  59941. /**
  59942. * Gets the rgb output component
  59943. */
  59944. get rgb(): NodeMaterialConnectionPoint;
  59945. /**
  59946. * Gets the r output component
  59947. */
  59948. get r(): NodeMaterialConnectionPoint;
  59949. /**
  59950. * Gets the g output component
  59951. */
  59952. get g(): NodeMaterialConnectionPoint;
  59953. /**
  59954. * Gets the b output component
  59955. */
  59956. get b(): NodeMaterialConnectionPoint;
  59957. /**
  59958. * Gets the a output component
  59959. */
  59960. get a(): NodeMaterialConnectionPoint;
  59961. get target(): NodeMaterialBlockTargets;
  59962. autoConfigure(material: NodeMaterial): void;
  59963. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59965. isReady(): boolean;
  59966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59967. private get _isMixed();
  59968. private _injectVertexCode;
  59969. private _writeTextureRead;
  59970. private _writeOutput;
  59971. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59972. protected _dumpPropertiesCode(): string;
  59973. serialize(): any;
  59974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59975. }
  59976. }
  59977. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59980. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59981. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59982. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59983. import { Scene } from "babylonjs/scene";
  59984. /**
  59985. * Class used to store shared data between 2 NodeMaterialBuildState
  59986. */
  59987. export class NodeMaterialBuildStateSharedData {
  59988. /**
  59989. * Gets the list of emitted varyings
  59990. */
  59991. temps: string[];
  59992. /**
  59993. * Gets the list of emitted varyings
  59994. */
  59995. varyings: string[];
  59996. /**
  59997. * Gets the varying declaration string
  59998. */
  59999. varyingDeclaration: string;
  60000. /**
  60001. * Input blocks
  60002. */
  60003. inputBlocks: InputBlock[];
  60004. /**
  60005. * Input blocks
  60006. */
  60007. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60008. /**
  60009. * Bindable blocks (Blocks that need to set data to the effect)
  60010. */
  60011. bindableBlocks: NodeMaterialBlock[];
  60012. /**
  60013. * List of blocks that can provide a compilation fallback
  60014. */
  60015. blocksWithFallbacks: NodeMaterialBlock[];
  60016. /**
  60017. * List of blocks that can provide a define update
  60018. */
  60019. blocksWithDefines: NodeMaterialBlock[];
  60020. /**
  60021. * List of blocks that can provide a repeatable content
  60022. */
  60023. repeatableContentBlocks: NodeMaterialBlock[];
  60024. /**
  60025. * List of blocks that can provide a dynamic list of uniforms
  60026. */
  60027. dynamicUniformBlocks: NodeMaterialBlock[];
  60028. /**
  60029. * List of blocks that can block the isReady function for the material
  60030. */
  60031. blockingBlocks: NodeMaterialBlock[];
  60032. /**
  60033. * Gets the list of animated inputs
  60034. */
  60035. animatedInputs: InputBlock[];
  60036. /**
  60037. * Build Id used to avoid multiple recompilations
  60038. */
  60039. buildId: number;
  60040. /** List of emitted variables */
  60041. variableNames: {
  60042. [key: string]: number;
  60043. };
  60044. /** List of emitted defines */
  60045. defineNames: {
  60046. [key: string]: number;
  60047. };
  60048. /** Should emit comments? */
  60049. emitComments: boolean;
  60050. /** Emit build activity */
  60051. verbose: boolean;
  60052. /** Gets or sets the hosting scene */
  60053. scene: Scene;
  60054. /**
  60055. * Gets the compilation hints emitted at compilation time
  60056. */
  60057. hints: {
  60058. needWorldViewMatrix: boolean;
  60059. needWorldViewProjectionMatrix: boolean;
  60060. needAlphaBlending: boolean;
  60061. needAlphaTesting: boolean;
  60062. };
  60063. /**
  60064. * List of compilation checks
  60065. */
  60066. checks: {
  60067. emitVertex: boolean;
  60068. emitFragment: boolean;
  60069. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60070. };
  60071. /** Creates a new shared data */
  60072. constructor();
  60073. /**
  60074. * Emits console errors and exceptions if there is a failing check
  60075. */
  60076. emitErrors(): void;
  60077. }
  60078. }
  60079. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60080. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60081. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60082. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60083. /**
  60084. * Class used to store node based material build state
  60085. */
  60086. export class NodeMaterialBuildState {
  60087. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60088. supportUniformBuffers: boolean;
  60089. /**
  60090. * Gets the list of emitted attributes
  60091. */
  60092. attributes: string[];
  60093. /**
  60094. * Gets the list of emitted uniforms
  60095. */
  60096. uniforms: string[];
  60097. /**
  60098. * Gets the list of emitted constants
  60099. */
  60100. constants: string[];
  60101. /**
  60102. * Gets the list of emitted samplers
  60103. */
  60104. samplers: string[];
  60105. /**
  60106. * Gets the list of emitted functions
  60107. */
  60108. functions: {
  60109. [key: string]: string;
  60110. };
  60111. /**
  60112. * Gets the list of emitted extensions
  60113. */
  60114. extensions: {
  60115. [key: string]: string;
  60116. };
  60117. /**
  60118. * Gets the target of the compilation state
  60119. */
  60120. target: NodeMaterialBlockTargets;
  60121. /**
  60122. * Gets the list of emitted counters
  60123. */
  60124. counters: {
  60125. [key: string]: number;
  60126. };
  60127. /**
  60128. * Shared data between multiple NodeMaterialBuildState instances
  60129. */
  60130. sharedData: NodeMaterialBuildStateSharedData;
  60131. /** @hidden */
  60132. _vertexState: NodeMaterialBuildState;
  60133. /** @hidden */
  60134. _attributeDeclaration: string;
  60135. /** @hidden */
  60136. _uniformDeclaration: string;
  60137. /** @hidden */
  60138. _constantDeclaration: string;
  60139. /** @hidden */
  60140. _samplerDeclaration: string;
  60141. /** @hidden */
  60142. _varyingTransfer: string;
  60143. private _repeatableContentAnchorIndex;
  60144. /** @hidden */
  60145. _builtCompilationString: string;
  60146. /**
  60147. * Gets the emitted compilation strings
  60148. */
  60149. compilationString: string;
  60150. /**
  60151. * Finalize the compilation strings
  60152. * @param state defines the current compilation state
  60153. */
  60154. finalize(state: NodeMaterialBuildState): void;
  60155. /** @hidden */
  60156. get _repeatableContentAnchor(): string;
  60157. /** @hidden */
  60158. _getFreeVariableName(prefix: string): string;
  60159. /** @hidden */
  60160. _getFreeDefineName(prefix: string): string;
  60161. /** @hidden */
  60162. _excludeVariableName(name: string): void;
  60163. /** @hidden */
  60164. _emit2DSampler(name: string): void;
  60165. /** @hidden */
  60166. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60167. /** @hidden */
  60168. _emitExtension(name: string, extension: string): void;
  60169. /** @hidden */
  60170. _emitFunction(name: string, code: string, comments: string): void;
  60171. /** @hidden */
  60172. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60173. replaceStrings?: {
  60174. search: RegExp;
  60175. replace: string;
  60176. }[];
  60177. repeatKey?: string;
  60178. }): string;
  60179. /** @hidden */
  60180. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60181. repeatKey?: string;
  60182. removeAttributes?: boolean;
  60183. removeUniforms?: boolean;
  60184. removeVaryings?: boolean;
  60185. removeIfDef?: boolean;
  60186. replaceStrings?: {
  60187. search: RegExp;
  60188. replace: string;
  60189. }[];
  60190. }, storeKey?: string): void;
  60191. /** @hidden */
  60192. _registerTempVariable(name: string): boolean;
  60193. /** @hidden */
  60194. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60195. /** @hidden */
  60196. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60197. /** @hidden */
  60198. _emitFloat(value: number): string;
  60199. }
  60200. }
  60201. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60202. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60204. import { Nullable } from "babylonjs/types";
  60205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60206. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60207. import { Effect } from "babylonjs/Materials/effect";
  60208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60209. import { Mesh } from "babylonjs/Meshes/mesh";
  60210. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60211. import { Scene } from "babylonjs/scene";
  60212. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60213. /**
  60214. * Defines a block that can be used inside a node based material
  60215. */
  60216. export class NodeMaterialBlock {
  60217. private _buildId;
  60218. private _buildTarget;
  60219. private _target;
  60220. private _isFinalMerger;
  60221. private _isInput;
  60222. protected _isUnique: boolean;
  60223. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60224. inputsAreExclusive: boolean;
  60225. /** @hidden */
  60226. _codeVariableName: string;
  60227. /** @hidden */
  60228. _inputs: NodeMaterialConnectionPoint[];
  60229. /** @hidden */
  60230. _outputs: NodeMaterialConnectionPoint[];
  60231. /** @hidden */
  60232. _preparationId: number;
  60233. /**
  60234. * Gets or sets the name of the block
  60235. */
  60236. name: string;
  60237. /**
  60238. * Gets or sets the unique id of the node
  60239. */
  60240. uniqueId: number;
  60241. /**
  60242. * Gets or sets the comments associated with this block
  60243. */
  60244. comments: string;
  60245. /**
  60246. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60247. */
  60248. get isUnique(): boolean;
  60249. /**
  60250. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60251. */
  60252. get isFinalMerger(): boolean;
  60253. /**
  60254. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60255. */
  60256. get isInput(): boolean;
  60257. /**
  60258. * Gets or sets the build Id
  60259. */
  60260. get buildId(): number;
  60261. set buildId(value: number);
  60262. /**
  60263. * Gets or sets the target of the block
  60264. */
  60265. get target(): NodeMaterialBlockTargets;
  60266. set target(value: NodeMaterialBlockTargets);
  60267. /**
  60268. * Gets the list of input points
  60269. */
  60270. get inputs(): NodeMaterialConnectionPoint[];
  60271. /** Gets the list of output points */
  60272. get outputs(): NodeMaterialConnectionPoint[];
  60273. /**
  60274. * Find an input by its name
  60275. * @param name defines the name of the input to look for
  60276. * @returns the input or null if not found
  60277. */
  60278. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60279. /**
  60280. * Find an output by its name
  60281. * @param name defines the name of the outputto look for
  60282. * @returns the output or null if not found
  60283. */
  60284. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60285. /**
  60286. * Creates a new NodeMaterialBlock
  60287. * @param name defines the block name
  60288. * @param target defines the target of that block (Vertex by default)
  60289. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60290. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60291. */
  60292. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60293. /**
  60294. * Initialize the block and prepare the context for build
  60295. * @param state defines the state that will be used for the build
  60296. */
  60297. initialize(state: NodeMaterialBuildState): void;
  60298. /**
  60299. * Bind data to effect. Will only be called for blocks with isBindable === true
  60300. * @param effect defines the effect to bind data to
  60301. * @param nodeMaterial defines the hosting NodeMaterial
  60302. * @param mesh defines the mesh that will be rendered
  60303. */
  60304. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60305. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60306. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60307. protected _writeFloat(value: number): string;
  60308. /**
  60309. * Gets the current class name e.g. "NodeMaterialBlock"
  60310. * @returns the class name
  60311. */
  60312. getClassName(): string;
  60313. /**
  60314. * Register a new input. Must be called inside a block constructor
  60315. * @param name defines the connection point name
  60316. * @param type defines the connection point type
  60317. * @param isOptional defines a boolean indicating that this input can be omitted
  60318. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60319. * @returns the current block
  60320. */
  60321. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60322. /**
  60323. * Register a new output. Must be called inside a block constructor
  60324. * @param name defines the connection point name
  60325. * @param type defines the connection point type
  60326. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60327. * @returns the current block
  60328. */
  60329. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60330. /**
  60331. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60332. * @param forOutput defines an optional connection point to check compatibility with
  60333. * @returns the first available input or null
  60334. */
  60335. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60336. /**
  60337. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60338. * @param forBlock defines an optional block to check compatibility with
  60339. * @returns the first available input or null
  60340. */
  60341. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60342. /**
  60343. * Gets the sibling of the given output
  60344. * @param current defines the current output
  60345. * @returns the next output in the list or null
  60346. */
  60347. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60348. /**
  60349. * Connect current block with another block
  60350. * @param other defines the block to connect with
  60351. * @param options define the various options to help pick the right connections
  60352. * @returns the current block
  60353. */
  60354. connectTo(other: NodeMaterialBlock, options?: {
  60355. input?: string;
  60356. output?: string;
  60357. outputSwizzle?: string;
  60358. }): this | undefined;
  60359. protected _buildBlock(state: NodeMaterialBuildState): void;
  60360. /**
  60361. * Add uniforms, samplers and uniform buffers at compilation time
  60362. * @param state defines the state to update
  60363. * @param nodeMaterial defines the node material requesting the update
  60364. * @param defines defines the material defines to update
  60365. * @param uniformBuffers defines the list of uniform buffer names
  60366. */
  60367. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60368. /**
  60369. * Add potential fallbacks if shader compilation fails
  60370. * @param mesh defines the mesh to be rendered
  60371. * @param fallbacks defines the current prioritized list of fallbacks
  60372. */
  60373. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60374. /**
  60375. * Initialize defines for shader compilation
  60376. * @param mesh defines the mesh to be rendered
  60377. * @param nodeMaterial defines the node material requesting the update
  60378. * @param defines defines the material defines to update
  60379. * @param useInstances specifies that instances should be used
  60380. */
  60381. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60382. /**
  60383. * Update defines for shader compilation
  60384. * @param mesh defines the mesh to be rendered
  60385. * @param nodeMaterial defines the node material requesting the update
  60386. * @param defines defines the material defines to update
  60387. * @param useInstances specifies that instances should be used
  60388. */
  60389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60390. /**
  60391. * Lets the block try to connect some inputs automatically
  60392. * @param material defines the hosting NodeMaterial
  60393. */
  60394. autoConfigure(material: NodeMaterial): void;
  60395. /**
  60396. * Function called when a block is declared as repeatable content generator
  60397. * @param vertexShaderState defines the current compilation state for the vertex shader
  60398. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60399. * @param mesh defines the mesh to be rendered
  60400. * @param defines defines the material defines to update
  60401. */
  60402. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60403. /**
  60404. * Checks if the block is ready
  60405. * @param mesh defines the mesh to be rendered
  60406. * @param nodeMaterial defines the node material requesting the update
  60407. * @param defines defines the material defines to update
  60408. * @param useInstances specifies that instances should be used
  60409. * @returns true if the block is ready
  60410. */
  60411. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60412. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60413. private _processBuild;
  60414. /**
  60415. * Compile the current node and generate the shader code
  60416. * @param state defines the current compilation state (uniforms, samplers, current string)
  60417. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60418. * @returns true if already built
  60419. */
  60420. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60421. protected _inputRename(name: string): string;
  60422. protected _outputRename(name: string): string;
  60423. protected _dumpPropertiesCode(): string;
  60424. /** @hidden */
  60425. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60426. /** @hidden */
  60427. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60428. /**
  60429. * Clone the current block to a new identical block
  60430. * @param scene defines the hosting scene
  60431. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60432. * @returns a copy of the current block
  60433. */
  60434. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60435. /**
  60436. * Serializes this block in a JSON representation
  60437. * @returns the serialized block object
  60438. */
  60439. serialize(): any;
  60440. /** @hidden */
  60441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60442. /**
  60443. * Release resources
  60444. */
  60445. dispose(): void;
  60446. }
  60447. }
  60448. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60449. /**
  60450. * Enum defining the type of animations supported by InputBlock
  60451. */
  60452. export enum AnimatedInputBlockTypes {
  60453. /** No animation */
  60454. None = 0,
  60455. /** Time based animation. Will only work for floats */
  60456. Time = 1
  60457. }
  60458. }
  60459. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60461. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60462. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60463. import { Nullable } from "babylonjs/types";
  60464. import { Effect } from "babylonjs/Materials/effect";
  60465. import { Matrix } from "babylonjs/Maths/math.vector";
  60466. import { Scene } from "babylonjs/scene";
  60467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60469. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60470. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60471. import { Observable } from "babylonjs/Misc/observable";
  60472. /**
  60473. * Block used to expose an input value
  60474. */
  60475. export class InputBlock extends NodeMaterialBlock {
  60476. private _mode;
  60477. private _associatedVariableName;
  60478. private _storedValue;
  60479. private _valueCallback;
  60480. private _type;
  60481. private _animationType;
  60482. /** Gets or set a value used to limit the range of float values */
  60483. min: number;
  60484. /** Gets or set a value used to limit the range of float values */
  60485. max: number;
  60486. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60487. isBoolean: boolean;
  60488. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60489. matrixMode: number;
  60490. /** @hidden */
  60491. _systemValue: Nullable<NodeMaterialSystemValues>;
  60492. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60493. visibleInInspector: boolean;
  60494. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60495. isConstant: boolean;
  60496. /** Gets or sets the group to use to display this block in the Inspector */
  60497. groupInInspector: string;
  60498. /** Gets an observable raised when the value is changed */
  60499. onValueChangedObservable: Observable<InputBlock>;
  60500. /**
  60501. * Gets or sets the connection point type (default is float)
  60502. */
  60503. get type(): NodeMaterialBlockConnectionPointTypes;
  60504. /**
  60505. * Creates a new InputBlock
  60506. * @param name defines the block name
  60507. * @param target defines the target of that block (Vertex by default)
  60508. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60509. */
  60510. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60511. /**
  60512. * Gets the output component
  60513. */
  60514. get output(): NodeMaterialConnectionPoint;
  60515. /**
  60516. * Set the source of this connection point to a vertex attribute
  60517. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60518. * @returns the current connection point
  60519. */
  60520. setAsAttribute(attributeName?: string): InputBlock;
  60521. /**
  60522. * Set the source of this connection point to a system value
  60523. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60524. * @returns the current connection point
  60525. */
  60526. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60527. /**
  60528. * Gets or sets the value of that point.
  60529. * Please note that this value will be ignored if valueCallback is defined
  60530. */
  60531. get value(): any;
  60532. set value(value: any);
  60533. /**
  60534. * Gets or sets a callback used to get the value of that point.
  60535. * Please note that setting this value will force the connection point to ignore the value property
  60536. */
  60537. get valueCallback(): () => any;
  60538. set valueCallback(value: () => any);
  60539. /**
  60540. * Gets or sets the associated variable name in the shader
  60541. */
  60542. get associatedVariableName(): string;
  60543. set associatedVariableName(value: string);
  60544. /** Gets or sets the type of animation applied to the input */
  60545. get animationType(): AnimatedInputBlockTypes;
  60546. set animationType(value: AnimatedInputBlockTypes);
  60547. /**
  60548. * Gets a boolean indicating that this connection point not defined yet
  60549. */
  60550. get isUndefined(): boolean;
  60551. /**
  60552. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60553. * In this case the connection point name must be the name of the uniform to use.
  60554. * Can only be set on inputs
  60555. */
  60556. get isUniform(): boolean;
  60557. set isUniform(value: boolean);
  60558. /**
  60559. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60560. * In this case the connection point name must be the name of the attribute to use
  60561. * Can only be set on inputs
  60562. */
  60563. get isAttribute(): boolean;
  60564. set isAttribute(value: boolean);
  60565. /**
  60566. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60567. * Can only be set on exit points
  60568. */
  60569. get isVarying(): boolean;
  60570. set isVarying(value: boolean);
  60571. /**
  60572. * Gets a boolean indicating that the current connection point is a system value
  60573. */
  60574. get isSystemValue(): boolean;
  60575. /**
  60576. * Gets or sets the current well known value or null if not defined as a system value
  60577. */
  60578. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60579. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60580. /**
  60581. * Gets the current class name
  60582. * @returns the class name
  60583. */
  60584. getClassName(): string;
  60585. /**
  60586. * Animate the input if animationType !== None
  60587. * @param scene defines the rendering scene
  60588. */
  60589. animate(scene: Scene): void;
  60590. private _emitDefine;
  60591. initialize(state: NodeMaterialBuildState): void;
  60592. /**
  60593. * Set the input block to its default value (based on its type)
  60594. */
  60595. setDefaultValue(): void;
  60596. private _emitConstant;
  60597. private _emit;
  60598. /** @hidden */
  60599. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60600. /** @hidden */
  60601. _transmit(effect: Effect, scene: Scene): void;
  60602. protected _buildBlock(state: NodeMaterialBuildState): void;
  60603. protected _dumpPropertiesCode(): string;
  60604. dispose(): void;
  60605. serialize(): any;
  60606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60607. }
  60608. }
  60609. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60610. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60611. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60612. import { Nullable } from "babylonjs/types";
  60613. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60614. import { Observable } from "babylonjs/Misc/observable";
  60615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60616. /**
  60617. * Enum used to define the compatibility state between two connection points
  60618. */
  60619. export enum NodeMaterialConnectionPointCompatibilityStates {
  60620. /** Points are compatibles */
  60621. Compatible = 0,
  60622. /** Points are incompatible because of their types */
  60623. TypeIncompatible = 1,
  60624. /** Points are incompatible because of their targets (vertex vs fragment) */
  60625. TargetIncompatible = 2
  60626. }
  60627. /**
  60628. * Defines the direction of a connection point
  60629. */
  60630. export enum NodeMaterialConnectionPointDirection {
  60631. /** Input */
  60632. Input = 0,
  60633. /** Output */
  60634. Output = 1
  60635. }
  60636. /**
  60637. * Defines a connection point for a block
  60638. */
  60639. export class NodeMaterialConnectionPoint {
  60640. /** @hidden */
  60641. _ownerBlock: NodeMaterialBlock;
  60642. /** @hidden */
  60643. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60644. private _endpoints;
  60645. private _associatedVariableName;
  60646. private _direction;
  60647. /** @hidden */
  60648. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60649. /** @hidden */
  60650. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60651. private _type;
  60652. /** @hidden */
  60653. _enforceAssociatedVariableName: boolean;
  60654. /** Gets the direction of the point */
  60655. get direction(): NodeMaterialConnectionPointDirection;
  60656. /**
  60657. * Gets or sets the additional types supported by this connection point
  60658. */
  60659. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60660. /**
  60661. * Gets or sets the additional types excluded by this connection point
  60662. */
  60663. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60664. /**
  60665. * Observable triggered when this point is connected
  60666. */
  60667. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60668. /**
  60669. * Gets or sets the associated variable name in the shader
  60670. */
  60671. get associatedVariableName(): string;
  60672. set associatedVariableName(value: string);
  60673. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60674. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60675. /**
  60676. * Gets or sets the connection point type (default is float)
  60677. */
  60678. get type(): NodeMaterialBlockConnectionPointTypes;
  60679. set type(value: NodeMaterialBlockConnectionPointTypes);
  60680. /**
  60681. * Gets or sets the connection point name
  60682. */
  60683. name: string;
  60684. /**
  60685. * Gets or sets a boolean indicating that this connection point can be omitted
  60686. */
  60687. isOptional: boolean;
  60688. /**
  60689. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60690. */
  60691. define: string;
  60692. /** @hidden */
  60693. _prioritizeVertex: boolean;
  60694. private _target;
  60695. /** Gets or sets the target of that connection point */
  60696. get target(): NodeMaterialBlockTargets;
  60697. set target(value: NodeMaterialBlockTargets);
  60698. /**
  60699. * Gets a boolean indicating that the current point is connected
  60700. */
  60701. get isConnected(): boolean;
  60702. /**
  60703. * Gets a boolean indicating that the current point is connected to an input block
  60704. */
  60705. get isConnectedToInputBlock(): boolean;
  60706. /**
  60707. * Gets a the connected input block (if any)
  60708. */
  60709. get connectInputBlock(): Nullable<InputBlock>;
  60710. /** Get the other side of the connection (if any) */
  60711. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60712. /** Get the block that owns this connection point */
  60713. get ownerBlock(): NodeMaterialBlock;
  60714. /** Get the block connected on the other side of this connection (if any) */
  60715. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60716. /** Get the block connected on the endpoints of this connection (if any) */
  60717. get connectedBlocks(): Array<NodeMaterialBlock>;
  60718. /** Gets the list of connected endpoints */
  60719. get endpoints(): NodeMaterialConnectionPoint[];
  60720. /** Gets a boolean indicating if that output point is connected to at least one input */
  60721. get hasEndpoints(): boolean;
  60722. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60723. get isConnectedInVertexShader(): boolean;
  60724. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60725. get isConnectedInFragmentShader(): boolean;
  60726. /**
  60727. * Creates a new connection point
  60728. * @param name defines the connection point name
  60729. * @param ownerBlock defines the block hosting this connection point
  60730. * @param direction defines the direction of the connection point
  60731. */
  60732. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60733. /**
  60734. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60735. * @returns the class name
  60736. */
  60737. getClassName(): string;
  60738. /**
  60739. * Gets a boolean indicating if the current point can be connected to another point
  60740. * @param connectionPoint defines the other connection point
  60741. * @returns a boolean
  60742. */
  60743. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60744. /**
  60745. * Gets a number indicating if the current point can be connected to another point
  60746. * @param connectionPoint defines the other connection point
  60747. * @returns a number defining the compatibility state
  60748. */
  60749. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60750. /**
  60751. * Connect this point to another connection point
  60752. * @param connectionPoint defines the other connection point
  60753. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60754. * @returns the current connection point
  60755. */
  60756. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60757. /**
  60758. * Disconnect this point from one of his endpoint
  60759. * @param endpoint defines the other connection point
  60760. * @returns the current connection point
  60761. */
  60762. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60763. /**
  60764. * Serializes this point in a JSON representation
  60765. * @returns the serialized point object
  60766. */
  60767. serialize(): any;
  60768. /**
  60769. * Release resources
  60770. */
  60771. dispose(): void;
  60772. }
  60773. }
  60774. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60778. import { Mesh } from "babylonjs/Meshes/mesh";
  60779. import { Effect } from "babylonjs/Materials/effect";
  60780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60781. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60783. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60784. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60785. /**
  60786. * Block used to add support for vertex skinning (bones)
  60787. */
  60788. export class BonesBlock extends NodeMaterialBlock {
  60789. /**
  60790. * Creates a new BonesBlock
  60791. * @param name defines the block name
  60792. */
  60793. constructor(name: string);
  60794. /**
  60795. * Initialize the block and prepare the context for build
  60796. * @param state defines the state that will be used for the build
  60797. */
  60798. initialize(state: NodeMaterialBuildState): void;
  60799. /**
  60800. * Gets the current class name
  60801. * @returns the class name
  60802. */
  60803. getClassName(): string;
  60804. /**
  60805. * Gets the matrix indices input component
  60806. */
  60807. get matricesIndices(): NodeMaterialConnectionPoint;
  60808. /**
  60809. * Gets the matrix weights input component
  60810. */
  60811. get matricesWeights(): NodeMaterialConnectionPoint;
  60812. /**
  60813. * Gets the extra matrix indices input component
  60814. */
  60815. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the extra matrix weights input component
  60818. */
  60819. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60820. /**
  60821. * Gets the world input component
  60822. */
  60823. get world(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the output component
  60826. */
  60827. get output(): NodeMaterialConnectionPoint;
  60828. autoConfigure(material: NodeMaterial): void;
  60829. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60832. protected _buildBlock(state: NodeMaterialBuildState): this;
  60833. }
  60834. }
  60835. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60840. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60841. /**
  60842. * Block used to add support for instances
  60843. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60844. */
  60845. export class InstancesBlock extends NodeMaterialBlock {
  60846. /**
  60847. * Creates a new InstancesBlock
  60848. * @param name defines the block name
  60849. */
  60850. constructor(name: string);
  60851. /**
  60852. * Gets the current class name
  60853. * @returns the class name
  60854. */
  60855. getClassName(): string;
  60856. /**
  60857. * Gets the first world row input component
  60858. */
  60859. get world0(): NodeMaterialConnectionPoint;
  60860. /**
  60861. * Gets the second world row input component
  60862. */
  60863. get world1(): NodeMaterialConnectionPoint;
  60864. /**
  60865. * Gets the third world row input component
  60866. */
  60867. get world2(): NodeMaterialConnectionPoint;
  60868. /**
  60869. * Gets the forth world row input component
  60870. */
  60871. get world3(): NodeMaterialConnectionPoint;
  60872. /**
  60873. * Gets the world input component
  60874. */
  60875. get world(): NodeMaterialConnectionPoint;
  60876. /**
  60877. * Gets the output component
  60878. */
  60879. get output(): NodeMaterialConnectionPoint;
  60880. /**
  60881. * Gets the isntanceID component
  60882. */
  60883. get instanceID(): NodeMaterialConnectionPoint;
  60884. autoConfigure(material: NodeMaterial): void;
  60885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60886. protected _buildBlock(state: NodeMaterialBuildState): this;
  60887. }
  60888. }
  60889. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60894. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60895. import { Effect } from "babylonjs/Materials/effect";
  60896. import { Mesh } from "babylonjs/Meshes/mesh";
  60897. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60898. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60899. /**
  60900. * Block used to add morph targets support to vertex shader
  60901. */
  60902. export class MorphTargetsBlock extends NodeMaterialBlock {
  60903. private _repeatableContentAnchor;
  60904. /**
  60905. * Create a new MorphTargetsBlock
  60906. * @param name defines the block name
  60907. */
  60908. constructor(name: string);
  60909. /**
  60910. * Gets the current class name
  60911. * @returns the class name
  60912. */
  60913. getClassName(): string;
  60914. /**
  60915. * Gets the position input component
  60916. */
  60917. get position(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the normal input component
  60920. */
  60921. get normal(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the tangent input component
  60924. */
  60925. get tangent(): NodeMaterialConnectionPoint;
  60926. /**
  60927. * Gets the tangent input component
  60928. */
  60929. get uv(): NodeMaterialConnectionPoint;
  60930. /**
  60931. * Gets the position output component
  60932. */
  60933. get positionOutput(): NodeMaterialConnectionPoint;
  60934. /**
  60935. * Gets the normal output component
  60936. */
  60937. get normalOutput(): NodeMaterialConnectionPoint;
  60938. /**
  60939. * Gets the tangent output component
  60940. */
  60941. get tangentOutput(): NodeMaterialConnectionPoint;
  60942. /**
  60943. * Gets the tangent output component
  60944. */
  60945. get uvOutput(): NodeMaterialConnectionPoint;
  60946. initialize(state: NodeMaterialBuildState): void;
  60947. autoConfigure(material: NodeMaterial): void;
  60948. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60949. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60950. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60951. protected _buildBlock(state: NodeMaterialBuildState): this;
  60952. }
  60953. }
  60954. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60958. import { Nullable } from "babylonjs/types";
  60959. import { Scene } from "babylonjs/scene";
  60960. import { Effect } from "babylonjs/Materials/effect";
  60961. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60962. import { Mesh } from "babylonjs/Meshes/mesh";
  60963. import { Light } from "babylonjs/Lights/light";
  60964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60965. /**
  60966. * Block used to get data information from a light
  60967. */
  60968. export class LightInformationBlock extends NodeMaterialBlock {
  60969. private _lightDataUniformName;
  60970. private _lightColorUniformName;
  60971. private _lightTypeDefineName;
  60972. /**
  60973. * Gets or sets the light associated with this block
  60974. */
  60975. light: Nullable<Light>;
  60976. /**
  60977. * Creates a new LightInformationBlock
  60978. * @param name defines the block name
  60979. */
  60980. constructor(name: string);
  60981. /**
  60982. * Gets the current class name
  60983. * @returns the class name
  60984. */
  60985. getClassName(): string;
  60986. /**
  60987. * Gets the world position input component
  60988. */
  60989. get worldPosition(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the direction output component
  60992. */
  60993. get direction(): NodeMaterialConnectionPoint;
  60994. /**
  60995. * Gets the direction output component
  60996. */
  60997. get color(): NodeMaterialConnectionPoint;
  60998. /**
  60999. * Gets the direction output component
  61000. */
  61001. get intensity(): NodeMaterialConnectionPoint;
  61002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61004. protected _buildBlock(state: NodeMaterialBuildState): this;
  61005. serialize(): any;
  61006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61007. }
  61008. }
  61009. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61010. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61011. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61012. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61013. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61014. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61015. }
  61016. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61021. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61022. import { Effect } from "babylonjs/Materials/effect";
  61023. import { Mesh } from "babylonjs/Meshes/mesh";
  61024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61025. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61026. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61027. /**
  61028. * Block used to add image processing support to fragment shader
  61029. */
  61030. export class ImageProcessingBlock extends NodeMaterialBlock {
  61031. /**
  61032. * Create a new ImageProcessingBlock
  61033. * @param name defines the block name
  61034. */
  61035. constructor(name: string);
  61036. /**
  61037. * Gets the current class name
  61038. * @returns the class name
  61039. */
  61040. getClassName(): string;
  61041. /**
  61042. * Gets the color input component
  61043. */
  61044. get color(): NodeMaterialConnectionPoint;
  61045. /**
  61046. * Gets the output component
  61047. */
  61048. get output(): NodeMaterialConnectionPoint;
  61049. /**
  61050. * Initialize the block and prepare the context for build
  61051. * @param state defines the state that will be used for the build
  61052. */
  61053. initialize(state: NodeMaterialBuildState): void;
  61054. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61057. protected _buildBlock(state: NodeMaterialBuildState): this;
  61058. }
  61059. }
  61060. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  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 { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61066. import { Effect } from "babylonjs/Materials/effect";
  61067. import { Mesh } from "babylonjs/Meshes/mesh";
  61068. import { Scene } from "babylonjs/scene";
  61069. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61070. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61071. /**
  61072. * Block used to pertub normals based on a normal map
  61073. */
  61074. export class PerturbNormalBlock extends NodeMaterialBlock {
  61075. private _tangentSpaceParameterName;
  61076. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61077. invertX: boolean;
  61078. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61079. invertY: boolean;
  61080. /**
  61081. * Create a new PerturbNormalBlock
  61082. * @param name defines the block name
  61083. */
  61084. constructor(name: string);
  61085. /**
  61086. * Gets the current class name
  61087. * @returns the class name
  61088. */
  61089. getClassName(): string;
  61090. /**
  61091. * Gets the world position input component
  61092. */
  61093. get worldPosition(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the world normal input component
  61096. */
  61097. get worldNormal(): NodeMaterialConnectionPoint;
  61098. /**
  61099. * Gets the world tangent input component
  61100. */
  61101. get worldTangent(): NodeMaterialConnectionPoint;
  61102. /**
  61103. * Gets the uv input component
  61104. */
  61105. get uv(): NodeMaterialConnectionPoint;
  61106. /**
  61107. * Gets the normal map color input component
  61108. */
  61109. get normalMapColor(): NodeMaterialConnectionPoint;
  61110. /**
  61111. * Gets the strength input component
  61112. */
  61113. get strength(): NodeMaterialConnectionPoint;
  61114. /**
  61115. * Gets the output component
  61116. */
  61117. get output(): NodeMaterialConnectionPoint;
  61118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61119. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61120. autoConfigure(material: NodeMaterial): void;
  61121. protected _buildBlock(state: NodeMaterialBuildState): this;
  61122. protected _dumpPropertiesCode(): string;
  61123. serialize(): any;
  61124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61125. }
  61126. }
  61127. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61131. /**
  61132. * Block used to discard a pixel if a value is smaller than a cutoff
  61133. */
  61134. export class DiscardBlock extends NodeMaterialBlock {
  61135. /**
  61136. * Create a new DiscardBlock
  61137. * @param name defines the block name
  61138. */
  61139. constructor(name: string);
  61140. /**
  61141. * Gets the current class name
  61142. * @returns the class name
  61143. */
  61144. getClassName(): string;
  61145. /**
  61146. * Gets the color input component
  61147. */
  61148. get value(): NodeMaterialConnectionPoint;
  61149. /**
  61150. * Gets the cutoff input component
  61151. */
  61152. get cutoff(): NodeMaterialConnectionPoint;
  61153. protected _buildBlock(state: NodeMaterialBuildState): this;
  61154. }
  61155. }
  61156. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61160. /**
  61161. * Block used to test if the fragment shader is front facing
  61162. */
  61163. export class FrontFacingBlock extends NodeMaterialBlock {
  61164. /**
  61165. * Creates a new FrontFacingBlock
  61166. * @param name defines the block name
  61167. */
  61168. constructor(name: string);
  61169. /**
  61170. * Gets the current class name
  61171. * @returns the class name
  61172. */
  61173. getClassName(): string;
  61174. /**
  61175. * Gets the output component
  61176. */
  61177. get output(): NodeMaterialConnectionPoint;
  61178. protected _buildBlock(state: NodeMaterialBuildState): this;
  61179. }
  61180. }
  61181. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61185. /**
  61186. * Block used to get the derivative value on x and y of a given input
  61187. */
  61188. export class DerivativeBlock extends NodeMaterialBlock {
  61189. /**
  61190. * Create a new DerivativeBlock
  61191. * @param name defines the block name
  61192. */
  61193. constructor(name: string);
  61194. /**
  61195. * Gets the current class name
  61196. * @returns the class name
  61197. */
  61198. getClassName(): string;
  61199. /**
  61200. * Gets the input component
  61201. */
  61202. get input(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the derivative output on x
  61205. */
  61206. get dx(): NodeMaterialConnectionPoint;
  61207. /**
  61208. * Gets the derivative output on y
  61209. */
  61210. get dy(): NodeMaterialConnectionPoint;
  61211. protected _buildBlock(state: NodeMaterialBuildState): this;
  61212. }
  61213. }
  61214. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61215. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61216. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61217. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61218. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61219. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61220. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61221. }
  61222. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61225. import { Mesh } from "babylonjs/Meshes/mesh";
  61226. import { Effect } from "babylonjs/Materials/effect";
  61227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61229. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61230. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61231. /**
  61232. * Block used to add support for scene fog
  61233. */
  61234. export class FogBlock extends NodeMaterialBlock {
  61235. private _fogDistanceName;
  61236. private _fogParameters;
  61237. /**
  61238. * Create a new FogBlock
  61239. * @param name defines the block name
  61240. */
  61241. constructor(name: string);
  61242. /**
  61243. * Gets the current class name
  61244. * @returns the class name
  61245. */
  61246. getClassName(): string;
  61247. /**
  61248. * Gets the world position input component
  61249. */
  61250. get worldPosition(): NodeMaterialConnectionPoint;
  61251. /**
  61252. * Gets the view input component
  61253. */
  61254. get view(): NodeMaterialConnectionPoint;
  61255. /**
  61256. * Gets the color input component
  61257. */
  61258. get input(): NodeMaterialConnectionPoint;
  61259. /**
  61260. * Gets the fog color input component
  61261. */
  61262. get fogColor(): NodeMaterialConnectionPoint;
  61263. /**
  61264. * Gets the output component
  61265. */
  61266. get output(): NodeMaterialConnectionPoint;
  61267. autoConfigure(material: NodeMaterial): void;
  61268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61270. protected _buildBlock(state: NodeMaterialBuildState): this;
  61271. }
  61272. }
  61273. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61278. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61279. import { Effect } from "babylonjs/Materials/effect";
  61280. import { Mesh } from "babylonjs/Meshes/mesh";
  61281. import { Light } from "babylonjs/Lights/light";
  61282. import { Nullable } from "babylonjs/types";
  61283. import { Scene } from "babylonjs/scene";
  61284. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61285. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61286. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61287. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61288. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61289. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61290. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61291. /**
  61292. * Block used to add light in the fragment shader
  61293. */
  61294. export class LightBlock extends NodeMaterialBlock {
  61295. private _lightId;
  61296. /**
  61297. * Gets or sets the light associated with this block
  61298. */
  61299. light: Nullable<Light>;
  61300. /**
  61301. * Create a new LightBlock
  61302. * @param name defines the block name
  61303. */
  61304. constructor(name: string);
  61305. /**
  61306. * Gets the current class name
  61307. * @returns the class name
  61308. */
  61309. getClassName(): string;
  61310. /**
  61311. * Gets the world position input component
  61312. */
  61313. get worldPosition(): NodeMaterialConnectionPoint;
  61314. /**
  61315. * Gets the world normal input component
  61316. */
  61317. get worldNormal(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the camera (or eye) position component
  61320. */
  61321. get cameraPosition(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the glossiness component
  61324. */
  61325. get glossiness(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the glossinness power component
  61328. */
  61329. get glossPower(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the diffuse color component
  61332. */
  61333. get diffuseColor(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the specular color component
  61336. */
  61337. get specularColor(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the diffuse output component
  61340. */
  61341. get diffuseOutput(): NodeMaterialConnectionPoint;
  61342. /**
  61343. * Gets the specular output component
  61344. */
  61345. get specularOutput(): NodeMaterialConnectionPoint;
  61346. /**
  61347. * Gets the shadow output component
  61348. */
  61349. get shadow(): NodeMaterialConnectionPoint;
  61350. autoConfigure(material: NodeMaterial): void;
  61351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61352. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61353. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61354. private _injectVertexCode;
  61355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61356. serialize(): any;
  61357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61358. }
  61359. }
  61360. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61361. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61362. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61363. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61364. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61365. }
  61366. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61367. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61368. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61369. }
  61370. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61374. /**
  61375. * Block used to multiply 2 values
  61376. */
  61377. export class MultiplyBlock extends NodeMaterialBlock {
  61378. /**
  61379. * Creates a new MultiplyBlock
  61380. * @param name defines the block name
  61381. */
  61382. constructor(name: string);
  61383. /**
  61384. * Gets the current class name
  61385. * @returns the class name
  61386. */
  61387. getClassName(): string;
  61388. /**
  61389. * Gets the left operand input component
  61390. */
  61391. get left(): NodeMaterialConnectionPoint;
  61392. /**
  61393. * Gets the right operand input component
  61394. */
  61395. get right(): NodeMaterialConnectionPoint;
  61396. /**
  61397. * Gets the output component
  61398. */
  61399. get output(): NodeMaterialConnectionPoint;
  61400. protected _buildBlock(state: NodeMaterialBuildState): this;
  61401. }
  61402. }
  61403. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61407. /**
  61408. * Block used to add 2 vectors
  61409. */
  61410. export class AddBlock extends NodeMaterialBlock {
  61411. /**
  61412. * Creates a new AddBlock
  61413. * @param name defines the block name
  61414. */
  61415. constructor(name: string);
  61416. /**
  61417. * Gets the current class name
  61418. * @returns the class name
  61419. */
  61420. getClassName(): string;
  61421. /**
  61422. * Gets the left operand input component
  61423. */
  61424. get left(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the right operand input component
  61427. */
  61428. get right(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the output component
  61431. */
  61432. get output(): NodeMaterialConnectionPoint;
  61433. protected _buildBlock(state: NodeMaterialBuildState): this;
  61434. }
  61435. }
  61436. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61440. /**
  61441. * Block used to scale a vector by a float
  61442. */
  61443. export class ScaleBlock extends NodeMaterialBlock {
  61444. /**
  61445. * Creates a new ScaleBlock
  61446. * @param name defines the block name
  61447. */
  61448. constructor(name: string);
  61449. /**
  61450. * Gets the current class name
  61451. * @returns the class name
  61452. */
  61453. getClassName(): string;
  61454. /**
  61455. * Gets the input component
  61456. */
  61457. get input(): NodeMaterialConnectionPoint;
  61458. /**
  61459. * Gets the factor input component
  61460. */
  61461. get factor(): NodeMaterialConnectionPoint;
  61462. /**
  61463. * Gets the output component
  61464. */
  61465. get output(): NodeMaterialConnectionPoint;
  61466. protected _buildBlock(state: NodeMaterialBuildState): this;
  61467. }
  61468. }
  61469. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61473. import { Scene } from "babylonjs/scene";
  61474. /**
  61475. * Block used to clamp a float
  61476. */
  61477. export class ClampBlock extends NodeMaterialBlock {
  61478. /** Gets or sets the minimum range */
  61479. minimum: number;
  61480. /** Gets or sets the maximum range */
  61481. maximum: number;
  61482. /**
  61483. * Creates a new ClampBlock
  61484. * @param name defines the block name
  61485. */
  61486. constructor(name: string);
  61487. /**
  61488. * Gets the current class name
  61489. * @returns the class name
  61490. */
  61491. getClassName(): string;
  61492. /**
  61493. * Gets the value input component
  61494. */
  61495. get value(): NodeMaterialConnectionPoint;
  61496. /**
  61497. * Gets the output component
  61498. */
  61499. get output(): NodeMaterialConnectionPoint;
  61500. protected _buildBlock(state: NodeMaterialBuildState): this;
  61501. protected _dumpPropertiesCode(): string;
  61502. serialize(): any;
  61503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61504. }
  61505. }
  61506. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61510. /**
  61511. * Block used to apply a cross product between 2 vectors
  61512. */
  61513. export class CrossBlock extends NodeMaterialBlock {
  61514. /**
  61515. * Creates a new CrossBlock
  61516. * @param name defines the block name
  61517. */
  61518. constructor(name: string);
  61519. /**
  61520. * Gets the current class name
  61521. * @returns the class name
  61522. */
  61523. getClassName(): string;
  61524. /**
  61525. * Gets the left operand input component
  61526. */
  61527. get left(): NodeMaterialConnectionPoint;
  61528. /**
  61529. * Gets the right operand input component
  61530. */
  61531. get right(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the output component
  61534. */
  61535. get output(): NodeMaterialConnectionPoint;
  61536. protected _buildBlock(state: NodeMaterialBuildState): this;
  61537. }
  61538. }
  61539. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61543. /**
  61544. * Block used to apply a dot product between 2 vectors
  61545. */
  61546. export class DotBlock extends NodeMaterialBlock {
  61547. /**
  61548. * Creates a new DotBlock
  61549. * @param name defines the block name
  61550. */
  61551. constructor(name: string);
  61552. /**
  61553. * Gets the current class name
  61554. * @returns the class name
  61555. */
  61556. getClassName(): string;
  61557. /**
  61558. * Gets the left operand input component
  61559. */
  61560. get left(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the right operand input component
  61563. */
  61564. get right(): NodeMaterialConnectionPoint;
  61565. /**
  61566. * Gets the output component
  61567. */
  61568. get output(): NodeMaterialConnectionPoint;
  61569. protected _buildBlock(state: NodeMaterialBuildState): this;
  61570. }
  61571. }
  61572. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61576. import { Vector2 } from "babylonjs/Maths/math.vector";
  61577. import { Scene } from "babylonjs/scene";
  61578. /**
  61579. * Block used to remap a float from a range to a new one
  61580. */
  61581. export class RemapBlock extends NodeMaterialBlock {
  61582. /**
  61583. * Gets or sets the source range
  61584. */
  61585. sourceRange: Vector2;
  61586. /**
  61587. * Gets or sets the target range
  61588. */
  61589. targetRange: Vector2;
  61590. /**
  61591. * Creates a new RemapBlock
  61592. * @param name defines the block name
  61593. */
  61594. constructor(name: string);
  61595. /**
  61596. * Gets the current class name
  61597. * @returns the class name
  61598. */
  61599. getClassName(): string;
  61600. /**
  61601. * Gets the input component
  61602. */
  61603. get input(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the source min input component
  61606. */
  61607. get sourceMin(): NodeMaterialConnectionPoint;
  61608. /**
  61609. * Gets the source max input component
  61610. */
  61611. get sourceMax(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the target min input component
  61614. */
  61615. get targetMin(): NodeMaterialConnectionPoint;
  61616. /**
  61617. * Gets the target max input component
  61618. */
  61619. get targetMax(): NodeMaterialConnectionPoint;
  61620. /**
  61621. * Gets the output component
  61622. */
  61623. get output(): NodeMaterialConnectionPoint;
  61624. protected _buildBlock(state: NodeMaterialBuildState): this;
  61625. protected _dumpPropertiesCode(): string;
  61626. serialize(): any;
  61627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61628. }
  61629. }
  61630. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61634. /**
  61635. * Block used to normalize a vector
  61636. */
  61637. export class NormalizeBlock extends NodeMaterialBlock {
  61638. /**
  61639. * Creates a new NormalizeBlock
  61640. * @param name defines the block name
  61641. */
  61642. constructor(name: string);
  61643. /**
  61644. * Gets the current class name
  61645. * @returns the class name
  61646. */
  61647. getClassName(): string;
  61648. /**
  61649. * Gets the input component
  61650. */
  61651. get input(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the output component
  61654. */
  61655. get output(): NodeMaterialConnectionPoint;
  61656. protected _buildBlock(state: NodeMaterialBuildState): this;
  61657. }
  61658. }
  61659. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61663. import { Scene } from "babylonjs/scene";
  61664. /**
  61665. * Operations supported by the Trigonometry block
  61666. */
  61667. export enum TrigonometryBlockOperations {
  61668. /** Cos */
  61669. Cos = 0,
  61670. /** Sin */
  61671. Sin = 1,
  61672. /** Abs */
  61673. Abs = 2,
  61674. /** Exp */
  61675. Exp = 3,
  61676. /** Exp2 */
  61677. Exp2 = 4,
  61678. /** Round */
  61679. Round = 5,
  61680. /** Floor */
  61681. Floor = 6,
  61682. /** Ceiling */
  61683. Ceiling = 7,
  61684. /** Square root */
  61685. Sqrt = 8,
  61686. /** Log */
  61687. Log = 9,
  61688. /** Tangent */
  61689. Tan = 10,
  61690. /** Arc tangent */
  61691. ArcTan = 11,
  61692. /** Arc cosinus */
  61693. ArcCos = 12,
  61694. /** Arc sinus */
  61695. ArcSin = 13,
  61696. /** Fraction */
  61697. Fract = 14,
  61698. /** Sign */
  61699. Sign = 15,
  61700. /** To radians (from degrees) */
  61701. Radians = 16,
  61702. /** To degrees (from radians) */
  61703. Degrees = 17
  61704. }
  61705. /**
  61706. * Block used to apply trigonometry operation to floats
  61707. */
  61708. export class TrigonometryBlock extends NodeMaterialBlock {
  61709. /**
  61710. * Gets or sets the operation applied by the block
  61711. */
  61712. operation: TrigonometryBlockOperations;
  61713. /**
  61714. * Creates a new TrigonometryBlock
  61715. * @param name defines the block name
  61716. */
  61717. constructor(name: string);
  61718. /**
  61719. * Gets the current class name
  61720. * @returns the class name
  61721. */
  61722. getClassName(): string;
  61723. /**
  61724. * Gets the input component
  61725. */
  61726. get input(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the output component
  61729. */
  61730. get output(): NodeMaterialConnectionPoint;
  61731. protected _buildBlock(state: NodeMaterialBuildState): this;
  61732. serialize(): any;
  61733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61734. protected _dumpPropertiesCode(): string;
  61735. }
  61736. }
  61737. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61741. /**
  61742. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61743. */
  61744. export class ColorMergerBlock extends NodeMaterialBlock {
  61745. /**
  61746. * Create a new ColorMergerBlock
  61747. * @param name defines the block name
  61748. */
  61749. constructor(name: string);
  61750. /**
  61751. * Gets the current class name
  61752. * @returns the class name
  61753. */
  61754. getClassName(): string;
  61755. /**
  61756. * Gets the rgb component (input)
  61757. */
  61758. get rgbIn(): NodeMaterialConnectionPoint;
  61759. /**
  61760. * Gets the r component (input)
  61761. */
  61762. get r(): NodeMaterialConnectionPoint;
  61763. /**
  61764. * Gets the g component (input)
  61765. */
  61766. get g(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the b component (input)
  61769. */
  61770. get b(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the a component (input)
  61773. */
  61774. get a(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the rgba component (output)
  61777. */
  61778. get rgba(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the rgb component (output)
  61781. */
  61782. get rgbOut(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the rgb component (output)
  61785. * @deprecated Please use rgbOut instead.
  61786. */
  61787. get rgb(): NodeMaterialConnectionPoint;
  61788. protected _buildBlock(state: NodeMaterialBuildState): this;
  61789. }
  61790. }
  61791. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61795. /**
  61796. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61797. */
  61798. export class VectorMergerBlock extends NodeMaterialBlock {
  61799. /**
  61800. * Create a new VectorMergerBlock
  61801. * @param name defines the block name
  61802. */
  61803. constructor(name: string);
  61804. /**
  61805. * Gets the current class name
  61806. * @returns the class name
  61807. */
  61808. getClassName(): string;
  61809. /**
  61810. * Gets the xyz component (input)
  61811. */
  61812. get xyzIn(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the xy component (input)
  61815. */
  61816. get xyIn(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the x component (input)
  61819. */
  61820. get x(): NodeMaterialConnectionPoint;
  61821. /**
  61822. * Gets the y component (input)
  61823. */
  61824. get y(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the z component (input)
  61827. */
  61828. get z(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the w component (input)
  61831. */
  61832. get w(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the xyzw component (output)
  61835. */
  61836. get xyzw(): NodeMaterialConnectionPoint;
  61837. /**
  61838. * Gets the xyz component (output)
  61839. */
  61840. get xyzOut(): NodeMaterialConnectionPoint;
  61841. /**
  61842. * Gets the xy component (output)
  61843. */
  61844. get xyOut(): NodeMaterialConnectionPoint;
  61845. /**
  61846. * Gets the xy component (output)
  61847. * @deprecated Please use xyOut instead.
  61848. */
  61849. get xy(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the xyz component (output)
  61852. * @deprecated Please use xyzOut instead.
  61853. */
  61854. get xyz(): NodeMaterialConnectionPoint;
  61855. protected _buildBlock(state: NodeMaterialBuildState): this;
  61856. }
  61857. }
  61858. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61862. /**
  61863. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61864. */
  61865. export class ColorSplitterBlock extends NodeMaterialBlock {
  61866. /**
  61867. * Create a new ColorSplitterBlock
  61868. * @param name defines the block name
  61869. */
  61870. constructor(name: string);
  61871. /**
  61872. * Gets the current class name
  61873. * @returns the class name
  61874. */
  61875. getClassName(): string;
  61876. /**
  61877. * Gets the rgba component (input)
  61878. */
  61879. get rgba(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the rgb component (input)
  61882. */
  61883. get rgbIn(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the rgb component (output)
  61886. */
  61887. get rgbOut(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the r component (output)
  61890. */
  61891. get r(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Gets the g component (output)
  61894. */
  61895. get g(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the b component (output)
  61898. */
  61899. get b(): NodeMaterialConnectionPoint;
  61900. /**
  61901. * Gets the a component (output)
  61902. */
  61903. get a(): NodeMaterialConnectionPoint;
  61904. protected _inputRename(name: string): string;
  61905. protected _outputRename(name: string): string;
  61906. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61907. }
  61908. }
  61909. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61913. /**
  61914. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61915. */
  61916. export class VectorSplitterBlock extends NodeMaterialBlock {
  61917. /**
  61918. * Create a new VectorSplitterBlock
  61919. * @param name defines the block name
  61920. */
  61921. constructor(name: string);
  61922. /**
  61923. * Gets the current class name
  61924. * @returns the class name
  61925. */
  61926. getClassName(): string;
  61927. /**
  61928. * Gets the xyzw component (input)
  61929. */
  61930. get xyzw(): NodeMaterialConnectionPoint;
  61931. /**
  61932. * Gets the xyz component (input)
  61933. */
  61934. get xyzIn(): NodeMaterialConnectionPoint;
  61935. /**
  61936. * Gets the xy component (input)
  61937. */
  61938. get xyIn(): NodeMaterialConnectionPoint;
  61939. /**
  61940. * Gets the xyz component (output)
  61941. */
  61942. get xyzOut(): NodeMaterialConnectionPoint;
  61943. /**
  61944. * Gets the xy component (output)
  61945. */
  61946. get xyOut(): NodeMaterialConnectionPoint;
  61947. /**
  61948. * Gets the x component (output)
  61949. */
  61950. get x(): NodeMaterialConnectionPoint;
  61951. /**
  61952. * Gets the y component (output)
  61953. */
  61954. get y(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the z component (output)
  61957. */
  61958. get z(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the w component (output)
  61961. */
  61962. get w(): NodeMaterialConnectionPoint;
  61963. protected _inputRename(name: string): string;
  61964. protected _outputRename(name: string): string;
  61965. protected _buildBlock(state: NodeMaterialBuildState): this;
  61966. }
  61967. }
  61968. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61972. /**
  61973. * Block used to lerp between 2 values
  61974. */
  61975. export class LerpBlock extends NodeMaterialBlock {
  61976. /**
  61977. * Creates a new LerpBlock
  61978. * @param name defines the block name
  61979. */
  61980. constructor(name: string);
  61981. /**
  61982. * Gets the current class name
  61983. * @returns the class name
  61984. */
  61985. getClassName(): string;
  61986. /**
  61987. * Gets the left operand input component
  61988. */
  61989. get left(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the right operand input component
  61992. */
  61993. get right(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the gradient operand input component
  61996. */
  61997. get gradient(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the output component
  62000. */
  62001. get output(): NodeMaterialConnectionPoint;
  62002. protected _buildBlock(state: NodeMaterialBuildState): this;
  62003. }
  62004. }
  62005. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62009. /**
  62010. * Block used to divide 2 vectors
  62011. */
  62012. export class DivideBlock extends NodeMaterialBlock {
  62013. /**
  62014. * Creates a new DivideBlock
  62015. * @param name defines the block name
  62016. */
  62017. constructor(name: string);
  62018. /**
  62019. * Gets the current class name
  62020. * @returns the class name
  62021. */
  62022. getClassName(): string;
  62023. /**
  62024. * Gets the left operand input component
  62025. */
  62026. get left(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the right operand input component
  62029. */
  62030. get right(): NodeMaterialConnectionPoint;
  62031. /**
  62032. * Gets the output component
  62033. */
  62034. get output(): NodeMaterialConnectionPoint;
  62035. protected _buildBlock(state: NodeMaterialBuildState): this;
  62036. }
  62037. }
  62038. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62042. /**
  62043. * Block used to subtract 2 vectors
  62044. */
  62045. export class SubtractBlock extends NodeMaterialBlock {
  62046. /**
  62047. * Creates a new SubtractBlock
  62048. * @param name defines the block name
  62049. */
  62050. constructor(name: string);
  62051. /**
  62052. * Gets the current class name
  62053. * @returns the class name
  62054. */
  62055. getClassName(): string;
  62056. /**
  62057. * Gets the left operand input component
  62058. */
  62059. get left(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the right operand input component
  62062. */
  62063. get right(): NodeMaterialConnectionPoint;
  62064. /**
  62065. * Gets the output component
  62066. */
  62067. get output(): NodeMaterialConnectionPoint;
  62068. protected _buildBlock(state: NodeMaterialBuildState): this;
  62069. }
  62070. }
  62071. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62075. /**
  62076. * Block used to step a value
  62077. */
  62078. export class StepBlock extends NodeMaterialBlock {
  62079. /**
  62080. * Creates a new StepBlock
  62081. * @param name defines the block name
  62082. */
  62083. constructor(name: string);
  62084. /**
  62085. * Gets the current class name
  62086. * @returns the class name
  62087. */
  62088. getClassName(): string;
  62089. /**
  62090. * Gets the value operand input component
  62091. */
  62092. get value(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the edge operand input component
  62095. */
  62096. get edge(): NodeMaterialConnectionPoint;
  62097. /**
  62098. * Gets the output component
  62099. */
  62100. get output(): NodeMaterialConnectionPoint;
  62101. protected _buildBlock(state: NodeMaterialBuildState): this;
  62102. }
  62103. }
  62104. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62108. /**
  62109. * Block used to get the opposite (1 - x) of a value
  62110. */
  62111. export class OneMinusBlock extends NodeMaterialBlock {
  62112. /**
  62113. * Creates a new OneMinusBlock
  62114. * @param name defines the block name
  62115. */
  62116. constructor(name: string);
  62117. /**
  62118. * Gets the current class name
  62119. * @returns the class name
  62120. */
  62121. getClassName(): string;
  62122. /**
  62123. * Gets the input component
  62124. */
  62125. get input(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the output component
  62128. */
  62129. get output(): NodeMaterialConnectionPoint;
  62130. protected _buildBlock(state: NodeMaterialBuildState): this;
  62131. }
  62132. }
  62133. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62137. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62138. /**
  62139. * Block used to get the view direction
  62140. */
  62141. export class ViewDirectionBlock extends NodeMaterialBlock {
  62142. /**
  62143. * Creates a new ViewDirectionBlock
  62144. * @param name defines the block name
  62145. */
  62146. constructor(name: string);
  62147. /**
  62148. * Gets the current class name
  62149. * @returns the class name
  62150. */
  62151. getClassName(): string;
  62152. /**
  62153. * Gets the world position component
  62154. */
  62155. get worldPosition(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the camera position component
  62158. */
  62159. get cameraPosition(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the output component
  62162. */
  62163. get output(): NodeMaterialConnectionPoint;
  62164. autoConfigure(material: NodeMaterial): void;
  62165. protected _buildBlock(state: NodeMaterialBuildState): this;
  62166. }
  62167. }
  62168. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62172. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62173. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62174. /**
  62175. * Block used to compute fresnel value
  62176. */
  62177. export class FresnelBlock extends NodeMaterialBlock {
  62178. /**
  62179. * Create a new FresnelBlock
  62180. * @param name defines the block name
  62181. */
  62182. constructor(name: string);
  62183. /**
  62184. * Gets the current class name
  62185. * @returns the class name
  62186. */
  62187. getClassName(): string;
  62188. /**
  62189. * Gets the world normal input component
  62190. */
  62191. get worldNormal(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the view direction input component
  62194. */
  62195. get viewDirection(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the bias input component
  62198. */
  62199. get bias(): NodeMaterialConnectionPoint;
  62200. /**
  62201. * Gets the camera (or eye) position component
  62202. */
  62203. get power(): NodeMaterialConnectionPoint;
  62204. /**
  62205. * Gets the fresnel output component
  62206. */
  62207. get fresnel(): NodeMaterialConnectionPoint;
  62208. autoConfigure(material: NodeMaterial): void;
  62209. protected _buildBlock(state: NodeMaterialBuildState): this;
  62210. }
  62211. }
  62212. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62216. /**
  62217. * Block used to get the max of 2 values
  62218. */
  62219. export class MaxBlock extends NodeMaterialBlock {
  62220. /**
  62221. * Creates a new MaxBlock
  62222. * @param name defines the block name
  62223. */
  62224. constructor(name: string);
  62225. /**
  62226. * Gets the current class name
  62227. * @returns the class name
  62228. */
  62229. getClassName(): string;
  62230. /**
  62231. * Gets the left operand input component
  62232. */
  62233. get left(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the right operand input component
  62236. */
  62237. get right(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the output component
  62240. */
  62241. get output(): NodeMaterialConnectionPoint;
  62242. protected _buildBlock(state: NodeMaterialBuildState): this;
  62243. }
  62244. }
  62245. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62249. /**
  62250. * Block used to get the min of 2 values
  62251. */
  62252. export class MinBlock extends NodeMaterialBlock {
  62253. /**
  62254. * Creates a new MinBlock
  62255. * @param name defines the block name
  62256. */
  62257. constructor(name: string);
  62258. /**
  62259. * Gets the current class name
  62260. * @returns the class name
  62261. */
  62262. getClassName(): string;
  62263. /**
  62264. * Gets the left operand input component
  62265. */
  62266. get left(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the right operand input component
  62269. */
  62270. get right(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the output component
  62273. */
  62274. get output(): NodeMaterialConnectionPoint;
  62275. protected _buildBlock(state: NodeMaterialBuildState): this;
  62276. }
  62277. }
  62278. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62282. /**
  62283. * Block used to get the distance between 2 values
  62284. */
  62285. export class DistanceBlock extends NodeMaterialBlock {
  62286. /**
  62287. * Creates a new DistanceBlock
  62288. * @param name defines the block name
  62289. */
  62290. constructor(name: string);
  62291. /**
  62292. * Gets the current class name
  62293. * @returns the class name
  62294. */
  62295. getClassName(): string;
  62296. /**
  62297. * Gets the left operand input component
  62298. */
  62299. get left(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the right operand input component
  62302. */
  62303. get right(): NodeMaterialConnectionPoint;
  62304. /**
  62305. * Gets the output component
  62306. */
  62307. get output(): NodeMaterialConnectionPoint;
  62308. protected _buildBlock(state: NodeMaterialBuildState): this;
  62309. }
  62310. }
  62311. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62315. /**
  62316. * Block used to get the length of a vector
  62317. */
  62318. export class LengthBlock extends NodeMaterialBlock {
  62319. /**
  62320. * Creates a new LengthBlock
  62321. * @param name defines the block name
  62322. */
  62323. constructor(name: string);
  62324. /**
  62325. * Gets the current class name
  62326. * @returns the class name
  62327. */
  62328. getClassName(): string;
  62329. /**
  62330. * Gets the value input component
  62331. */
  62332. get value(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the output component
  62335. */
  62336. get output(): NodeMaterialConnectionPoint;
  62337. protected _buildBlock(state: NodeMaterialBuildState): this;
  62338. }
  62339. }
  62340. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62344. /**
  62345. * Block used to get negative version of a value (i.e. x * -1)
  62346. */
  62347. export class NegateBlock extends NodeMaterialBlock {
  62348. /**
  62349. * Creates a new NegateBlock
  62350. * @param name defines the block name
  62351. */
  62352. constructor(name: string);
  62353. /**
  62354. * Gets the current class name
  62355. * @returns the class name
  62356. */
  62357. getClassName(): string;
  62358. /**
  62359. * Gets the value input component
  62360. */
  62361. get value(): NodeMaterialConnectionPoint;
  62362. /**
  62363. * Gets the output component
  62364. */
  62365. get output(): NodeMaterialConnectionPoint;
  62366. protected _buildBlock(state: NodeMaterialBuildState): this;
  62367. }
  62368. }
  62369. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62373. /**
  62374. * Block used to get the value of the first parameter raised to the power of the second
  62375. */
  62376. export class PowBlock extends NodeMaterialBlock {
  62377. /**
  62378. * Creates a new PowBlock
  62379. * @param name defines the block name
  62380. */
  62381. constructor(name: string);
  62382. /**
  62383. * Gets the current class name
  62384. * @returns the class name
  62385. */
  62386. getClassName(): string;
  62387. /**
  62388. * Gets the value operand input component
  62389. */
  62390. get value(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the power operand input component
  62393. */
  62394. get power(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the output component
  62397. */
  62398. get output(): NodeMaterialConnectionPoint;
  62399. protected _buildBlock(state: NodeMaterialBuildState): this;
  62400. }
  62401. }
  62402. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62406. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62407. /**
  62408. * Block used to get a random number
  62409. */
  62410. export class RandomNumberBlock extends NodeMaterialBlock {
  62411. /**
  62412. * Creates a new RandomNumberBlock
  62413. * @param name defines the block name
  62414. */
  62415. constructor(name: string);
  62416. /**
  62417. * Gets the current class name
  62418. * @returns the class name
  62419. */
  62420. getClassName(): string;
  62421. /**
  62422. * Gets the seed input component
  62423. */
  62424. get seed(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the output component
  62427. */
  62428. get output(): NodeMaterialConnectionPoint;
  62429. protected _buildBlock(state: NodeMaterialBuildState): this;
  62430. }
  62431. }
  62432. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62436. /**
  62437. * Block used to compute arc tangent of 2 values
  62438. */
  62439. export class ArcTan2Block extends NodeMaterialBlock {
  62440. /**
  62441. * Creates a new ArcTan2Block
  62442. * @param name defines the block name
  62443. */
  62444. constructor(name: string);
  62445. /**
  62446. * Gets the current class name
  62447. * @returns the class name
  62448. */
  62449. getClassName(): string;
  62450. /**
  62451. * Gets the x operand input component
  62452. */
  62453. get x(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the y operand input component
  62456. */
  62457. get y(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the output component
  62460. */
  62461. get output(): NodeMaterialConnectionPoint;
  62462. protected _buildBlock(state: NodeMaterialBuildState): this;
  62463. }
  62464. }
  62465. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62469. /**
  62470. * Block used to smooth step a value
  62471. */
  62472. export class SmoothStepBlock extends NodeMaterialBlock {
  62473. /**
  62474. * Creates a new SmoothStepBlock
  62475. * @param name defines the block name
  62476. */
  62477. constructor(name: string);
  62478. /**
  62479. * Gets the current class name
  62480. * @returns the class name
  62481. */
  62482. getClassName(): string;
  62483. /**
  62484. * Gets the value operand input component
  62485. */
  62486. get value(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the first edge operand input component
  62489. */
  62490. get edge0(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the second edge operand input component
  62493. */
  62494. get edge1(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the output component
  62497. */
  62498. get output(): NodeMaterialConnectionPoint;
  62499. protected _buildBlock(state: NodeMaterialBuildState): this;
  62500. }
  62501. }
  62502. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62506. /**
  62507. * Block used to get the reciprocal (1 / x) of a value
  62508. */
  62509. export class ReciprocalBlock extends NodeMaterialBlock {
  62510. /**
  62511. * Creates a new ReciprocalBlock
  62512. * @param name defines the block name
  62513. */
  62514. constructor(name: string);
  62515. /**
  62516. * Gets the current class name
  62517. * @returns the class name
  62518. */
  62519. getClassName(): string;
  62520. /**
  62521. * Gets the input component
  62522. */
  62523. get input(): NodeMaterialConnectionPoint;
  62524. /**
  62525. * Gets the output component
  62526. */
  62527. get output(): NodeMaterialConnectionPoint;
  62528. protected _buildBlock(state: NodeMaterialBuildState): this;
  62529. }
  62530. }
  62531. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62535. /**
  62536. * Block used to replace a color by another one
  62537. */
  62538. export class ReplaceColorBlock extends NodeMaterialBlock {
  62539. /**
  62540. * Creates a new ReplaceColorBlock
  62541. * @param name defines the block name
  62542. */
  62543. constructor(name: string);
  62544. /**
  62545. * Gets the current class name
  62546. * @returns the class name
  62547. */
  62548. getClassName(): string;
  62549. /**
  62550. * Gets the value input component
  62551. */
  62552. get value(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the reference input component
  62555. */
  62556. get reference(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the distance input component
  62559. */
  62560. get distance(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the replacement input component
  62563. */
  62564. get replacement(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the output component
  62567. */
  62568. get output(): NodeMaterialConnectionPoint;
  62569. protected _buildBlock(state: NodeMaterialBuildState): this;
  62570. }
  62571. }
  62572. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62576. /**
  62577. * Block used to posterize a value
  62578. * @see https://en.wikipedia.org/wiki/Posterization
  62579. */
  62580. export class PosterizeBlock extends NodeMaterialBlock {
  62581. /**
  62582. * Creates a new PosterizeBlock
  62583. * @param name defines the block name
  62584. */
  62585. constructor(name: string);
  62586. /**
  62587. * Gets the current class name
  62588. * @returns the class name
  62589. */
  62590. getClassName(): string;
  62591. /**
  62592. * Gets the value input component
  62593. */
  62594. get value(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the steps input component
  62597. */
  62598. get steps(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Gets the output component
  62601. */
  62602. get output(): NodeMaterialConnectionPoint;
  62603. protected _buildBlock(state: NodeMaterialBuildState): this;
  62604. }
  62605. }
  62606. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62610. import { Scene } from "babylonjs/scene";
  62611. /**
  62612. * Operations supported by the Wave block
  62613. */
  62614. export enum WaveBlockKind {
  62615. /** SawTooth */
  62616. SawTooth = 0,
  62617. /** Square */
  62618. Square = 1,
  62619. /** Triangle */
  62620. Triangle = 2
  62621. }
  62622. /**
  62623. * Block used to apply wave operation to floats
  62624. */
  62625. export class WaveBlock extends NodeMaterialBlock {
  62626. /**
  62627. * Gets or sets the kibnd of wave to be applied by the block
  62628. */
  62629. kind: WaveBlockKind;
  62630. /**
  62631. * Creates a new WaveBlock
  62632. * @param name defines the block name
  62633. */
  62634. constructor(name: string);
  62635. /**
  62636. * Gets the current class name
  62637. * @returns the class name
  62638. */
  62639. getClassName(): string;
  62640. /**
  62641. * Gets the input component
  62642. */
  62643. get input(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the output component
  62646. */
  62647. get output(): NodeMaterialConnectionPoint;
  62648. protected _buildBlock(state: NodeMaterialBuildState): this;
  62649. serialize(): any;
  62650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62651. }
  62652. }
  62653. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62657. import { Color3 } from "babylonjs/Maths/math.color";
  62658. import { Scene } from "babylonjs/scene";
  62659. /**
  62660. * Class used to store a color step for the GradientBlock
  62661. */
  62662. export class GradientBlockColorStep {
  62663. /**
  62664. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62665. */
  62666. step: number;
  62667. /**
  62668. * Gets or sets the color associated with this step
  62669. */
  62670. color: Color3;
  62671. /**
  62672. * Creates a new GradientBlockColorStep
  62673. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62674. * @param color defines the color associated with this step
  62675. */
  62676. constructor(
  62677. /**
  62678. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62679. */
  62680. step: number,
  62681. /**
  62682. * Gets or sets the color associated with this step
  62683. */
  62684. color: Color3);
  62685. }
  62686. /**
  62687. * Block used to return a color from a gradient based on an input value between 0 and 1
  62688. */
  62689. export class GradientBlock extends NodeMaterialBlock {
  62690. /**
  62691. * Gets or sets the list of color steps
  62692. */
  62693. colorSteps: GradientBlockColorStep[];
  62694. /**
  62695. * Creates a new GradientBlock
  62696. * @param name defines the block name
  62697. */
  62698. constructor(name: string);
  62699. /**
  62700. * Gets the current class name
  62701. * @returns the class name
  62702. */
  62703. getClassName(): string;
  62704. /**
  62705. * Gets the gradient input component
  62706. */
  62707. get gradient(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the output component
  62710. */
  62711. get output(): NodeMaterialConnectionPoint;
  62712. private _writeColorConstant;
  62713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62714. serialize(): any;
  62715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62716. protected _dumpPropertiesCode(): string;
  62717. }
  62718. }
  62719. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62723. /**
  62724. * Block used to normalize lerp between 2 values
  62725. */
  62726. export class NLerpBlock extends NodeMaterialBlock {
  62727. /**
  62728. * Creates a new NLerpBlock
  62729. * @param name defines the block name
  62730. */
  62731. constructor(name: string);
  62732. /**
  62733. * Gets the current class name
  62734. * @returns the class name
  62735. */
  62736. getClassName(): string;
  62737. /**
  62738. * Gets the left operand input component
  62739. */
  62740. get left(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the right operand input component
  62743. */
  62744. get right(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the gradient operand input component
  62747. */
  62748. get gradient(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the output component
  62751. */
  62752. get output(): NodeMaterialConnectionPoint;
  62753. protected _buildBlock(state: NodeMaterialBuildState): this;
  62754. }
  62755. }
  62756. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62760. import { Scene } from "babylonjs/scene";
  62761. /**
  62762. * block used to Generate a Worley Noise 3D Noise Pattern
  62763. */
  62764. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62765. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62766. manhattanDistance: boolean;
  62767. /**
  62768. * Creates a new WorleyNoise3DBlock
  62769. * @param name defines the block name
  62770. */
  62771. constructor(name: string);
  62772. /**
  62773. * Gets the current class name
  62774. * @returns the class name
  62775. */
  62776. getClassName(): string;
  62777. /**
  62778. * Gets the seed input component
  62779. */
  62780. get seed(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the jitter input component
  62783. */
  62784. get jitter(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the output component
  62787. */
  62788. get output(): NodeMaterialConnectionPoint;
  62789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62790. /**
  62791. * Exposes the properties to the UI?
  62792. */
  62793. protected _dumpPropertiesCode(): string;
  62794. /**
  62795. * Exposes the properties to the Seralize?
  62796. */
  62797. serialize(): any;
  62798. /**
  62799. * Exposes the properties to the deseralize?
  62800. */
  62801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62802. }
  62803. }
  62804. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62808. /**
  62809. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62810. */
  62811. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62812. /**
  62813. * Creates a new SimplexPerlin3DBlock
  62814. * @param name defines the block name
  62815. */
  62816. constructor(name: string);
  62817. /**
  62818. * Gets the current class name
  62819. * @returns the class name
  62820. */
  62821. getClassName(): string;
  62822. /**
  62823. * Gets the seed operand input component
  62824. */
  62825. get seed(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the output component
  62828. */
  62829. get output(): NodeMaterialConnectionPoint;
  62830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62831. }
  62832. }
  62833. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62837. /**
  62838. * Block used to blend normals
  62839. */
  62840. export class NormalBlendBlock extends NodeMaterialBlock {
  62841. /**
  62842. * Creates a new NormalBlendBlock
  62843. * @param name defines the block name
  62844. */
  62845. constructor(name: string);
  62846. /**
  62847. * Gets the current class name
  62848. * @returns the class name
  62849. */
  62850. getClassName(): string;
  62851. /**
  62852. * Gets the first input component
  62853. */
  62854. get normalMap0(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the second input component
  62857. */
  62858. get normalMap1(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the output component
  62861. */
  62862. get output(): NodeMaterialConnectionPoint;
  62863. protected _buildBlock(state: NodeMaterialBuildState): this;
  62864. }
  62865. }
  62866. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62870. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62871. /**
  62872. * Block used to rotate a 2d vector by a given angle
  62873. */
  62874. export class Rotate2dBlock extends NodeMaterialBlock {
  62875. /**
  62876. * Creates a new Rotate2dBlock
  62877. * @param name defines the block name
  62878. */
  62879. constructor(name: string);
  62880. /**
  62881. * Gets the current class name
  62882. * @returns the class name
  62883. */
  62884. getClassName(): string;
  62885. /**
  62886. * Gets the input vector
  62887. */
  62888. get input(): NodeMaterialConnectionPoint;
  62889. /**
  62890. * Gets the input angle
  62891. */
  62892. get angle(): NodeMaterialConnectionPoint;
  62893. /**
  62894. * Gets the output component
  62895. */
  62896. get output(): NodeMaterialConnectionPoint;
  62897. autoConfigure(material: NodeMaterial): void;
  62898. protected _buildBlock(state: NodeMaterialBuildState): this;
  62899. }
  62900. }
  62901. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62905. /**
  62906. * Block used to get the reflected vector from a direction and a normal
  62907. */
  62908. export class ReflectBlock extends NodeMaterialBlock {
  62909. /**
  62910. * Creates a new ReflectBlock
  62911. * @param name defines the block name
  62912. */
  62913. constructor(name: string);
  62914. /**
  62915. * Gets the current class name
  62916. * @returns the class name
  62917. */
  62918. getClassName(): string;
  62919. /**
  62920. * Gets the incident component
  62921. */
  62922. get incident(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the normal component
  62925. */
  62926. get normal(): NodeMaterialConnectionPoint;
  62927. /**
  62928. * Gets the output component
  62929. */
  62930. get output(): NodeMaterialConnectionPoint;
  62931. protected _buildBlock(state: NodeMaterialBuildState): this;
  62932. }
  62933. }
  62934. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62938. /**
  62939. * Block used to get the refracted vector from a direction and a normal
  62940. */
  62941. export class RefractBlock extends NodeMaterialBlock {
  62942. /**
  62943. * Creates a new RefractBlock
  62944. * @param name defines the block name
  62945. */
  62946. constructor(name: string);
  62947. /**
  62948. * Gets the current class name
  62949. * @returns the class name
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * Gets the incident component
  62954. */
  62955. get incident(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the normal component
  62958. */
  62959. get normal(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the index of refraction component
  62962. */
  62963. get ior(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the output component
  62966. */
  62967. get output(): NodeMaterialConnectionPoint;
  62968. protected _buildBlock(state: NodeMaterialBuildState): this;
  62969. }
  62970. }
  62971. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62975. /**
  62976. * Block used to desaturate a color
  62977. */
  62978. export class DesaturateBlock extends NodeMaterialBlock {
  62979. /**
  62980. * Creates a new DesaturateBlock
  62981. * @param name defines the block name
  62982. */
  62983. constructor(name: string);
  62984. /**
  62985. * Gets the current class name
  62986. * @returns the class name
  62987. */
  62988. getClassName(): string;
  62989. /**
  62990. * Gets the color operand input component
  62991. */
  62992. get color(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the level operand input component
  62995. */
  62996. get level(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the output component
  62999. */
  63000. get output(): NodeMaterialConnectionPoint;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module "babylonjs/Materials/Node/Blocks/index" {
  63005. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63006. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63007. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63008. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63009. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63010. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63011. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63012. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63013. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63014. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63015. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63016. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63017. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63018. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63019. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63020. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63021. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63022. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63023. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63024. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63025. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63026. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63027. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63028. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63029. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63030. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63031. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63032. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63033. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63034. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63035. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63036. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63037. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63038. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63039. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63040. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63041. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63042. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63043. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63044. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63045. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63046. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63047. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63048. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63049. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63050. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63051. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63052. }
  63053. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63054. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63055. }
  63056. declare module "babylonjs/Materials/Node/index" {
  63057. export * from "babylonjs/Materials/Node/Enums/index";
  63058. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63059. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63060. export * from "babylonjs/Materials/Node/nodeMaterial";
  63061. export * from "babylonjs/Materials/Node/Blocks/index";
  63062. export * from "babylonjs/Materials/Node/Optimizers/index";
  63063. }
  63064. declare module "babylonjs/Materials/effectRenderer" {
  63065. import { Nullable } from "babylonjs/types";
  63066. import { Texture } from "babylonjs/Materials/Textures/texture";
  63067. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63068. import { Viewport } from "babylonjs/Maths/math.viewport";
  63069. import { Observable } from "babylonjs/Misc/observable";
  63070. import { Effect } from "babylonjs/Materials/effect";
  63071. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63072. import "babylonjs/Shaders/postprocess.vertex";
  63073. /**
  63074. * Effect Render Options
  63075. */
  63076. export interface IEffectRendererOptions {
  63077. /**
  63078. * Defines the vertices positions.
  63079. */
  63080. positions?: number[];
  63081. /**
  63082. * Defines the indices.
  63083. */
  63084. indices?: number[];
  63085. }
  63086. /**
  63087. * Helper class to render one or more effects
  63088. */
  63089. export class EffectRenderer {
  63090. private engine;
  63091. private static _DefaultOptions;
  63092. private _vertexBuffers;
  63093. private _indexBuffer;
  63094. private _ringBufferIndex;
  63095. private _ringScreenBuffer;
  63096. private _fullscreenViewport;
  63097. private _getNextFrameBuffer;
  63098. /**
  63099. * Creates an effect renderer
  63100. * @param engine the engine to use for rendering
  63101. * @param options defines the options of the effect renderer
  63102. */
  63103. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63104. /**
  63105. * Sets the current viewport in normalized coordinates 0-1
  63106. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63107. */
  63108. setViewport(viewport?: Viewport): void;
  63109. /**
  63110. * Binds the embedded attributes buffer to the effect.
  63111. * @param effect Defines the effect to bind the attributes for
  63112. */
  63113. bindBuffers(effect: Effect): void;
  63114. /**
  63115. * Sets the current effect wrapper to use during draw.
  63116. * The effect needs to be ready before calling this api.
  63117. * This also sets the default full screen position attribute.
  63118. * @param effectWrapper Defines the effect to draw with
  63119. */
  63120. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63121. /**
  63122. * Draws a full screen quad.
  63123. */
  63124. draw(): void;
  63125. /**
  63126. * renders one or more effects to a specified texture
  63127. * @param effectWrappers list of effects to renderer
  63128. * @param outputTexture texture to draw to, if null it will render to the screen
  63129. */
  63130. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63131. /**
  63132. * Disposes of the effect renderer
  63133. */
  63134. dispose(): void;
  63135. }
  63136. /**
  63137. * Options to create an EffectWrapper
  63138. */
  63139. interface EffectWrapperCreationOptions {
  63140. /**
  63141. * Engine to use to create the effect
  63142. */
  63143. engine: ThinEngine;
  63144. /**
  63145. * Fragment shader for the effect
  63146. */
  63147. fragmentShader: string;
  63148. /**
  63149. * Vertex shader for the effect
  63150. */
  63151. vertexShader?: string;
  63152. /**
  63153. * Attributes to use in the shader
  63154. */
  63155. attributeNames?: Array<string>;
  63156. /**
  63157. * Uniforms to use in the shader
  63158. */
  63159. uniformNames?: Array<string>;
  63160. /**
  63161. * Texture sampler names to use in the shader
  63162. */
  63163. samplerNames?: Array<string>;
  63164. /**
  63165. * The friendly name of the effect displayed in Spector.
  63166. */
  63167. name?: string;
  63168. }
  63169. /**
  63170. * Wraps an effect to be used for rendering
  63171. */
  63172. export class EffectWrapper {
  63173. /**
  63174. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63175. */
  63176. onApplyObservable: Observable<{}>;
  63177. /**
  63178. * The underlying effect
  63179. */
  63180. effect: Effect;
  63181. /**
  63182. * Creates an effect to be renderer
  63183. * @param creationOptions options to create the effect
  63184. */
  63185. constructor(creationOptions: EffectWrapperCreationOptions);
  63186. /**
  63187. * Disposes of the effect wrapper
  63188. */
  63189. dispose(): void;
  63190. }
  63191. }
  63192. declare module "babylonjs/Materials/index" {
  63193. export * from "babylonjs/Materials/Background/index";
  63194. export * from "babylonjs/Materials/colorCurves";
  63195. export * from "babylonjs/Materials/iEffectFallbacks";
  63196. export * from "babylonjs/Materials/effectFallbacks";
  63197. export * from "babylonjs/Materials/effect";
  63198. export * from "babylonjs/Materials/fresnelParameters";
  63199. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63200. export * from "babylonjs/Materials/material";
  63201. export * from "babylonjs/Materials/materialDefines";
  63202. export * from "babylonjs/Materials/materialHelper";
  63203. export * from "babylonjs/Materials/multiMaterial";
  63204. export * from "babylonjs/Materials/PBR/index";
  63205. export * from "babylonjs/Materials/pushMaterial";
  63206. export * from "babylonjs/Materials/shaderMaterial";
  63207. export * from "babylonjs/Materials/standardMaterial";
  63208. export * from "babylonjs/Materials/Textures/index";
  63209. export * from "babylonjs/Materials/uniformBuffer";
  63210. export * from "babylonjs/Materials/materialFlags";
  63211. export * from "babylonjs/Materials/Node/index";
  63212. export * from "babylonjs/Materials/effectRenderer";
  63213. }
  63214. declare module "babylonjs/Maths/index" {
  63215. export * from "babylonjs/Maths/math.scalar";
  63216. export * from "babylonjs/Maths/math";
  63217. export * from "babylonjs/Maths/sphericalPolynomial";
  63218. }
  63219. declare module "babylonjs/Misc/workerPool" {
  63220. import { IDisposable } from "babylonjs/scene";
  63221. /**
  63222. * Helper class to push actions to a pool of workers.
  63223. */
  63224. export class WorkerPool implements IDisposable {
  63225. private _workerInfos;
  63226. private _pendingActions;
  63227. /**
  63228. * Constructor
  63229. * @param workers Array of workers to use for actions
  63230. */
  63231. constructor(workers: Array<Worker>);
  63232. /**
  63233. * Terminates all workers and clears any pending actions.
  63234. */
  63235. dispose(): void;
  63236. /**
  63237. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63238. * pended until a worker has completed its action.
  63239. * @param action The action to perform. Call onComplete when the action is complete.
  63240. */
  63241. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63242. private _execute;
  63243. }
  63244. }
  63245. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63246. import { IDisposable } from "babylonjs/scene";
  63247. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63248. /**
  63249. * Configuration for Draco compression
  63250. */
  63251. export interface IDracoCompressionConfiguration {
  63252. /**
  63253. * Configuration for the decoder.
  63254. */
  63255. decoder: {
  63256. /**
  63257. * The url to the WebAssembly module.
  63258. */
  63259. wasmUrl?: string;
  63260. /**
  63261. * The url to the WebAssembly binary.
  63262. */
  63263. wasmBinaryUrl?: string;
  63264. /**
  63265. * The url to the fallback JavaScript module.
  63266. */
  63267. fallbackUrl?: string;
  63268. };
  63269. }
  63270. /**
  63271. * Draco compression (https://google.github.io/draco/)
  63272. *
  63273. * This class wraps the Draco module.
  63274. *
  63275. * **Encoder**
  63276. *
  63277. * The encoder is not currently implemented.
  63278. *
  63279. * **Decoder**
  63280. *
  63281. * 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.
  63282. *
  63283. * To update the configuration, use the following code:
  63284. * ```javascript
  63285. * DracoCompression.Configuration = {
  63286. * decoder: {
  63287. * wasmUrl: "<url to the WebAssembly library>",
  63288. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63289. * fallbackUrl: "<url to the fallback JavaScript library>",
  63290. * }
  63291. * };
  63292. * ```
  63293. *
  63294. * 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.
  63295. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63296. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63297. *
  63298. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63299. * ```javascript
  63300. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63301. * ```
  63302. *
  63303. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63304. */
  63305. export class DracoCompression implements IDisposable {
  63306. private _workerPoolPromise?;
  63307. private _decoderModulePromise?;
  63308. /**
  63309. * The configuration. Defaults to the following urls:
  63310. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63311. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63312. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63313. */
  63314. static Configuration: IDracoCompressionConfiguration;
  63315. /**
  63316. * Returns true if the decoder configuration is available.
  63317. */
  63318. static get DecoderAvailable(): boolean;
  63319. /**
  63320. * Default number of workers to create when creating the draco compression object.
  63321. */
  63322. static DefaultNumWorkers: number;
  63323. private static GetDefaultNumWorkers;
  63324. private static _Default;
  63325. /**
  63326. * Default instance for the draco compression object.
  63327. */
  63328. static get Default(): DracoCompression;
  63329. /**
  63330. * Constructor
  63331. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63332. */
  63333. constructor(numWorkers?: number);
  63334. /**
  63335. * Stop all async operations and release resources.
  63336. */
  63337. dispose(): void;
  63338. /**
  63339. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63340. * @returns a promise that resolves when ready
  63341. */
  63342. whenReadyAsync(): Promise<void>;
  63343. /**
  63344. * Decode Draco compressed mesh data to vertex data.
  63345. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63346. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63347. * @returns A promise that resolves with the decoded vertex data
  63348. */
  63349. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63350. [kind: string]: number;
  63351. }): Promise<VertexData>;
  63352. }
  63353. }
  63354. declare module "babylonjs/Meshes/Compression/index" {
  63355. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63356. }
  63357. declare module "babylonjs/Meshes/csg" {
  63358. import { Nullable } from "babylonjs/types";
  63359. import { Scene } from "babylonjs/scene";
  63360. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63361. import { Mesh } from "babylonjs/Meshes/mesh";
  63362. import { Material } from "babylonjs/Materials/material";
  63363. /**
  63364. * Class for building Constructive Solid Geometry
  63365. */
  63366. export class CSG {
  63367. private polygons;
  63368. /**
  63369. * The world matrix
  63370. */
  63371. matrix: Matrix;
  63372. /**
  63373. * Stores the position
  63374. */
  63375. position: Vector3;
  63376. /**
  63377. * Stores the rotation
  63378. */
  63379. rotation: Vector3;
  63380. /**
  63381. * Stores the rotation quaternion
  63382. */
  63383. rotationQuaternion: Nullable<Quaternion>;
  63384. /**
  63385. * Stores the scaling vector
  63386. */
  63387. scaling: Vector3;
  63388. /**
  63389. * Convert the Mesh to CSG
  63390. * @param mesh The Mesh to convert to CSG
  63391. * @returns A new CSG from the Mesh
  63392. */
  63393. static FromMesh(mesh: Mesh): CSG;
  63394. /**
  63395. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63396. * @param polygons Polygons used to construct a CSG solid
  63397. */
  63398. private static FromPolygons;
  63399. /**
  63400. * Clones, or makes a deep copy, of the CSG
  63401. * @returns A new CSG
  63402. */
  63403. clone(): CSG;
  63404. /**
  63405. * Unions this CSG with another CSG
  63406. * @param csg The CSG to union against this CSG
  63407. * @returns The unioned CSG
  63408. */
  63409. union(csg: CSG): CSG;
  63410. /**
  63411. * Unions this CSG with another CSG in place
  63412. * @param csg The CSG to union against this CSG
  63413. */
  63414. unionInPlace(csg: CSG): void;
  63415. /**
  63416. * Subtracts this CSG with another CSG
  63417. * @param csg The CSG to subtract against this CSG
  63418. * @returns A new CSG
  63419. */
  63420. subtract(csg: CSG): CSG;
  63421. /**
  63422. * Subtracts this CSG with another CSG in place
  63423. * @param csg The CSG to subtact against this CSG
  63424. */
  63425. subtractInPlace(csg: CSG): void;
  63426. /**
  63427. * Intersect this CSG with another CSG
  63428. * @param csg The CSG to intersect against this CSG
  63429. * @returns A new CSG
  63430. */
  63431. intersect(csg: CSG): CSG;
  63432. /**
  63433. * Intersects this CSG with another CSG in place
  63434. * @param csg The CSG to intersect against this CSG
  63435. */
  63436. intersectInPlace(csg: CSG): void;
  63437. /**
  63438. * Return a new CSG solid with solid and empty space switched. This solid is
  63439. * not modified.
  63440. * @returns A new CSG solid with solid and empty space switched
  63441. */
  63442. inverse(): CSG;
  63443. /**
  63444. * Inverses the CSG in place
  63445. */
  63446. inverseInPlace(): void;
  63447. /**
  63448. * This is used to keep meshes transformations so they can be restored
  63449. * when we build back a Babylon Mesh
  63450. * NB : All CSG operations are performed in world coordinates
  63451. * @param csg The CSG to copy the transform attributes from
  63452. * @returns This CSG
  63453. */
  63454. copyTransformAttributes(csg: CSG): CSG;
  63455. /**
  63456. * Build Raw mesh from CSG
  63457. * Coordinates here are in world space
  63458. * @param name The name of the mesh geometry
  63459. * @param scene The Scene
  63460. * @param keepSubMeshes Specifies if the submeshes should be kept
  63461. * @returns A new Mesh
  63462. */
  63463. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63464. /**
  63465. * Build Mesh from CSG taking material and transforms into account
  63466. * @param name The name of the Mesh
  63467. * @param material The material of the Mesh
  63468. * @param scene The Scene
  63469. * @param keepSubMeshes Specifies if submeshes should be kept
  63470. * @returns The new Mesh
  63471. */
  63472. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63473. }
  63474. }
  63475. declare module "babylonjs/Meshes/trailMesh" {
  63476. import { Mesh } from "babylonjs/Meshes/mesh";
  63477. import { Scene } from "babylonjs/scene";
  63478. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63479. /**
  63480. * Class used to create a trail following a mesh
  63481. */
  63482. export class TrailMesh extends Mesh {
  63483. private _generator;
  63484. private _autoStart;
  63485. private _running;
  63486. private _diameter;
  63487. private _length;
  63488. private _sectionPolygonPointsCount;
  63489. private _sectionVectors;
  63490. private _sectionNormalVectors;
  63491. private _beforeRenderObserver;
  63492. /**
  63493. * @constructor
  63494. * @param name The value used by scene.getMeshByName() to do a lookup.
  63495. * @param generator The mesh or transform node to generate a trail.
  63496. * @param scene The scene to add this mesh to.
  63497. * @param diameter Diameter of trailing mesh. Default is 1.
  63498. * @param length Length of trailing mesh. Default is 60.
  63499. * @param autoStart Automatically start trailing mesh. Default true.
  63500. */
  63501. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63502. /**
  63503. * "TrailMesh"
  63504. * @returns "TrailMesh"
  63505. */
  63506. getClassName(): string;
  63507. private _createMesh;
  63508. /**
  63509. * Start trailing mesh.
  63510. */
  63511. start(): void;
  63512. /**
  63513. * Stop trailing mesh.
  63514. */
  63515. stop(): void;
  63516. /**
  63517. * Update trailing mesh geometry.
  63518. */
  63519. update(): void;
  63520. /**
  63521. * Returns a new TrailMesh object.
  63522. * @param name is a string, the name given to the new mesh
  63523. * @param newGenerator use new generator object for cloned trail mesh
  63524. * @returns a new mesh
  63525. */
  63526. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63527. /**
  63528. * Serializes this trail mesh
  63529. * @param serializationObject object to write serialization to
  63530. */
  63531. serialize(serializationObject: any): void;
  63532. /**
  63533. * Parses a serialized trail mesh
  63534. * @param parsedMesh the serialized mesh
  63535. * @param scene the scene to create the trail mesh in
  63536. * @returns the created trail mesh
  63537. */
  63538. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63539. }
  63540. }
  63541. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63542. import { Nullable } from "babylonjs/types";
  63543. import { Scene } from "babylonjs/scene";
  63544. import { Vector4 } from "babylonjs/Maths/math.vector";
  63545. import { Color4 } from "babylonjs/Maths/math.color";
  63546. import { Mesh } from "babylonjs/Meshes/mesh";
  63547. /**
  63548. * Class containing static functions to help procedurally build meshes
  63549. */
  63550. export class TiledBoxBuilder {
  63551. /**
  63552. * Creates a box mesh
  63553. * 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)
  63554. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63558. * @param name defines the name of the mesh
  63559. * @param options defines the options used to create the mesh
  63560. * @param scene defines the hosting scene
  63561. * @returns the box mesh
  63562. */
  63563. static CreateTiledBox(name: string, options: {
  63564. pattern?: number;
  63565. width?: number;
  63566. height?: number;
  63567. depth?: number;
  63568. tileSize?: number;
  63569. tileWidth?: number;
  63570. tileHeight?: number;
  63571. alignHorizontal?: number;
  63572. alignVertical?: number;
  63573. faceUV?: Vector4[];
  63574. faceColors?: Color4[];
  63575. sideOrientation?: number;
  63576. updatable?: boolean;
  63577. }, scene?: Nullable<Scene>): Mesh;
  63578. }
  63579. }
  63580. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63581. import { Vector4 } from "babylonjs/Maths/math.vector";
  63582. import { Mesh } from "babylonjs/Meshes/mesh";
  63583. /**
  63584. * Class containing static functions to help procedurally build meshes
  63585. */
  63586. export class TorusKnotBuilder {
  63587. /**
  63588. * Creates a torus knot mesh
  63589. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63590. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63591. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63592. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63596. * @param name defines the name of the mesh
  63597. * @param options defines the options used to create the mesh
  63598. * @param scene defines the hosting scene
  63599. * @returns the torus knot mesh
  63600. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63601. */
  63602. static CreateTorusKnot(name: string, options: {
  63603. radius?: number;
  63604. tube?: number;
  63605. radialSegments?: number;
  63606. tubularSegments?: number;
  63607. p?: number;
  63608. q?: number;
  63609. updatable?: boolean;
  63610. sideOrientation?: number;
  63611. frontUVs?: Vector4;
  63612. backUVs?: Vector4;
  63613. }, scene: any): Mesh;
  63614. }
  63615. }
  63616. declare module "babylonjs/Meshes/polygonMesh" {
  63617. import { Scene } from "babylonjs/scene";
  63618. import { Vector2 } from "babylonjs/Maths/math.vector";
  63619. import { Mesh } from "babylonjs/Meshes/mesh";
  63620. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63621. import { Path2 } from "babylonjs/Maths/math.path";
  63622. /**
  63623. * Polygon
  63624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63625. */
  63626. export class Polygon {
  63627. /**
  63628. * Creates a rectangle
  63629. * @param xmin bottom X coord
  63630. * @param ymin bottom Y coord
  63631. * @param xmax top X coord
  63632. * @param ymax top Y coord
  63633. * @returns points that make the resulting rectation
  63634. */
  63635. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63636. /**
  63637. * Creates a circle
  63638. * @param radius radius of circle
  63639. * @param cx scale in x
  63640. * @param cy scale in y
  63641. * @param numberOfSides number of sides that make up the circle
  63642. * @returns points that make the resulting circle
  63643. */
  63644. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63645. /**
  63646. * Creates a polygon from input string
  63647. * @param input Input polygon data
  63648. * @returns the parsed points
  63649. */
  63650. static Parse(input: string): Vector2[];
  63651. /**
  63652. * Starts building a polygon from x and y coordinates
  63653. * @param x x coordinate
  63654. * @param y y coordinate
  63655. * @returns the started path2
  63656. */
  63657. static StartingAt(x: number, y: number): Path2;
  63658. }
  63659. /**
  63660. * Builds a polygon
  63661. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63662. */
  63663. export class PolygonMeshBuilder {
  63664. private _points;
  63665. private _outlinepoints;
  63666. private _holes;
  63667. private _name;
  63668. private _scene;
  63669. private _epoints;
  63670. private _eholes;
  63671. private _addToepoint;
  63672. /**
  63673. * Babylon reference to the earcut plugin.
  63674. */
  63675. bjsEarcut: any;
  63676. /**
  63677. * Creates a PolygonMeshBuilder
  63678. * @param name name of the builder
  63679. * @param contours Path of the polygon
  63680. * @param scene scene to add to when creating the mesh
  63681. * @param earcutInjection can be used to inject your own earcut reference
  63682. */
  63683. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63684. /**
  63685. * Adds a whole within the polygon
  63686. * @param hole Array of points defining the hole
  63687. * @returns this
  63688. */
  63689. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63690. /**
  63691. * Creates the polygon
  63692. * @param updatable If the mesh should be updatable
  63693. * @param depth The depth of the mesh created
  63694. * @returns the created mesh
  63695. */
  63696. build(updatable?: boolean, depth?: number): Mesh;
  63697. /**
  63698. * Creates the polygon
  63699. * @param depth The depth of the mesh created
  63700. * @returns the created VertexData
  63701. */
  63702. buildVertexData(depth?: number): VertexData;
  63703. /**
  63704. * Adds a side to the polygon
  63705. * @param positions points that make the polygon
  63706. * @param normals normals of the polygon
  63707. * @param uvs uvs of the polygon
  63708. * @param indices indices of the polygon
  63709. * @param bounds bounds of the polygon
  63710. * @param points points of the polygon
  63711. * @param depth depth of the polygon
  63712. * @param flip flip of the polygon
  63713. */
  63714. private addSide;
  63715. }
  63716. }
  63717. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63718. import { Scene } from "babylonjs/scene";
  63719. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63720. import { Color4 } from "babylonjs/Maths/math.color";
  63721. import { Mesh } from "babylonjs/Meshes/mesh";
  63722. import { Nullable } from "babylonjs/types";
  63723. /**
  63724. * Class containing static functions to help procedurally build meshes
  63725. */
  63726. export class PolygonBuilder {
  63727. /**
  63728. * Creates a polygon mesh
  63729. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63730. * * 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
  63731. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63734. * * Remember you can only change the shape positions, not their number when updating a polygon
  63735. * @param name defines the name of the mesh
  63736. * @param options defines the options used to create the mesh
  63737. * @param scene defines the hosting scene
  63738. * @param earcutInjection can be used to inject your own earcut reference
  63739. * @returns the polygon mesh
  63740. */
  63741. static CreatePolygon(name: string, options: {
  63742. shape: Vector3[];
  63743. holes?: Vector3[][];
  63744. depth?: number;
  63745. faceUV?: Vector4[];
  63746. faceColors?: Color4[];
  63747. updatable?: boolean;
  63748. sideOrientation?: number;
  63749. frontUVs?: Vector4;
  63750. backUVs?: Vector4;
  63751. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63752. /**
  63753. * Creates an extruded polygon mesh, with depth in the Y direction.
  63754. * * 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)
  63755. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63756. * @param name defines the name of the mesh
  63757. * @param options defines the options used to create the mesh
  63758. * @param scene defines the hosting scene
  63759. * @param earcutInjection can be used to inject your own earcut reference
  63760. * @returns the polygon mesh
  63761. */
  63762. static ExtrudePolygon(name: string, options: {
  63763. shape: Vector3[];
  63764. holes?: Vector3[][];
  63765. depth?: number;
  63766. faceUV?: Vector4[];
  63767. faceColors?: Color4[];
  63768. updatable?: boolean;
  63769. sideOrientation?: number;
  63770. frontUVs?: Vector4;
  63771. backUVs?: Vector4;
  63772. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63773. }
  63774. }
  63775. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63776. import { Scene } from "babylonjs/scene";
  63777. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63778. import { Mesh } from "babylonjs/Meshes/mesh";
  63779. import { Nullable } from "babylonjs/types";
  63780. /**
  63781. * Class containing static functions to help procedurally build meshes
  63782. */
  63783. export class LatheBuilder {
  63784. /**
  63785. * Creates lathe mesh.
  63786. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63787. * * 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
  63788. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63789. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63790. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63791. * * 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
  63792. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63793. * * 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
  63794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63796. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63798. * @param name defines the name of the mesh
  63799. * @param options defines the options used to create the mesh
  63800. * @param scene defines the hosting scene
  63801. * @returns the lathe mesh
  63802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63803. */
  63804. static CreateLathe(name: string, options: {
  63805. shape: Vector3[];
  63806. radius?: number;
  63807. tessellation?: number;
  63808. clip?: number;
  63809. arc?: number;
  63810. closed?: boolean;
  63811. updatable?: boolean;
  63812. sideOrientation?: number;
  63813. frontUVs?: Vector4;
  63814. backUVs?: Vector4;
  63815. cap?: number;
  63816. invertUV?: boolean;
  63817. }, scene?: Nullable<Scene>): Mesh;
  63818. }
  63819. }
  63820. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63821. import { Nullable } from "babylonjs/types";
  63822. import { Scene } from "babylonjs/scene";
  63823. import { Vector4 } from "babylonjs/Maths/math.vector";
  63824. import { Mesh } from "babylonjs/Meshes/mesh";
  63825. /**
  63826. * Class containing static functions to help procedurally build meshes
  63827. */
  63828. export class TiledPlaneBuilder {
  63829. /**
  63830. * Creates a tiled plane mesh
  63831. * * The parameter `pattern` will, depending on value, do nothing or
  63832. * * * flip (reflect about central vertical) alternate tiles across and up
  63833. * * * flip every tile on alternate rows
  63834. * * * rotate (180 degs) alternate tiles across and up
  63835. * * * rotate every tile on alternate rows
  63836. * * * flip and rotate alternate tiles across and up
  63837. * * * flip and rotate every tile on alternate rows
  63838. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63839. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63842. * * 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)
  63843. * * 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)
  63844. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63845. * @param name defines the name of the mesh
  63846. * @param options defines the options used to create the mesh
  63847. * @param scene defines the hosting scene
  63848. * @returns the box mesh
  63849. */
  63850. static CreateTiledPlane(name: string, options: {
  63851. pattern?: number;
  63852. tileSize?: number;
  63853. tileWidth?: number;
  63854. tileHeight?: number;
  63855. size?: number;
  63856. width?: number;
  63857. height?: number;
  63858. alignHorizontal?: number;
  63859. alignVertical?: number;
  63860. sideOrientation?: number;
  63861. frontUVs?: Vector4;
  63862. backUVs?: Vector4;
  63863. updatable?: boolean;
  63864. }, scene?: Nullable<Scene>): Mesh;
  63865. }
  63866. }
  63867. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63868. import { Nullable } from "babylonjs/types";
  63869. import { Scene } from "babylonjs/scene";
  63870. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63871. import { Mesh } from "babylonjs/Meshes/mesh";
  63872. /**
  63873. * Class containing static functions to help procedurally build meshes
  63874. */
  63875. export class TubeBuilder {
  63876. /**
  63877. * Creates a tube mesh.
  63878. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63879. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63880. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63881. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63882. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63883. * * 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)
  63884. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63885. * * 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
  63886. * * 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
  63887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63889. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63891. * @param name defines the name of the mesh
  63892. * @param options defines the options used to create the mesh
  63893. * @param scene defines the hosting scene
  63894. * @returns the tube mesh
  63895. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63896. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63897. */
  63898. static CreateTube(name: string, options: {
  63899. path: Vector3[];
  63900. radius?: number;
  63901. tessellation?: number;
  63902. radiusFunction?: {
  63903. (i: number, distance: number): number;
  63904. };
  63905. cap?: number;
  63906. arc?: number;
  63907. updatable?: boolean;
  63908. sideOrientation?: number;
  63909. frontUVs?: Vector4;
  63910. backUVs?: Vector4;
  63911. instance?: Mesh;
  63912. invertUV?: boolean;
  63913. }, scene?: Nullable<Scene>): Mesh;
  63914. }
  63915. }
  63916. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63917. import { Scene } from "babylonjs/scene";
  63918. import { Vector4 } from "babylonjs/Maths/math.vector";
  63919. import { Mesh } from "babylonjs/Meshes/mesh";
  63920. import { Nullable } from "babylonjs/types";
  63921. /**
  63922. * Class containing static functions to help procedurally build meshes
  63923. */
  63924. export class IcoSphereBuilder {
  63925. /**
  63926. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63927. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63928. * * 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`)
  63929. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63930. * * 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
  63931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63934. * @param name defines the name of the mesh
  63935. * @param options defines the options used to create the mesh
  63936. * @param scene defines the hosting scene
  63937. * @returns the icosahedron mesh
  63938. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63939. */
  63940. static CreateIcoSphere(name: string, options: {
  63941. radius?: number;
  63942. radiusX?: number;
  63943. radiusY?: number;
  63944. radiusZ?: number;
  63945. flat?: boolean;
  63946. subdivisions?: number;
  63947. sideOrientation?: number;
  63948. frontUVs?: Vector4;
  63949. backUVs?: Vector4;
  63950. updatable?: boolean;
  63951. }, scene?: Nullable<Scene>): Mesh;
  63952. }
  63953. }
  63954. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63955. import { Vector3 } from "babylonjs/Maths/math.vector";
  63956. import { Mesh } from "babylonjs/Meshes/mesh";
  63957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63958. /**
  63959. * Class containing static functions to help procedurally build meshes
  63960. */
  63961. export class DecalBuilder {
  63962. /**
  63963. * Creates a decal mesh.
  63964. * 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
  63965. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63966. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63967. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63968. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63969. * @param name defines the name of the mesh
  63970. * @param sourceMesh defines the mesh where the decal must be applied
  63971. * @param options defines the options used to create the mesh
  63972. * @param scene defines the hosting scene
  63973. * @returns the decal mesh
  63974. * @see https://doc.babylonjs.com/how_to/decals
  63975. */
  63976. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63977. position?: Vector3;
  63978. normal?: Vector3;
  63979. size?: Vector3;
  63980. angle?: number;
  63981. }): Mesh;
  63982. }
  63983. }
  63984. declare module "babylonjs/Meshes/meshBuilder" {
  63985. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63986. import { Nullable } from "babylonjs/types";
  63987. import { Scene } from "babylonjs/scene";
  63988. import { Mesh } from "babylonjs/Meshes/mesh";
  63989. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63990. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63992. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63993. import { Plane } from "babylonjs/Maths/math.plane";
  63994. /**
  63995. * Class containing static functions to help procedurally build meshes
  63996. */
  63997. export class MeshBuilder {
  63998. /**
  63999. * Creates a box mesh
  64000. * * The parameter `size` sets the size (float) of each box side (default 1)
  64001. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64002. * * 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)
  64003. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64007. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64008. * @param name defines the name of the mesh
  64009. * @param options defines the options used to create the mesh
  64010. * @param scene defines the hosting scene
  64011. * @returns the box mesh
  64012. */
  64013. static CreateBox(name: string, options: {
  64014. size?: number;
  64015. width?: number;
  64016. height?: number;
  64017. depth?: number;
  64018. faceUV?: Vector4[];
  64019. faceColors?: Color4[];
  64020. sideOrientation?: number;
  64021. frontUVs?: Vector4;
  64022. backUVs?: Vector4;
  64023. updatable?: boolean;
  64024. }, scene?: Nullable<Scene>): Mesh;
  64025. /**
  64026. * Creates a tiled box mesh
  64027. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64029. * @param name defines the name of the mesh
  64030. * @param options defines the options used to create the mesh
  64031. * @param scene defines the hosting scene
  64032. * @returns the tiled box mesh
  64033. */
  64034. static CreateTiledBox(name: string, options: {
  64035. pattern?: number;
  64036. size?: number;
  64037. width?: number;
  64038. height?: number;
  64039. depth: number;
  64040. tileSize?: number;
  64041. tileWidth?: number;
  64042. tileHeight?: number;
  64043. faceUV?: Vector4[];
  64044. faceColors?: Color4[];
  64045. alignHorizontal?: number;
  64046. alignVertical?: number;
  64047. sideOrientation?: number;
  64048. updatable?: boolean;
  64049. }, scene?: Nullable<Scene>): Mesh;
  64050. /**
  64051. * Creates a sphere mesh
  64052. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64053. * * 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`)
  64054. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64055. * * 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
  64056. * * 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)
  64057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64060. * @param name defines the name of the mesh
  64061. * @param options defines the options used to create the mesh
  64062. * @param scene defines the hosting scene
  64063. * @returns the sphere mesh
  64064. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64065. */
  64066. static CreateSphere(name: string, options: {
  64067. segments?: number;
  64068. diameter?: number;
  64069. diameterX?: number;
  64070. diameterY?: number;
  64071. diameterZ?: number;
  64072. arc?: number;
  64073. slice?: number;
  64074. sideOrientation?: number;
  64075. frontUVs?: Vector4;
  64076. backUVs?: Vector4;
  64077. updatable?: boolean;
  64078. }, scene?: Nullable<Scene>): Mesh;
  64079. /**
  64080. * Creates a plane polygonal mesh. By default, this is a disc
  64081. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64082. * * 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
  64083. * * 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
  64084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64087. * @param name defines the name of the mesh
  64088. * @param options defines the options used to create the mesh
  64089. * @param scene defines the hosting scene
  64090. * @returns the plane polygonal mesh
  64091. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64092. */
  64093. static CreateDisc(name: string, options: {
  64094. radius?: number;
  64095. tessellation?: number;
  64096. arc?: number;
  64097. updatable?: boolean;
  64098. sideOrientation?: number;
  64099. frontUVs?: Vector4;
  64100. backUVs?: Vector4;
  64101. }, scene?: Nullable<Scene>): Mesh;
  64102. /**
  64103. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64104. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64105. * * 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`)
  64106. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64107. * * 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
  64108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64111. * @param name defines the name of the mesh
  64112. * @param options defines the options used to create the mesh
  64113. * @param scene defines the hosting scene
  64114. * @returns the icosahedron mesh
  64115. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64116. */
  64117. static CreateIcoSphere(name: string, options: {
  64118. radius?: number;
  64119. radiusX?: number;
  64120. radiusY?: number;
  64121. radiusZ?: number;
  64122. flat?: boolean;
  64123. subdivisions?: number;
  64124. sideOrientation?: number;
  64125. frontUVs?: Vector4;
  64126. backUVs?: Vector4;
  64127. updatable?: boolean;
  64128. }, scene?: Nullable<Scene>): Mesh;
  64129. /**
  64130. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64131. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64132. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64133. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64134. * * 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
  64135. * * 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
  64136. * * 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
  64137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64140. * * 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
  64141. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64142. * * 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
  64143. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64145. * @param name defines the name of the mesh
  64146. * @param options defines the options used to create the mesh
  64147. * @param scene defines the hosting scene
  64148. * @returns the ribbon mesh
  64149. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64151. */
  64152. static CreateRibbon(name: string, options: {
  64153. pathArray: Vector3[][];
  64154. closeArray?: boolean;
  64155. closePath?: boolean;
  64156. offset?: number;
  64157. updatable?: boolean;
  64158. sideOrientation?: number;
  64159. frontUVs?: Vector4;
  64160. backUVs?: Vector4;
  64161. instance?: Mesh;
  64162. invertUV?: boolean;
  64163. uvs?: Vector2[];
  64164. colors?: Color4[];
  64165. }, scene?: Nullable<Scene>): Mesh;
  64166. /**
  64167. * Creates a cylinder or a cone mesh
  64168. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64169. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64170. * * 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.
  64171. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64172. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64173. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64174. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64175. * * 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).
  64176. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64177. * * 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).
  64178. * * 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
  64179. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64180. * * 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
  64181. * * 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.
  64182. * * If `enclose` is false, a ring surface is one element.
  64183. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64184. * * 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
  64185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64188. * @param name defines the name of the mesh
  64189. * @param options defines the options used to create the mesh
  64190. * @param scene defines the hosting scene
  64191. * @returns the cylinder mesh
  64192. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64193. */
  64194. static CreateCylinder(name: string, options: {
  64195. height?: number;
  64196. diameterTop?: number;
  64197. diameterBottom?: number;
  64198. diameter?: number;
  64199. tessellation?: number;
  64200. subdivisions?: number;
  64201. arc?: number;
  64202. faceColors?: Color4[];
  64203. faceUV?: Vector4[];
  64204. updatable?: boolean;
  64205. hasRings?: boolean;
  64206. enclose?: boolean;
  64207. cap?: number;
  64208. sideOrientation?: number;
  64209. frontUVs?: Vector4;
  64210. backUVs?: Vector4;
  64211. }, scene?: Nullable<Scene>): Mesh;
  64212. /**
  64213. * Creates a torus mesh
  64214. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64215. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64216. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64220. * @param name defines the name of the mesh
  64221. * @param options defines the options used to create the mesh
  64222. * @param scene defines the hosting scene
  64223. * @returns the torus mesh
  64224. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64225. */
  64226. static CreateTorus(name: string, options: {
  64227. diameter?: number;
  64228. thickness?: number;
  64229. tessellation?: number;
  64230. updatable?: boolean;
  64231. sideOrientation?: number;
  64232. frontUVs?: Vector4;
  64233. backUVs?: Vector4;
  64234. }, scene?: Nullable<Scene>): Mesh;
  64235. /**
  64236. * Creates a torus knot mesh
  64237. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64238. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64239. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64240. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64244. * @param name defines the name of the mesh
  64245. * @param options defines the options used to create the mesh
  64246. * @param scene defines the hosting scene
  64247. * @returns the torus knot mesh
  64248. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64249. */
  64250. static CreateTorusKnot(name: string, options: {
  64251. radius?: number;
  64252. tube?: number;
  64253. radialSegments?: number;
  64254. tubularSegments?: number;
  64255. p?: number;
  64256. q?: number;
  64257. updatable?: boolean;
  64258. sideOrientation?: number;
  64259. frontUVs?: Vector4;
  64260. backUVs?: Vector4;
  64261. }, scene?: Nullable<Scene>): Mesh;
  64262. /**
  64263. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64264. * * 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
  64265. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64266. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64267. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64268. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64269. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64270. * * 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
  64271. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64274. * @param name defines the name of the new line system
  64275. * @param options defines the options used to create the line system
  64276. * @param scene defines the hosting scene
  64277. * @returns a new line system mesh
  64278. */
  64279. static CreateLineSystem(name: string, options: {
  64280. lines: Vector3[][];
  64281. updatable?: boolean;
  64282. instance?: Nullable<LinesMesh>;
  64283. colors?: Nullable<Color4[][]>;
  64284. useVertexAlpha?: boolean;
  64285. }, scene: Nullable<Scene>): LinesMesh;
  64286. /**
  64287. * Creates a line mesh
  64288. * 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
  64289. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64290. * * The parameter `points` is an array successive Vector3
  64291. * * 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
  64292. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64293. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64294. * * When updating an instance, remember that only point positions can change, not the number of points
  64295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64297. * @param name defines the name of the new line system
  64298. * @param options defines the options used to create the line system
  64299. * @param scene defines the hosting scene
  64300. * @returns a new line mesh
  64301. */
  64302. static CreateLines(name: string, options: {
  64303. points: Vector3[];
  64304. updatable?: boolean;
  64305. instance?: Nullable<LinesMesh>;
  64306. colors?: Color4[];
  64307. useVertexAlpha?: boolean;
  64308. }, scene?: Nullable<Scene>): LinesMesh;
  64309. /**
  64310. * Creates a dashed line mesh
  64311. * * 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
  64312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64313. * * The parameter `points` is an array successive Vector3
  64314. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64315. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64316. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64317. * * 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
  64318. * * When updating an instance, remember that only point positions can change, not the number of points
  64319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64320. * @param name defines the name of the mesh
  64321. * @param options defines the options used to create the mesh
  64322. * @param scene defines the hosting scene
  64323. * @returns the dashed line mesh
  64324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64325. */
  64326. static CreateDashedLines(name: string, options: {
  64327. points: Vector3[];
  64328. dashSize?: number;
  64329. gapSize?: number;
  64330. dashNb?: number;
  64331. updatable?: boolean;
  64332. instance?: LinesMesh;
  64333. }, scene?: Nullable<Scene>): LinesMesh;
  64334. /**
  64335. * 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.
  64336. * * 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.
  64337. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64338. * * 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.
  64339. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64340. * * 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
  64341. * * 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
  64342. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64347. * @param name defines the name of the mesh
  64348. * @param options defines the options used to create the mesh
  64349. * @param scene defines the hosting scene
  64350. * @returns the extruded shape mesh
  64351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64353. */
  64354. static ExtrudeShape(name: string, options: {
  64355. shape: Vector3[];
  64356. path: Vector3[];
  64357. scale?: number;
  64358. rotation?: number;
  64359. cap?: number;
  64360. updatable?: boolean;
  64361. sideOrientation?: number;
  64362. frontUVs?: Vector4;
  64363. backUVs?: Vector4;
  64364. instance?: Mesh;
  64365. invertUV?: boolean;
  64366. }, scene?: Nullable<Scene>): Mesh;
  64367. /**
  64368. * Creates an custom extruded shape mesh.
  64369. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64370. * * 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.
  64371. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64372. * * 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
  64373. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64374. * * 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
  64375. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64376. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64377. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64378. * * 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
  64379. * * 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
  64380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64385. * @param name defines the name of the mesh
  64386. * @param options defines the options used to create the mesh
  64387. * @param scene defines the hosting scene
  64388. * @returns the custom extruded shape mesh
  64389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64390. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64392. */
  64393. static ExtrudeShapeCustom(name: string, options: {
  64394. shape: Vector3[];
  64395. path: Vector3[];
  64396. scaleFunction?: any;
  64397. rotationFunction?: any;
  64398. ribbonCloseArray?: boolean;
  64399. ribbonClosePath?: boolean;
  64400. cap?: number;
  64401. updatable?: boolean;
  64402. sideOrientation?: number;
  64403. frontUVs?: Vector4;
  64404. backUVs?: Vector4;
  64405. instance?: Mesh;
  64406. invertUV?: boolean;
  64407. }, scene?: Nullable<Scene>): Mesh;
  64408. /**
  64409. * Creates lathe mesh.
  64410. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64411. * * 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
  64412. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64413. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64414. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64415. * * 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
  64416. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64417. * * 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
  64418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64422. * @param name defines the name of the mesh
  64423. * @param options defines the options used to create the mesh
  64424. * @param scene defines the hosting scene
  64425. * @returns the lathe mesh
  64426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64427. */
  64428. static CreateLathe(name: string, options: {
  64429. shape: Vector3[];
  64430. radius?: number;
  64431. tessellation?: number;
  64432. clip?: number;
  64433. arc?: number;
  64434. closed?: boolean;
  64435. updatable?: boolean;
  64436. sideOrientation?: number;
  64437. frontUVs?: Vector4;
  64438. backUVs?: Vector4;
  64439. cap?: number;
  64440. invertUV?: boolean;
  64441. }, scene?: Nullable<Scene>): Mesh;
  64442. /**
  64443. * Creates a tiled plane mesh
  64444. * * You can set a limited pattern arrangement with the tiles
  64445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64448. * @param name defines the name of the mesh
  64449. * @param options defines the options used to create the mesh
  64450. * @param scene defines the hosting scene
  64451. * @returns the plane mesh
  64452. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64453. */
  64454. static CreateTiledPlane(name: string, options: {
  64455. pattern?: number;
  64456. tileSize?: number;
  64457. tileWidth?: number;
  64458. tileHeight?: number;
  64459. size?: number;
  64460. width?: number;
  64461. height?: number;
  64462. alignHorizontal?: number;
  64463. alignVertical?: number;
  64464. sideOrientation?: number;
  64465. frontUVs?: Vector4;
  64466. backUVs?: Vector4;
  64467. updatable?: boolean;
  64468. }, scene?: Nullable<Scene>): Mesh;
  64469. /**
  64470. * Creates a plane mesh
  64471. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64472. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64473. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64477. * @param name defines the name of the mesh
  64478. * @param options defines the options used to create the mesh
  64479. * @param scene defines the hosting scene
  64480. * @returns the plane mesh
  64481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64482. */
  64483. static CreatePlane(name: string, options: {
  64484. size?: number;
  64485. width?: number;
  64486. height?: number;
  64487. sideOrientation?: number;
  64488. frontUVs?: Vector4;
  64489. backUVs?: Vector4;
  64490. updatable?: boolean;
  64491. sourcePlane?: Plane;
  64492. }, scene?: Nullable<Scene>): Mesh;
  64493. /**
  64494. * Creates a ground mesh
  64495. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64496. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64498. * @param name defines the name of the mesh
  64499. * @param options defines the options used to create the mesh
  64500. * @param scene defines the hosting scene
  64501. * @returns the ground mesh
  64502. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64503. */
  64504. static CreateGround(name: string, options: {
  64505. width?: number;
  64506. height?: number;
  64507. subdivisions?: number;
  64508. subdivisionsX?: number;
  64509. subdivisionsY?: number;
  64510. updatable?: boolean;
  64511. }, scene?: Nullable<Scene>): Mesh;
  64512. /**
  64513. * Creates a tiled ground mesh
  64514. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64515. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64516. * * 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
  64517. * * 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
  64518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64519. * @param name defines the name of the mesh
  64520. * @param options defines the options used to create the mesh
  64521. * @param scene defines the hosting scene
  64522. * @returns the tiled ground mesh
  64523. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64524. */
  64525. static CreateTiledGround(name: string, options: {
  64526. xmin: number;
  64527. zmin: number;
  64528. xmax: number;
  64529. zmax: number;
  64530. subdivisions?: {
  64531. w: number;
  64532. h: number;
  64533. };
  64534. precision?: {
  64535. w: number;
  64536. h: number;
  64537. };
  64538. updatable?: boolean;
  64539. }, scene?: Nullable<Scene>): Mesh;
  64540. /**
  64541. * Creates a ground mesh from a height map
  64542. * * The parameter `url` sets the URL of the height map image resource.
  64543. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64544. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64545. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64546. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64547. * * 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.
  64548. * * 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).
  64549. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64551. * @param name defines the name of the mesh
  64552. * @param url defines the url to the height map
  64553. * @param options defines the options used to create the mesh
  64554. * @param scene defines the hosting scene
  64555. * @returns the ground mesh
  64556. * @see https://doc.babylonjs.com/babylon101/height_map
  64557. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64558. */
  64559. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64560. width?: number;
  64561. height?: number;
  64562. subdivisions?: number;
  64563. minHeight?: number;
  64564. maxHeight?: number;
  64565. colorFilter?: Color3;
  64566. alphaFilter?: number;
  64567. updatable?: boolean;
  64568. onReady?: (mesh: GroundMesh) => void;
  64569. }, scene?: Nullable<Scene>): GroundMesh;
  64570. /**
  64571. * Creates a polygon mesh
  64572. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64573. * * 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
  64574. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64577. * * Remember you can only change the shape positions, not their number when updating a polygon
  64578. * @param name defines the name of the mesh
  64579. * @param options defines the options used to create the mesh
  64580. * @param scene defines the hosting scene
  64581. * @param earcutInjection can be used to inject your own earcut reference
  64582. * @returns the polygon mesh
  64583. */
  64584. static CreatePolygon(name: string, options: {
  64585. shape: Vector3[];
  64586. holes?: Vector3[][];
  64587. depth?: number;
  64588. faceUV?: Vector4[];
  64589. faceColors?: Color4[];
  64590. updatable?: boolean;
  64591. sideOrientation?: number;
  64592. frontUVs?: Vector4;
  64593. backUVs?: Vector4;
  64594. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64595. /**
  64596. * Creates an extruded polygon mesh, with depth in the Y direction.
  64597. * * 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)
  64598. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64599. * @param name defines the name of the mesh
  64600. * @param options defines the options used to create the mesh
  64601. * @param scene defines the hosting scene
  64602. * @param earcutInjection can be used to inject your own earcut reference
  64603. * @returns the polygon mesh
  64604. */
  64605. static ExtrudePolygon(name: string, options: {
  64606. shape: Vector3[];
  64607. holes?: Vector3[][];
  64608. depth?: number;
  64609. faceUV?: Vector4[];
  64610. faceColors?: Color4[];
  64611. updatable?: boolean;
  64612. sideOrientation?: number;
  64613. frontUVs?: Vector4;
  64614. backUVs?: Vector4;
  64615. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64616. /**
  64617. * Creates a tube mesh.
  64618. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64619. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64620. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64621. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64622. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64623. * * 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)
  64624. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64625. * * 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
  64626. * * 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
  64627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64631. * @param name defines the name of the mesh
  64632. * @param options defines the options used to create the mesh
  64633. * @param scene defines the hosting scene
  64634. * @returns the tube mesh
  64635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64636. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64637. */
  64638. static CreateTube(name: string, options: {
  64639. path: Vector3[];
  64640. radius?: number;
  64641. tessellation?: number;
  64642. radiusFunction?: {
  64643. (i: number, distance: number): number;
  64644. };
  64645. cap?: number;
  64646. arc?: number;
  64647. updatable?: boolean;
  64648. sideOrientation?: number;
  64649. frontUVs?: Vector4;
  64650. backUVs?: Vector4;
  64651. instance?: Mesh;
  64652. invertUV?: boolean;
  64653. }, scene?: Nullable<Scene>): Mesh;
  64654. /**
  64655. * Creates a polyhedron mesh
  64656. * * 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
  64657. * * The parameter `size` (positive float, default 1) sets the polygon size
  64658. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64659. * * 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`
  64660. * * 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
  64661. * * 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)`)
  64662. * * 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
  64663. * * 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
  64664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64667. * @param name defines the name of the mesh
  64668. * @param options defines the options used to create the mesh
  64669. * @param scene defines the hosting scene
  64670. * @returns the polyhedron mesh
  64671. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64672. */
  64673. static CreatePolyhedron(name: string, options: {
  64674. type?: number;
  64675. size?: number;
  64676. sizeX?: number;
  64677. sizeY?: number;
  64678. sizeZ?: number;
  64679. custom?: any;
  64680. faceUV?: Vector4[];
  64681. faceColors?: Color4[];
  64682. flat?: boolean;
  64683. updatable?: boolean;
  64684. sideOrientation?: number;
  64685. frontUVs?: Vector4;
  64686. backUVs?: Vector4;
  64687. }, scene?: Nullable<Scene>): Mesh;
  64688. /**
  64689. * Creates a decal mesh.
  64690. * 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
  64691. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64692. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64693. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64694. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64695. * @param name defines the name of the mesh
  64696. * @param sourceMesh defines the mesh where the decal must be applied
  64697. * @param options defines the options used to create the mesh
  64698. * @param scene defines the hosting scene
  64699. * @returns the decal mesh
  64700. * @see https://doc.babylonjs.com/how_to/decals
  64701. */
  64702. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64703. position?: Vector3;
  64704. normal?: Vector3;
  64705. size?: Vector3;
  64706. angle?: number;
  64707. }): Mesh;
  64708. }
  64709. }
  64710. declare module "babylonjs/Meshes/meshSimplification" {
  64711. import { Mesh } from "babylonjs/Meshes/mesh";
  64712. /**
  64713. * A simplifier interface for future simplification implementations
  64714. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64715. */
  64716. export interface ISimplifier {
  64717. /**
  64718. * Simplification of a given mesh according to the given settings.
  64719. * Since this requires computation, it is assumed that the function runs async.
  64720. * @param settings The settings of the simplification, including quality and distance
  64721. * @param successCallback A callback that will be called after the mesh was simplified.
  64722. * @param errorCallback in case of an error, this callback will be called. optional.
  64723. */
  64724. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64725. }
  64726. /**
  64727. * Expected simplification settings.
  64728. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64729. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64730. */
  64731. export interface ISimplificationSettings {
  64732. /**
  64733. * Gets or sets the expected quality
  64734. */
  64735. quality: number;
  64736. /**
  64737. * Gets or sets the distance when this optimized version should be used
  64738. */
  64739. distance: number;
  64740. /**
  64741. * Gets an already optimized mesh
  64742. */
  64743. optimizeMesh?: boolean;
  64744. }
  64745. /**
  64746. * Class used to specify simplification options
  64747. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64748. */
  64749. export class SimplificationSettings implements ISimplificationSettings {
  64750. /** expected quality */
  64751. quality: number;
  64752. /** distance when this optimized version should be used */
  64753. distance: number;
  64754. /** already optimized mesh */
  64755. optimizeMesh?: boolean | undefined;
  64756. /**
  64757. * Creates a SimplificationSettings
  64758. * @param quality expected quality
  64759. * @param distance distance when this optimized version should be used
  64760. * @param optimizeMesh already optimized mesh
  64761. */
  64762. constructor(
  64763. /** expected quality */
  64764. quality: number,
  64765. /** distance when this optimized version should be used */
  64766. distance: number,
  64767. /** already optimized mesh */
  64768. optimizeMesh?: boolean | undefined);
  64769. }
  64770. /**
  64771. * Interface used to define a simplification task
  64772. */
  64773. export interface ISimplificationTask {
  64774. /**
  64775. * Array of settings
  64776. */
  64777. settings: Array<ISimplificationSettings>;
  64778. /**
  64779. * Simplification type
  64780. */
  64781. simplificationType: SimplificationType;
  64782. /**
  64783. * Mesh to simplify
  64784. */
  64785. mesh: Mesh;
  64786. /**
  64787. * Callback called on success
  64788. */
  64789. successCallback?: () => void;
  64790. /**
  64791. * Defines if parallel processing can be used
  64792. */
  64793. parallelProcessing: boolean;
  64794. }
  64795. /**
  64796. * Queue used to order the simplification tasks
  64797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64798. */
  64799. export class SimplificationQueue {
  64800. private _simplificationArray;
  64801. /**
  64802. * Gets a boolean indicating that the process is still running
  64803. */
  64804. running: boolean;
  64805. /**
  64806. * Creates a new queue
  64807. */
  64808. constructor();
  64809. /**
  64810. * Adds a new simplification task
  64811. * @param task defines a task to add
  64812. */
  64813. addTask(task: ISimplificationTask): void;
  64814. /**
  64815. * Execute next task
  64816. */
  64817. executeNext(): void;
  64818. /**
  64819. * Execute a simplification task
  64820. * @param task defines the task to run
  64821. */
  64822. runSimplification(task: ISimplificationTask): void;
  64823. private getSimplifier;
  64824. }
  64825. /**
  64826. * The implemented types of simplification
  64827. * At the moment only Quadratic Error Decimation is implemented
  64828. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64829. */
  64830. export enum SimplificationType {
  64831. /** Quadratic error decimation */
  64832. QUADRATIC = 0
  64833. }
  64834. }
  64835. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64836. import { Scene } from "babylonjs/scene";
  64837. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64838. import { ISceneComponent } from "babylonjs/sceneComponent";
  64839. module "babylonjs/scene" {
  64840. interface Scene {
  64841. /** @hidden (Backing field) */
  64842. _simplificationQueue: SimplificationQueue;
  64843. /**
  64844. * Gets or sets the simplification queue attached to the scene
  64845. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64846. */
  64847. simplificationQueue: SimplificationQueue;
  64848. }
  64849. }
  64850. module "babylonjs/Meshes/mesh" {
  64851. interface Mesh {
  64852. /**
  64853. * Simplify the mesh according to the given array of settings.
  64854. * Function will return immediately and will simplify async
  64855. * @param settings a collection of simplification settings
  64856. * @param parallelProcessing should all levels calculate parallel or one after the other
  64857. * @param simplificationType the type of simplification to run
  64858. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64859. * @returns the current mesh
  64860. */
  64861. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64862. }
  64863. }
  64864. /**
  64865. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64866. * created in a scene
  64867. */
  64868. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64869. /**
  64870. * The component name helpfull to identify the component in the list of scene components.
  64871. */
  64872. readonly name: string;
  64873. /**
  64874. * The scene the component belongs to.
  64875. */
  64876. scene: Scene;
  64877. /**
  64878. * Creates a new instance of the component for the given scene
  64879. * @param scene Defines the scene to register the component in
  64880. */
  64881. constructor(scene: Scene);
  64882. /**
  64883. * Registers the component in a given scene
  64884. */
  64885. register(): void;
  64886. /**
  64887. * Rebuilds the elements related to this component in case of
  64888. * context lost for instance.
  64889. */
  64890. rebuild(): void;
  64891. /**
  64892. * Disposes the component and the associated ressources
  64893. */
  64894. dispose(): void;
  64895. private _beforeCameraUpdate;
  64896. }
  64897. }
  64898. declare module "babylonjs/Meshes/Builders/index" {
  64899. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64900. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64901. export * from "babylonjs/Meshes/Builders/discBuilder";
  64902. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64903. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64904. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64905. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64906. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64907. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64908. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64909. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64910. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64911. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64912. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64913. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64914. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64915. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64916. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64917. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64918. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64919. }
  64920. declare module "babylonjs/Meshes/index" {
  64921. export * from "babylonjs/Meshes/abstractMesh";
  64922. export * from "babylonjs/Meshes/buffer";
  64923. export * from "babylonjs/Meshes/Compression/index";
  64924. export * from "babylonjs/Meshes/csg";
  64925. export * from "babylonjs/Meshes/geometry";
  64926. export * from "babylonjs/Meshes/groundMesh";
  64927. export * from "babylonjs/Meshes/trailMesh";
  64928. export * from "babylonjs/Meshes/instancedMesh";
  64929. export * from "babylonjs/Meshes/linesMesh";
  64930. export * from "babylonjs/Meshes/mesh";
  64931. export * from "babylonjs/Meshes/mesh.vertexData";
  64932. export * from "babylonjs/Meshes/meshBuilder";
  64933. export * from "babylonjs/Meshes/meshSimplification";
  64934. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64935. export * from "babylonjs/Meshes/polygonMesh";
  64936. export * from "babylonjs/Meshes/subMesh";
  64937. export * from "babylonjs/Meshes/meshLODLevel";
  64938. export * from "babylonjs/Meshes/transformNode";
  64939. export * from "babylonjs/Meshes/Builders/index";
  64940. export * from "babylonjs/Meshes/dataBuffer";
  64941. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64942. }
  64943. declare module "babylonjs/Morph/index" {
  64944. export * from "babylonjs/Morph/morphTarget";
  64945. export * from "babylonjs/Morph/morphTargetManager";
  64946. }
  64947. declare module "babylonjs/Navigation/INavigationEngine" {
  64948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64949. import { Vector3 } from "babylonjs/Maths/math";
  64950. import { Mesh } from "babylonjs/Meshes/mesh";
  64951. import { Scene } from "babylonjs/scene";
  64952. /**
  64953. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64954. */
  64955. export interface INavigationEnginePlugin {
  64956. /**
  64957. * plugin name
  64958. */
  64959. name: string;
  64960. /**
  64961. * Creates a navigation mesh
  64962. * @param meshes array of all the geometry used to compute the navigatio mesh
  64963. * @param parameters bunch of parameters used to filter geometry
  64964. */
  64965. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64966. /**
  64967. * Create a navigation mesh debug mesh
  64968. * @param scene is where the mesh will be added
  64969. * @returns debug display mesh
  64970. */
  64971. createDebugNavMesh(scene: Scene): Mesh;
  64972. /**
  64973. * Get a navigation mesh constrained position, closest to the parameter position
  64974. * @param position world position
  64975. * @returns the closest point to position constrained by the navigation mesh
  64976. */
  64977. getClosestPoint(position: Vector3): Vector3;
  64978. /**
  64979. * Get a navigation mesh constrained position, within a particular radius
  64980. * @param position world position
  64981. * @param maxRadius the maximum distance to the constrained world position
  64982. * @returns the closest point to position constrained by the navigation mesh
  64983. */
  64984. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64985. /**
  64986. * Compute the final position from a segment made of destination-position
  64987. * @param position world position
  64988. * @param destination world position
  64989. * @returns the resulting point along the navmesh
  64990. */
  64991. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64992. /**
  64993. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64994. * @param start world position
  64995. * @param end world position
  64996. * @returns array containing world position composing the path
  64997. */
  64998. computePath(start: Vector3, end: Vector3): Vector3[];
  64999. /**
  65000. * If this plugin is supported
  65001. * @returns true if plugin is supported
  65002. */
  65003. isSupported(): boolean;
  65004. /**
  65005. * Create a new Crowd so you can add agents
  65006. * @param maxAgents the maximum agent count in the crowd
  65007. * @param maxAgentRadius the maximum radius an agent can have
  65008. * @param scene to attach the crowd to
  65009. * @returns the crowd you can add agents to
  65010. */
  65011. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65012. /**
  65013. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65014. * The queries will try to find a solution within those bounds
  65015. * default is (1,1,1)
  65016. * @param extent x,y,z value that define the extent around the queries point of reference
  65017. */
  65018. setDefaultQueryExtent(extent: Vector3): void;
  65019. /**
  65020. * Get the Bounding box extent specified by setDefaultQueryExtent
  65021. * @returns the box extent values
  65022. */
  65023. getDefaultQueryExtent(): Vector3;
  65024. /**
  65025. * Release all resources
  65026. */
  65027. dispose(): void;
  65028. }
  65029. /**
  65030. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65031. */
  65032. export interface ICrowd {
  65033. /**
  65034. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65035. * You can attach anything to that node. The node position is updated in the scene update tick.
  65036. * @param pos world position that will be constrained by the navigation mesh
  65037. * @param parameters agent parameters
  65038. * @param transform hooked to the agent that will be update by the scene
  65039. * @returns agent index
  65040. */
  65041. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65042. /**
  65043. * Returns the agent position in world space
  65044. * @param index agent index returned by addAgent
  65045. * @returns world space position
  65046. */
  65047. getAgentPosition(index: number): Vector3;
  65048. /**
  65049. * Gets the agent velocity in world space
  65050. * @param index agent index returned by addAgent
  65051. * @returns world space velocity
  65052. */
  65053. getAgentVelocity(index: number): Vector3;
  65054. /**
  65055. * remove a particular agent previously created
  65056. * @param index agent index returned by addAgent
  65057. */
  65058. removeAgent(index: number): void;
  65059. /**
  65060. * get the list of all agents attached to this crowd
  65061. * @returns list of agent indices
  65062. */
  65063. getAgents(): number[];
  65064. /**
  65065. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65066. * @param deltaTime in seconds
  65067. */
  65068. update(deltaTime: number): void;
  65069. /**
  65070. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65071. * @param index agent index returned by addAgent
  65072. * @param destination targeted world position
  65073. */
  65074. agentGoto(index: number, destination: Vector3): void;
  65075. /**
  65076. * Teleport the agent to a new position
  65077. * @param index agent index returned by addAgent
  65078. * @param destination targeted world position
  65079. */
  65080. agentTeleport(index: number, destination: Vector3): void;
  65081. /**
  65082. * Update agent parameters
  65083. * @param index agent index returned by addAgent
  65084. * @param parameters agent parameters
  65085. */
  65086. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65087. /**
  65088. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65089. * The queries will try to find a solution within those bounds
  65090. * default is (1,1,1)
  65091. * @param extent x,y,z value that define the extent around the queries point of reference
  65092. */
  65093. setDefaultQueryExtent(extent: Vector3): void;
  65094. /**
  65095. * Get the Bounding box extent specified by setDefaultQueryExtent
  65096. * @returns the box extent values
  65097. */
  65098. getDefaultQueryExtent(): Vector3;
  65099. /**
  65100. * Release all resources
  65101. */
  65102. dispose(): void;
  65103. }
  65104. /**
  65105. * Configures an agent
  65106. */
  65107. export interface IAgentParameters {
  65108. /**
  65109. * Agent radius. [Limit: >= 0]
  65110. */
  65111. radius: number;
  65112. /**
  65113. * Agent height. [Limit: > 0]
  65114. */
  65115. height: number;
  65116. /**
  65117. * Maximum allowed acceleration. [Limit: >= 0]
  65118. */
  65119. maxAcceleration: number;
  65120. /**
  65121. * Maximum allowed speed. [Limit: >= 0]
  65122. */
  65123. maxSpeed: number;
  65124. /**
  65125. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65126. */
  65127. collisionQueryRange: number;
  65128. /**
  65129. * The path visibility optimization range. [Limit: > 0]
  65130. */
  65131. pathOptimizationRange: number;
  65132. /**
  65133. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65134. */
  65135. separationWeight: number;
  65136. }
  65137. /**
  65138. * Configures the navigation mesh creation
  65139. */
  65140. export interface INavMeshParameters {
  65141. /**
  65142. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65143. */
  65144. cs: number;
  65145. /**
  65146. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65147. */
  65148. ch: number;
  65149. /**
  65150. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65151. */
  65152. walkableSlopeAngle: number;
  65153. /**
  65154. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65155. * be considered walkable. [Limit: >= 3] [Units: vx]
  65156. */
  65157. walkableHeight: number;
  65158. /**
  65159. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65160. */
  65161. walkableClimb: number;
  65162. /**
  65163. * The distance to erode/shrink the walkable area of the heightfield away from
  65164. * obstructions. [Limit: >=0] [Units: vx]
  65165. */
  65166. walkableRadius: number;
  65167. /**
  65168. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65169. */
  65170. maxEdgeLen: number;
  65171. /**
  65172. * The maximum distance a simplfied contour's border edges should deviate
  65173. * the original raw contour. [Limit: >=0] [Units: vx]
  65174. */
  65175. maxSimplificationError: number;
  65176. /**
  65177. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65178. */
  65179. minRegionArea: number;
  65180. /**
  65181. * Any regions with a span count smaller than this value will, if possible,
  65182. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65183. */
  65184. mergeRegionArea: number;
  65185. /**
  65186. * The maximum number of vertices allowed for polygons generated during the
  65187. * contour to polygon conversion process. [Limit: >= 3]
  65188. */
  65189. maxVertsPerPoly: number;
  65190. /**
  65191. * Sets the sampling distance to use when generating the detail mesh.
  65192. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65193. */
  65194. detailSampleDist: number;
  65195. /**
  65196. * The maximum distance the detail mesh surface should deviate from heightfield
  65197. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65198. */
  65199. detailSampleMaxError: number;
  65200. }
  65201. }
  65202. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65203. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65204. import { Mesh } from "babylonjs/Meshes/mesh";
  65205. import { Scene } from "babylonjs/scene";
  65206. import { Vector3 } from "babylonjs/Maths/math";
  65207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65208. /**
  65209. * RecastJS navigation plugin
  65210. */
  65211. export class RecastJSPlugin implements INavigationEnginePlugin {
  65212. /**
  65213. * Reference to the Recast library
  65214. */
  65215. bjsRECAST: any;
  65216. /**
  65217. * plugin name
  65218. */
  65219. name: string;
  65220. /**
  65221. * the first navmesh created. We might extend this to support multiple navmeshes
  65222. */
  65223. navMesh: any;
  65224. /**
  65225. * Initializes the recastJS plugin
  65226. * @param recastInjection can be used to inject your own recast reference
  65227. */
  65228. constructor(recastInjection?: any);
  65229. /**
  65230. * Creates a navigation mesh
  65231. * @param meshes array of all the geometry used to compute the navigatio mesh
  65232. * @param parameters bunch of parameters used to filter geometry
  65233. */
  65234. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65235. /**
  65236. * Create a navigation mesh debug mesh
  65237. * @param scene is where the mesh will be added
  65238. * @returns debug display mesh
  65239. */
  65240. createDebugNavMesh(scene: Scene): Mesh;
  65241. /**
  65242. * Get a navigation mesh constrained position, closest to the parameter position
  65243. * @param position world position
  65244. * @returns the closest point to position constrained by the navigation mesh
  65245. */
  65246. getClosestPoint(position: Vector3): Vector3;
  65247. /**
  65248. * Get a navigation mesh constrained position, within a particular radius
  65249. * @param position world position
  65250. * @param maxRadius the maximum distance to the constrained world position
  65251. * @returns the closest point to position constrained by the navigation mesh
  65252. */
  65253. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65254. /**
  65255. * Compute the final position from a segment made of destination-position
  65256. * @param position world position
  65257. * @param destination world position
  65258. * @returns the resulting point along the navmesh
  65259. */
  65260. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65261. /**
  65262. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65263. * @param start world position
  65264. * @param end world position
  65265. * @returns array containing world position composing the path
  65266. */
  65267. computePath(start: Vector3, end: Vector3): Vector3[];
  65268. /**
  65269. * Create a new Crowd so you can add agents
  65270. * @param maxAgents the maximum agent count in the crowd
  65271. * @param maxAgentRadius the maximum radius an agent can have
  65272. * @param scene to attach the crowd to
  65273. * @returns the crowd you can add agents to
  65274. */
  65275. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65276. /**
  65277. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65278. * The queries will try to find a solution within those bounds
  65279. * default is (1,1,1)
  65280. * @param extent x,y,z value that define the extent around the queries point of reference
  65281. */
  65282. setDefaultQueryExtent(extent: Vector3): void;
  65283. /**
  65284. * Get the Bounding box extent specified by setDefaultQueryExtent
  65285. * @returns the box extent values
  65286. */
  65287. getDefaultQueryExtent(): Vector3;
  65288. /**
  65289. * Disposes
  65290. */
  65291. dispose(): void;
  65292. /**
  65293. * If this plugin is supported
  65294. * @returns true if plugin is supported
  65295. */
  65296. isSupported(): boolean;
  65297. }
  65298. /**
  65299. * Recast detour crowd implementation
  65300. */
  65301. export class RecastJSCrowd implements ICrowd {
  65302. /**
  65303. * Recast/detour plugin
  65304. */
  65305. bjsRECASTPlugin: RecastJSPlugin;
  65306. /**
  65307. * Link to the detour crowd
  65308. */
  65309. recastCrowd: any;
  65310. /**
  65311. * One transform per agent
  65312. */
  65313. transforms: TransformNode[];
  65314. /**
  65315. * All agents created
  65316. */
  65317. agents: number[];
  65318. /**
  65319. * Link to the scene is kept to unregister the crowd from the scene
  65320. */
  65321. private _scene;
  65322. /**
  65323. * Observer for crowd updates
  65324. */
  65325. private _onBeforeAnimationsObserver;
  65326. /**
  65327. * Constructor
  65328. * @param plugin recastJS plugin
  65329. * @param maxAgents the maximum agent count in the crowd
  65330. * @param maxAgentRadius the maximum radius an agent can have
  65331. * @param scene to attach the crowd to
  65332. * @returns the crowd you can add agents to
  65333. */
  65334. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65335. /**
  65336. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65337. * You can attach anything to that node. The node position is updated in the scene update tick.
  65338. * @param pos world position that will be constrained by the navigation mesh
  65339. * @param parameters agent parameters
  65340. * @param transform hooked to the agent that will be update by the scene
  65341. * @returns agent index
  65342. */
  65343. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65344. /**
  65345. * Returns the agent position in world space
  65346. * @param index agent index returned by addAgent
  65347. * @returns world space position
  65348. */
  65349. getAgentPosition(index: number): Vector3;
  65350. /**
  65351. * Returns the agent velocity in world space
  65352. * @param index agent index returned by addAgent
  65353. * @returns world space velocity
  65354. */
  65355. getAgentVelocity(index: number): Vector3;
  65356. /**
  65357. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65358. * @param index agent index returned by addAgent
  65359. * @param destination targeted world position
  65360. */
  65361. agentGoto(index: number, destination: Vector3): void;
  65362. /**
  65363. * Teleport the agent to a new position
  65364. * @param index agent index returned by addAgent
  65365. * @param destination targeted world position
  65366. */
  65367. agentTeleport(index: number, destination: Vector3): void;
  65368. /**
  65369. * Update agent parameters
  65370. * @param index agent index returned by addAgent
  65371. * @param parameters agent parameters
  65372. */
  65373. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65374. /**
  65375. * remove a particular agent previously created
  65376. * @param index agent index returned by addAgent
  65377. */
  65378. removeAgent(index: number): void;
  65379. /**
  65380. * get the list of all agents attached to this crowd
  65381. * @returns list of agent indices
  65382. */
  65383. getAgents(): number[];
  65384. /**
  65385. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65386. * @param deltaTime in seconds
  65387. */
  65388. update(deltaTime: number): void;
  65389. /**
  65390. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65391. * The queries will try to find a solution within those bounds
  65392. * default is (1,1,1)
  65393. * @param extent x,y,z value that define the extent around the queries point of reference
  65394. */
  65395. setDefaultQueryExtent(extent: Vector3): void;
  65396. /**
  65397. * Get the Bounding box extent specified by setDefaultQueryExtent
  65398. * @returns the box extent values
  65399. */
  65400. getDefaultQueryExtent(): Vector3;
  65401. /**
  65402. * Release all resources
  65403. */
  65404. dispose(): void;
  65405. }
  65406. }
  65407. declare module "babylonjs/Navigation/Plugins/index" {
  65408. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65409. }
  65410. declare module "babylonjs/Navigation/index" {
  65411. export * from "babylonjs/Navigation/INavigationEngine";
  65412. export * from "babylonjs/Navigation/Plugins/index";
  65413. }
  65414. declare module "babylonjs/Offline/database" {
  65415. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65416. /**
  65417. * Class used to enable access to IndexedDB
  65418. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65419. */
  65420. export class Database implements IOfflineProvider {
  65421. private _callbackManifestChecked;
  65422. private _currentSceneUrl;
  65423. private _db;
  65424. private _enableSceneOffline;
  65425. private _enableTexturesOffline;
  65426. private _manifestVersionFound;
  65427. private _mustUpdateRessources;
  65428. private _hasReachedQuota;
  65429. private _isSupported;
  65430. private _idbFactory;
  65431. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65432. private static IsUASupportingBlobStorage;
  65433. /**
  65434. * Gets a boolean indicating if Database storate is enabled (off by default)
  65435. */
  65436. static IDBStorageEnabled: boolean;
  65437. /**
  65438. * Gets a boolean indicating if scene must be saved in the database
  65439. */
  65440. get enableSceneOffline(): boolean;
  65441. /**
  65442. * Gets a boolean indicating if textures must be saved in the database
  65443. */
  65444. get enableTexturesOffline(): boolean;
  65445. /**
  65446. * Creates a new Database
  65447. * @param urlToScene defines the url to load the scene
  65448. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65449. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65450. */
  65451. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65452. private static _ParseURL;
  65453. private static _ReturnFullUrlLocation;
  65454. private _checkManifestFile;
  65455. /**
  65456. * Open the database and make it available
  65457. * @param successCallback defines the callback to call on success
  65458. * @param errorCallback defines the callback to call on error
  65459. */
  65460. open(successCallback: () => void, errorCallback: () => void): void;
  65461. /**
  65462. * Loads an image from the database
  65463. * @param url defines the url to load from
  65464. * @param image defines the target DOM image
  65465. */
  65466. loadImage(url: string, image: HTMLImageElement): void;
  65467. private _loadImageFromDBAsync;
  65468. private _saveImageIntoDBAsync;
  65469. private _checkVersionFromDB;
  65470. private _loadVersionFromDBAsync;
  65471. private _saveVersionIntoDBAsync;
  65472. /**
  65473. * Loads a file from database
  65474. * @param url defines the URL to load from
  65475. * @param sceneLoaded defines a callback to call on success
  65476. * @param progressCallBack defines a callback to call when progress changed
  65477. * @param errorCallback defines a callback to call on error
  65478. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65479. */
  65480. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65481. private _loadFileAsync;
  65482. private _saveFileAsync;
  65483. /**
  65484. * Validates if xhr data is correct
  65485. * @param xhr defines the request to validate
  65486. * @param dataType defines the expected data type
  65487. * @returns true if data is correct
  65488. */
  65489. private static _ValidateXHRData;
  65490. }
  65491. }
  65492. declare module "babylonjs/Offline/index" {
  65493. export * from "babylonjs/Offline/database";
  65494. export * from "babylonjs/Offline/IOfflineProvider";
  65495. }
  65496. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65497. /** @hidden */
  65498. export var gpuUpdateParticlesPixelShader: {
  65499. name: string;
  65500. shader: string;
  65501. };
  65502. }
  65503. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65504. /** @hidden */
  65505. export var gpuUpdateParticlesVertexShader: {
  65506. name: string;
  65507. shader: string;
  65508. };
  65509. }
  65510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65511. /** @hidden */
  65512. export var clipPlaneFragmentDeclaration2: {
  65513. name: string;
  65514. shader: string;
  65515. };
  65516. }
  65517. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65518. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65519. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65520. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65521. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65522. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65523. /** @hidden */
  65524. export var gpuRenderParticlesPixelShader: {
  65525. name: string;
  65526. shader: string;
  65527. };
  65528. }
  65529. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65530. /** @hidden */
  65531. export var clipPlaneVertexDeclaration2: {
  65532. name: string;
  65533. shader: string;
  65534. };
  65535. }
  65536. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65537. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65538. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65539. /** @hidden */
  65540. export var gpuRenderParticlesVertexShader: {
  65541. name: string;
  65542. shader: string;
  65543. };
  65544. }
  65545. declare module "babylonjs/Particles/gpuParticleSystem" {
  65546. import { Nullable } from "babylonjs/types";
  65547. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65548. import { Observable } from "babylonjs/Misc/observable";
  65549. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65550. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65551. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65552. import { Scene, IDisposable } from "babylonjs/scene";
  65553. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65555. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65556. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65557. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65558. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65559. /**
  65560. * This represents a GPU particle system in Babylon
  65561. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65562. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65563. */
  65564. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65565. /**
  65566. * The layer mask we are rendering the particles through.
  65567. */
  65568. layerMask: number;
  65569. private _capacity;
  65570. private _activeCount;
  65571. private _currentActiveCount;
  65572. private _accumulatedCount;
  65573. private _renderEffect;
  65574. private _updateEffect;
  65575. private _buffer0;
  65576. private _buffer1;
  65577. private _spriteBuffer;
  65578. private _updateVAO;
  65579. private _renderVAO;
  65580. private _targetIndex;
  65581. private _sourceBuffer;
  65582. private _targetBuffer;
  65583. private _engine;
  65584. private _currentRenderId;
  65585. private _started;
  65586. private _stopped;
  65587. private _timeDelta;
  65588. private _randomTexture;
  65589. private _randomTexture2;
  65590. private _attributesStrideSize;
  65591. private _updateEffectOptions;
  65592. private _randomTextureSize;
  65593. private _actualFrame;
  65594. private readonly _rawTextureWidth;
  65595. /**
  65596. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65597. */
  65598. static get IsSupported(): boolean;
  65599. /**
  65600. * An event triggered when the system is disposed.
  65601. */
  65602. onDisposeObservable: Observable<GPUParticleSystem>;
  65603. /**
  65604. * Gets the maximum number of particles active at the same time.
  65605. * @returns The max number of active particles.
  65606. */
  65607. getCapacity(): number;
  65608. /**
  65609. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65610. * to override the particles.
  65611. */
  65612. forceDepthWrite: boolean;
  65613. /**
  65614. * Gets or set the number of active particles
  65615. */
  65616. get activeParticleCount(): number;
  65617. set activeParticleCount(value: number);
  65618. private _preWarmDone;
  65619. /**
  65620. * Is this system ready to be used/rendered
  65621. * @return true if the system is ready
  65622. */
  65623. isReady(): boolean;
  65624. /**
  65625. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65626. * @returns True if it has been started, otherwise false.
  65627. */
  65628. isStarted(): boolean;
  65629. /**
  65630. * Starts the particle system and begins to emit
  65631. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65632. */
  65633. start(delay?: number): void;
  65634. /**
  65635. * Stops the particle system.
  65636. */
  65637. stop(): void;
  65638. /**
  65639. * Remove all active particles
  65640. */
  65641. reset(): void;
  65642. /**
  65643. * Returns the string "GPUParticleSystem"
  65644. * @returns a string containing the class name
  65645. */
  65646. getClassName(): string;
  65647. private _colorGradientsTexture;
  65648. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65649. /**
  65650. * Adds a new color gradient
  65651. * @param gradient defines the gradient to use (between 0 and 1)
  65652. * @param color1 defines the color to affect to the specified gradient
  65653. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65654. * @returns the current particle system
  65655. */
  65656. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65657. /**
  65658. * Remove a specific color gradient
  65659. * @param gradient defines the gradient to remove
  65660. * @returns the current particle system
  65661. */
  65662. removeColorGradient(gradient: number): GPUParticleSystem;
  65663. private _angularSpeedGradientsTexture;
  65664. private _sizeGradientsTexture;
  65665. private _velocityGradientsTexture;
  65666. private _limitVelocityGradientsTexture;
  65667. private _dragGradientsTexture;
  65668. private _addFactorGradient;
  65669. /**
  65670. * Adds a new size gradient
  65671. * @param gradient defines the gradient to use (between 0 and 1)
  65672. * @param factor defines the size factor to affect to the specified gradient
  65673. * @returns the current particle system
  65674. */
  65675. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65676. /**
  65677. * Remove a specific size gradient
  65678. * @param gradient defines the gradient to remove
  65679. * @returns the current particle system
  65680. */
  65681. removeSizeGradient(gradient: number): GPUParticleSystem;
  65682. /**
  65683. * Adds a new angular speed gradient
  65684. * @param gradient defines the gradient to use (between 0 and 1)
  65685. * @param factor defines the angular speed to affect to the specified gradient
  65686. * @returns the current particle system
  65687. */
  65688. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65689. /**
  65690. * Remove a specific angular speed gradient
  65691. * @param gradient defines the gradient to remove
  65692. * @returns the current particle system
  65693. */
  65694. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65695. /**
  65696. * Adds a new velocity gradient
  65697. * @param gradient defines the gradient to use (between 0 and 1)
  65698. * @param factor defines the velocity to affect to the specified gradient
  65699. * @returns the current particle system
  65700. */
  65701. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65702. /**
  65703. * Remove a specific velocity gradient
  65704. * @param gradient defines the gradient to remove
  65705. * @returns the current particle system
  65706. */
  65707. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65708. /**
  65709. * Adds a new limit velocity gradient
  65710. * @param gradient defines the gradient to use (between 0 and 1)
  65711. * @param factor defines the limit velocity value to affect to the specified gradient
  65712. * @returns the current particle system
  65713. */
  65714. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65715. /**
  65716. * Remove a specific limit velocity gradient
  65717. * @param gradient defines the gradient to remove
  65718. * @returns the current particle system
  65719. */
  65720. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65721. /**
  65722. * Adds a new drag gradient
  65723. * @param gradient defines the gradient to use (between 0 and 1)
  65724. * @param factor defines the drag value to affect to the specified gradient
  65725. * @returns the current particle system
  65726. */
  65727. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65728. /**
  65729. * Remove a specific drag gradient
  65730. * @param gradient defines the gradient to remove
  65731. * @returns the current particle system
  65732. */
  65733. removeDragGradient(gradient: number): GPUParticleSystem;
  65734. /**
  65735. * Not supported by GPUParticleSystem
  65736. * @param gradient defines the gradient to use (between 0 and 1)
  65737. * @param factor defines the emit rate value to affect to the specified gradient
  65738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65739. * @returns the current particle system
  65740. */
  65741. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65742. /**
  65743. * Not supported by GPUParticleSystem
  65744. * @param gradient defines the gradient to remove
  65745. * @returns the current particle system
  65746. */
  65747. removeEmitRateGradient(gradient: number): IParticleSystem;
  65748. /**
  65749. * Not supported by GPUParticleSystem
  65750. * @param gradient defines the gradient to use (between 0 and 1)
  65751. * @param factor defines the start size value to affect to the specified gradient
  65752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65753. * @returns the current particle system
  65754. */
  65755. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65756. /**
  65757. * Not supported by GPUParticleSystem
  65758. * @param gradient defines the gradient to remove
  65759. * @returns the current particle system
  65760. */
  65761. removeStartSizeGradient(gradient: number): IParticleSystem;
  65762. /**
  65763. * Not supported by GPUParticleSystem
  65764. * @param gradient defines the gradient to use (between 0 and 1)
  65765. * @param min defines the color remap minimal range
  65766. * @param max defines the color remap maximal range
  65767. * @returns the current particle system
  65768. */
  65769. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65770. /**
  65771. * Not supported by GPUParticleSystem
  65772. * @param gradient defines the gradient to remove
  65773. * @returns the current particle system
  65774. */
  65775. removeColorRemapGradient(): IParticleSystem;
  65776. /**
  65777. * Not supported by GPUParticleSystem
  65778. * @param gradient defines the gradient to use (between 0 and 1)
  65779. * @param min defines the alpha remap minimal range
  65780. * @param max defines the alpha remap maximal range
  65781. * @returns the current particle system
  65782. */
  65783. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65784. /**
  65785. * Not supported by GPUParticleSystem
  65786. * @param gradient defines the gradient to remove
  65787. * @returns the current particle system
  65788. */
  65789. removeAlphaRemapGradient(): IParticleSystem;
  65790. /**
  65791. * Not supported by GPUParticleSystem
  65792. * @param gradient defines the gradient to use (between 0 and 1)
  65793. * @param color defines the color to affect to the specified gradient
  65794. * @returns the current particle system
  65795. */
  65796. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65797. /**
  65798. * Not supported by GPUParticleSystem
  65799. * @param gradient defines the gradient to remove
  65800. * @returns the current particle system
  65801. */
  65802. removeRampGradient(): IParticleSystem;
  65803. /**
  65804. * Not supported by GPUParticleSystem
  65805. * @returns the list of ramp gradients
  65806. */
  65807. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65808. /**
  65809. * Not supported by GPUParticleSystem
  65810. * Gets or sets a boolean indicating that ramp gradients must be used
  65811. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65812. */
  65813. get useRampGradients(): boolean;
  65814. set useRampGradients(value: boolean);
  65815. /**
  65816. * Not supported by GPUParticleSystem
  65817. * @param gradient defines the gradient to use (between 0 and 1)
  65818. * @param factor defines the life time factor to affect to the specified gradient
  65819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65820. * @returns the current particle system
  65821. */
  65822. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65823. /**
  65824. * Not supported by GPUParticleSystem
  65825. * @param gradient defines the gradient to remove
  65826. * @returns the current particle system
  65827. */
  65828. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65829. /**
  65830. * Instantiates a GPU particle system.
  65831. * 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.
  65832. * @param name The name of the particle system
  65833. * @param options The options used to create the system
  65834. * @param scene The scene the particle system belongs to
  65835. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65836. */
  65837. constructor(name: string, options: Partial<{
  65838. capacity: number;
  65839. randomTextureSize: number;
  65840. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65841. protected _reset(): void;
  65842. private _createUpdateVAO;
  65843. private _createRenderVAO;
  65844. private _initialize;
  65845. /** @hidden */
  65846. _recreateUpdateEffect(): void;
  65847. /** @hidden */
  65848. _recreateRenderEffect(): void;
  65849. /**
  65850. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65851. * @param preWarm defines if we are in the pre-warmimg phase
  65852. */
  65853. animate(preWarm?: boolean): void;
  65854. private _createFactorGradientTexture;
  65855. private _createSizeGradientTexture;
  65856. private _createAngularSpeedGradientTexture;
  65857. private _createVelocityGradientTexture;
  65858. private _createLimitVelocityGradientTexture;
  65859. private _createDragGradientTexture;
  65860. private _createColorGradientTexture;
  65861. /**
  65862. * Renders the particle system in its current state
  65863. * @param preWarm defines if the system should only update the particles but not render them
  65864. * @returns the current number of particles
  65865. */
  65866. render(preWarm?: boolean): number;
  65867. /**
  65868. * Rebuilds the particle system
  65869. */
  65870. rebuild(): void;
  65871. private _releaseBuffers;
  65872. private _releaseVAOs;
  65873. /**
  65874. * Disposes the particle system and free the associated resources
  65875. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65876. */
  65877. dispose(disposeTexture?: boolean): void;
  65878. /**
  65879. * Clones the particle system.
  65880. * @param name The name of the cloned object
  65881. * @param newEmitter The new emitter to use
  65882. * @returns the cloned particle system
  65883. */
  65884. clone(name: string, newEmitter: any): GPUParticleSystem;
  65885. /**
  65886. * Serializes the particle system to a JSON object.
  65887. * @returns the JSON object
  65888. */
  65889. serialize(): any;
  65890. /**
  65891. * Parses a JSON object to create a GPU particle system.
  65892. * @param parsedParticleSystem The JSON object to parse
  65893. * @param scene The scene to create the particle system in
  65894. * @param rootUrl The root url to use to load external dependencies like texture
  65895. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65896. * @returns the parsed GPU particle system
  65897. */
  65898. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65899. }
  65900. }
  65901. declare module "babylonjs/Particles/particleSystemSet" {
  65902. import { Nullable } from "babylonjs/types";
  65903. import { Color3 } from "babylonjs/Maths/math.color";
  65904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65906. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65907. import { Scene, IDisposable } from "babylonjs/scene";
  65908. /**
  65909. * Represents a set of particle systems working together to create a specific effect
  65910. */
  65911. export class ParticleSystemSet implements IDisposable {
  65912. /**
  65913. * Gets or sets base Assets URL
  65914. */
  65915. static BaseAssetsUrl: string;
  65916. private _emitterCreationOptions;
  65917. private _emitterNode;
  65918. /**
  65919. * Gets the particle system list
  65920. */
  65921. systems: IParticleSystem[];
  65922. /**
  65923. * Gets the emitter node used with this set
  65924. */
  65925. get emitterNode(): Nullable<TransformNode>;
  65926. /**
  65927. * Creates a new emitter mesh as a sphere
  65928. * @param options defines the options used to create the sphere
  65929. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65930. * @param scene defines the hosting scene
  65931. */
  65932. setEmitterAsSphere(options: {
  65933. diameter: number;
  65934. segments: number;
  65935. color: Color3;
  65936. }, renderingGroupId: number, scene: Scene): void;
  65937. /**
  65938. * Starts all particle systems of the set
  65939. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65940. */
  65941. start(emitter?: AbstractMesh): void;
  65942. /**
  65943. * Release all associated resources
  65944. */
  65945. dispose(): void;
  65946. /**
  65947. * Serialize the set into a JSON compatible object
  65948. * @returns a JSON compatible representation of the set
  65949. */
  65950. serialize(): any;
  65951. /**
  65952. * Parse a new ParticleSystemSet from a serialized source
  65953. * @param data defines a JSON compatible representation of the set
  65954. * @param scene defines the hosting scene
  65955. * @param gpu defines if we want GPU particles or CPU particles
  65956. * @returns a new ParticleSystemSet
  65957. */
  65958. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65959. }
  65960. }
  65961. declare module "babylonjs/Particles/particleHelper" {
  65962. import { Nullable } from "babylonjs/types";
  65963. import { Scene } from "babylonjs/scene";
  65964. import { Vector3 } from "babylonjs/Maths/math.vector";
  65965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65966. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65967. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  65968. /**
  65969. * This class is made for on one-liner static method to help creating particle system set.
  65970. */
  65971. export class ParticleHelper {
  65972. /**
  65973. * Gets or sets base Assets URL
  65974. */
  65975. static BaseAssetsUrl: string;
  65976. /**
  65977. * Create a default particle system that you can tweak
  65978. * @param emitter defines the emitter to use
  65979. * @param capacity defines the system capacity (default is 500 particles)
  65980. * @param scene defines the hosting scene
  65981. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65982. * @returns the new Particle system
  65983. */
  65984. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65985. /**
  65986. * This is the main static method (one-liner) of this helper to create different particle systems
  65987. * @param type This string represents the type to the particle system to create
  65988. * @param scene The scene where the particle system should live
  65989. * @param gpu If the system will use gpu
  65990. * @returns the ParticleSystemSet created
  65991. */
  65992. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65993. /**
  65994. * Static function used to export a particle system to a ParticleSystemSet variable.
  65995. * Please note that the emitter shape is not exported
  65996. * @param systems defines the particle systems to export
  65997. * @returns the created particle system set
  65998. */
  65999. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66000. }
  66001. }
  66002. declare module "babylonjs/Particles/particleSystemComponent" {
  66003. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66004. import { Effect } from "babylonjs/Materials/effect";
  66005. import "babylonjs/Shaders/particles.vertex";
  66006. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66007. module "babylonjs/Engines/engine" {
  66008. interface Engine {
  66009. /**
  66010. * Create an effect to use with particle systems.
  66011. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66012. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66013. * @param uniformsNames defines a list of attribute names
  66014. * @param samplers defines an array of string used to represent textures
  66015. * @param defines defines the string containing the defines to use to compile the shaders
  66016. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66017. * @param onCompiled defines a function to call when the effect creation is successful
  66018. * @param onError defines a function to call when the effect creation has failed
  66019. * @returns the new Effect
  66020. */
  66021. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66022. }
  66023. }
  66024. module "babylonjs/Meshes/mesh" {
  66025. interface Mesh {
  66026. /**
  66027. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66028. * @returns an array of IParticleSystem
  66029. */
  66030. getEmittedParticleSystems(): IParticleSystem[];
  66031. /**
  66032. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66033. * @returns an array of IParticleSystem
  66034. */
  66035. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66036. }
  66037. }
  66038. /**
  66039. * @hidden
  66040. */
  66041. export var _IDoNeedToBeInTheBuild: number;
  66042. }
  66043. declare module "babylonjs/Particles/pointsCloudSystem" {
  66044. import { Color4 } from "babylonjs/Maths/math";
  66045. import { Mesh } from "babylonjs/Meshes/mesh";
  66046. import { Scene, IDisposable } from "babylonjs/scene";
  66047. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66048. /** Defines the 4 color options */
  66049. export enum PointColor {
  66050. /** color value */
  66051. Color = 2,
  66052. /** uv value */
  66053. UV = 1,
  66054. /** random value */
  66055. Random = 0,
  66056. /** stated value */
  66057. Stated = 3
  66058. }
  66059. /**
  66060. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66061. * 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.
  66062. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66063. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66064. *
  66065. * Full documentation here : TO BE ENTERED
  66066. */
  66067. export class PointsCloudSystem implements IDisposable {
  66068. /**
  66069. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66070. * Example : var p = SPS.particles[i];
  66071. */
  66072. particles: CloudPoint[];
  66073. /**
  66074. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66075. */
  66076. nbParticles: number;
  66077. /**
  66078. * This a counter for your own usage. It's not set by any SPS functions.
  66079. */
  66080. counter: number;
  66081. /**
  66082. * The PCS name. This name is also given to the underlying mesh.
  66083. */
  66084. name: string;
  66085. /**
  66086. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66087. */
  66088. mesh: Mesh;
  66089. /**
  66090. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66091. * Please read :
  66092. */
  66093. vars: any;
  66094. /**
  66095. * @hidden
  66096. */
  66097. _size: number;
  66098. private _scene;
  66099. private _promises;
  66100. private _positions;
  66101. private _indices;
  66102. private _normals;
  66103. private _colors;
  66104. private _uvs;
  66105. private _indices32;
  66106. private _positions32;
  66107. private _colors32;
  66108. private _uvs32;
  66109. private _updatable;
  66110. private _isVisibilityBoxLocked;
  66111. private _alwaysVisible;
  66112. private _groups;
  66113. private _groupCounter;
  66114. private _computeParticleColor;
  66115. private _computeParticleTexture;
  66116. private _computeParticleRotation;
  66117. private _computeBoundingBox;
  66118. private _isReady;
  66119. /**
  66120. * Creates a PCS (Points Cloud System) object
  66121. * @param name (String) is the PCS name, this will be the underlying mesh name
  66122. * @param pointSize (number) is the size for each point
  66123. * @param scene (Scene) is the scene in which the PCS is added
  66124. * @param options defines the options of the PCS e.g.
  66125. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66126. */
  66127. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66128. updatable?: boolean;
  66129. });
  66130. /**
  66131. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66132. * If no points were added to the PCS, the returned mesh is just a single point.
  66133. * @returns a promise for the created mesh
  66134. */
  66135. buildMeshAsync(): Promise<Mesh>;
  66136. /**
  66137. * @hidden
  66138. */
  66139. private _buildMesh;
  66140. private _addParticle;
  66141. private _randomUnitVector;
  66142. private _getColorIndicesForCoord;
  66143. private _setPointsColorOrUV;
  66144. private _colorFromTexture;
  66145. private _calculateDensity;
  66146. /**
  66147. * Adds points to the PCS in random positions within a unit sphere
  66148. * @param nb (positive integer) the number of particles to be created from this model
  66149. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66150. * @returns the number of groups in the system
  66151. */
  66152. addPoints(nb: number, pointFunction?: any): number;
  66153. /**
  66154. * Adds points to the PCS from the surface of the model shape
  66155. * @param mesh is any Mesh object that will be used as a surface model for the points
  66156. * @param nb (positive integer) the number of particles to be created from this model
  66157. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66158. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66159. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66160. * @returns the number of groups in the system
  66161. */
  66162. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66163. /**
  66164. * Adds points to the PCS inside the model shape
  66165. * @param mesh is any Mesh object that will be used as a surface model for the points
  66166. * @param nb (positive integer) the number of particles to be created from this model
  66167. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66168. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66169. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66170. * @returns the number of groups in the system
  66171. */
  66172. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66173. /**
  66174. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66175. * This method calls `updateParticle()` for each particle of the SPS.
  66176. * For an animated SPS, it is usually called within the render loop.
  66177. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66178. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66179. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66180. * @returns the PCS.
  66181. */
  66182. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66183. /**
  66184. * Disposes the PCS.
  66185. */
  66186. dispose(): void;
  66187. /**
  66188. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66189. * doc :
  66190. * @returns the PCS.
  66191. */
  66192. refreshVisibleSize(): PointsCloudSystem;
  66193. /**
  66194. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66195. * @param size the size (float) of the visibility box
  66196. * note : this doesn't lock the PCS mesh bounding box.
  66197. * doc :
  66198. */
  66199. setVisibilityBox(size: number): void;
  66200. /**
  66201. * Gets whether the PCS is always visible or not
  66202. * doc :
  66203. */
  66204. get isAlwaysVisible(): boolean;
  66205. /**
  66206. * Sets the PCS as always visible or not
  66207. * doc :
  66208. */
  66209. set isAlwaysVisible(val: boolean);
  66210. /**
  66211. * Tells to `setParticles()` to compute the particle rotations or not
  66212. * Default value : false. The PCS is faster when it's set to false
  66213. * Note : particle rotations are only applied to parent particles
  66214. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66215. */
  66216. set computeParticleRotation(val: boolean);
  66217. /**
  66218. * Tells to `setParticles()` to compute the particle colors or not.
  66219. * Default value : true. The PCS is faster when it's set to false.
  66220. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66221. */
  66222. set computeParticleColor(val: boolean);
  66223. set computeParticleTexture(val: boolean);
  66224. /**
  66225. * Gets if `setParticles()` computes the particle colors or not.
  66226. * Default value : false. The PCS is faster when it's set to false.
  66227. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66228. */
  66229. get computeParticleColor(): boolean;
  66230. /**
  66231. * Gets if `setParticles()` computes the particle textures or not.
  66232. * Default value : false. The PCS is faster when it's set to false.
  66233. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66234. */
  66235. get computeParticleTexture(): boolean;
  66236. /**
  66237. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66238. */
  66239. set computeBoundingBox(val: boolean);
  66240. /**
  66241. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66242. */
  66243. get computeBoundingBox(): boolean;
  66244. /**
  66245. * This function does nothing. It may be overwritten to set all the particle first values.
  66246. * The PCS doesn't call this function, you may have to call it by your own.
  66247. * doc :
  66248. */
  66249. initParticles(): void;
  66250. /**
  66251. * This function does nothing. It may be overwritten to recycle a particle
  66252. * The PCS doesn't call this function, you can to call it
  66253. * doc :
  66254. * @param particle The particle to recycle
  66255. * @returns the recycled particle
  66256. */
  66257. recycleParticle(particle: CloudPoint): CloudPoint;
  66258. /**
  66259. * Updates a particle : this function should be overwritten by the user.
  66260. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66261. * doc :
  66262. * @example : just set a particle position or velocity and recycle conditions
  66263. * @param particle The particle to update
  66264. * @returns the updated particle
  66265. */
  66266. updateParticle(particle: CloudPoint): CloudPoint;
  66267. /**
  66268. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66269. * This does nothing and may be overwritten by the user.
  66270. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66271. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66272. * @param update the boolean update value actually passed to setParticles()
  66273. */
  66274. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66275. /**
  66276. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66277. * This will be passed three parameters.
  66278. * This does nothing and may be overwritten by the user.
  66279. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66280. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66281. * @param update the boolean update value actually passed to setParticles()
  66282. */
  66283. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66284. }
  66285. }
  66286. declare module "babylonjs/Particles/cloudPoint" {
  66287. import { Nullable } from "babylonjs/types";
  66288. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66289. import { Mesh } from "babylonjs/Meshes/mesh";
  66290. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66291. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66292. /**
  66293. * Represents one particle of a points cloud system.
  66294. */
  66295. export class CloudPoint {
  66296. /**
  66297. * particle global index
  66298. */
  66299. idx: number;
  66300. /**
  66301. * The color of the particle
  66302. */
  66303. color: Nullable<Color4>;
  66304. /**
  66305. * The world space position of the particle.
  66306. */
  66307. position: Vector3;
  66308. /**
  66309. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66310. */
  66311. rotation: Vector3;
  66312. /**
  66313. * The world space rotation quaternion of the particle.
  66314. */
  66315. rotationQuaternion: Nullable<Quaternion>;
  66316. /**
  66317. * The uv of the particle.
  66318. */
  66319. uv: Nullable<Vector2>;
  66320. /**
  66321. * The current speed of the particle.
  66322. */
  66323. velocity: Vector3;
  66324. /**
  66325. * The pivot point in the particle local space.
  66326. */
  66327. pivot: Vector3;
  66328. /**
  66329. * Must the particle be translated from its pivot point in its local space ?
  66330. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66331. * Default : false
  66332. */
  66333. translateFromPivot: boolean;
  66334. /**
  66335. * Index of this particle in the global "positions" array (Internal use)
  66336. * @hidden
  66337. */
  66338. _pos: number;
  66339. /**
  66340. * @hidden Index of this particle in the global "indices" array (Internal use)
  66341. */
  66342. _ind: number;
  66343. /**
  66344. * Group this particle belongs to
  66345. */
  66346. _group: PointsGroup;
  66347. /**
  66348. * Group id of this particle
  66349. */
  66350. groupId: number;
  66351. /**
  66352. * Index of the particle in its group id (Internal use)
  66353. */
  66354. idxInGroup: number;
  66355. /**
  66356. * @hidden Particle BoundingInfo object (Internal use)
  66357. */
  66358. _boundingInfo: BoundingInfo;
  66359. /**
  66360. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66361. */
  66362. _pcs: PointsCloudSystem;
  66363. /**
  66364. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66365. */
  66366. _stillInvisible: boolean;
  66367. /**
  66368. * @hidden Last computed particle rotation matrix
  66369. */
  66370. _rotationMatrix: number[];
  66371. /**
  66372. * Parent particle Id, if any.
  66373. * Default null.
  66374. */
  66375. parentId: Nullable<number>;
  66376. /**
  66377. * @hidden Internal global position in the PCS.
  66378. */
  66379. _globalPosition: Vector3;
  66380. /**
  66381. * Creates a Point Cloud object.
  66382. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66383. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66384. * @param group (PointsGroup) is the group the particle belongs to
  66385. * @param groupId (integer) is the group identifier in the PCS.
  66386. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66387. * @param pcs defines the PCS it is associated to
  66388. */
  66389. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66390. /**
  66391. * get point size
  66392. */
  66393. get size(): Vector3;
  66394. /**
  66395. * Set point size
  66396. */
  66397. set size(scale: Vector3);
  66398. /**
  66399. * Legacy support, changed quaternion to rotationQuaternion
  66400. */
  66401. get quaternion(): Nullable<Quaternion>;
  66402. /**
  66403. * Legacy support, changed quaternion to rotationQuaternion
  66404. */
  66405. set quaternion(q: Nullable<Quaternion>);
  66406. /**
  66407. * Returns a boolean. True if the particle intersects a mesh, else false
  66408. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66409. * @param target is the object (point or mesh) what the intersection is computed against
  66410. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66411. * @returns true if it intersects
  66412. */
  66413. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66414. /**
  66415. * get the rotation matrix of the particle
  66416. * @hidden
  66417. */
  66418. getRotationMatrix(m: Matrix): void;
  66419. }
  66420. /**
  66421. * Represents a group of points in a points cloud system
  66422. * * PCS internal tool, don't use it manually.
  66423. */
  66424. export class PointsGroup {
  66425. /**
  66426. * The group id
  66427. * @hidden
  66428. */
  66429. groupID: number;
  66430. /**
  66431. * image data for group (internal use)
  66432. * @hidden
  66433. */
  66434. _groupImageData: Nullable<ArrayBufferView>;
  66435. /**
  66436. * Image Width (internal use)
  66437. * @hidden
  66438. */
  66439. _groupImgWidth: number;
  66440. /**
  66441. * Image Height (internal use)
  66442. * @hidden
  66443. */
  66444. _groupImgHeight: number;
  66445. /**
  66446. * Custom position function (internal use)
  66447. * @hidden
  66448. */
  66449. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66450. /**
  66451. * density per facet for surface points
  66452. * @hidden
  66453. */
  66454. _groupDensity: number[];
  66455. /**
  66456. * Only when points are colored by texture carries pointer to texture list array
  66457. * @hidden
  66458. */
  66459. _textureNb: number;
  66460. /**
  66461. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66462. * PCS internal tool, don't use it manually.
  66463. * @hidden
  66464. */
  66465. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66466. }
  66467. }
  66468. declare module "babylonjs/Particles/index" {
  66469. export * from "babylonjs/Particles/baseParticleSystem";
  66470. export * from "babylonjs/Particles/EmitterTypes/index";
  66471. export * from "babylonjs/Particles/gpuParticleSystem";
  66472. export * from "babylonjs/Particles/IParticleSystem";
  66473. export * from "babylonjs/Particles/particle";
  66474. export * from "babylonjs/Particles/particleHelper";
  66475. export * from "babylonjs/Particles/particleSystem";
  66476. export * from "babylonjs/Particles/particleSystemComponent";
  66477. export * from "babylonjs/Particles/particleSystemSet";
  66478. export * from "babylonjs/Particles/solidParticle";
  66479. export * from "babylonjs/Particles/solidParticleSystem";
  66480. export * from "babylonjs/Particles/cloudPoint";
  66481. export * from "babylonjs/Particles/pointsCloudSystem";
  66482. export * from "babylonjs/Particles/subEmitter";
  66483. }
  66484. declare module "babylonjs/Physics/physicsEngineComponent" {
  66485. import { Nullable } from "babylonjs/types";
  66486. import { Observable, Observer } from "babylonjs/Misc/observable";
  66487. import { Vector3 } from "babylonjs/Maths/math.vector";
  66488. import { Mesh } from "babylonjs/Meshes/mesh";
  66489. import { ISceneComponent } from "babylonjs/sceneComponent";
  66490. import { Scene } from "babylonjs/scene";
  66491. import { Node } from "babylonjs/node";
  66492. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66493. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66494. module "babylonjs/scene" {
  66495. interface Scene {
  66496. /** @hidden (Backing field) */
  66497. _physicsEngine: Nullable<IPhysicsEngine>;
  66498. /** @hidden */
  66499. _physicsTimeAccumulator: number;
  66500. /**
  66501. * Gets the current physics engine
  66502. * @returns a IPhysicsEngine or null if none attached
  66503. */
  66504. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66505. /**
  66506. * Enables physics to the current scene
  66507. * @param gravity defines the scene's gravity for the physics engine
  66508. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66509. * @return a boolean indicating if the physics engine was initialized
  66510. */
  66511. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66512. /**
  66513. * Disables and disposes the physics engine associated with the scene
  66514. */
  66515. disablePhysicsEngine(): void;
  66516. /**
  66517. * Gets a boolean indicating if there is an active physics engine
  66518. * @returns a boolean indicating if there is an active physics engine
  66519. */
  66520. isPhysicsEnabled(): boolean;
  66521. /**
  66522. * Deletes a physics compound impostor
  66523. * @param compound defines the compound to delete
  66524. */
  66525. deleteCompoundImpostor(compound: any): void;
  66526. /**
  66527. * An event triggered when physic simulation is about to be run
  66528. */
  66529. onBeforePhysicsObservable: Observable<Scene>;
  66530. /**
  66531. * An event triggered when physic simulation has been done
  66532. */
  66533. onAfterPhysicsObservable: Observable<Scene>;
  66534. }
  66535. }
  66536. module "babylonjs/Meshes/abstractMesh" {
  66537. interface AbstractMesh {
  66538. /** @hidden */
  66539. _physicsImpostor: Nullable<PhysicsImpostor>;
  66540. /**
  66541. * Gets or sets impostor used for physic simulation
  66542. * @see http://doc.babylonjs.com/features/physics_engine
  66543. */
  66544. physicsImpostor: Nullable<PhysicsImpostor>;
  66545. /**
  66546. * Gets the current physics impostor
  66547. * @see http://doc.babylonjs.com/features/physics_engine
  66548. * @returns a physics impostor or null
  66549. */
  66550. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66551. /** Apply a physic impulse to the mesh
  66552. * @param force defines the force to apply
  66553. * @param contactPoint defines where to apply the force
  66554. * @returns the current mesh
  66555. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66556. */
  66557. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66558. /**
  66559. * Creates a physic joint between two meshes
  66560. * @param otherMesh defines the other mesh to use
  66561. * @param pivot1 defines the pivot to use on this mesh
  66562. * @param pivot2 defines the pivot to use on the other mesh
  66563. * @param options defines additional options (can be plugin dependent)
  66564. * @returns the current mesh
  66565. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66566. */
  66567. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66568. /** @hidden */
  66569. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66570. }
  66571. }
  66572. /**
  66573. * Defines the physics engine scene component responsible to manage a physics engine
  66574. */
  66575. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66576. /**
  66577. * The component name helpful to identify the component in the list of scene components.
  66578. */
  66579. readonly name: string;
  66580. /**
  66581. * The scene the component belongs to.
  66582. */
  66583. scene: Scene;
  66584. /**
  66585. * Creates a new instance of the component for the given scene
  66586. * @param scene Defines the scene to register the component in
  66587. */
  66588. constructor(scene: Scene);
  66589. /**
  66590. * Registers the component in a given scene
  66591. */
  66592. register(): void;
  66593. /**
  66594. * Rebuilds the elements related to this component in case of
  66595. * context lost for instance.
  66596. */
  66597. rebuild(): void;
  66598. /**
  66599. * Disposes the component and the associated ressources
  66600. */
  66601. dispose(): void;
  66602. }
  66603. }
  66604. declare module "babylonjs/Physics/physicsHelper" {
  66605. import { Nullable } from "babylonjs/types";
  66606. import { Vector3 } from "babylonjs/Maths/math.vector";
  66607. import { Mesh } from "babylonjs/Meshes/mesh";
  66608. import { Scene } from "babylonjs/scene";
  66609. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66610. /**
  66611. * A helper for physics simulations
  66612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66613. */
  66614. export class PhysicsHelper {
  66615. private _scene;
  66616. private _physicsEngine;
  66617. /**
  66618. * Initializes the Physics helper
  66619. * @param scene Babylon.js scene
  66620. */
  66621. constructor(scene: Scene);
  66622. /**
  66623. * Applies a radial explosion impulse
  66624. * @param origin the origin of the explosion
  66625. * @param radiusOrEventOptions the radius or the options of radial explosion
  66626. * @param strength the explosion strength
  66627. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66628. * @returns A physics radial explosion event, or null
  66629. */
  66630. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66631. /**
  66632. * Applies a radial explosion force
  66633. * @param origin the origin of the explosion
  66634. * @param radiusOrEventOptions the radius or the options of radial explosion
  66635. * @param strength the explosion strength
  66636. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66637. * @returns A physics radial explosion event, or null
  66638. */
  66639. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66640. /**
  66641. * Creates a gravitational field
  66642. * @param origin the origin of the explosion
  66643. * @param radiusOrEventOptions the radius or the options of radial explosion
  66644. * @param strength the explosion strength
  66645. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66646. * @returns A physics gravitational field event, or null
  66647. */
  66648. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66649. /**
  66650. * Creates a physics updraft event
  66651. * @param origin the origin of the updraft
  66652. * @param radiusOrEventOptions the radius or the options of the updraft
  66653. * @param strength the strength of the updraft
  66654. * @param height the height of the updraft
  66655. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66656. * @returns A physics updraft event, or null
  66657. */
  66658. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66659. /**
  66660. * Creates a physics vortex event
  66661. * @param origin the of the vortex
  66662. * @param radiusOrEventOptions the radius or the options of the vortex
  66663. * @param strength the strength of the vortex
  66664. * @param height the height of the vortex
  66665. * @returns a Physics vortex event, or null
  66666. * A physics vortex event or null
  66667. */
  66668. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66669. }
  66670. /**
  66671. * Represents a physics radial explosion event
  66672. */
  66673. class PhysicsRadialExplosionEvent {
  66674. private _scene;
  66675. private _options;
  66676. private _sphere;
  66677. private _dataFetched;
  66678. /**
  66679. * Initializes a radial explosioin event
  66680. * @param _scene BabylonJS scene
  66681. * @param _options The options for the vortex event
  66682. */
  66683. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66684. /**
  66685. * Returns the data related to the radial explosion event (sphere).
  66686. * @returns The radial explosion event data
  66687. */
  66688. getData(): PhysicsRadialExplosionEventData;
  66689. /**
  66690. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66691. * @param impostor A physics imposter
  66692. * @param origin the origin of the explosion
  66693. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66694. */
  66695. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66696. /**
  66697. * Triggers affecterd impostors callbacks
  66698. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66699. */
  66700. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66701. /**
  66702. * Disposes the sphere.
  66703. * @param force Specifies if the sphere should be disposed by force
  66704. */
  66705. dispose(force?: boolean): void;
  66706. /*** Helpers ***/
  66707. private _prepareSphere;
  66708. private _intersectsWithSphere;
  66709. }
  66710. /**
  66711. * Represents a gravitational field event
  66712. */
  66713. class PhysicsGravitationalFieldEvent {
  66714. private _physicsHelper;
  66715. private _scene;
  66716. private _origin;
  66717. private _options;
  66718. private _tickCallback;
  66719. private _sphere;
  66720. private _dataFetched;
  66721. /**
  66722. * Initializes the physics gravitational field event
  66723. * @param _physicsHelper A physics helper
  66724. * @param _scene BabylonJS scene
  66725. * @param _origin The origin position of the gravitational field event
  66726. * @param _options The options for the vortex event
  66727. */
  66728. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66729. /**
  66730. * Returns the data related to the gravitational field event (sphere).
  66731. * @returns A gravitational field event
  66732. */
  66733. getData(): PhysicsGravitationalFieldEventData;
  66734. /**
  66735. * Enables the gravitational field.
  66736. */
  66737. enable(): void;
  66738. /**
  66739. * Disables the gravitational field.
  66740. */
  66741. disable(): void;
  66742. /**
  66743. * Disposes the sphere.
  66744. * @param force The force to dispose from the gravitational field event
  66745. */
  66746. dispose(force?: boolean): void;
  66747. private _tick;
  66748. }
  66749. /**
  66750. * Represents a physics updraft event
  66751. */
  66752. class PhysicsUpdraftEvent {
  66753. private _scene;
  66754. private _origin;
  66755. private _options;
  66756. private _physicsEngine;
  66757. private _originTop;
  66758. private _originDirection;
  66759. private _tickCallback;
  66760. private _cylinder;
  66761. private _cylinderPosition;
  66762. private _dataFetched;
  66763. /**
  66764. * Initializes the physics updraft event
  66765. * @param _scene BabylonJS scene
  66766. * @param _origin The origin position of the updraft
  66767. * @param _options The options for the updraft event
  66768. */
  66769. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66770. /**
  66771. * Returns the data related to the updraft event (cylinder).
  66772. * @returns A physics updraft event
  66773. */
  66774. getData(): PhysicsUpdraftEventData;
  66775. /**
  66776. * Enables the updraft.
  66777. */
  66778. enable(): void;
  66779. /**
  66780. * Disables the updraft.
  66781. */
  66782. disable(): void;
  66783. /**
  66784. * Disposes the cylinder.
  66785. * @param force Specifies if the updraft should be disposed by force
  66786. */
  66787. dispose(force?: boolean): void;
  66788. private getImpostorHitData;
  66789. private _tick;
  66790. /*** Helpers ***/
  66791. private _prepareCylinder;
  66792. private _intersectsWithCylinder;
  66793. }
  66794. /**
  66795. * Represents a physics vortex event
  66796. */
  66797. class PhysicsVortexEvent {
  66798. private _scene;
  66799. private _origin;
  66800. private _options;
  66801. private _physicsEngine;
  66802. private _originTop;
  66803. private _tickCallback;
  66804. private _cylinder;
  66805. private _cylinderPosition;
  66806. private _dataFetched;
  66807. /**
  66808. * Initializes the physics vortex event
  66809. * @param _scene The BabylonJS scene
  66810. * @param _origin The origin position of the vortex
  66811. * @param _options The options for the vortex event
  66812. */
  66813. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66814. /**
  66815. * Returns the data related to the vortex event (cylinder).
  66816. * @returns The physics vortex event data
  66817. */
  66818. getData(): PhysicsVortexEventData;
  66819. /**
  66820. * Enables the vortex.
  66821. */
  66822. enable(): void;
  66823. /**
  66824. * Disables the cortex.
  66825. */
  66826. disable(): void;
  66827. /**
  66828. * Disposes the sphere.
  66829. * @param force
  66830. */
  66831. dispose(force?: boolean): void;
  66832. private getImpostorHitData;
  66833. private _tick;
  66834. /*** Helpers ***/
  66835. private _prepareCylinder;
  66836. private _intersectsWithCylinder;
  66837. }
  66838. /**
  66839. * Options fot the radial explosion event
  66840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66841. */
  66842. export class PhysicsRadialExplosionEventOptions {
  66843. /**
  66844. * The radius of the sphere for the radial explosion.
  66845. */
  66846. radius: number;
  66847. /**
  66848. * The strenth of the explosion.
  66849. */
  66850. strength: number;
  66851. /**
  66852. * The strenght of the force in correspondence to the distance of the affected object
  66853. */
  66854. falloff: PhysicsRadialImpulseFalloff;
  66855. /**
  66856. * Sphere options for the radial explosion.
  66857. */
  66858. sphere: {
  66859. segments: number;
  66860. diameter: number;
  66861. };
  66862. /**
  66863. * Sphere options for the radial explosion.
  66864. */
  66865. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66866. }
  66867. /**
  66868. * Options fot the updraft event
  66869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66870. */
  66871. export class PhysicsUpdraftEventOptions {
  66872. /**
  66873. * The radius of the cylinder for the vortex
  66874. */
  66875. radius: number;
  66876. /**
  66877. * The strenth of the updraft.
  66878. */
  66879. strength: number;
  66880. /**
  66881. * The height of the cylinder for the updraft.
  66882. */
  66883. height: number;
  66884. /**
  66885. * The mode for the the updraft.
  66886. */
  66887. updraftMode: PhysicsUpdraftMode;
  66888. }
  66889. /**
  66890. * Options fot the vortex event
  66891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66892. */
  66893. export class PhysicsVortexEventOptions {
  66894. /**
  66895. * The radius of the cylinder for the vortex
  66896. */
  66897. radius: number;
  66898. /**
  66899. * The strenth of the vortex.
  66900. */
  66901. strength: number;
  66902. /**
  66903. * The height of the cylinder for the vortex.
  66904. */
  66905. height: number;
  66906. /**
  66907. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66908. */
  66909. centripetalForceThreshold: number;
  66910. /**
  66911. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66912. */
  66913. centripetalForceMultiplier: number;
  66914. /**
  66915. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66916. */
  66917. centrifugalForceMultiplier: number;
  66918. /**
  66919. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66920. */
  66921. updraftForceMultiplier: number;
  66922. }
  66923. /**
  66924. * The strenght of the force in correspondence to the distance of the affected object
  66925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66926. */
  66927. export enum PhysicsRadialImpulseFalloff {
  66928. /** Defines that impulse is constant in strength across it's whole radius */
  66929. Constant = 0,
  66930. /** Defines that impulse gets weaker if it's further from the origin */
  66931. Linear = 1
  66932. }
  66933. /**
  66934. * The strength of the force in correspondence to the distance of the affected object
  66935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66936. */
  66937. export enum PhysicsUpdraftMode {
  66938. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66939. Center = 0,
  66940. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66941. Perpendicular = 1
  66942. }
  66943. /**
  66944. * Interface for a physics hit data
  66945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66946. */
  66947. export interface PhysicsHitData {
  66948. /**
  66949. * The force applied at the contact point
  66950. */
  66951. force: Vector3;
  66952. /**
  66953. * The contact point
  66954. */
  66955. contactPoint: Vector3;
  66956. /**
  66957. * The distance from the origin to the contact point
  66958. */
  66959. distanceFromOrigin: number;
  66960. }
  66961. /**
  66962. * Interface for radial explosion event data
  66963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66964. */
  66965. export interface PhysicsRadialExplosionEventData {
  66966. /**
  66967. * A sphere used for the radial explosion event
  66968. */
  66969. sphere: Mesh;
  66970. }
  66971. /**
  66972. * Interface for gravitational field event data
  66973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66974. */
  66975. export interface PhysicsGravitationalFieldEventData {
  66976. /**
  66977. * A sphere mesh used for the gravitational field event
  66978. */
  66979. sphere: Mesh;
  66980. }
  66981. /**
  66982. * Interface for updraft event data
  66983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66984. */
  66985. export interface PhysicsUpdraftEventData {
  66986. /**
  66987. * A cylinder used for the updraft event
  66988. */
  66989. cylinder: Mesh;
  66990. }
  66991. /**
  66992. * Interface for vortex event data
  66993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66994. */
  66995. export interface PhysicsVortexEventData {
  66996. /**
  66997. * A cylinder used for the vortex event
  66998. */
  66999. cylinder: Mesh;
  67000. }
  67001. /**
  67002. * Interface for an affected physics impostor
  67003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67004. */
  67005. export interface PhysicsAffectedImpostorWithData {
  67006. /**
  67007. * The impostor affected by the effect
  67008. */
  67009. impostor: PhysicsImpostor;
  67010. /**
  67011. * The data about the hit/horce from the explosion
  67012. */
  67013. hitData: PhysicsHitData;
  67014. }
  67015. }
  67016. declare module "babylonjs/Physics/Plugins/index" {
  67017. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67018. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67019. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67020. }
  67021. declare module "babylonjs/Physics/index" {
  67022. export * from "babylonjs/Physics/IPhysicsEngine";
  67023. export * from "babylonjs/Physics/physicsEngine";
  67024. export * from "babylonjs/Physics/physicsEngineComponent";
  67025. export * from "babylonjs/Physics/physicsHelper";
  67026. export * from "babylonjs/Physics/physicsImpostor";
  67027. export * from "babylonjs/Physics/physicsJoint";
  67028. export * from "babylonjs/Physics/Plugins/index";
  67029. }
  67030. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67031. /** @hidden */
  67032. export var blackAndWhitePixelShader: {
  67033. name: string;
  67034. shader: string;
  67035. };
  67036. }
  67037. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67038. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67039. import { Camera } from "babylonjs/Cameras/camera";
  67040. import { Engine } from "babylonjs/Engines/engine";
  67041. import "babylonjs/Shaders/blackAndWhite.fragment";
  67042. /**
  67043. * Post process used to render in black and white
  67044. */
  67045. export class BlackAndWhitePostProcess extends PostProcess {
  67046. /**
  67047. * Linear about to convert he result to black and white (default: 1)
  67048. */
  67049. degree: number;
  67050. /**
  67051. * Creates a black and white post process
  67052. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67053. * @param name The name of the effect.
  67054. * @param options The required width/height ratio to downsize to before computing the render pass.
  67055. * @param camera The camera to apply the render pass to.
  67056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67057. * @param engine The engine which the post process will be applied. (default: current engine)
  67058. * @param reusable If the post process can be reused on the same frame. (default: false)
  67059. */
  67060. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67061. }
  67062. }
  67063. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67064. import { Nullable } from "babylonjs/types";
  67065. import { Camera } from "babylonjs/Cameras/camera";
  67066. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67067. import { Engine } from "babylonjs/Engines/engine";
  67068. /**
  67069. * This represents a set of one or more post processes in Babylon.
  67070. * A post process can be used to apply a shader to a texture after it is rendered.
  67071. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67072. */
  67073. export class PostProcessRenderEffect {
  67074. private _postProcesses;
  67075. private _getPostProcesses;
  67076. private _singleInstance;
  67077. private _cameras;
  67078. private _indicesForCamera;
  67079. /**
  67080. * Name of the effect
  67081. * @hidden
  67082. */
  67083. _name: string;
  67084. /**
  67085. * Instantiates a post process render effect.
  67086. * A post process can be used to apply a shader to a texture after it is rendered.
  67087. * @param engine The engine the effect is tied to
  67088. * @param name The name of the effect
  67089. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67090. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67091. */
  67092. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67093. /**
  67094. * Checks if all the post processes in the effect are supported.
  67095. */
  67096. get isSupported(): boolean;
  67097. /**
  67098. * Updates the current state of the effect
  67099. * @hidden
  67100. */
  67101. _update(): void;
  67102. /**
  67103. * Attaches the effect on cameras
  67104. * @param cameras The camera to attach to.
  67105. * @hidden
  67106. */
  67107. _attachCameras(cameras: Camera): void;
  67108. /**
  67109. * Attaches the effect on cameras
  67110. * @param cameras The camera to attach to.
  67111. * @hidden
  67112. */
  67113. _attachCameras(cameras: Camera[]): void;
  67114. /**
  67115. * Detaches the effect on cameras
  67116. * @param cameras The camera to detatch from.
  67117. * @hidden
  67118. */
  67119. _detachCameras(cameras: Camera): void;
  67120. /**
  67121. * Detatches the effect on cameras
  67122. * @param cameras The camera to detatch from.
  67123. * @hidden
  67124. */
  67125. _detachCameras(cameras: Camera[]): void;
  67126. /**
  67127. * Enables the effect on given cameras
  67128. * @param cameras The camera to enable.
  67129. * @hidden
  67130. */
  67131. _enable(cameras: Camera): void;
  67132. /**
  67133. * Enables the effect on given cameras
  67134. * @param cameras The camera to enable.
  67135. * @hidden
  67136. */
  67137. _enable(cameras: Nullable<Camera[]>): void;
  67138. /**
  67139. * Disables the effect on the given cameras
  67140. * @param cameras The camera to disable.
  67141. * @hidden
  67142. */
  67143. _disable(cameras: Camera): void;
  67144. /**
  67145. * Disables the effect on the given cameras
  67146. * @param cameras The camera to disable.
  67147. * @hidden
  67148. */
  67149. _disable(cameras: Nullable<Camera[]>): void;
  67150. /**
  67151. * Gets a list of the post processes contained in the effect.
  67152. * @param camera The camera to get the post processes on.
  67153. * @returns The list of the post processes in the effect.
  67154. */
  67155. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67156. }
  67157. }
  67158. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67160. /** @hidden */
  67161. export var extractHighlightsPixelShader: {
  67162. name: string;
  67163. shader: string;
  67164. };
  67165. }
  67166. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67167. import { Nullable } from "babylonjs/types";
  67168. import { Camera } from "babylonjs/Cameras/camera";
  67169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67170. import { Engine } from "babylonjs/Engines/engine";
  67171. import "babylonjs/Shaders/extractHighlights.fragment";
  67172. /**
  67173. * 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.
  67174. */
  67175. export class ExtractHighlightsPostProcess extends PostProcess {
  67176. /**
  67177. * The luminance threshold, pixels below this value will be set to black.
  67178. */
  67179. threshold: number;
  67180. /** @hidden */
  67181. _exposure: number;
  67182. /**
  67183. * Post process which has the input texture to be used when performing highlight extraction
  67184. * @hidden
  67185. */
  67186. _inputPostProcess: Nullable<PostProcess>;
  67187. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67188. }
  67189. }
  67190. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67191. /** @hidden */
  67192. export var bloomMergePixelShader: {
  67193. name: string;
  67194. shader: string;
  67195. };
  67196. }
  67197. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67199. import { Nullable } from "babylonjs/types";
  67200. import { Engine } from "babylonjs/Engines/engine";
  67201. import { Camera } from "babylonjs/Cameras/camera";
  67202. import "babylonjs/Shaders/bloomMerge.fragment";
  67203. /**
  67204. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67205. */
  67206. export class BloomMergePostProcess extends PostProcess {
  67207. /** Weight of the bloom to be added to the original input. */
  67208. weight: number;
  67209. /**
  67210. * Creates a new instance of @see BloomMergePostProcess
  67211. * @param name The name of the effect.
  67212. * @param originalFromInput Post process which's input will be used for the merge.
  67213. * @param blurred Blurred highlights post process which's output will be used.
  67214. * @param weight Weight of the bloom to be added to the original input.
  67215. * @param options The required width/height ratio to downsize to before computing the render pass.
  67216. * @param camera The camera to apply the render pass to.
  67217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67218. * @param engine The engine which the post process will be applied. (default: current engine)
  67219. * @param reusable If the post process can be reused on the same frame. (default: false)
  67220. * @param textureType Type of textures used when performing the post process. (default: 0)
  67221. * @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)
  67222. */
  67223. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67224. /** Weight of the bloom to be added to the original input. */
  67225. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67226. }
  67227. }
  67228. declare module "babylonjs/PostProcesses/bloomEffect" {
  67229. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67231. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67232. import { Camera } from "babylonjs/Cameras/camera";
  67233. import { Scene } from "babylonjs/scene";
  67234. /**
  67235. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67236. */
  67237. export class BloomEffect extends PostProcessRenderEffect {
  67238. private bloomScale;
  67239. /**
  67240. * @hidden Internal
  67241. */
  67242. _effects: Array<PostProcess>;
  67243. /**
  67244. * @hidden Internal
  67245. */
  67246. _downscale: ExtractHighlightsPostProcess;
  67247. private _blurX;
  67248. private _blurY;
  67249. private _merge;
  67250. /**
  67251. * The luminance threshold to find bright areas of the image to bloom.
  67252. */
  67253. get threshold(): number;
  67254. set threshold(value: number);
  67255. /**
  67256. * The strength of the bloom.
  67257. */
  67258. get weight(): number;
  67259. set weight(value: number);
  67260. /**
  67261. * Specifies the size of the bloom blur kernel, relative to the final output size
  67262. */
  67263. get kernel(): number;
  67264. set kernel(value: number);
  67265. /**
  67266. * Creates a new instance of @see BloomEffect
  67267. * @param scene The scene the effect belongs to.
  67268. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67269. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67270. * @param bloomWeight The the strength of bloom.
  67271. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67272. * @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)
  67273. */
  67274. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67275. /**
  67276. * Disposes each of the internal effects for a given camera.
  67277. * @param camera The camera to dispose the effect on.
  67278. */
  67279. disposeEffects(camera: Camera): void;
  67280. /**
  67281. * @hidden Internal
  67282. */
  67283. _updateEffects(): void;
  67284. /**
  67285. * Internal
  67286. * @returns if all the contained post processes are ready.
  67287. * @hidden
  67288. */
  67289. _isReady(): boolean;
  67290. }
  67291. }
  67292. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67293. /** @hidden */
  67294. export var chromaticAberrationPixelShader: {
  67295. name: string;
  67296. shader: string;
  67297. };
  67298. }
  67299. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67300. import { Vector2 } from "babylonjs/Maths/math.vector";
  67301. import { Nullable } from "babylonjs/types";
  67302. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67303. import { Camera } from "babylonjs/Cameras/camera";
  67304. import { Engine } from "babylonjs/Engines/engine";
  67305. import "babylonjs/Shaders/chromaticAberration.fragment";
  67306. /**
  67307. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67308. */
  67309. export class ChromaticAberrationPostProcess extends PostProcess {
  67310. /**
  67311. * The amount of seperation of rgb channels (default: 30)
  67312. */
  67313. aberrationAmount: number;
  67314. /**
  67315. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67316. */
  67317. radialIntensity: number;
  67318. /**
  67319. * 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))
  67320. */
  67321. direction: Vector2;
  67322. /**
  67323. * 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))
  67324. */
  67325. centerPosition: Vector2;
  67326. /**
  67327. * Creates a new instance ChromaticAberrationPostProcess
  67328. * @param name The name of the effect.
  67329. * @param screenWidth The width of the screen to apply the effect on.
  67330. * @param screenHeight The height of the screen to apply the effect on.
  67331. * @param options The required width/height ratio to downsize to before computing the render pass.
  67332. * @param camera The camera to apply the render pass to.
  67333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67334. * @param engine The engine which the post process will be applied. (default: current engine)
  67335. * @param reusable If the post process can be reused on the same frame. (default: false)
  67336. * @param textureType Type of textures used when performing the post process. (default: 0)
  67337. * @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)
  67338. */
  67339. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67340. }
  67341. }
  67342. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67343. /** @hidden */
  67344. export var circleOfConfusionPixelShader: {
  67345. name: string;
  67346. shader: string;
  67347. };
  67348. }
  67349. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67350. import { Nullable } from "babylonjs/types";
  67351. import { Engine } from "babylonjs/Engines/engine";
  67352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67354. import { Camera } from "babylonjs/Cameras/camera";
  67355. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67356. /**
  67357. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67358. */
  67359. export class CircleOfConfusionPostProcess extends PostProcess {
  67360. /**
  67361. * 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.
  67362. */
  67363. lensSize: number;
  67364. /**
  67365. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67366. */
  67367. fStop: number;
  67368. /**
  67369. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67370. */
  67371. focusDistance: number;
  67372. /**
  67373. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67374. */
  67375. focalLength: number;
  67376. private _depthTexture;
  67377. /**
  67378. * Creates a new instance CircleOfConfusionPostProcess
  67379. * @param name The name of the effect.
  67380. * @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.
  67381. * @param options The required width/height ratio to downsize to before computing the render pass.
  67382. * @param camera The camera to apply the render pass to.
  67383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67384. * @param engine The engine which the post process will be applied. (default: current engine)
  67385. * @param reusable If the post process can be reused on the same frame. (default: false)
  67386. * @param textureType Type of textures used when performing the post process. (default: 0)
  67387. * @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)
  67388. */
  67389. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67390. /**
  67391. * 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.
  67392. */
  67393. set depthTexture(value: RenderTargetTexture);
  67394. }
  67395. }
  67396. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67397. /** @hidden */
  67398. export var colorCorrectionPixelShader: {
  67399. name: string;
  67400. shader: string;
  67401. };
  67402. }
  67403. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67404. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67405. import { Engine } from "babylonjs/Engines/engine";
  67406. import { Camera } from "babylonjs/Cameras/camera";
  67407. import "babylonjs/Shaders/colorCorrection.fragment";
  67408. /**
  67409. *
  67410. * This post-process allows the modification of rendered colors by using
  67411. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67412. *
  67413. * The object needs to be provided an url to a texture containing the color
  67414. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67415. * Use an image editing software to tweak the LUT to match your needs.
  67416. *
  67417. * For an example of a color LUT, see here:
  67418. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67419. * For explanations on color grading, see here:
  67420. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67421. *
  67422. */
  67423. export class ColorCorrectionPostProcess extends PostProcess {
  67424. private _colorTableTexture;
  67425. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67426. }
  67427. }
  67428. declare module "babylonjs/Shaders/convolution.fragment" {
  67429. /** @hidden */
  67430. export var convolutionPixelShader: {
  67431. name: string;
  67432. shader: string;
  67433. };
  67434. }
  67435. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67436. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67437. import { Nullable } from "babylonjs/types";
  67438. import { Camera } from "babylonjs/Cameras/camera";
  67439. import { Engine } from "babylonjs/Engines/engine";
  67440. import "babylonjs/Shaders/convolution.fragment";
  67441. /**
  67442. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67443. * input texture to perform effects such as edge detection or sharpening
  67444. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67445. */
  67446. export class ConvolutionPostProcess extends PostProcess {
  67447. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67448. kernel: number[];
  67449. /**
  67450. * Creates a new instance ConvolutionPostProcess
  67451. * @param name The name of the effect.
  67452. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67453. * @param options The required width/height ratio to downsize to before computing the render pass.
  67454. * @param camera The camera to apply the render pass to.
  67455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67456. * @param engine The engine which the post process will be applied. (default: current engine)
  67457. * @param reusable If the post process can be reused on the same frame. (default: false)
  67458. * @param textureType Type of textures used when performing the post process. (default: 0)
  67459. */
  67460. constructor(name: string,
  67461. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67462. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67463. /**
  67464. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67465. */
  67466. static EdgeDetect0Kernel: number[];
  67467. /**
  67468. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67469. */
  67470. static EdgeDetect1Kernel: number[];
  67471. /**
  67472. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67473. */
  67474. static EdgeDetect2Kernel: number[];
  67475. /**
  67476. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67477. */
  67478. static SharpenKernel: number[];
  67479. /**
  67480. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67481. */
  67482. static EmbossKernel: number[];
  67483. /**
  67484. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67485. */
  67486. static GaussianKernel: number[];
  67487. }
  67488. }
  67489. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67490. import { Nullable } from "babylonjs/types";
  67491. import { Vector2 } from "babylonjs/Maths/math.vector";
  67492. import { Camera } from "babylonjs/Cameras/camera";
  67493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67494. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67495. import { Engine } from "babylonjs/Engines/engine";
  67496. import { Scene } from "babylonjs/scene";
  67497. /**
  67498. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67499. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67500. * based on samples that have a large difference in distance than the center pixel.
  67501. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67502. */
  67503. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67504. direction: Vector2;
  67505. /**
  67506. * Creates a new instance CircleOfConfusionPostProcess
  67507. * @param name The name of the effect.
  67508. * @param scene The scene the effect belongs to.
  67509. * @param direction The direction the blur should be applied.
  67510. * @param kernel The size of the kernel used to blur.
  67511. * @param options The required width/height ratio to downsize to before computing the render pass.
  67512. * @param camera The camera to apply the render pass to.
  67513. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67514. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67516. * @param engine The engine which the post process will be applied. (default: current engine)
  67517. * @param reusable If the post process can be reused on the same frame. (default: false)
  67518. * @param textureType Type of textures used when performing the post process. (default: 0)
  67519. * @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)
  67520. */
  67521. 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);
  67522. }
  67523. }
  67524. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67525. /** @hidden */
  67526. export var depthOfFieldMergePixelShader: {
  67527. name: string;
  67528. shader: string;
  67529. };
  67530. }
  67531. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67532. import { Nullable } from "babylonjs/types";
  67533. import { Camera } from "babylonjs/Cameras/camera";
  67534. import { Effect } from "babylonjs/Materials/effect";
  67535. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67536. import { Engine } from "babylonjs/Engines/engine";
  67537. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67538. /**
  67539. * Options to be set when merging outputs from the default pipeline.
  67540. */
  67541. export class DepthOfFieldMergePostProcessOptions {
  67542. /**
  67543. * The original image to merge on top of
  67544. */
  67545. originalFromInput: PostProcess;
  67546. /**
  67547. * Parameters to perform the merge of the depth of field effect
  67548. */
  67549. depthOfField?: {
  67550. circleOfConfusion: PostProcess;
  67551. blurSteps: Array<PostProcess>;
  67552. };
  67553. /**
  67554. * Parameters to perform the merge of bloom effect
  67555. */
  67556. bloom?: {
  67557. blurred: PostProcess;
  67558. weight: number;
  67559. };
  67560. }
  67561. /**
  67562. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67563. */
  67564. export class DepthOfFieldMergePostProcess extends PostProcess {
  67565. private blurSteps;
  67566. /**
  67567. * Creates a new instance of DepthOfFieldMergePostProcess
  67568. * @param name The name of the effect.
  67569. * @param originalFromInput Post process which's input will be used for the merge.
  67570. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67571. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67572. * @param options The required width/height ratio to downsize to before computing the render pass.
  67573. * @param camera The camera to apply the render pass to.
  67574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67575. * @param engine The engine which the post process will be applied. (default: current engine)
  67576. * @param reusable If the post process can be reused on the same frame. (default: false)
  67577. * @param textureType Type of textures used when performing the post process. (default: 0)
  67578. * @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)
  67579. */
  67580. 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);
  67581. /**
  67582. * Updates the effect with the current post process compile time values and recompiles the shader.
  67583. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67584. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67585. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67586. * @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
  67587. * @param onCompiled Called when the shader has been compiled.
  67588. * @param onError Called if there is an error when compiling a shader.
  67589. */
  67590. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67591. }
  67592. }
  67593. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67594. import { Nullable } from "babylonjs/types";
  67595. import { Camera } from "babylonjs/Cameras/camera";
  67596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67598. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67599. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67600. import { Scene } from "babylonjs/scene";
  67601. /**
  67602. * Specifies the level of max blur that should be applied when using the depth of field effect
  67603. */
  67604. export enum DepthOfFieldEffectBlurLevel {
  67605. /**
  67606. * Subtle blur
  67607. */
  67608. Low = 0,
  67609. /**
  67610. * Medium blur
  67611. */
  67612. Medium = 1,
  67613. /**
  67614. * Large blur
  67615. */
  67616. High = 2
  67617. }
  67618. /**
  67619. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67620. */
  67621. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67622. private _circleOfConfusion;
  67623. /**
  67624. * @hidden Internal, blurs from high to low
  67625. */
  67626. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67627. private _depthOfFieldBlurY;
  67628. private _dofMerge;
  67629. /**
  67630. * @hidden Internal post processes in depth of field effect
  67631. */
  67632. _effects: Array<PostProcess>;
  67633. /**
  67634. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67635. */
  67636. set focalLength(value: number);
  67637. get focalLength(): number;
  67638. /**
  67639. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67640. */
  67641. set fStop(value: number);
  67642. get fStop(): number;
  67643. /**
  67644. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67645. */
  67646. set focusDistance(value: number);
  67647. get focusDistance(): number;
  67648. /**
  67649. * 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.
  67650. */
  67651. set lensSize(value: number);
  67652. get lensSize(): number;
  67653. /**
  67654. * Creates a new instance DepthOfFieldEffect
  67655. * @param scene The scene the effect belongs to.
  67656. * @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.
  67657. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67658. * @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)
  67659. */
  67660. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67661. /**
  67662. * Get the current class name of the current effet
  67663. * @returns "DepthOfFieldEffect"
  67664. */
  67665. getClassName(): string;
  67666. /**
  67667. * 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.
  67668. */
  67669. set depthTexture(value: RenderTargetTexture);
  67670. /**
  67671. * Disposes each of the internal effects for a given camera.
  67672. * @param camera The camera to dispose the effect on.
  67673. */
  67674. disposeEffects(camera: Camera): void;
  67675. /**
  67676. * @hidden Internal
  67677. */
  67678. _updateEffects(): void;
  67679. /**
  67680. * Internal
  67681. * @returns if all the contained post processes are ready.
  67682. * @hidden
  67683. */
  67684. _isReady(): boolean;
  67685. }
  67686. }
  67687. declare module "babylonjs/Shaders/displayPass.fragment" {
  67688. /** @hidden */
  67689. export var displayPassPixelShader: {
  67690. name: string;
  67691. shader: string;
  67692. };
  67693. }
  67694. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67695. import { Nullable } from "babylonjs/types";
  67696. import { Camera } from "babylonjs/Cameras/camera";
  67697. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67698. import { Engine } from "babylonjs/Engines/engine";
  67699. import "babylonjs/Shaders/displayPass.fragment";
  67700. /**
  67701. * DisplayPassPostProcess which produces an output the same as it's input
  67702. */
  67703. export class DisplayPassPostProcess extends PostProcess {
  67704. /**
  67705. * Creates the DisplayPassPostProcess
  67706. * @param name The name of the effect.
  67707. * @param options The required width/height ratio to downsize to before computing the render pass.
  67708. * @param camera The camera to apply the render pass to.
  67709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67710. * @param engine The engine which the post process will be applied. (default: current engine)
  67711. * @param reusable If the post process can be reused on the same frame. (default: false)
  67712. */
  67713. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67714. }
  67715. }
  67716. declare module "babylonjs/Shaders/filter.fragment" {
  67717. /** @hidden */
  67718. export var filterPixelShader: {
  67719. name: string;
  67720. shader: string;
  67721. };
  67722. }
  67723. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67724. import { Nullable } from "babylonjs/types";
  67725. import { Matrix } from "babylonjs/Maths/math.vector";
  67726. import { Camera } from "babylonjs/Cameras/camera";
  67727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67728. import { Engine } from "babylonjs/Engines/engine";
  67729. import "babylonjs/Shaders/filter.fragment";
  67730. /**
  67731. * Applies a kernel filter to the image
  67732. */
  67733. export class FilterPostProcess extends PostProcess {
  67734. /** The matrix to be applied to the image */
  67735. kernelMatrix: Matrix;
  67736. /**
  67737. *
  67738. * @param name The name of the effect.
  67739. * @param kernelMatrix The matrix to be applied to the image
  67740. * @param options The required width/height ratio to downsize to before computing the render pass.
  67741. * @param camera The camera to apply the render pass to.
  67742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67743. * @param engine The engine which the post process will be applied. (default: current engine)
  67744. * @param reusable If the post process can be reused on the same frame. (default: false)
  67745. */
  67746. constructor(name: string,
  67747. /** The matrix to be applied to the image */
  67748. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67749. }
  67750. }
  67751. declare module "babylonjs/Shaders/fxaa.fragment" {
  67752. /** @hidden */
  67753. export var fxaaPixelShader: {
  67754. name: string;
  67755. shader: string;
  67756. };
  67757. }
  67758. declare module "babylonjs/Shaders/fxaa.vertex" {
  67759. /** @hidden */
  67760. export var fxaaVertexShader: {
  67761. name: string;
  67762. shader: string;
  67763. };
  67764. }
  67765. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67766. import { Nullable } from "babylonjs/types";
  67767. import { Camera } from "babylonjs/Cameras/camera";
  67768. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67769. import { Engine } from "babylonjs/Engines/engine";
  67770. import "babylonjs/Shaders/fxaa.fragment";
  67771. import "babylonjs/Shaders/fxaa.vertex";
  67772. /**
  67773. * Fxaa post process
  67774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67775. */
  67776. export class FxaaPostProcess extends PostProcess {
  67777. /** @hidden */
  67778. texelWidth: number;
  67779. /** @hidden */
  67780. texelHeight: number;
  67781. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67782. private _getDefines;
  67783. }
  67784. }
  67785. declare module "babylonjs/Shaders/grain.fragment" {
  67786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67787. /** @hidden */
  67788. export var grainPixelShader: {
  67789. name: string;
  67790. shader: string;
  67791. };
  67792. }
  67793. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67794. import { Nullable } from "babylonjs/types";
  67795. import { Camera } from "babylonjs/Cameras/camera";
  67796. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67797. import { Engine } from "babylonjs/Engines/engine";
  67798. import "babylonjs/Shaders/grain.fragment";
  67799. /**
  67800. * The GrainPostProcess adds noise to the image at mid luminance levels
  67801. */
  67802. export class GrainPostProcess extends PostProcess {
  67803. /**
  67804. * The intensity of the grain added (default: 30)
  67805. */
  67806. intensity: number;
  67807. /**
  67808. * If the grain should be randomized on every frame
  67809. */
  67810. animated: boolean;
  67811. /**
  67812. * Creates a new instance of @see GrainPostProcess
  67813. * @param name The name of the effect.
  67814. * @param options The required width/height ratio to downsize to before computing the render pass.
  67815. * @param camera The camera to apply the render pass to.
  67816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67817. * @param engine The engine which the post process will be applied. (default: current engine)
  67818. * @param reusable If the post process can be reused on the same frame. (default: false)
  67819. * @param textureType Type of textures used when performing the post process. (default: 0)
  67820. * @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)
  67821. */
  67822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67823. }
  67824. }
  67825. declare module "babylonjs/Shaders/highlights.fragment" {
  67826. /** @hidden */
  67827. export var highlightsPixelShader: {
  67828. name: string;
  67829. shader: string;
  67830. };
  67831. }
  67832. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67833. import { Nullable } from "babylonjs/types";
  67834. import { Camera } from "babylonjs/Cameras/camera";
  67835. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67836. import { Engine } from "babylonjs/Engines/engine";
  67837. import "babylonjs/Shaders/highlights.fragment";
  67838. /**
  67839. * Extracts highlights from the image
  67840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67841. */
  67842. export class HighlightsPostProcess extends PostProcess {
  67843. /**
  67844. * Extracts highlights from the image
  67845. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67846. * @param name The name of the effect.
  67847. * @param options The required width/height ratio to downsize to before computing the render pass.
  67848. * @param camera The camera to apply the render pass to.
  67849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67850. * @param engine The engine which the post process will be applied. (default: current engine)
  67851. * @param reusable If the post process can be reused on the same frame. (default: false)
  67852. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67853. */
  67854. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67855. }
  67856. }
  67857. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67858. /** @hidden */
  67859. export var mrtFragmentDeclaration: {
  67860. name: string;
  67861. shader: string;
  67862. };
  67863. }
  67864. declare module "babylonjs/Shaders/geometry.fragment" {
  67865. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67866. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67867. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67868. /** @hidden */
  67869. export var geometryPixelShader: {
  67870. name: string;
  67871. shader: string;
  67872. };
  67873. }
  67874. declare module "babylonjs/Shaders/geometry.vertex" {
  67875. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67876. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67877. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67878. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67879. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67880. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67881. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67882. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67883. /** @hidden */
  67884. export var geometryVertexShader: {
  67885. name: string;
  67886. shader: string;
  67887. };
  67888. }
  67889. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67890. import { Matrix } from "babylonjs/Maths/math.vector";
  67891. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67892. import { Mesh } from "babylonjs/Meshes/mesh";
  67893. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67894. import { Effect } from "babylonjs/Materials/effect";
  67895. import { Scene } from "babylonjs/scene";
  67896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67897. import "babylonjs/Shaders/geometry.fragment";
  67898. import "babylonjs/Shaders/geometry.vertex";
  67899. /** @hidden */
  67900. interface ISavedTransformationMatrix {
  67901. world: Matrix;
  67902. viewProjection: Matrix;
  67903. }
  67904. /**
  67905. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67906. */
  67907. export class GeometryBufferRenderer {
  67908. /**
  67909. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67910. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67911. */
  67912. static readonly POSITION_TEXTURE_TYPE: number;
  67913. /**
  67914. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67915. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67916. */
  67917. static readonly VELOCITY_TEXTURE_TYPE: number;
  67918. /**
  67919. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67920. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67921. */
  67922. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67923. /**
  67924. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67925. * in order to compute objects velocities when enableVelocity is set to "true"
  67926. * @hidden
  67927. */
  67928. _previousTransformationMatrices: {
  67929. [index: number]: ISavedTransformationMatrix;
  67930. };
  67931. /**
  67932. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67933. * in order to compute objects velocities when enableVelocity is set to "true"
  67934. * @hidden
  67935. */
  67936. _previousBonesTransformationMatrices: {
  67937. [index: number]: Float32Array;
  67938. };
  67939. /**
  67940. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67941. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67942. */
  67943. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67944. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67945. renderTransparentMeshes: boolean;
  67946. private _scene;
  67947. private _multiRenderTarget;
  67948. private _ratio;
  67949. private _enablePosition;
  67950. private _enableVelocity;
  67951. private _enableReflectivity;
  67952. private _positionIndex;
  67953. private _velocityIndex;
  67954. private _reflectivityIndex;
  67955. protected _effect: Effect;
  67956. protected _cachedDefines: string;
  67957. /**
  67958. * Set the render list (meshes to be rendered) used in the G buffer.
  67959. */
  67960. set renderList(meshes: Mesh[]);
  67961. /**
  67962. * Gets wether or not G buffer are supported by the running hardware.
  67963. * This requires draw buffer supports
  67964. */
  67965. get isSupported(): boolean;
  67966. /**
  67967. * Returns the index of the given texture type in the G-Buffer textures array
  67968. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67969. * @returns the index of the given texture type in the G-Buffer textures array
  67970. */
  67971. getTextureIndex(textureType: number): number;
  67972. /**
  67973. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67974. */
  67975. get enablePosition(): boolean;
  67976. /**
  67977. * Sets whether or not objects positions are enabled for the G buffer.
  67978. */
  67979. set enablePosition(enable: boolean);
  67980. /**
  67981. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67982. */
  67983. get enableVelocity(): boolean;
  67984. /**
  67985. * Sets wether or not objects velocities are enabled for the G buffer.
  67986. */
  67987. set enableVelocity(enable: boolean);
  67988. /**
  67989. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67990. */
  67991. get enableReflectivity(): boolean;
  67992. /**
  67993. * Sets wether or not objects roughness are enabled for the G buffer.
  67994. */
  67995. set enableReflectivity(enable: boolean);
  67996. /**
  67997. * Gets the scene associated with the buffer.
  67998. */
  67999. get scene(): Scene;
  68000. /**
  68001. * Gets the ratio used by the buffer during its creation.
  68002. * How big is the buffer related to the main canvas.
  68003. */
  68004. get ratio(): number;
  68005. /** @hidden */
  68006. static _SceneComponentInitialization: (scene: Scene) => void;
  68007. /**
  68008. * Creates a new G Buffer for the scene
  68009. * @param scene The scene the buffer belongs to
  68010. * @param ratio How big is the buffer related to the main canvas.
  68011. */
  68012. constructor(scene: Scene, ratio?: number);
  68013. /**
  68014. * Checks wether everything is ready to render a submesh to the G buffer.
  68015. * @param subMesh the submesh to check readiness for
  68016. * @param useInstances is the mesh drawn using instance or not
  68017. * @returns true if ready otherwise false
  68018. */
  68019. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68020. /**
  68021. * Gets the current underlying G Buffer.
  68022. * @returns the buffer
  68023. */
  68024. getGBuffer(): MultiRenderTarget;
  68025. /**
  68026. * Gets the number of samples used to render the buffer (anti aliasing).
  68027. */
  68028. get samples(): number;
  68029. /**
  68030. * Sets the number of samples used to render the buffer (anti aliasing).
  68031. */
  68032. set samples(value: number);
  68033. /**
  68034. * Disposes the renderer and frees up associated resources.
  68035. */
  68036. dispose(): void;
  68037. protected _createRenderTargets(): void;
  68038. private _copyBonesTransformationMatrices;
  68039. }
  68040. }
  68041. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68042. import { Nullable } from "babylonjs/types";
  68043. import { Scene } from "babylonjs/scene";
  68044. import { ISceneComponent } from "babylonjs/sceneComponent";
  68045. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68046. module "babylonjs/scene" {
  68047. interface Scene {
  68048. /** @hidden (Backing field) */
  68049. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68050. /**
  68051. * Gets or Sets the current geometry buffer associated to the scene.
  68052. */
  68053. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68054. /**
  68055. * Enables a GeometryBufferRender and associates it with the scene
  68056. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68057. * @returns the GeometryBufferRenderer
  68058. */
  68059. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68060. /**
  68061. * Disables the GeometryBufferRender associated with the scene
  68062. */
  68063. disableGeometryBufferRenderer(): void;
  68064. }
  68065. }
  68066. /**
  68067. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68068. * in several rendering techniques.
  68069. */
  68070. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68071. /**
  68072. * The component name helpful to identify the component in the list of scene components.
  68073. */
  68074. readonly name: string;
  68075. /**
  68076. * The scene the component belongs to.
  68077. */
  68078. scene: Scene;
  68079. /**
  68080. * Creates a new instance of the component for the given scene
  68081. * @param scene Defines the scene to register the component in
  68082. */
  68083. constructor(scene: Scene);
  68084. /**
  68085. * Registers the component in a given scene
  68086. */
  68087. register(): void;
  68088. /**
  68089. * Rebuilds the elements related to this component in case of
  68090. * context lost for instance.
  68091. */
  68092. rebuild(): void;
  68093. /**
  68094. * Disposes the component and the associated ressources
  68095. */
  68096. dispose(): void;
  68097. private _gatherRenderTargets;
  68098. }
  68099. }
  68100. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68101. /** @hidden */
  68102. export var motionBlurPixelShader: {
  68103. name: string;
  68104. shader: string;
  68105. };
  68106. }
  68107. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68108. import { Nullable } from "babylonjs/types";
  68109. import { Camera } from "babylonjs/Cameras/camera";
  68110. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68111. import { Scene } from "babylonjs/scene";
  68112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68113. import "babylonjs/Animations/animatable";
  68114. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68115. import "babylonjs/Shaders/motionBlur.fragment";
  68116. import { Engine } from "babylonjs/Engines/engine";
  68117. /**
  68118. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68119. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68120. * As an example, all you have to do is to create the post-process:
  68121. * var mb = new BABYLON.MotionBlurPostProcess(
  68122. * 'mb', // The name of the effect.
  68123. * scene, // The scene containing the objects to blur according to their velocity.
  68124. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68125. * camera // The camera to apply the render pass to.
  68126. * );
  68127. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68128. */
  68129. export class MotionBlurPostProcess extends PostProcess {
  68130. /**
  68131. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68132. */
  68133. motionStrength: number;
  68134. /**
  68135. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68136. */
  68137. get motionBlurSamples(): number;
  68138. /**
  68139. * Sets the number of iterations to be used for motion blur quality
  68140. */
  68141. set motionBlurSamples(samples: number);
  68142. private _motionBlurSamples;
  68143. private _geometryBufferRenderer;
  68144. /**
  68145. * Creates a new instance MotionBlurPostProcess
  68146. * @param name The name of the effect.
  68147. * @param scene The scene containing the objects to blur according to their velocity.
  68148. * @param options The required width/height ratio to downsize to before computing the render pass.
  68149. * @param camera The camera to apply the render pass to.
  68150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68151. * @param engine The engine which the post process will be applied. (default: current engine)
  68152. * @param reusable If the post process can be reused on the same frame. (default: false)
  68153. * @param textureType Type of textures used when performing the post process. (default: 0)
  68154. * @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)
  68155. */
  68156. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68157. /**
  68158. * Excludes the given skinned mesh from computing bones velocities.
  68159. * 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.
  68160. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68161. */
  68162. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68163. /**
  68164. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68165. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68166. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68167. */
  68168. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68169. /**
  68170. * Disposes the post process.
  68171. * @param camera The camera to dispose the post process on.
  68172. */
  68173. dispose(camera?: Camera): void;
  68174. }
  68175. }
  68176. declare module "babylonjs/Shaders/refraction.fragment" {
  68177. /** @hidden */
  68178. export var refractionPixelShader: {
  68179. name: string;
  68180. shader: string;
  68181. };
  68182. }
  68183. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68184. import { Color3 } from "babylonjs/Maths/math.color";
  68185. import { Camera } from "babylonjs/Cameras/camera";
  68186. import { Texture } from "babylonjs/Materials/Textures/texture";
  68187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68188. import { Engine } from "babylonjs/Engines/engine";
  68189. import "babylonjs/Shaders/refraction.fragment";
  68190. /**
  68191. * Post process which applies a refractin texture
  68192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68193. */
  68194. export class RefractionPostProcess extends PostProcess {
  68195. /** the base color of the refraction (used to taint the rendering) */
  68196. color: Color3;
  68197. /** simulated refraction depth */
  68198. depth: number;
  68199. /** the coefficient of the base color (0 to remove base color tainting) */
  68200. colorLevel: number;
  68201. private _refTexture;
  68202. private _ownRefractionTexture;
  68203. /**
  68204. * Gets or sets the refraction texture
  68205. * Please note that you are responsible for disposing the texture if you set it manually
  68206. */
  68207. get refractionTexture(): Texture;
  68208. set refractionTexture(value: Texture);
  68209. /**
  68210. * Initializes the RefractionPostProcess
  68211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68212. * @param name The name of the effect.
  68213. * @param refractionTextureUrl Url of the refraction texture to use
  68214. * @param color the base color of the refraction (used to taint the rendering)
  68215. * @param depth simulated refraction depth
  68216. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68217. * @param camera The camera to apply the render pass to.
  68218. * @param options The required width/height ratio to downsize to before computing the render pass.
  68219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68220. * @param engine The engine which the post process will be applied. (default: current engine)
  68221. * @param reusable If the post process can be reused on the same frame. (default: false)
  68222. */
  68223. constructor(name: string, refractionTextureUrl: string,
  68224. /** the base color of the refraction (used to taint the rendering) */
  68225. color: Color3,
  68226. /** simulated refraction depth */
  68227. depth: number,
  68228. /** the coefficient of the base color (0 to remove base color tainting) */
  68229. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68230. /**
  68231. * Disposes of the post process
  68232. * @param camera Camera to dispose post process on
  68233. */
  68234. dispose(camera: Camera): void;
  68235. }
  68236. }
  68237. declare module "babylonjs/Shaders/sharpen.fragment" {
  68238. /** @hidden */
  68239. export var sharpenPixelShader: {
  68240. name: string;
  68241. shader: string;
  68242. };
  68243. }
  68244. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68245. import { Nullable } from "babylonjs/types";
  68246. import { Camera } from "babylonjs/Cameras/camera";
  68247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68248. import "babylonjs/Shaders/sharpen.fragment";
  68249. import { Engine } from "babylonjs/Engines/engine";
  68250. /**
  68251. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68252. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68253. */
  68254. export class SharpenPostProcess extends PostProcess {
  68255. /**
  68256. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68257. */
  68258. colorAmount: number;
  68259. /**
  68260. * How much sharpness should be applied (default: 0.3)
  68261. */
  68262. edgeAmount: number;
  68263. /**
  68264. * Creates a new instance ConvolutionPostProcess
  68265. * @param name The name of the effect.
  68266. * @param options The required width/height ratio to downsize to before computing the render pass.
  68267. * @param camera The camera to apply the render pass to.
  68268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68269. * @param engine The engine which the post process will be applied. (default: current engine)
  68270. * @param reusable If the post process can be reused on the same frame. (default: false)
  68271. * @param textureType Type of textures used when performing the post process. (default: 0)
  68272. * @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)
  68273. */
  68274. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68275. }
  68276. }
  68277. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68278. import { Nullable } from "babylonjs/types";
  68279. import { Camera } from "babylonjs/Cameras/camera";
  68280. import { Engine } from "babylonjs/Engines/engine";
  68281. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68283. /**
  68284. * PostProcessRenderPipeline
  68285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68286. */
  68287. export class PostProcessRenderPipeline {
  68288. private engine;
  68289. private _renderEffects;
  68290. private _renderEffectsForIsolatedPass;
  68291. /**
  68292. * List of inspectable custom properties (used by the Inspector)
  68293. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68294. */
  68295. inspectableCustomProperties: IInspectable[];
  68296. /**
  68297. * @hidden
  68298. */
  68299. protected _cameras: Camera[];
  68300. /** @hidden */
  68301. _name: string;
  68302. /**
  68303. * Gets pipeline name
  68304. */
  68305. get name(): string;
  68306. /** Gets the list of attached cameras */
  68307. get cameras(): Camera[];
  68308. /**
  68309. * Initializes a PostProcessRenderPipeline
  68310. * @param engine engine to add the pipeline to
  68311. * @param name name of the pipeline
  68312. */
  68313. constructor(engine: Engine, name: string);
  68314. /**
  68315. * Gets the class name
  68316. * @returns "PostProcessRenderPipeline"
  68317. */
  68318. getClassName(): string;
  68319. /**
  68320. * If all the render effects in the pipeline are supported
  68321. */
  68322. get isSupported(): boolean;
  68323. /**
  68324. * Adds an effect to the pipeline
  68325. * @param renderEffect the effect to add
  68326. */
  68327. addEffect(renderEffect: PostProcessRenderEffect): void;
  68328. /** @hidden */
  68329. _rebuild(): void;
  68330. /** @hidden */
  68331. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68332. /** @hidden */
  68333. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68334. /** @hidden */
  68335. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68336. /** @hidden */
  68337. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68338. /** @hidden */
  68339. _attachCameras(cameras: Camera, unique: boolean): void;
  68340. /** @hidden */
  68341. _attachCameras(cameras: Camera[], unique: boolean): void;
  68342. /** @hidden */
  68343. _detachCameras(cameras: Camera): void;
  68344. /** @hidden */
  68345. _detachCameras(cameras: Nullable<Camera[]>): void;
  68346. /** @hidden */
  68347. _update(): void;
  68348. /** @hidden */
  68349. _reset(): void;
  68350. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68351. /**
  68352. * Disposes of the pipeline
  68353. */
  68354. dispose(): void;
  68355. }
  68356. }
  68357. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68358. import { Camera } from "babylonjs/Cameras/camera";
  68359. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68360. /**
  68361. * PostProcessRenderPipelineManager class
  68362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68363. */
  68364. export class PostProcessRenderPipelineManager {
  68365. private _renderPipelines;
  68366. /**
  68367. * Initializes a PostProcessRenderPipelineManager
  68368. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68369. */
  68370. constructor();
  68371. /**
  68372. * Gets the list of supported render pipelines
  68373. */
  68374. get supportedPipelines(): PostProcessRenderPipeline[];
  68375. /**
  68376. * Adds a pipeline to the manager
  68377. * @param renderPipeline The pipeline to add
  68378. */
  68379. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68380. /**
  68381. * Attaches a camera to the pipeline
  68382. * @param renderPipelineName The name of the pipeline to attach to
  68383. * @param cameras the camera to attach
  68384. * @param unique if the camera can be attached multiple times to the pipeline
  68385. */
  68386. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68387. /**
  68388. * Detaches a camera from the pipeline
  68389. * @param renderPipelineName The name of the pipeline to detach from
  68390. * @param cameras the camera to detach
  68391. */
  68392. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68393. /**
  68394. * Enables an effect by name on a pipeline
  68395. * @param renderPipelineName the name of the pipeline to enable the effect in
  68396. * @param renderEffectName the name of the effect to enable
  68397. * @param cameras the cameras that the effect should be enabled on
  68398. */
  68399. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68400. /**
  68401. * Disables an effect by name on a pipeline
  68402. * @param renderPipelineName the name of the pipeline to disable the effect in
  68403. * @param renderEffectName the name of the effect to disable
  68404. * @param cameras the cameras that the effect should be disabled on
  68405. */
  68406. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68407. /**
  68408. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68409. */
  68410. update(): void;
  68411. /** @hidden */
  68412. _rebuild(): void;
  68413. /**
  68414. * Disposes of the manager and pipelines
  68415. */
  68416. dispose(): void;
  68417. }
  68418. }
  68419. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68420. import { ISceneComponent } from "babylonjs/sceneComponent";
  68421. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68422. import { Scene } from "babylonjs/scene";
  68423. module "babylonjs/scene" {
  68424. interface Scene {
  68425. /** @hidden (Backing field) */
  68426. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68427. /**
  68428. * Gets the postprocess render pipeline manager
  68429. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68430. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68431. */
  68432. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68433. }
  68434. }
  68435. /**
  68436. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68437. */
  68438. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68439. /**
  68440. * The component name helpfull to identify the component in the list of scene components.
  68441. */
  68442. readonly name: string;
  68443. /**
  68444. * The scene the component belongs to.
  68445. */
  68446. scene: Scene;
  68447. /**
  68448. * Creates a new instance of the component for the given scene
  68449. * @param scene Defines the scene to register the component in
  68450. */
  68451. constructor(scene: Scene);
  68452. /**
  68453. * Registers the component in a given scene
  68454. */
  68455. register(): void;
  68456. /**
  68457. * Rebuilds the elements related to this component in case of
  68458. * context lost for instance.
  68459. */
  68460. rebuild(): void;
  68461. /**
  68462. * Disposes the component and the associated ressources
  68463. */
  68464. dispose(): void;
  68465. private _gatherRenderTargets;
  68466. }
  68467. }
  68468. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68469. import { Nullable } from "babylonjs/types";
  68470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68471. import { Camera } from "babylonjs/Cameras/camera";
  68472. import { IDisposable } from "babylonjs/scene";
  68473. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68474. import { Scene } from "babylonjs/scene";
  68475. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68476. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68477. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68478. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68479. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68480. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68481. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68482. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68483. import { Animation } from "babylonjs/Animations/animation";
  68484. /**
  68485. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68486. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68487. */
  68488. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68489. private _scene;
  68490. private _camerasToBeAttached;
  68491. /**
  68492. * ID of the sharpen post process,
  68493. */
  68494. private readonly SharpenPostProcessId;
  68495. /**
  68496. * @ignore
  68497. * ID of the image processing post process;
  68498. */
  68499. readonly ImageProcessingPostProcessId: string;
  68500. /**
  68501. * @ignore
  68502. * ID of the Fast Approximate Anti-Aliasing post process;
  68503. */
  68504. readonly FxaaPostProcessId: string;
  68505. /**
  68506. * ID of the chromatic aberration post process,
  68507. */
  68508. private readonly ChromaticAberrationPostProcessId;
  68509. /**
  68510. * ID of the grain post process
  68511. */
  68512. private readonly GrainPostProcessId;
  68513. /**
  68514. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68515. */
  68516. sharpen: SharpenPostProcess;
  68517. private _sharpenEffect;
  68518. private bloom;
  68519. /**
  68520. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68521. */
  68522. depthOfField: DepthOfFieldEffect;
  68523. /**
  68524. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68525. */
  68526. fxaa: FxaaPostProcess;
  68527. /**
  68528. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68529. */
  68530. imageProcessing: ImageProcessingPostProcess;
  68531. /**
  68532. * Chromatic aberration post process which will shift rgb colors in the image
  68533. */
  68534. chromaticAberration: ChromaticAberrationPostProcess;
  68535. private _chromaticAberrationEffect;
  68536. /**
  68537. * Grain post process which add noise to the image
  68538. */
  68539. grain: GrainPostProcess;
  68540. private _grainEffect;
  68541. /**
  68542. * Glow post process which adds a glow to emissive areas of the image
  68543. */
  68544. private _glowLayer;
  68545. /**
  68546. * Animations which can be used to tweak settings over a period of time
  68547. */
  68548. animations: Animation[];
  68549. private _imageProcessingConfigurationObserver;
  68550. private _sharpenEnabled;
  68551. private _bloomEnabled;
  68552. private _depthOfFieldEnabled;
  68553. private _depthOfFieldBlurLevel;
  68554. private _fxaaEnabled;
  68555. private _imageProcessingEnabled;
  68556. private _defaultPipelineTextureType;
  68557. private _bloomScale;
  68558. private _chromaticAberrationEnabled;
  68559. private _grainEnabled;
  68560. private _buildAllowed;
  68561. /**
  68562. * Gets active scene
  68563. */
  68564. get scene(): Scene;
  68565. /**
  68566. * Enable or disable the sharpen process from the pipeline
  68567. */
  68568. set sharpenEnabled(enabled: boolean);
  68569. get sharpenEnabled(): boolean;
  68570. private _resizeObserver;
  68571. private _hardwareScaleLevel;
  68572. private _bloomKernel;
  68573. /**
  68574. * Specifies the size of the bloom blur kernel, relative to the final output size
  68575. */
  68576. get bloomKernel(): number;
  68577. set bloomKernel(value: number);
  68578. /**
  68579. * Specifies the weight of the bloom in the final rendering
  68580. */
  68581. private _bloomWeight;
  68582. /**
  68583. * Specifies the luma threshold for the area that will be blurred by the bloom
  68584. */
  68585. private _bloomThreshold;
  68586. private _hdr;
  68587. /**
  68588. * The strength of the bloom.
  68589. */
  68590. set bloomWeight(value: number);
  68591. get bloomWeight(): number;
  68592. /**
  68593. * The strength of the bloom.
  68594. */
  68595. set bloomThreshold(value: number);
  68596. get bloomThreshold(): number;
  68597. /**
  68598. * The scale of the bloom, lower value will provide better performance.
  68599. */
  68600. set bloomScale(value: number);
  68601. get bloomScale(): number;
  68602. /**
  68603. * Enable or disable the bloom from the pipeline
  68604. */
  68605. set bloomEnabled(enabled: boolean);
  68606. get bloomEnabled(): boolean;
  68607. private _rebuildBloom;
  68608. /**
  68609. * If the depth of field is enabled.
  68610. */
  68611. get depthOfFieldEnabled(): boolean;
  68612. set depthOfFieldEnabled(enabled: boolean);
  68613. /**
  68614. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68615. */
  68616. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68617. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68618. /**
  68619. * If the anti aliasing is enabled.
  68620. */
  68621. set fxaaEnabled(enabled: boolean);
  68622. get fxaaEnabled(): boolean;
  68623. private _samples;
  68624. /**
  68625. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68626. */
  68627. set samples(sampleCount: number);
  68628. get samples(): number;
  68629. /**
  68630. * If image processing is enabled.
  68631. */
  68632. set imageProcessingEnabled(enabled: boolean);
  68633. get imageProcessingEnabled(): boolean;
  68634. /**
  68635. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68636. */
  68637. set glowLayerEnabled(enabled: boolean);
  68638. get glowLayerEnabled(): boolean;
  68639. /**
  68640. * Gets the glow layer (or null if not defined)
  68641. */
  68642. get glowLayer(): Nullable<GlowLayer>;
  68643. /**
  68644. * Enable or disable the chromaticAberration process from the pipeline
  68645. */
  68646. set chromaticAberrationEnabled(enabled: boolean);
  68647. get chromaticAberrationEnabled(): boolean;
  68648. /**
  68649. * Enable or disable the grain process from the pipeline
  68650. */
  68651. set grainEnabled(enabled: boolean);
  68652. get grainEnabled(): boolean;
  68653. /**
  68654. * @constructor
  68655. * @param name - The rendering pipeline name (default: "")
  68656. * @param hdr - If high dynamic range textures should be used (default: true)
  68657. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68658. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68659. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68660. */
  68661. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68662. /**
  68663. * Get the class name
  68664. * @returns "DefaultRenderingPipeline"
  68665. */
  68666. getClassName(): string;
  68667. /**
  68668. * Force the compilation of the entire pipeline.
  68669. */
  68670. prepare(): void;
  68671. private _hasCleared;
  68672. private _prevPostProcess;
  68673. private _prevPrevPostProcess;
  68674. private _setAutoClearAndTextureSharing;
  68675. private _depthOfFieldSceneObserver;
  68676. private _buildPipeline;
  68677. private _disposePostProcesses;
  68678. /**
  68679. * Adds a camera to the pipeline
  68680. * @param camera the camera to be added
  68681. */
  68682. addCamera(camera: Camera): void;
  68683. /**
  68684. * Removes a camera from the pipeline
  68685. * @param camera the camera to remove
  68686. */
  68687. removeCamera(camera: Camera): void;
  68688. /**
  68689. * Dispose of the pipeline and stop all post processes
  68690. */
  68691. dispose(): void;
  68692. /**
  68693. * Serialize the rendering pipeline (Used when exporting)
  68694. * @returns the serialized object
  68695. */
  68696. serialize(): any;
  68697. /**
  68698. * Parse the serialized pipeline
  68699. * @param source Source pipeline.
  68700. * @param scene The scene to load the pipeline to.
  68701. * @param rootUrl The URL of the serialized pipeline.
  68702. * @returns An instantiated pipeline from the serialized object.
  68703. */
  68704. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68705. }
  68706. }
  68707. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68708. /** @hidden */
  68709. export var lensHighlightsPixelShader: {
  68710. name: string;
  68711. shader: string;
  68712. };
  68713. }
  68714. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68715. /** @hidden */
  68716. export var depthOfFieldPixelShader: {
  68717. name: string;
  68718. shader: string;
  68719. };
  68720. }
  68721. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68722. import { Camera } from "babylonjs/Cameras/camera";
  68723. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68724. import { Scene } from "babylonjs/scene";
  68725. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68726. import "babylonjs/Shaders/chromaticAberration.fragment";
  68727. import "babylonjs/Shaders/lensHighlights.fragment";
  68728. import "babylonjs/Shaders/depthOfField.fragment";
  68729. /**
  68730. * BABYLON.JS Chromatic Aberration GLSL Shader
  68731. * Author: Olivier Guyot
  68732. * Separates very slightly R, G and B colors on the edges of the screen
  68733. * Inspired by Francois Tarlier & Martins Upitis
  68734. */
  68735. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68736. /**
  68737. * @ignore
  68738. * The chromatic aberration PostProcess id in the pipeline
  68739. */
  68740. LensChromaticAberrationEffect: string;
  68741. /**
  68742. * @ignore
  68743. * The highlights enhancing PostProcess id in the pipeline
  68744. */
  68745. HighlightsEnhancingEffect: string;
  68746. /**
  68747. * @ignore
  68748. * The depth-of-field PostProcess id in the pipeline
  68749. */
  68750. LensDepthOfFieldEffect: string;
  68751. private _scene;
  68752. private _depthTexture;
  68753. private _grainTexture;
  68754. private _chromaticAberrationPostProcess;
  68755. private _highlightsPostProcess;
  68756. private _depthOfFieldPostProcess;
  68757. private _edgeBlur;
  68758. private _grainAmount;
  68759. private _chromaticAberration;
  68760. private _distortion;
  68761. private _highlightsGain;
  68762. private _highlightsThreshold;
  68763. private _dofDistance;
  68764. private _dofAperture;
  68765. private _dofDarken;
  68766. private _dofPentagon;
  68767. private _blurNoise;
  68768. /**
  68769. * @constructor
  68770. *
  68771. * Effect parameters are as follow:
  68772. * {
  68773. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68774. * edge_blur: number; // from 0 to x (1 for realism)
  68775. * distortion: number; // from 0 to x (1 for realism)
  68776. * grain_amount: number; // from 0 to 1
  68777. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68778. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68779. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68780. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68781. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68782. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68783. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68784. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68785. * }
  68786. * Note: if an effect parameter is unset, effect is disabled
  68787. *
  68788. * @param name The rendering pipeline name
  68789. * @param parameters - An object containing all parameters (see above)
  68790. * @param scene The scene linked to this pipeline
  68791. * @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)
  68792. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68793. */
  68794. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68795. /**
  68796. * Get the class name
  68797. * @returns "LensRenderingPipeline"
  68798. */
  68799. getClassName(): string;
  68800. /**
  68801. * Gets associated scene
  68802. */
  68803. get scene(): Scene;
  68804. /**
  68805. * Gets or sets the edge blur
  68806. */
  68807. get edgeBlur(): number;
  68808. set edgeBlur(value: number);
  68809. /**
  68810. * Gets or sets the grain amount
  68811. */
  68812. get grainAmount(): number;
  68813. set grainAmount(value: number);
  68814. /**
  68815. * Gets or sets the chromatic aberration amount
  68816. */
  68817. get chromaticAberration(): number;
  68818. set chromaticAberration(value: number);
  68819. /**
  68820. * Gets or sets the depth of field aperture
  68821. */
  68822. get dofAperture(): number;
  68823. set dofAperture(value: number);
  68824. /**
  68825. * Gets or sets the edge distortion
  68826. */
  68827. get edgeDistortion(): number;
  68828. set edgeDistortion(value: number);
  68829. /**
  68830. * Gets or sets the depth of field distortion
  68831. */
  68832. get dofDistortion(): number;
  68833. set dofDistortion(value: number);
  68834. /**
  68835. * Gets or sets the darken out of focus amount
  68836. */
  68837. get darkenOutOfFocus(): number;
  68838. set darkenOutOfFocus(value: number);
  68839. /**
  68840. * Gets or sets a boolean indicating if blur noise is enabled
  68841. */
  68842. get blurNoise(): boolean;
  68843. set blurNoise(value: boolean);
  68844. /**
  68845. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68846. */
  68847. get pentagonBokeh(): boolean;
  68848. set pentagonBokeh(value: boolean);
  68849. /**
  68850. * Gets or sets the highlight grain amount
  68851. */
  68852. get highlightsGain(): number;
  68853. set highlightsGain(value: number);
  68854. /**
  68855. * Gets or sets the highlight threshold
  68856. */
  68857. get highlightsThreshold(): number;
  68858. set highlightsThreshold(value: number);
  68859. /**
  68860. * Sets the amount of blur at the edges
  68861. * @param amount blur amount
  68862. */
  68863. setEdgeBlur(amount: number): void;
  68864. /**
  68865. * Sets edge blur to 0
  68866. */
  68867. disableEdgeBlur(): void;
  68868. /**
  68869. * Sets the amout of grain
  68870. * @param amount Amount of grain
  68871. */
  68872. setGrainAmount(amount: number): void;
  68873. /**
  68874. * Set grain amount to 0
  68875. */
  68876. disableGrain(): void;
  68877. /**
  68878. * Sets the chromatic aberration amount
  68879. * @param amount amount of chromatic aberration
  68880. */
  68881. setChromaticAberration(amount: number): void;
  68882. /**
  68883. * Sets chromatic aberration amount to 0
  68884. */
  68885. disableChromaticAberration(): void;
  68886. /**
  68887. * Sets the EdgeDistortion amount
  68888. * @param amount amount of EdgeDistortion
  68889. */
  68890. setEdgeDistortion(amount: number): void;
  68891. /**
  68892. * Sets edge distortion to 0
  68893. */
  68894. disableEdgeDistortion(): void;
  68895. /**
  68896. * Sets the FocusDistance amount
  68897. * @param amount amount of FocusDistance
  68898. */
  68899. setFocusDistance(amount: number): void;
  68900. /**
  68901. * Disables depth of field
  68902. */
  68903. disableDepthOfField(): void;
  68904. /**
  68905. * Sets the Aperture amount
  68906. * @param amount amount of Aperture
  68907. */
  68908. setAperture(amount: number): void;
  68909. /**
  68910. * Sets the DarkenOutOfFocus amount
  68911. * @param amount amount of DarkenOutOfFocus
  68912. */
  68913. setDarkenOutOfFocus(amount: number): void;
  68914. private _pentagonBokehIsEnabled;
  68915. /**
  68916. * Creates a pentagon bokeh effect
  68917. */
  68918. enablePentagonBokeh(): void;
  68919. /**
  68920. * Disables the pentagon bokeh effect
  68921. */
  68922. disablePentagonBokeh(): void;
  68923. /**
  68924. * Enables noise blur
  68925. */
  68926. enableNoiseBlur(): void;
  68927. /**
  68928. * Disables noise blur
  68929. */
  68930. disableNoiseBlur(): void;
  68931. /**
  68932. * Sets the HighlightsGain amount
  68933. * @param amount amount of HighlightsGain
  68934. */
  68935. setHighlightsGain(amount: number): void;
  68936. /**
  68937. * Sets the HighlightsThreshold amount
  68938. * @param amount amount of HighlightsThreshold
  68939. */
  68940. setHighlightsThreshold(amount: number): void;
  68941. /**
  68942. * Disables highlights
  68943. */
  68944. disableHighlights(): void;
  68945. /**
  68946. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68947. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68948. */
  68949. dispose(disableDepthRender?: boolean): void;
  68950. private _createChromaticAberrationPostProcess;
  68951. private _createHighlightsPostProcess;
  68952. private _createDepthOfFieldPostProcess;
  68953. private _createGrainTexture;
  68954. }
  68955. }
  68956. declare module "babylonjs/Shaders/ssao2.fragment" {
  68957. /** @hidden */
  68958. export var ssao2PixelShader: {
  68959. name: string;
  68960. shader: string;
  68961. };
  68962. }
  68963. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  68964. /** @hidden */
  68965. export var ssaoCombinePixelShader: {
  68966. name: string;
  68967. shader: string;
  68968. };
  68969. }
  68970. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  68971. import { Camera } from "babylonjs/Cameras/camera";
  68972. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68973. import { Scene } from "babylonjs/scene";
  68974. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68975. import "babylonjs/Shaders/ssao2.fragment";
  68976. import "babylonjs/Shaders/ssaoCombine.fragment";
  68977. /**
  68978. * Render pipeline to produce ssao effect
  68979. */
  68980. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68981. /**
  68982. * @ignore
  68983. * The PassPostProcess id in the pipeline that contains the original scene color
  68984. */
  68985. SSAOOriginalSceneColorEffect: string;
  68986. /**
  68987. * @ignore
  68988. * The SSAO PostProcess id in the pipeline
  68989. */
  68990. SSAORenderEffect: string;
  68991. /**
  68992. * @ignore
  68993. * The horizontal blur PostProcess id in the pipeline
  68994. */
  68995. SSAOBlurHRenderEffect: string;
  68996. /**
  68997. * @ignore
  68998. * The vertical blur PostProcess id in the pipeline
  68999. */
  69000. SSAOBlurVRenderEffect: string;
  69001. /**
  69002. * @ignore
  69003. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69004. */
  69005. SSAOCombineRenderEffect: string;
  69006. /**
  69007. * The output strength of the SSAO post-process. Default value is 1.0.
  69008. */
  69009. totalStrength: number;
  69010. /**
  69011. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69012. */
  69013. maxZ: number;
  69014. /**
  69015. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69016. */
  69017. minZAspect: number;
  69018. private _samples;
  69019. /**
  69020. * Number of samples used for the SSAO calculations. Default value is 8
  69021. */
  69022. set samples(n: number);
  69023. get samples(): number;
  69024. private _textureSamples;
  69025. /**
  69026. * Number of samples to use for antialiasing
  69027. */
  69028. set textureSamples(n: number);
  69029. get textureSamples(): number;
  69030. /**
  69031. * Ratio object used for SSAO ratio and blur ratio
  69032. */
  69033. private _ratio;
  69034. /**
  69035. * Dynamically generated sphere sampler.
  69036. */
  69037. private _sampleSphere;
  69038. /**
  69039. * Blur filter offsets
  69040. */
  69041. private _samplerOffsets;
  69042. private _expensiveBlur;
  69043. /**
  69044. * If bilateral blur should be used
  69045. */
  69046. set expensiveBlur(b: boolean);
  69047. get expensiveBlur(): boolean;
  69048. /**
  69049. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69050. */
  69051. radius: number;
  69052. /**
  69053. * The base color of the SSAO post-process
  69054. * The final result is "base + ssao" between [0, 1]
  69055. */
  69056. base: number;
  69057. /**
  69058. * Support test.
  69059. */
  69060. static get IsSupported(): boolean;
  69061. private _scene;
  69062. private _depthTexture;
  69063. private _normalTexture;
  69064. private _randomTexture;
  69065. private _originalColorPostProcess;
  69066. private _ssaoPostProcess;
  69067. private _blurHPostProcess;
  69068. private _blurVPostProcess;
  69069. private _ssaoCombinePostProcess;
  69070. /**
  69071. * Gets active scene
  69072. */
  69073. get scene(): Scene;
  69074. /**
  69075. * @constructor
  69076. * @param name The rendering pipeline name
  69077. * @param scene The scene linked to this pipeline
  69078. * @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 }
  69079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69080. */
  69081. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69082. /**
  69083. * Get the class name
  69084. * @returns "SSAO2RenderingPipeline"
  69085. */
  69086. getClassName(): string;
  69087. /**
  69088. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69089. */
  69090. dispose(disableGeometryBufferRenderer?: boolean): void;
  69091. private _createBlurPostProcess;
  69092. /** @hidden */
  69093. _rebuild(): void;
  69094. private _bits;
  69095. private _radicalInverse_VdC;
  69096. private _hammersley;
  69097. private _hemisphereSample_uniform;
  69098. private _generateHemisphere;
  69099. private _createSSAOPostProcess;
  69100. private _createSSAOCombinePostProcess;
  69101. private _createRandomTexture;
  69102. /**
  69103. * Serialize the rendering pipeline (Used when exporting)
  69104. * @returns the serialized object
  69105. */
  69106. serialize(): any;
  69107. /**
  69108. * Parse the serialized pipeline
  69109. * @param source Source pipeline.
  69110. * @param scene The scene to load the pipeline to.
  69111. * @param rootUrl The URL of the serialized pipeline.
  69112. * @returns An instantiated pipeline from the serialized object.
  69113. */
  69114. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69115. }
  69116. }
  69117. declare module "babylonjs/Shaders/ssao.fragment" {
  69118. /** @hidden */
  69119. export var ssaoPixelShader: {
  69120. name: string;
  69121. shader: string;
  69122. };
  69123. }
  69124. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69125. import { Camera } from "babylonjs/Cameras/camera";
  69126. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69127. import { Scene } from "babylonjs/scene";
  69128. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69129. import "babylonjs/Shaders/ssao.fragment";
  69130. import "babylonjs/Shaders/ssaoCombine.fragment";
  69131. /**
  69132. * Render pipeline to produce ssao effect
  69133. */
  69134. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69135. /**
  69136. * @ignore
  69137. * The PassPostProcess id in the pipeline that contains the original scene color
  69138. */
  69139. SSAOOriginalSceneColorEffect: string;
  69140. /**
  69141. * @ignore
  69142. * The SSAO PostProcess id in the pipeline
  69143. */
  69144. SSAORenderEffect: string;
  69145. /**
  69146. * @ignore
  69147. * The horizontal blur PostProcess id in the pipeline
  69148. */
  69149. SSAOBlurHRenderEffect: string;
  69150. /**
  69151. * @ignore
  69152. * The vertical blur PostProcess id in the pipeline
  69153. */
  69154. SSAOBlurVRenderEffect: string;
  69155. /**
  69156. * @ignore
  69157. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69158. */
  69159. SSAOCombineRenderEffect: string;
  69160. /**
  69161. * The output strength of the SSAO post-process. Default value is 1.0.
  69162. */
  69163. totalStrength: number;
  69164. /**
  69165. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69166. */
  69167. radius: number;
  69168. /**
  69169. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69170. * Must not be equal to fallOff and superior to fallOff.
  69171. * Default value is 0.0075
  69172. */
  69173. area: number;
  69174. /**
  69175. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69176. * Must not be equal to area and inferior to area.
  69177. * Default value is 0.000001
  69178. */
  69179. fallOff: number;
  69180. /**
  69181. * The base color of the SSAO post-process
  69182. * The final result is "base + ssao" between [0, 1]
  69183. */
  69184. base: number;
  69185. private _scene;
  69186. private _depthTexture;
  69187. private _randomTexture;
  69188. private _originalColorPostProcess;
  69189. private _ssaoPostProcess;
  69190. private _blurHPostProcess;
  69191. private _blurVPostProcess;
  69192. private _ssaoCombinePostProcess;
  69193. private _firstUpdate;
  69194. /**
  69195. * Gets active scene
  69196. */
  69197. get scene(): Scene;
  69198. /**
  69199. * @constructor
  69200. * @param name - The rendering pipeline name
  69201. * @param scene - The scene linked to this pipeline
  69202. * @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 }
  69203. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69204. */
  69205. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69206. /**
  69207. * Get the class name
  69208. * @returns "SSAORenderingPipeline"
  69209. */
  69210. getClassName(): string;
  69211. /**
  69212. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69213. */
  69214. dispose(disableDepthRender?: boolean): void;
  69215. private _createBlurPostProcess;
  69216. /** @hidden */
  69217. _rebuild(): void;
  69218. private _createSSAOPostProcess;
  69219. private _createSSAOCombinePostProcess;
  69220. private _createRandomTexture;
  69221. }
  69222. }
  69223. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69224. /** @hidden */
  69225. export var screenSpaceReflectionPixelShader: {
  69226. name: string;
  69227. shader: string;
  69228. };
  69229. }
  69230. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69231. import { Nullable } from "babylonjs/types";
  69232. import { Camera } from "babylonjs/Cameras/camera";
  69233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69234. import { Scene } from "babylonjs/scene";
  69235. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69236. import { Engine } from "babylonjs/Engines/engine";
  69237. /**
  69238. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69239. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69240. */
  69241. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69242. /**
  69243. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69244. */
  69245. threshold: number;
  69246. /**
  69247. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69248. */
  69249. strength: number;
  69250. /**
  69251. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69252. */
  69253. reflectionSpecularFalloffExponent: number;
  69254. /**
  69255. * 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]
  69256. */
  69257. step: number;
  69258. /**
  69259. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69260. */
  69261. roughnessFactor: number;
  69262. private _geometryBufferRenderer;
  69263. private _enableSmoothReflections;
  69264. private _reflectionSamples;
  69265. private _smoothSteps;
  69266. /**
  69267. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69268. * @param name The name of the effect.
  69269. * @param scene The scene containing the objects to calculate reflections.
  69270. * @param options The required width/height ratio to downsize to before computing the render pass.
  69271. * @param camera The camera to apply the render pass to.
  69272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69273. * @param engine The engine which the post process will be applied. (default: current engine)
  69274. * @param reusable If the post process can be reused on the same frame. (default: false)
  69275. * @param textureType Type of textures used when performing the post process. (default: 0)
  69276. * @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)
  69277. */
  69278. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69279. /**
  69280. * Gets wether or not smoothing reflections is enabled.
  69281. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69282. */
  69283. get enableSmoothReflections(): boolean;
  69284. /**
  69285. * Sets wether or not smoothing reflections is enabled.
  69286. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69287. */
  69288. set enableSmoothReflections(enabled: boolean);
  69289. /**
  69290. * Gets the number of samples taken while computing reflections. More samples count is high,
  69291. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69292. */
  69293. get reflectionSamples(): number;
  69294. /**
  69295. * Sets the number of samples taken while computing reflections. More samples count is high,
  69296. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69297. */
  69298. set reflectionSamples(samples: number);
  69299. /**
  69300. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69301. * more the post-process will require GPU power and can generate a drop in FPS.
  69302. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69303. */
  69304. get smoothSteps(): number;
  69305. set smoothSteps(steps: number);
  69306. private _updateEffectDefines;
  69307. }
  69308. }
  69309. declare module "babylonjs/Shaders/standard.fragment" {
  69310. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69311. /** @hidden */
  69312. export var standardPixelShader: {
  69313. name: string;
  69314. shader: string;
  69315. };
  69316. }
  69317. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69318. import { Nullable } from "babylonjs/types";
  69319. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69320. import { Camera } from "babylonjs/Cameras/camera";
  69321. import { Texture } from "babylonjs/Materials/Textures/texture";
  69322. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69323. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69324. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69325. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69326. import { IDisposable } from "babylonjs/scene";
  69327. import { SpotLight } from "babylonjs/Lights/spotLight";
  69328. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69329. import { Scene } from "babylonjs/scene";
  69330. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69331. import { Animation } from "babylonjs/Animations/animation";
  69332. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69333. import "babylonjs/Shaders/standard.fragment";
  69334. /**
  69335. * Standard rendering pipeline
  69336. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69337. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69338. */
  69339. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69340. /**
  69341. * Public members
  69342. */
  69343. /**
  69344. * Post-process which contains the original scene color before the pipeline applies all the effects
  69345. */
  69346. originalPostProcess: Nullable<PostProcess>;
  69347. /**
  69348. * Post-process used to down scale an image x4
  69349. */
  69350. downSampleX4PostProcess: Nullable<PostProcess>;
  69351. /**
  69352. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69353. */
  69354. brightPassPostProcess: Nullable<PostProcess>;
  69355. /**
  69356. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69357. */
  69358. blurHPostProcesses: PostProcess[];
  69359. /**
  69360. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69361. */
  69362. blurVPostProcesses: PostProcess[];
  69363. /**
  69364. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69365. */
  69366. textureAdderPostProcess: Nullable<PostProcess>;
  69367. /**
  69368. * Post-process used to create volumetric lighting effect
  69369. */
  69370. volumetricLightPostProcess: Nullable<PostProcess>;
  69371. /**
  69372. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69373. */
  69374. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69375. /**
  69376. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69377. */
  69378. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69379. /**
  69380. * Post-process used to merge the volumetric light effect and the real scene color
  69381. */
  69382. volumetricLightMergePostProces: Nullable<PostProcess>;
  69383. /**
  69384. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69385. */
  69386. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69387. /**
  69388. * Base post-process used to calculate the average luminance of the final image for HDR
  69389. */
  69390. luminancePostProcess: Nullable<PostProcess>;
  69391. /**
  69392. * Post-processes used to create down sample post-processes in order to get
  69393. * the average luminance of the final image for HDR
  69394. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69395. */
  69396. luminanceDownSamplePostProcesses: PostProcess[];
  69397. /**
  69398. * Post-process used to create a HDR effect (light adaptation)
  69399. */
  69400. hdrPostProcess: Nullable<PostProcess>;
  69401. /**
  69402. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69403. */
  69404. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69405. /**
  69406. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69407. */
  69408. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69409. /**
  69410. * Post-process used to merge the final HDR post-process and the real scene color
  69411. */
  69412. hdrFinalPostProcess: Nullable<PostProcess>;
  69413. /**
  69414. * Post-process used to create a lens flare effect
  69415. */
  69416. lensFlarePostProcess: Nullable<PostProcess>;
  69417. /**
  69418. * Post-process that merges the result of the lens flare post-process and the real scene color
  69419. */
  69420. lensFlareComposePostProcess: Nullable<PostProcess>;
  69421. /**
  69422. * Post-process used to create a motion blur effect
  69423. */
  69424. motionBlurPostProcess: Nullable<PostProcess>;
  69425. /**
  69426. * Post-process used to create a depth of field effect
  69427. */
  69428. depthOfFieldPostProcess: Nullable<PostProcess>;
  69429. /**
  69430. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69431. */
  69432. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69433. /**
  69434. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69435. */
  69436. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69437. /**
  69438. * Represents the brightness threshold in order to configure the illuminated surfaces
  69439. */
  69440. brightThreshold: number;
  69441. /**
  69442. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69443. */
  69444. blurWidth: number;
  69445. /**
  69446. * Sets if the blur for highlighted surfaces must be only horizontal
  69447. */
  69448. horizontalBlur: boolean;
  69449. /**
  69450. * Gets the overall exposure used by the pipeline
  69451. */
  69452. get exposure(): number;
  69453. /**
  69454. * Sets the overall exposure used by the pipeline
  69455. */
  69456. set exposure(value: number);
  69457. /**
  69458. * Texture used typically to simulate "dirty" on camera lens
  69459. */
  69460. lensTexture: Nullable<Texture>;
  69461. /**
  69462. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69463. */
  69464. volumetricLightCoefficient: number;
  69465. /**
  69466. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69467. */
  69468. volumetricLightPower: number;
  69469. /**
  69470. * Used the set the blur intensity to smooth the volumetric lights
  69471. */
  69472. volumetricLightBlurScale: number;
  69473. /**
  69474. * Light (spot or directional) used to generate the volumetric lights rays
  69475. * The source light must have a shadow generate so the pipeline can get its
  69476. * depth map
  69477. */
  69478. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69479. /**
  69480. * For eye adaptation, represents the minimum luminance the eye can see
  69481. */
  69482. hdrMinimumLuminance: number;
  69483. /**
  69484. * For eye adaptation, represents the decrease luminance speed
  69485. */
  69486. hdrDecreaseRate: number;
  69487. /**
  69488. * For eye adaptation, represents the increase luminance speed
  69489. */
  69490. hdrIncreaseRate: number;
  69491. /**
  69492. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69493. */
  69494. get hdrAutoExposure(): boolean;
  69495. /**
  69496. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69497. */
  69498. set hdrAutoExposure(value: boolean);
  69499. /**
  69500. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69501. */
  69502. lensColorTexture: Nullable<Texture>;
  69503. /**
  69504. * The overall strengh for the lens flare effect
  69505. */
  69506. lensFlareStrength: number;
  69507. /**
  69508. * Dispersion coefficient for lens flare ghosts
  69509. */
  69510. lensFlareGhostDispersal: number;
  69511. /**
  69512. * Main lens flare halo width
  69513. */
  69514. lensFlareHaloWidth: number;
  69515. /**
  69516. * Based on the lens distortion effect, defines how much the lens flare result
  69517. * is distorted
  69518. */
  69519. lensFlareDistortionStrength: number;
  69520. /**
  69521. * Configures the blur intensity used for for lens flare (halo)
  69522. */
  69523. lensFlareBlurWidth: number;
  69524. /**
  69525. * Lens star texture must be used to simulate rays on the flares and is available
  69526. * in the documentation
  69527. */
  69528. lensStarTexture: Nullable<Texture>;
  69529. /**
  69530. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69531. * flare effect by taking account of the dirt texture
  69532. */
  69533. lensFlareDirtTexture: Nullable<Texture>;
  69534. /**
  69535. * Represents the focal length for the depth of field effect
  69536. */
  69537. depthOfFieldDistance: number;
  69538. /**
  69539. * Represents the blur intensity for the blurred part of the depth of field effect
  69540. */
  69541. depthOfFieldBlurWidth: number;
  69542. /**
  69543. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69544. */
  69545. get motionStrength(): number;
  69546. /**
  69547. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69548. */
  69549. set motionStrength(strength: number);
  69550. /**
  69551. * Gets wether or not the motion blur post-process is object based or screen based.
  69552. */
  69553. get objectBasedMotionBlur(): boolean;
  69554. /**
  69555. * Sets wether or not the motion blur post-process should be object based or screen based
  69556. */
  69557. set objectBasedMotionBlur(value: boolean);
  69558. /**
  69559. * List of animations for the pipeline (IAnimatable implementation)
  69560. */
  69561. animations: Animation[];
  69562. /**
  69563. * Private members
  69564. */
  69565. private _scene;
  69566. private _currentDepthOfFieldSource;
  69567. private _basePostProcess;
  69568. private _fixedExposure;
  69569. private _currentExposure;
  69570. private _hdrAutoExposure;
  69571. private _hdrCurrentLuminance;
  69572. private _motionStrength;
  69573. private _isObjectBasedMotionBlur;
  69574. private _floatTextureType;
  69575. private _camerasToBeAttached;
  69576. private _ratio;
  69577. private _bloomEnabled;
  69578. private _depthOfFieldEnabled;
  69579. private _vlsEnabled;
  69580. private _lensFlareEnabled;
  69581. private _hdrEnabled;
  69582. private _motionBlurEnabled;
  69583. private _fxaaEnabled;
  69584. private _screenSpaceReflectionsEnabled;
  69585. private _motionBlurSamples;
  69586. private _volumetricLightStepsCount;
  69587. private _samples;
  69588. /**
  69589. * @ignore
  69590. * Specifies if the bloom pipeline is enabled
  69591. */
  69592. get BloomEnabled(): boolean;
  69593. set BloomEnabled(enabled: boolean);
  69594. /**
  69595. * @ignore
  69596. * Specifies if the depth of field pipeline is enabed
  69597. */
  69598. get DepthOfFieldEnabled(): boolean;
  69599. set DepthOfFieldEnabled(enabled: boolean);
  69600. /**
  69601. * @ignore
  69602. * Specifies if the lens flare pipeline is enabed
  69603. */
  69604. get LensFlareEnabled(): boolean;
  69605. set LensFlareEnabled(enabled: boolean);
  69606. /**
  69607. * @ignore
  69608. * Specifies if the HDR pipeline is enabled
  69609. */
  69610. get HDREnabled(): boolean;
  69611. set HDREnabled(enabled: boolean);
  69612. /**
  69613. * @ignore
  69614. * Specifies if the volumetric lights scattering effect is enabled
  69615. */
  69616. get VLSEnabled(): boolean;
  69617. set VLSEnabled(enabled: boolean);
  69618. /**
  69619. * @ignore
  69620. * Specifies if the motion blur effect is enabled
  69621. */
  69622. get MotionBlurEnabled(): boolean;
  69623. set MotionBlurEnabled(enabled: boolean);
  69624. /**
  69625. * Specifies if anti-aliasing is enabled
  69626. */
  69627. get fxaaEnabled(): boolean;
  69628. set fxaaEnabled(enabled: boolean);
  69629. /**
  69630. * Specifies if screen space reflections are enabled.
  69631. */
  69632. get screenSpaceReflectionsEnabled(): boolean;
  69633. set screenSpaceReflectionsEnabled(enabled: boolean);
  69634. /**
  69635. * Specifies the number of steps used to calculate the volumetric lights
  69636. * Typically in interval [50, 200]
  69637. */
  69638. get volumetricLightStepsCount(): number;
  69639. set volumetricLightStepsCount(count: number);
  69640. /**
  69641. * Specifies the number of samples used for the motion blur effect
  69642. * Typically in interval [16, 64]
  69643. */
  69644. get motionBlurSamples(): number;
  69645. set motionBlurSamples(samples: number);
  69646. /**
  69647. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69648. */
  69649. get samples(): number;
  69650. set samples(sampleCount: number);
  69651. /**
  69652. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69653. * @constructor
  69654. * @param name The rendering pipeline name
  69655. * @param scene The scene linked to this pipeline
  69656. * @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)
  69657. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69658. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69659. */
  69660. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69661. private _buildPipeline;
  69662. private _createDownSampleX4PostProcess;
  69663. private _createBrightPassPostProcess;
  69664. private _createBlurPostProcesses;
  69665. private _createTextureAdderPostProcess;
  69666. private _createVolumetricLightPostProcess;
  69667. private _createLuminancePostProcesses;
  69668. private _createHdrPostProcess;
  69669. private _createLensFlarePostProcess;
  69670. private _createDepthOfFieldPostProcess;
  69671. private _createMotionBlurPostProcess;
  69672. private _getDepthTexture;
  69673. private _disposePostProcesses;
  69674. /**
  69675. * Dispose of the pipeline and stop all post processes
  69676. */
  69677. dispose(): void;
  69678. /**
  69679. * Serialize the rendering pipeline (Used when exporting)
  69680. * @returns the serialized object
  69681. */
  69682. serialize(): any;
  69683. /**
  69684. * Parse the serialized pipeline
  69685. * @param source Source pipeline.
  69686. * @param scene The scene to load the pipeline to.
  69687. * @param rootUrl The URL of the serialized pipeline.
  69688. * @returns An instantiated pipeline from the serialized object.
  69689. */
  69690. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69691. /**
  69692. * Luminance steps
  69693. */
  69694. static LuminanceSteps: number;
  69695. }
  69696. }
  69697. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69698. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69699. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69700. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69701. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69702. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69703. }
  69704. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69705. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69706. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69707. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69708. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69709. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69710. }
  69711. declare module "babylonjs/Shaders/tonemap.fragment" {
  69712. /** @hidden */
  69713. export var tonemapPixelShader: {
  69714. name: string;
  69715. shader: string;
  69716. };
  69717. }
  69718. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69719. import { Camera } from "babylonjs/Cameras/camera";
  69720. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69721. import "babylonjs/Shaders/tonemap.fragment";
  69722. import { Engine } from "babylonjs/Engines/engine";
  69723. /** Defines operator used for tonemapping */
  69724. export enum TonemappingOperator {
  69725. /** Hable */
  69726. Hable = 0,
  69727. /** Reinhard */
  69728. Reinhard = 1,
  69729. /** HejiDawson */
  69730. HejiDawson = 2,
  69731. /** Photographic */
  69732. Photographic = 3
  69733. }
  69734. /**
  69735. * Defines a post process to apply tone mapping
  69736. */
  69737. export class TonemapPostProcess extends PostProcess {
  69738. private _operator;
  69739. /** Defines the required exposure adjustement */
  69740. exposureAdjustment: number;
  69741. /**
  69742. * Creates a new TonemapPostProcess
  69743. * @param name defines the name of the postprocess
  69744. * @param _operator defines the operator to use
  69745. * @param exposureAdjustment defines the required exposure adjustement
  69746. * @param camera defines the camera to use (can be null)
  69747. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69748. * @param engine defines the hosting engine (can be ignore if camera is set)
  69749. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69750. */
  69751. constructor(name: string, _operator: TonemappingOperator,
  69752. /** Defines the required exposure adjustement */
  69753. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69754. }
  69755. }
  69756. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69757. /** @hidden */
  69758. export var volumetricLightScatteringPixelShader: {
  69759. name: string;
  69760. shader: string;
  69761. };
  69762. }
  69763. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69764. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69767. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69769. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69770. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69771. /** @hidden */
  69772. export var volumetricLightScatteringPassVertexShader: {
  69773. name: string;
  69774. shader: string;
  69775. };
  69776. }
  69777. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69778. /** @hidden */
  69779. export var volumetricLightScatteringPassPixelShader: {
  69780. name: string;
  69781. shader: string;
  69782. };
  69783. }
  69784. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69785. import { Vector3 } from "babylonjs/Maths/math.vector";
  69786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69787. import { Mesh } from "babylonjs/Meshes/mesh";
  69788. import { Camera } from "babylonjs/Cameras/camera";
  69789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69791. import { Scene } from "babylonjs/scene";
  69792. import "babylonjs/Meshes/Builders/planeBuilder";
  69793. import "babylonjs/Shaders/depth.vertex";
  69794. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69795. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69796. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69797. import { Engine } from "babylonjs/Engines/engine";
  69798. /**
  69799. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69800. */
  69801. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69802. private _volumetricLightScatteringPass;
  69803. private _volumetricLightScatteringRTT;
  69804. private _viewPort;
  69805. private _screenCoordinates;
  69806. private _cachedDefines;
  69807. /**
  69808. * If not undefined, the mesh position is computed from the attached node position
  69809. */
  69810. attachedNode: {
  69811. position: Vector3;
  69812. };
  69813. /**
  69814. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69815. */
  69816. customMeshPosition: Vector3;
  69817. /**
  69818. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69819. */
  69820. useCustomMeshPosition: boolean;
  69821. /**
  69822. * If the post-process should inverse the light scattering direction
  69823. */
  69824. invert: boolean;
  69825. /**
  69826. * The internal mesh used by the post-process
  69827. */
  69828. mesh: Mesh;
  69829. /**
  69830. * @hidden
  69831. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69832. */
  69833. get useDiffuseColor(): boolean;
  69834. set useDiffuseColor(useDiffuseColor: boolean);
  69835. /**
  69836. * Array containing the excluded meshes not rendered in the internal pass
  69837. */
  69838. excludedMeshes: AbstractMesh[];
  69839. /**
  69840. * Controls the overall intensity of the post-process
  69841. */
  69842. exposure: number;
  69843. /**
  69844. * Dissipates each sample's contribution in range [0, 1]
  69845. */
  69846. decay: number;
  69847. /**
  69848. * Controls the overall intensity of each sample
  69849. */
  69850. weight: number;
  69851. /**
  69852. * Controls the density of each sample
  69853. */
  69854. density: number;
  69855. /**
  69856. * @constructor
  69857. * @param name The post-process name
  69858. * @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)
  69859. * @param camera The camera that the post-process will be attached to
  69860. * @param mesh The mesh used to create the light scattering
  69861. * @param samples The post-process quality, default 100
  69862. * @param samplingModeThe post-process filtering mode
  69863. * @param engine The babylon engine
  69864. * @param reusable If the post-process is reusable
  69865. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69866. */
  69867. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69868. /**
  69869. * Returns the string "VolumetricLightScatteringPostProcess"
  69870. * @returns "VolumetricLightScatteringPostProcess"
  69871. */
  69872. getClassName(): string;
  69873. private _isReady;
  69874. /**
  69875. * Sets the new light position for light scattering effect
  69876. * @param position The new custom light position
  69877. */
  69878. setCustomMeshPosition(position: Vector3): void;
  69879. /**
  69880. * Returns the light position for light scattering effect
  69881. * @return Vector3 The custom light position
  69882. */
  69883. getCustomMeshPosition(): Vector3;
  69884. /**
  69885. * Disposes the internal assets and detaches the post-process from the camera
  69886. */
  69887. dispose(camera: Camera): void;
  69888. /**
  69889. * Returns the render target texture used by the post-process
  69890. * @return the render target texture used by the post-process
  69891. */
  69892. getPass(): RenderTargetTexture;
  69893. private _meshExcluded;
  69894. private _createPass;
  69895. private _updateMeshScreenCoordinates;
  69896. /**
  69897. * Creates a default mesh for the Volumeric Light Scattering post-process
  69898. * @param name The mesh name
  69899. * @param scene The scene where to create the mesh
  69900. * @return the default mesh
  69901. */
  69902. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69903. }
  69904. }
  69905. declare module "babylonjs/PostProcesses/index" {
  69906. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69907. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69908. export * from "babylonjs/PostProcesses/bloomEffect";
  69909. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69910. export * from "babylonjs/PostProcesses/blurPostProcess";
  69911. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69912. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69913. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69914. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69915. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69916. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69917. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69918. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69919. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69920. export * from "babylonjs/PostProcesses/filterPostProcess";
  69921. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69922. export * from "babylonjs/PostProcesses/grainPostProcess";
  69923. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69924. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69925. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69926. export * from "babylonjs/PostProcesses/passPostProcess";
  69927. export * from "babylonjs/PostProcesses/postProcess";
  69928. export * from "babylonjs/PostProcesses/postProcessManager";
  69929. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69930. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69931. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69932. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69933. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69934. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69935. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69936. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69937. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69938. }
  69939. declare module "babylonjs/Probes/index" {
  69940. export * from "babylonjs/Probes/reflectionProbe";
  69941. }
  69942. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69943. import { Scene } from "babylonjs/scene";
  69944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69945. import { SmartArray } from "babylonjs/Misc/smartArray";
  69946. import { ISceneComponent } from "babylonjs/sceneComponent";
  69947. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69948. import "babylonjs/Meshes/Builders/boxBuilder";
  69949. import "babylonjs/Shaders/color.fragment";
  69950. import "babylonjs/Shaders/color.vertex";
  69951. import { Color3 } from "babylonjs/Maths/math.color";
  69952. module "babylonjs/scene" {
  69953. interface Scene {
  69954. /** @hidden (Backing field) */
  69955. _boundingBoxRenderer: BoundingBoxRenderer;
  69956. /** @hidden (Backing field) */
  69957. _forceShowBoundingBoxes: boolean;
  69958. /**
  69959. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69960. */
  69961. forceShowBoundingBoxes: boolean;
  69962. /**
  69963. * Gets the bounding box renderer associated with the scene
  69964. * @returns a BoundingBoxRenderer
  69965. */
  69966. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69967. }
  69968. }
  69969. module "babylonjs/Meshes/abstractMesh" {
  69970. interface AbstractMesh {
  69971. /** @hidden (Backing field) */
  69972. _showBoundingBox: boolean;
  69973. /**
  69974. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69975. */
  69976. showBoundingBox: boolean;
  69977. }
  69978. }
  69979. /**
  69980. * Component responsible of rendering the bounding box of the meshes in a scene.
  69981. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69982. */
  69983. export class BoundingBoxRenderer implements ISceneComponent {
  69984. /**
  69985. * The component name helpfull to identify the component in the list of scene components.
  69986. */
  69987. readonly name: string;
  69988. /**
  69989. * The scene the component belongs to.
  69990. */
  69991. scene: Scene;
  69992. /**
  69993. * Color of the bounding box lines placed in front of an object
  69994. */
  69995. frontColor: Color3;
  69996. /**
  69997. * Color of the bounding box lines placed behind an object
  69998. */
  69999. backColor: Color3;
  70000. /**
  70001. * Defines if the renderer should show the back lines or not
  70002. */
  70003. showBackLines: boolean;
  70004. /**
  70005. * @hidden
  70006. */
  70007. renderList: SmartArray<BoundingBox>;
  70008. private _colorShader;
  70009. private _vertexBuffers;
  70010. private _indexBuffer;
  70011. private _fillIndexBuffer;
  70012. private _fillIndexData;
  70013. /**
  70014. * Instantiates a new bounding box renderer in a scene.
  70015. * @param scene the scene the renderer renders in
  70016. */
  70017. constructor(scene: Scene);
  70018. /**
  70019. * Registers the component in a given scene
  70020. */
  70021. register(): void;
  70022. private _evaluateSubMesh;
  70023. private _activeMesh;
  70024. private _prepareRessources;
  70025. private _createIndexBuffer;
  70026. /**
  70027. * Rebuilds the elements related to this component in case of
  70028. * context lost for instance.
  70029. */
  70030. rebuild(): void;
  70031. /**
  70032. * @hidden
  70033. */
  70034. reset(): void;
  70035. /**
  70036. * Render the bounding boxes of a specific rendering group
  70037. * @param renderingGroupId defines the rendering group to render
  70038. */
  70039. render(renderingGroupId: number): void;
  70040. /**
  70041. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70042. * @param mesh Define the mesh to render the occlusion bounding box for
  70043. */
  70044. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70045. /**
  70046. * Dispose and release the resources attached to this renderer.
  70047. */
  70048. dispose(): void;
  70049. }
  70050. }
  70051. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70052. import { Nullable } from "babylonjs/types";
  70053. import { Scene } from "babylonjs/scene";
  70054. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70055. import { Camera } from "babylonjs/Cameras/camera";
  70056. import { ISceneComponent } from "babylonjs/sceneComponent";
  70057. module "babylonjs/scene" {
  70058. interface Scene {
  70059. /** @hidden (Backing field) */
  70060. _depthRenderer: {
  70061. [id: string]: DepthRenderer;
  70062. };
  70063. /**
  70064. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70065. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70066. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70067. * @returns the created depth renderer
  70068. */
  70069. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70070. /**
  70071. * Disables a depth renderer for a given camera
  70072. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70073. */
  70074. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70075. }
  70076. }
  70077. /**
  70078. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70079. * in several rendering techniques.
  70080. */
  70081. export class DepthRendererSceneComponent implements ISceneComponent {
  70082. /**
  70083. * The component name helpfull to identify the component in the list of scene components.
  70084. */
  70085. readonly name: string;
  70086. /**
  70087. * The scene the component belongs to.
  70088. */
  70089. scene: Scene;
  70090. /**
  70091. * Creates a new instance of the component for the given scene
  70092. * @param scene Defines the scene to register the component in
  70093. */
  70094. constructor(scene: Scene);
  70095. /**
  70096. * Registers the component in a given scene
  70097. */
  70098. register(): void;
  70099. /**
  70100. * Rebuilds the elements related to this component in case of
  70101. * context lost for instance.
  70102. */
  70103. rebuild(): void;
  70104. /**
  70105. * Disposes the component and the associated ressources
  70106. */
  70107. dispose(): void;
  70108. private _gatherRenderTargets;
  70109. private _gatherActiveCameraRenderTargets;
  70110. }
  70111. }
  70112. declare module "babylonjs/Shaders/outline.fragment" {
  70113. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70114. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70115. /** @hidden */
  70116. export var outlinePixelShader: {
  70117. name: string;
  70118. shader: string;
  70119. };
  70120. }
  70121. declare module "babylonjs/Shaders/outline.vertex" {
  70122. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70124. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70125. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70126. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70127. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70128. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70129. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70130. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70131. /** @hidden */
  70132. export var outlineVertexShader: {
  70133. name: string;
  70134. shader: string;
  70135. };
  70136. }
  70137. declare module "babylonjs/Rendering/outlineRenderer" {
  70138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70139. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70140. import { Scene } from "babylonjs/scene";
  70141. import { ISceneComponent } from "babylonjs/sceneComponent";
  70142. import "babylonjs/Shaders/outline.fragment";
  70143. import "babylonjs/Shaders/outline.vertex";
  70144. module "babylonjs/scene" {
  70145. interface Scene {
  70146. /** @hidden */
  70147. _outlineRenderer: OutlineRenderer;
  70148. /**
  70149. * Gets the outline renderer associated with the scene
  70150. * @returns a OutlineRenderer
  70151. */
  70152. getOutlineRenderer(): OutlineRenderer;
  70153. }
  70154. }
  70155. module "babylonjs/Meshes/abstractMesh" {
  70156. interface AbstractMesh {
  70157. /** @hidden (Backing field) */
  70158. _renderOutline: boolean;
  70159. /**
  70160. * Gets or sets a boolean indicating if the outline must be rendered as well
  70161. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70162. */
  70163. renderOutline: boolean;
  70164. /** @hidden (Backing field) */
  70165. _renderOverlay: boolean;
  70166. /**
  70167. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70168. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70169. */
  70170. renderOverlay: boolean;
  70171. }
  70172. }
  70173. /**
  70174. * This class is responsible to draw bothe outline/overlay of meshes.
  70175. * It should not be used directly but through the available method on mesh.
  70176. */
  70177. export class OutlineRenderer implements ISceneComponent {
  70178. /**
  70179. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70180. */
  70181. private static _StencilReference;
  70182. /**
  70183. * The name of the component. Each component must have a unique name.
  70184. */
  70185. name: string;
  70186. /**
  70187. * The scene the component belongs to.
  70188. */
  70189. scene: Scene;
  70190. /**
  70191. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70192. */
  70193. zOffset: number;
  70194. private _engine;
  70195. private _effect;
  70196. private _cachedDefines;
  70197. private _savedDepthWrite;
  70198. /**
  70199. * Instantiates a new outline renderer. (There could be only one per scene).
  70200. * @param scene Defines the scene it belongs to
  70201. */
  70202. constructor(scene: Scene);
  70203. /**
  70204. * Register the component to one instance of a scene.
  70205. */
  70206. register(): void;
  70207. /**
  70208. * Rebuilds the elements related to this component in case of
  70209. * context lost for instance.
  70210. */
  70211. rebuild(): void;
  70212. /**
  70213. * Disposes the component and the associated ressources.
  70214. */
  70215. dispose(): void;
  70216. /**
  70217. * Renders the outline in the canvas.
  70218. * @param subMesh Defines the sumesh to render
  70219. * @param batch Defines the batch of meshes in case of instances
  70220. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70221. */
  70222. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70223. /**
  70224. * Returns whether or not the outline renderer is ready for a given submesh.
  70225. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70226. * @param subMesh Defines the submesh to check readyness for
  70227. * @param useInstances Defines wheter wee are trying to render instances or not
  70228. * @returns true if ready otherwise false
  70229. */
  70230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70231. private _beforeRenderingMesh;
  70232. private _afterRenderingMesh;
  70233. }
  70234. }
  70235. declare module "babylonjs/Rendering/index" {
  70236. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70237. export * from "babylonjs/Rendering/depthRenderer";
  70238. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70239. export * from "babylonjs/Rendering/edgesRenderer";
  70240. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70241. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70242. export * from "babylonjs/Rendering/outlineRenderer";
  70243. export * from "babylonjs/Rendering/renderingGroup";
  70244. export * from "babylonjs/Rendering/renderingManager";
  70245. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70246. }
  70247. declare module "babylonjs/Sprites/ISprites" {
  70248. /**
  70249. * Defines the basic options interface of a Sprite Frame Source Size.
  70250. */
  70251. export interface ISpriteJSONSpriteSourceSize {
  70252. /**
  70253. * number of the original width of the Frame
  70254. */
  70255. w: number;
  70256. /**
  70257. * number of the original height of the Frame
  70258. */
  70259. h: number;
  70260. }
  70261. /**
  70262. * Defines the basic options interface of a Sprite Frame Data.
  70263. */
  70264. export interface ISpriteJSONSpriteFrameData {
  70265. /**
  70266. * number of the x offset of the Frame
  70267. */
  70268. x: number;
  70269. /**
  70270. * number of the y offset of the Frame
  70271. */
  70272. y: number;
  70273. /**
  70274. * number of the width of the Frame
  70275. */
  70276. w: number;
  70277. /**
  70278. * number of the height of the Frame
  70279. */
  70280. h: number;
  70281. }
  70282. /**
  70283. * Defines the basic options interface of a JSON Sprite.
  70284. */
  70285. export interface ISpriteJSONSprite {
  70286. /**
  70287. * string name of the Frame
  70288. */
  70289. filename: string;
  70290. /**
  70291. * ISpriteJSONSpriteFrame basic object of the frame data
  70292. */
  70293. frame: ISpriteJSONSpriteFrameData;
  70294. /**
  70295. * boolean to flag is the frame was rotated.
  70296. */
  70297. rotated: boolean;
  70298. /**
  70299. * boolean to flag is the frame was trimmed.
  70300. */
  70301. trimmed: boolean;
  70302. /**
  70303. * ISpriteJSONSpriteFrame basic object of the source data
  70304. */
  70305. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70306. /**
  70307. * ISpriteJSONSpriteFrame basic object of the source data
  70308. */
  70309. sourceSize: ISpriteJSONSpriteSourceSize;
  70310. }
  70311. /**
  70312. * Defines the basic options interface of a JSON atlas.
  70313. */
  70314. export interface ISpriteJSONAtlas {
  70315. /**
  70316. * Array of objects that contain the frame data.
  70317. */
  70318. frames: Array<ISpriteJSONSprite>;
  70319. /**
  70320. * object basic object containing the sprite meta data.
  70321. */
  70322. meta?: object;
  70323. }
  70324. }
  70325. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70326. /** @hidden */
  70327. export var spriteMapPixelShader: {
  70328. name: string;
  70329. shader: string;
  70330. };
  70331. }
  70332. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70333. /** @hidden */
  70334. export var spriteMapVertexShader: {
  70335. name: string;
  70336. shader: string;
  70337. };
  70338. }
  70339. declare module "babylonjs/Sprites/spriteMap" {
  70340. import { IDisposable, Scene } from "babylonjs/scene";
  70341. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70342. import { Texture } from "babylonjs/Materials/Textures/texture";
  70343. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70344. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70345. import "babylonjs/Meshes/Builders/planeBuilder";
  70346. import "babylonjs/Shaders/spriteMap.fragment";
  70347. import "babylonjs/Shaders/spriteMap.vertex";
  70348. /**
  70349. * Defines the basic options interface of a SpriteMap
  70350. */
  70351. export interface ISpriteMapOptions {
  70352. /**
  70353. * Vector2 of the number of cells in the grid.
  70354. */
  70355. stageSize?: Vector2;
  70356. /**
  70357. * Vector2 of the size of the output plane in World Units.
  70358. */
  70359. outputSize?: Vector2;
  70360. /**
  70361. * Vector3 of the position of the output plane in World Units.
  70362. */
  70363. outputPosition?: Vector3;
  70364. /**
  70365. * Vector3 of the rotation of the output plane.
  70366. */
  70367. outputRotation?: Vector3;
  70368. /**
  70369. * number of layers that the system will reserve in resources.
  70370. */
  70371. layerCount?: number;
  70372. /**
  70373. * number of max animation frames a single cell will reserve in resources.
  70374. */
  70375. maxAnimationFrames?: number;
  70376. /**
  70377. * number cell index of the base tile when the system compiles.
  70378. */
  70379. baseTile?: number;
  70380. /**
  70381. * boolean flip the sprite after its been repositioned by the framing data.
  70382. */
  70383. flipU?: boolean;
  70384. /**
  70385. * Vector3 scalar of the global RGB values of the SpriteMap.
  70386. */
  70387. colorMultiply?: Vector3;
  70388. }
  70389. /**
  70390. * Defines the IDisposable interface in order to be cleanable from resources.
  70391. */
  70392. export interface ISpriteMap extends IDisposable {
  70393. /**
  70394. * String name of the SpriteMap.
  70395. */
  70396. name: string;
  70397. /**
  70398. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70399. */
  70400. atlasJSON: ISpriteJSONAtlas;
  70401. /**
  70402. * Texture of the SpriteMap.
  70403. */
  70404. spriteSheet: Texture;
  70405. /**
  70406. * The parameters to initialize the SpriteMap with.
  70407. */
  70408. options: ISpriteMapOptions;
  70409. }
  70410. /**
  70411. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70412. */
  70413. export class SpriteMap implements ISpriteMap {
  70414. /** The Name of the spriteMap */
  70415. name: string;
  70416. /** The JSON file with the frame and meta data */
  70417. atlasJSON: ISpriteJSONAtlas;
  70418. /** The systems Sprite Sheet Texture */
  70419. spriteSheet: Texture;
  70420. /** Arguments passed with the Constructor */
  70421. options: ISpriteMapOptions;
  70422. /** Public Sprite Storage array, parsed from atlasJSON */
  70423. sprites: Array<ISpriteJSONSprite>;
  70424. /** Returns the Number of Sprites in the System */
  70425. get spriteCount(): number;
  70426. /** Returns the Position of Output Plane*/
  70427. get position(): Vector3;
  70428. /** Returns the Position of Output Plane*/
  70429. set position(v: Vector3);
  70430. /** Returns the Rotation of Output Plane*/
  70431. get rotation(): Vector3;
  70432. /** Returns the Rotation of Output Plane*/
  70433. set rotation(v: Vector3);
  70434. /** Sets the AnimationMap*/
  70435. get animationMap(): RawTexture;
  70436. /** Sets the AnimationMap*/
  70437. set animationMap(v: RawTexture);
  70438. /** Scene that the SpriteMap was created in */
  70439. private _scene;
  70440. /** Texture Buffer of Float32 that holds tile frame data*/
  70441. private _frameMap;
  70442. /** Texture Buffers of Float32 that holds tileMap data*/
  70443. private _tileMaps;
  70444. /** Texture Buffer of Float32 that holds Animation Data*/
  70445. private _animationMap;
  70446. /** Custom ShaderMaterial Central to the System*/
  70447. private _material;
  70448. /** Custom ShaderMaterial Central to the System*/
  70449. private _output;
  70450. /** Systems Time Ticker*/
  70451. private _time;
  70452. /**
  70453. * Creates a new SpriteMap
  70454. * @param name defines the SpriteMaps Name
  70455. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70456. * @param spriteSheet is the Texture that the Sprites are on.
  70457. * @param options a basic deployment configuration
  70458. * @param scene The Scene that the map is deployed on
  70459. */
  70460. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70461. /**
  70462. * Returns tileID location
  70463. * @returns Vector2 the cell position ID
  70464. */
  70465. getTileID(): Vector2;
  70466. /**
  70467. * Gets the UV location of the mouse over the SpriteMap.
  70468. * @returns Vector2 the UV position of the mouse interaction
  70469. */
  70470. getMousePosition(): Vector2;
  70471. /**
  70472. * Creates the "frame" texture Buffer
  70473. * -------------------------------------
  70474. * Structure of frames
  70475. * "filename": "Falling-Water-2.png",
  70476. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70477. * "rotated": true,
  70478. * "trimmed": true,
  70479. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70480. * "sourceSize": {"w":32,"h":32}
  70481. * @returns RawTexture of the frameMap
  70482. */
  70483. private _createFrameBuffer;
  70484. /**
  70485. * Creates the tileMap texture Buffer
  70486. * @param buffer normally and array of numbers, or a false to generate from scratch
  70487. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70488. * @returns RawTexture of the tileMap
  70489. */
  70490. private _createTileBuffer;
  70491. /**
  70492. * Modifies the data of the tileMaps
  70493. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70494. * @param pos is the iVector2 Coordinates of the Tile
  70495. * @param tile The SpriteIndex of the new Tile
  70496. */
  70497. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70498. /**
  70499. * Creates the animationMap texture Buffer
  70500. * @param buffer normally and array of numbers, or a false to generate from scratch
  70501. * @returns RawTexture of the animationMap
  70502. */
  70503. private _createTileAnimationBuffer;
  70504. /**
  70505. * Modifies the data of the animationMap
  70506. * @param cellID is the Index of the Sprite
  70507. * @param _frame is the target Animation frame
  70508. * @param toCell is the Target Index of the next frame of the animation
  70509. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70510. * @param speed is a global scalar of the time variable on the map.
  70511. */
  70512. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70513. /**
  70514. * Exports the .tilemaps file
  70515. */
  70516. saveTileMaps(): void;
  70517. /**
  70518. * Imports the .tilemaps file
  70519. * @param url of the .tilemaps file
  70520. */
  70521. loadTileMaps(url: string): void;
  70522. /**
  70523. * Release associated resources
  70524. */
  70525. dispose(): void;
  70526. }
  70527. }
  70528. declare module "babylonjs/Sprites/spritePackedManager" {
  70529. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70530. import { Scene } from "babylonjs/scene";
  70531. /**
  70532. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70533. * @see http://doc.babylonjs.com/babylon101/sprites
  70534. */
  70535. export class SpritePackedManager extends SpriteManager {
  70536. /** defines the packed manager's name */
  70537. name: string;
  70538. /**
  70539. * Creates a new sprite manager from a packed sprite sheet
  70540. * @param name defines the manager's name
  70541. * @param imgUrl defines the sprite sheet url
  70542. * @param capacity defines the maximum allowed number of sprites
  70543. * @param scene defines the hosting scene
  70544. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70545. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70546. * @param samplingMode defines the smapling mode to use with spritesheet
  70547. * @param fromPacked set to true; do not alter
  70548. */
  70549. constructor(
  70550. /** defines the packed manager's name */
  70551. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70552. }
  70553. }
  70554. declare module "babylonjs/Sprites/index" {
  70555. export * from "babylonjs/Sprites/sprite";
  70556. export * from "babylonjs/Sprites/ISprites";
  70557. export * from "babylonjs/Sprites/spriteManager";
  70558. export * from "babylonjs/Sprites/spriteMap";
  70559. export * from "babylonjs/Sprites/spritePackedManager";
  70560. export * from "babylonjs/Sprites/spriteSceneComponent";
  70561. }
  70562. declare module "babylonjs/States/index" {
  70563. export * from "babylonjs/States/alphaCullingState";
  70564. export * from "babylonjs/States/depthCullingState";
  70565. export * from "babylonjs/States/stencilState";
  70566. }
  70567. declare module "babylonjs/Misc/assetsManager" {
  70568. import { Scene } from "babylonjs/scene";
  70569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70570. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70571. import { Skeleton } from "babylonjs/Bones/skeleton";
  70572. import { Observable } from "babylonjs/Misc/observable";
  70573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70574. import { Texture } from "babylonjs/Materials/Textures/texture";
  70575. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70576. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70577. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70578. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70579. /**
  70580. * Defines the list of states available for a task inside a AssetsManager
  70581. */
  70582. export enum AssetTaskState {
  70583. /**
  70584. * Initialization
  70585. */
  70586. INIT = 0,
  70587. /**
  70588. * Running
  70589. */
  70590. RUNNING = 1,
  70591. /**
  70592. * Done
  70593. */
  70594. DONE = 2,
  70595. /**
  70596. * Error
  70597. */
  70598. ERROR = 3
  70599. }
  70600. /**
  70601. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70602. */
  70603. export abstract class AbstractAssetTask {
  70604. /**
  70605. * Task name
  70606. */ name: string;
  70607. /**
  70608. * Callback called when the task is successful
  70609. */
  70610. onSuccess: (task: any) => void;
  70611. /**
  70612. * Callback called when the task is not successful
  70613. */
  70614. onError: (task: any, message?: string, exception?: any) => void;
  70615. /**
  70616. * Creates a new AssetsManager
  70617. * @param name defines the name of the task
  70618. */
  70619. constructor(
  70620. /**
  70621. * Task name
  70622. */ name: string);
  70623. private _isCompleted;
  70624. private _taskState;
  70625. private _errorObject;
  70626. /**
  70627. * Get if the task is completed
  70628. */
  70629. get isCompleted(): boolean;
  70630. /**
  70631. * Gets the current state of the task
  70632. */
  70633. get taskState(): AssetTaskState;
  70634. /**
  70635. * Gets the current error object (if task is in error)
  70636. */
  70637. get errorObject(): {
  70638. message?: string;
  70639. exception?: any;
  70640. };
  70641. /**
  70642. * Internal only
  70643. * @hidden
  70644. */
  70645. _setErrorObject(message?: string, exception?: any): void;
  70646. /**
  70647. * Execute the current task
  70648. * @param scene defines the scene where you want your assets to be loaded
  70649. * @param onSuccess is a callback called when the task is successfully executed
  70650. * @param onError is a callback called if an error occurs
  70651. */
  70652. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70653. /**
  70654. * Execute the current task
  70655. * @param scene defines the scene where you want your assets to be loaded
  70656. * @param onSuccess is a callback called when the task is successfully executed
  70657. * @param onError is a callback called if an error occurs
  70658. */
  70659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70660. /**
  70661. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70662. * This can be used with failed tasks that have the reason for failure fixed.
  70663. */
  70664. reset(): void;
  70665. private onErrorCallback;
  70666. private onDoneCallback;
  70667. }
  70668. /**
  70669. * Define the interface used by progress events raised during assets loading
  70670. */
  70671. export interface IAssetsProgressEvent {
  70672. /**
  70673. * Defines the number of remaining tasks to process
  70674. */
  70675. remainingCount: number;
  70676. /**
  70677. * Defines the total number of tasks
  70678. */
  70679. totalCount: number;
  70680. /**
  70681. * Defines the task that was just processed
  70682. */
  70683. task: AbstractAssetTask;
  70684. }
  70685. /**
  70686. * Class used to share progress information about assets loading
  70687. */
  70688. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70689. /**
  70690. * Defines the number of remaining tasks to process
  70691. */
  70692. remainingCount: number;
  70693. /**
  70694. * Defines the total number of tasks
  70695. */
  70696. totalCount: number;
  70697. /**
  70698. * Defines the task that was just processed
  70699. */
  70700. task: AbstractAssetTask;
  70701. /**
  70702. * Creates a AssetsProgressEvent
  70703. * @param remainingCount defines the number of remaining tasks to process
  70704. * @param totalCount defines the total number of tasks
  70705. * @param task defines the task that was just processed
  70706. */
  70707. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70708. }
  70709. /**
  70710. * Define a task used by AssetsManager to load meshes
  70711. */
  70712. export class MeshAssetTask extends AbstractAssetTask {
  70713. /**
  70714. * Defines the name of the task
  70715. */
  70716. name: string;
  70717. /**
  70718. * Defines the list of mesh's names you want to load
  70719. */
  70720. meshesNames: any;
  70721. /**
  70722. * Defines the root url to use as a base to load your meshes and associated resources
  70723. */
  70724. rootUrl: string;
  70725. /**
  70726. * Defines the filename of the scene to load from
  70727. */
  70728. sceneFilename: string;
  70729. /**
  70730. * Gets the list of loaded meshes
  70731. */
  70732. loadedMeshes: Array<AbstractMesh>;
  70733. /**
  70734. * Gets the list of loaded particle systems
  70735. */
  70736. loadedParticleSystems: Array<IParticleSystem>;
  70737. /**
  70738. * Gets the list of loaded skeletons
  70739. */
  70740. loadedSkeletons: Array<Skeleton>;
  70741. /**
  70742. * Gets the list of loaded animation groups
  70743. */
  70744. loadedAnimationGroups: Array<AnimationGroup>;
  70745. /**
  70746. * Callback called when the task is successful
  70747. */
  70748. onSuccess: (task: MeshAssetTask) => void;
  70749. /**
  70750. * Callback called when the task is successful
  70751. */
  70752. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70753. /**
  70754. * Creates a new MeshAssetTask
  70755. * @param name defines the name of the task
  70756. * @param meshesNames defines the list of mesh's names you want to load
  70757. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70758. * @param sceneFilename defines the filename of the scene to load from
  70759. */
  70760. constructor(
  70761. /**
  70762. * Defines the name of the task
  70763. */
  70764. name: string,
  70765. /**
  70766. * Defines the list of mesh's names you want to load
  70767. */
  70768. meshesNames: any,
  70769. /**
  70770. * Defines the root url to use as a base to load your meshes and associated resources
  70771. */
  70772. rootUrl: string,
  70773. /**
  70774. * Defines the filename of the scene to load from
  70775. */
  70776. sceneFilename: string);
  70777. /**
  70778. * Execute the current task
  70779. * @param scene defines the scene where you want your assets to be loaded
  70780. * @param onSuccess is a callback called when the task is successfully executed
  70781. * @param onError is a callback called if an error occurs
  70782. */
  70783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70784. }
  70785. /**
  70786. * Define a task used by AssetsManager to load text content
  70787. */
  70788. export class TextFileAssetTask extends AbstractAssetTask {
  70789. /**
  70790. * Defines the name of the task
  70791. */
  70792. name: string;
  70793. /**
  70794. * Defines the location of the file to load
  70795. */
  70796. url: string;
  70797. /**
  70798. * Gets the loaded text string
  70799. */
  70800. text: string;
  70801. /**
  70802. * Callback called when the task is successful
  70803. */
  70804. onSuccess: (task: TextFileAssetTask) => void;
  70805. /**
  70806. * Callback called when the task is successful
  70807. */
  70808. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70809. /**
  70810. * Creates a new TextFileAssetTask object
  70811. * @param name defines the name of the task
  70812. * @param url defines the location of the file to load
  70813. */
  70814. constructor(
  70815. /**
  70816. * Defines the name of the task
  70817. */
  70818. name: string,
  70819. /**
  70820. * Defines the location of the file to load
  70821. */
  70822. url: string);
  70823. /**
  70824. * Execute the current task
  70825. * @param scene defines the scene where you want your assets to be loaded
  70826. * @param onSuccess is a callback called when the task is successfully executed
  70827. * @param onError is a callback called if an error occurs
  70828. */
  70829. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70830. }
  70831. /**
  70832. * Define a task used by AssetsManager to load binary data
  70833. */
  70834. export class BinaryFileAssetTask extends AbstractAssetTask {
  70835. /**
  70836. * Defines the name of the task
  70837. */
  70838. name: string;
  70839. /**
  70840. * Defines the location of the file to load
  70841. */
  70842. url: string;
  70843. /**
  70844. * Gets the lodaded data (as an array buffer)
  70845. */
  70846. data: ArrayBuffer;
  70847. /**
  70848. * Callback called when the task is successful
  70849. */
  70850. onSuccess: (task: BinaryFileAssetTask) => void;
  70851. /**
  70852. * Callback called when the task is successful
  70853. */
  70854. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70855. /**
  70856. * Creates a new BinaryFileAssetTask object
  70857. * @param name defines the name of the new task
  70858. * @param url defines the location of the file to load
  70859. */
  70860. constructor(
  70861. /**
  70862. * Defines the name of the task
  70863. */
  70864. name: string,
  70865. /**
  70866. * Defines the location of the file to load
  70867. */
  70868. url: string);
  70869. /**
  70870. * Execute the current task
  70871. * @param scene defines the scene where you want your assets to be loaded
  70872. * @param onSuccess is a callback called when the task is successfully executed
  70873. * @param onError is a callback called if an error occurs
  70874. */
  70875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70876. }
  70877. /**
  70878. * Define a task used by AssetsManager to load images
  70879. */
  70880. export class ImageAssetTask extends AbstractAssetTask {
  70881. /**
  70882. * Defines the name of the task
  70883. */
  70884. name: string;
  70885. /**
  70886. * Defines the location of the image to load
  70887. */
  70888. url: string;
  70889. /**
  70890. * Gets the loaded images
  70891. */
  70892. image: HTMLImageElement;
  70893. /**
  70894. * Callback called when the task is successful
  70895. */
  70896. onSuccess: (task: ImageAssetTask) => void;
  70897. /**
  70898. * Callback called when the task is successful
  70899. */
  70900. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70901. /**
  70902. * Creates a new ImageAssetTask
  70903. * @param name defines the name of the task
  70904. * @param url defines the location of the image to load
  70905. */
  70906. constructor(
  70907. /**
  70908. * Defines the name of the task
  70909. */
  70910. name: string,
  70911. /**
  70912. * Defines the location of the image to load
  70913. */
  70914. url: string);
  70915. /**
  70916. * Execute the current task
  70917. * @param scene defines the scene where you want your assets to be loaded
  70918. * @param onSuccess is a callback called when the task is successfully executed
  70919. * @param onError is a callback called if an error occurs
  70920. */
  70921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70922. }
  70923. /**
  70924. * Defines the interface used by texture loading tasks
  70925. */
  70926. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70927. /**
  70928. * Gets the loaded texture
  70929. */
  70930. texture: TEX;
  70931. }
  70932. /**
  70933. * Define a task used by AssetsManager to load 2D textures
  70934. */
  70935. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70936. /**
  70937. * Defines the name of the task
  70938. */
  70939. name: string;
  70940. /**
  70941. * Defines the location of the file to load
  70942. */
  70943. url: string;
  70944. /**
  70945. * Defines if mipmap should not be generated (default is false)
  70946. */
  70947. noMipmap?: boolean | undefined;
  70948. /**
  70949. * Defines if texture must be inverted on Y axis (default is false)
  70950. */
  70951. invertY?: boolean | undefined;
  70952. /**
  70953. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70954. */
  70955. samplingMode: number;
  70956. /**
  70957. * Gets the loaded texture
  70958. */
  70959. texture: Texture;
  70960. /**
  70961. * Callback called when the task is successful
  70962. */
  70963. onSuccess: (task: TextureAssetTask) => void;
  70964. /**
  70965. * Callback called when the task is successful
  70966. */
  70967. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70968. /**
  70969. * Creates a new TextureAssetTask object
  70970. * @param name defines the name of the task
  70971. * @param url defines the location of the file to load
  70972. * @param noMipmap defines if mipmap should not be generated (default is false)
  70973. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70974. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70975. */
  70976. constructor(
  70977. /**
  70978. * Defines the name of the task
  70979. */
  70980. name: string,
  70981. /**
  70982. * Defines the location of the file to load
  70983. */
  70984. url: string,
  70985. /**
  70986. * Defines if mipmap should not be generated (default is false)
  70987. */
  70988. noMipmap?: boolean | undefined,
  70989. /**
  70990. * Defines if texture must be inverted on Y axis (default is false)
  70991. */
  70992. invertY?: boolean | undefined,
  70993. /**
  70994. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70995. */
  70996. samplingMode?: number);
  70997. /**
  70998. * Execute the current task
  70999. * @param scene defines the scene where you want your assets to be loaded
  71000. * @param onSuccess is a callback called when the task is successfully executed
  71001. * @param onError is a callback called if an error occurs
  71002. */
  71003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71004. }
  71005. /**
  71006. * Define a task used by AssetsManager to load cube textures
  71007. */
  71008. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71009. /**
  71010. * Defines the name of the task
  71011. */
  71012. name: string;
  71013. /**
  71014. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71015. */
  71016. url: string;
  71017. /**
  71018. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71019. */
  71020. extensions?: string[] | undefined;
  71021. /**
  71022. * Defines if mipmaps should not be generated (default is false)
  71023. */
  71024. noMipmap?: boolean | undefined;
  71025. /**
  71026. * Defines the explicit list of files (undefined by default)
  71027. */
  71028. files?: string[] | undefined;
  71029. /**
  71030. * Gets the loaded texture
  71031. */
  71032. texture: CubeTexture;
  71033. /**
  71034. * Callback called when the task is successful
  71035. */
  71036. onSuccess: (task: CubeTextureAssetTask) => void;
  71037. /**
  71038. * Callback called when the task is successful
  71039. */
  71040. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71041. /**
  71042. * Creates a new CubeTextureAssetTask
  71043. * @param name defines the name of the task
  71044. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71045. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71046. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71047. * @param files defines the explicit list of files (undefined by default)
  71048. */
  71049. constructor(
  71050. /**
  71051. * Defines the name of the task
  71052. */
  71053. name: string,
  71054. /**
  71055. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71056. */
  71057. url: string,
  71058. /**
  71059. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71060. */
  71061. extensions?: string[] | undefined,
  71062. /**
  71063. * Defines if mipmaps should not be generated (default is false)
  71064. */
  71065. noMipmap?: boolean | undefined,
  71066. /**
  71067. * Defines the explicit list of files (undefined by default)
  71068. */
  71069. files?: string[] | undefined);
  71070. /**
  71071. * Execute the current task
  71072. * @param scene defines the scene where you want your assets to be loaded
  71073. * @param onSuccess is a callback called when the task is successfully executed
  71074. * @param onError is a callback called if an error occurs
  71075. */
  71076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71077. }
  71078. /**
  71079. * Define a task used by AssetsManager to load HDR cube textures
  71080. */
  71081. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71082. /**
  71083. * Defines the name of the task
  71084. */
  71085. name: string;
  71086. /**
  71087. * Defines the location of the file to load
  71088. */
  71089. url: string;
  71090. /**
  71091. * Defines the desired size (the more it increases the longer the generation will be)
  71092. */
  71093. size: number;
  71094. /**
  71095. * Defines if mipmaps should not be generated (default is false)
  71096. */
  71097. noMipmap: boolean;
  71098. /**
  71099. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71100. */
  71101. generateHarmonics: boolean;
  71102. /**
  71103. * 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)
  71104. */
  71105. gammaSpace: boolean;
  71106. /**
  71107. * Internal Use Only
  71108. */
  71109. reserved: boolean;
  71110. /**
  71111. * Gets the loaded texture
  71112. */
  71113. texture: HDRCubeTexture;
  71114. /**
  71115. * Callback called when the task is successful
  71116. */
  71117. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71118. /**
  71119. * Callback called when the task is successful
  71120. */
  71121. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71122. /**
  71123. * Creates a new HDRCubeTextureAssetTask object
  71124. * @param name defines the name of the task
  71125. * @param url defines the location of the file to load
  71126. * @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.
  71127. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71128. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71129. * @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)
  71130. * @param reserved Internal use only
  71131. */
  71132. constructor(
  71133. /**
  71134. * Defines the name of the task
  71135. */
  71136. name: string,
  71137. /**
  71138. * Defines the location of the file to load
  71139. */
  71140. url: string,
  71141. /**
  71142. * Defines the desired size (the more it increases the longer the generation will be)
  71143. */
  71144. size: number,
  71145. /**
  71146. * Defines if mipmaps should not be generated (default is false)
  71147. */
  71148. noMipmap?: boolean,
  71149. /**
  71150. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71151. */
  71152. generateHarmonics?: boolean,
  71153. /**
  71154. * 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)
  71155. */
  71156. gammaSpace?: boolean,
  71157. /**
  71158. * Internal Use Only
  71159. */
  71160. reserved?: boolean);
  71161. /**
  71162. * Execute the current task
  71163. * @param scene defines the scene where you want your assets to be loaded
  71164. * @param onSuccess is a callback called when the task is successfully executed
  71165. * @param onError is a callback called if an error occurs
  71166. */
  71167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71168. }
  71169. /**
  71170. * Define a task used by AssetsManager to load Equirectangular cube textures
  71171. */
  71172. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71173. /**
  71174. * Defines the name of the task
  71175. */
  71176. name: string;
  71177. /**
  71178. * Defines the location of the file to load
  71179. */
  71180. url: string;
  71181. /**
  71182. * Defines the desired size (the more it increases the longer the generation will be)
  71183. */
  71184. size: number;
  71185. /**
  71186. * Defines if mipmaps should not be generated (default is false)
  71187. */
  71188. noMipmap: boolean;
  71189. /**
  71190. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71191. * but the standard material would require them in Gamma space) (default is true)
  71192. */
  71193. gammaSpace: boolean;
  71194. /**
  71195. * Gets the loaded texture
  71196. */
  71197. texture: EquiRectangularCubeTexture;
  71198. /**
  71199. * Callback called when the task is successful
  71200. */
  71201. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71202. /**
  71203. * Callback called when the task is successful
  71204. */
  71205. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71206. /**
  71207. * Creates a new EquiRectangularCubeTextureAssetTask object
  71208. * @param name defines the name of the task
  71209. * @param url defines the location of the file to load
  71210. * @param size defines the desired size (the more it increases the longer the generation will be)
  71211. * If the size is omitted this implies you are using a preprocessed cubemap.
  71212. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71213. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71214. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71215. * (default is true)
  71216. */
  71217. constructor(
  71218. /**
  71219. * Defines the name of the task
  71220. */
  71221. name: string,
  71222. /**
  71223. * Defines the location of the file to load
  71224. */
  71225. url: string,
  71226. /**
  71227. * Defines the desired size (the more it increases the longer the generation will be)
  71228. */
  71229. size: number,
  71230. /**
  71231. * Defines if mipmaps should not be generated (default is false)
  71232. */
  71233. noMipmap?: boolean,
  71234. /**
  71235. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71236. * but the standard material would require them in Gamma space) (default is true)
  71237. */
  71238. gammaSpace?: boolean);
  71239. /**
  71240. * Execute the current task
  71241. * @param scene defines the scene where you want your assets to be loaded
  71242. * @param onSuccess is a callback called when the task is successfully executed
  71243. * @param onError is a callback called if an error occurs
  71244. */
  71245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71246. }
  71247. /**
  71248. * This class can be used to easily import assets into a scene
  71249. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71250. */
  71251. export class AssetsManager {
  71252. private _scene;
  71253. private _isLoading;
  71254. protected _tasks: AbstractAssetTask[];
  71255. protected _waitingTasksCount: number;
  71256. protected _totalTasksCount: number;
  71257. /**
  71258. * Callback called when all tasks are processed
  71259. */
  71260. onFinish: (tasks: AbstractAssetTask[]) => void;
  71261. /**
  71262. * Callback called when a task is successful
  71263. */
  71264. onTaskSuccess: (task: AbstractAssetTask) => void;
  71265. /**
  71266. * Callback called when a task had an error
  71267. */
  71268. onTaskError: (task: AbstractAssetTask) => void;
  71269. /**
  71270. * Callback called when a task is done (whatever the result is)
  71271. */
  71272. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71273. /**
  71274. * Observable called when all tasks are processed
  71275. */
  71276. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71277. /**
  71278. * Observable called when a task had an error
  71279. */
  71280. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71281. /**
  71282. * Observable called when all tasks were executed
  71283. */
  71284. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71285. /**
  71286. * Observable called when a task is done (whatever the result is)
  71287. */
  71288. onProgressObservable: Observable<IAssetsProgressEvent>;
  71289. /**
  71290. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71292. */
  71293. useDefaultLoadingScreen: boolean;
  71294. /**
  71295. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71296. * when all assets have been downloaded.
  71297. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71298. */
  71299. autoHideLoadingUI: boolean;
  71300. /**
  71301. * Creates a new AssetsManager
  71302. * @param scene defines the scene to work on
  71303. */
  71304. constructor(scene: Scene);
  71305. /**
  71306. * Add a MeshAssetTask to the list of active tasks
  71307. * @param taskName defines the name of the new task
  71308. * @param meshesNames defines the name of meshes to load
  71309. * @param rootUrl defines the root url to use to locate files
  71310. * @param sceneFilename defines the filename of the scene file
  71311. * @returns a new MeshAssetTask object
  71312. */
  71313. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71314. /**
  71315. * Add a TextFileAssetTask to the list of active tasks
  71316. * @param taskName defines the name of the new task
  71317. * @param url defines the url of the file to load
  71318. * @returns a new TextFileAssetTask object
  71319. */
  71320. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71321. /**
  71322. * Add a BinaryFileAssetTask to the list of active tasks
  71323. * @param taskName defines the name of the new task
  71324. * @param url defines the url of the file to load
  71325. * @returns a new BinaryFileAssetTask object
  71326. */
  71327. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71328. /**
  71329. * Add a ImageAssetTask to the list of active tasks
  71330. * @param taskName defines the name of the new task
  71331. * @param url defines the url of the file to load
  71332. * @returns a new ImageAssetTask object
  71333. */
  71334. addImageTask(taskName: string, url: string): ImageAssetTask;
  71335. /**
  71336. * Add a TextureAssetTask to the list of active tasks
  71337. * @param taskName defines the name of the new task
  71338. * @param url defines the url of the file to load
  71339. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71340. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71341. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71342. * @returns a new TextureAssetTask object
  71343. */
  71344. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71345. /**
  71346. * Add a CubeTextureAssetTask to the list of active tasks
  71347. * @param taskName defines the name of the new task
  71348. * @param url defines the url of the file to load
  71349. * @param extensions defines the extension to use to load the cube map (can be null)
  71350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71351. * @param files defines the list of files to load (can be null)
  71352. * @returns a new CubeTextureAssetTask object
  71353. */
  71354. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71355. /**
  71356. *
  71357. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71358. * @param taskName defines the name of the new task
  71359. * @param url defines the url of the file to load
  71360. * @param size defines the size you want for the cubemap (can be null)
  71361. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71362. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71363. * @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)
  71364. * @param reserved Internal use only
  71365. * @returns a new HDRCubeTextureAssetTask object
  71366. */
  71367. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71368. /**
  71369. *
  71370. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71371. * @param taskName defines the name of the new task
  71372. * @param url defines the url of the file to load
  71373. * @param size defines the size you want for the cubemap (can be null)
  71374. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71375. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71376. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71377. * @returns a new EquiRectangularCubeTextureAssetTask object
  71378. */
  71379. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71380. /**
  71381. * Remove a task from the assets manager.
  71382. * @param task the task to remove
  71383. */
  71384. removeTask(task: AbstractAssetTask): void;
  71385. private _decreaseWaitingTasksCount;
  71386. private _runTask;
  71387. /**
  71388. * Reset the AssetsManager and remove all tasks
  71389. * @return the current instance of the AssetsManager
  71390. */
  71391. reset(): AssetsManager;
  71392. /**
  71393. * Start the loading process
  71394. * @return the current instance of the AssetsManager
  71395. */
  71396. load(): AssetsManager;
  71397. /**
  71398. * Start the loading process as an async operation
  71399. * @return a promise returning the list of failed tasks
  71400. */
  71401. loadAsync(): Promise<void>;
  71402. }
  71403. }
  71404. declare module "babylonjs/Misc/deferred" {
  71405. /**
  71406. * Wrapper class for promise with external resolve and reject.
  71407. */
  71408. export class Deferred<T> {
  71409. /**
  71410. * The promise associated with this deferred object.
  71411. */
  71412. readonly promise: Promise<T>;
  71413. private _resolve;
  71414. private _reject;
  71415. /**
  71416. * The resolve method of the promise associated with this deferred object.
  71417. */
  71418. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71419. /**
  71420. * The reject method of the promise associated with this deferred object.
  71421. */
  71422. get reject(): (reason?: any) => void;
  71423. /**
  71424. * Constructor for this deferred object.
  71425. */
  71426. constructor();
  71427. }
  71428. }
  71429. declare module "babylonjs/Misc/meshExploder" {
  71430. import { Mesh } from "babylonjs/Meshes/mesh";
  71431. /**
  71432. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71433. */
  71434. export class MeshExploder {
  71435. private _centerMesh;
  71436. private _meshes;
  71437. private _meshesOrigins;
  71438. private _toCenterVectors;
  71439. private _scaledDirection;
  71440. private _newPosition;
  71441. private _centerPosition;
  71442. /**
  71443. * Explodes meshes from a center mesh.
  71444. * @param meshes The meshes to explode.
  71445. * @param centerMesh The mesh to be center of explosion.
  71446. */
  71447. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71448. private _setCenterMesh;
  71449. /**
  71450. * Get class name
  71451. * @returns "MeshExploder"
  71452. */
  71453. getClassName(): string;
  71454. /**
  71455. * "Exploded meshes"
  71456. * @returns Array of meshes with the centerMesh at index 0.
  71457. */
  71458. getMeshes(): Array<Mesh>;
  71459. /**
  71460. * Explodes meshes giving a specific direction
  71461. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71462. */
  71463. explode(direction?: number): void;
  71464. }
  71465. }
  71466. declare module "babylonjs/Misc/filesInput" {
  71467. import { Engine } from "babylonjs/Engines/engine";
  71468. import { Scene } from "babylonjs/scene";
  71469. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71470. /**
  71471. * Class used to help managing file picking and drag'n'drop
  71472. */
  71473. export class FilesInput {
  71474. /**
  71475. * List of files ready to be loaded
  71476. */
  71477. static get FilesToLoad(): {
  71478. [key: string]: File;
  71479. };
  71480. /**
  71481. * Callback called when a file is processed
  71482. */
  71483. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71484. private _engine;
  71485. private _currentScene;
  71486. private _sceneLoadedCallback;
  71487. private _progressCallback;
  71488. private _additionalRenderLoopLogicCallback;
  71489. private _textureLoadingCallback;
  71490. private _startingProcessingFilesCallback;
  71491. private _onReloadCallback;
  71492. private _errorCallback;
  71493. private _elementToMonitor;
  71494. private _sceneFileToLoad;
  71495. private _filesToLoad;
  71496. /**
  71497. * Creates a new FilesInput
  71498. * @param engine defines the rendering engine
  71499. * @param scene defines the hosting scene
  71500. * @param sceneLoadedCallback callback called when scene is loaded
  71501. * @param progressCallback callback called to track progress
  71502. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71503. * @param textureLoadingCallback callback called when a texture is loading
  71504. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71505. * @param onReloadCallback callback called when a reload is requested
  71506. * @param errorCallback callback call if an error occurs
  71507. */
  71508. 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);
  71509. private _dragEnterHandler;
  71510. private _dragOverHandler;
  71511. private _dropHandler;
  71512. /**
  71513. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71514. * @param elementToMonitor defines the DOM element to track
  71515. */
  71516. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71517. /**
  71518. * Release all associated resources
  71519. */
  71520. dispose(): void;
  71521. private renderFunction;
  71522. private drag;
  71523. private drop;
  71524. private _traverseFolder;
  71525. private _processFiles;
  71526. /**
  71527. * Load files from a drop event
  71528. * @param event defines the drop event to use as source
  71529. */
  71530. loadFiles(event: any): void;
  71531. private _processReload;
  71532. /**
  71533. * Reload the current scene from the loaded files
  71534. */
  71535. reload(): void;
  71536. }
  71537. }
  71538. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71539. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71540. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71541. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71542. }
  71543. declare module "babylonjs/Misc/sceneOptimizer" {
  71544. import { Scene, IDisposable } from "babylonjs/scene";
  71545. import { Observable } from "babylonjs/Misc/observable";
  71546. /**
  71547. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71549. */
  71550. export class SceneOptimization {
  71551. /**
  71552. * Defines the priority of this optimization (0 by default which means first in the list)
  71553. */
  71554. priority: number;
  71555. /**
  71556. * Gets a string describing the action executed by the current optimization
  71557. * @returns description string
  71558. */
  71559. getDescription(): string;
  71560. /**
  71561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71562. * @param scene defines the current scene where to apply this optimization
  71563. * @param optimizer defines the current optimizer
  71564. * @returns true if everything that can be done was applied
  71565. */
  71566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71567. /**
  71568. * Creates the SceneOptimization object
  71569. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71570. * @param desc defines the description associated with the optimization
  71571. */
  71572. constructor(
  71573. /**
  71574. * Defines the priority of this optimization (0 by default which means first in the list)
  71575. */
  71576. priority?: number);
  71577. }
  71578. /**
  71579. * Defines an optimization used to reduce the size of render target textures
  71580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71581. */
  71582. export class TextureOptimization extends SceneOptimization {
  71583. /**
  71584. * Defines the priority of this optimization (0 by default which means first in the list)
  71585. */
  71586. priority: number;
  71587. /**
  71588. * 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
  71589. */
  71590. maximumSize: number;
  71591. /**
  71592. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71593. */
  71594. step: number;
  71595. /**
  71596. * Gets a string describing the action executed by the current optimization
  71597. * @returns description string
  71598. */
  71599. getDescription(): string;
  71600. /**
  71601. * Creates the TextureOptimization object
  71602. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71603. * @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
  71604. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71605. */
  71606. constructor(
  71607. /**
  71608. * Defines the priority of this optimization (0 by default which means first in the list)
  71609. */
  71610. priority?: number,
  71611. /**
  71612. * 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
  71613. */
  71614. maximumSize?: number,
  71615. /**
  71616. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71617. */
  71618. step?: number);
  71619. /**
  71620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71621. * @param scene defines the current scene where to apply this optimization
  71622. * @param optimizer defines the current optimizer
  71623. * @returns true if everything that can be done was applied
  71624. */
  71625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71626. }
  71627. /**
  71628. * Defines an optimization used to increase or decrease the rendering resolution
  71629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71630. */
  71631. export class HardwareScalingOptimization extends SceneOptimization {
  71632. /**
  71633. * Defines the priority of this optimization (0 by default which means first in the list)
  71634. */
  71635. priority: number;
  71636. /**
  71637. * Defines the maximum scale to use (2 by default)
  71638. */
  71639. maximumScale: number;
  71640. /**
  71641. * Defines the step to use between two passes (0.5 by default)
  71642. */
  71643. step: number;
  71644. private _currentScale;
  71645. private _directionOffset;
  71646. /**
  71647. * Gets a string describing the action executed by the current optimization
  71648. * @return description string
  71649. */
  71650. getDescription(): string;
  71651. /**
  71652. * Creates the HardwareScalingOptimization object
  71653. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71654. * @param maximumScale defines the maximum scale to use (2 by default)
  71655. * @param step defines the step to use between two passes (0.5 by default)
  71656. */
  71657. constructor(
  71658. /**
  71659. * Defines the priority of this optimization (0 by default which means first in the list)
  71660. */
  71661. priority?: number,
  71662. /**
  71663. * Defines the maximum scale to use (2 by default)
  71664. */
  71665. maximumScale?: number,
  71666. /**
  71667. * Defines the step to use between two passes (0.5 by default)
  71668. */
  71669. step?: number);
  71670. /**
  71671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71672. * @param scene defines the current scene where to apply this optimization
  71673. * @param optimizer defines the current optimizer
  71674. * @returns true if everything that can be done was applied
  71675. */
  71676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71677. }
  71678. /**
  71679. * Defines an optimization used to remove shadows
  71680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71681. */
  71682. export class ShadowsOptimization extends SceneOptimization {
  71683. /**
  71684. * Gets a string describing the action executed by the current optimization
  71685. * @return description string
  71686. */
  71687. getDescription(): string;
  71688. /**
  71689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71690. * @param scene defines the current scene where to apply this optimization
  71691. * @param optimizer defines the current optimizer
  71692. * @returns true if everything that can be done was applied
  71693. */
  71694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71695. }
  71696. /**
  71697. * Defines an optimization used to turn post-processes off
  71698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71699. */
  71700. export class PostProcessesOptimization extends SceneOptimization {
  71701. /**
  71702. * Gets a string describing the action executed by the current optimization
  71703. * @return description string
  71704. */
  71705. getDescription(): string;
  71706. /**
  71707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71708. * @param scene defines the current scene where to apply this optimization
  71709. * @param optimizer defines the current optimizer
  71710. * @returns true if everything that can be done was applied
  71711. */
  71712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71713. }
  71714. /**
  71715. * Defines an optimization used to turn lens flares off
  71716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71717. */
  71718. export class LensFlaresOptimization extends SceneOptimization {
  71719. /**
  71720. * Gets a string describing the action executed by the current optimization
  71721. * @return description string
  71722. */
  71723. getDescription(): string;
  71724. /**
  71725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71726. * @param scene defines the current scene where to apply this optimization
  71727. * @param optimizer defines the current optimizer
  71728. * @returns true if everything that can be done was applied
  71729. */
  71730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71731. }
  71732. /**
  71733. * Defines an optimization based on user defined callback.
  71734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71735. */
  71736. export class CustomOptimization extends SceneOptimization {
  71737. /**
  71738. * Callback called to apply the custom optimization.
  71739. */
  71740. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71741. /**
  71742. * Callback called to get custom description
  71743. */
  71744. onGetDescription: () => string;
  71745. /**
  71746. * Gets a string describing the action executed by the current optimization
  71747. * @returns description string
  71748. */
  71749. getDescription(): string;
  71750. /**
  71751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71752. * @param scene defines the current scene where to apply this optimization
  71753. * @param optimizer defines the current optimizer
  71754. * @returns true if everything that can be done was applied
  71755. */
  71756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71757. }
  71758. /**
  71759. * Defines an optimization used to turn particles off
  71760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71761. */
  71762. export class ParticlesOptimization extends SceneOptimization {
  71763. /**
  71764. * Gets a string describing the action executed by the current optimization
  71765. * @return description string
  71766. */
  71767. getDescription(): string;
  71768. /**
  71769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71770. * @param scene defines the current scene where to apply this optimization
  71771. * @param optimizer defines the current optimizer
  71772. * @returns true if everything that can be done was applied
  71773. */
  71774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71775. }
  71776. /**
  71777. * Defines an optimization used to turn render targets off
  71778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71779. */
  71780. export class RenderTargetsOptimization extends SceneOptimization {
  71781. /**
  71782. * Gets a string describing the action executed by the current optimization
  71783. * @return description string
  71784. */
  71785. getDescription(): string;
  71786. /**
  71787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71788. * @param scene defines the current scene where to apply this optimization
  71789. * @param optimizer defines the current optimizer
  71790. * @returns true if everything that can be done was applied
  71791. */
  71792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71793. }
  71794. /**
  71795. * Defines an optimization used to merge meshes with compatible materials
  71796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71797. */
  71798. export class MergeMeshesOptimization extends SceneOptimization {
  71799. private static _UpdateSelectionTree;
  71800. /**
  71801. * Gets or sets a boolean which defines if optimization octree has to be updated
  71802. */
  71803. static get UpdateSelectionTree(): boolean;
  71804. /**
  71805. * Gets or sets a boolean which defines if optimization octree has to be updated
  71806. */
  71807. static set UpdateSelectionTree(value: boolean);
  71808. /**
  71809. * Gets a string describing the action executed by the current optimization
  71810. * @return description string
  71811. */
  71812. getDescription(): string;
  71813. private _canBeMerged;
  71814. /**
  71815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71816. * @param scene defines the current scene where to apply this optimization
  71817. * @param optimizer defines the current optimizer
  71818. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71819. * @returns true if everything that can be done was applied
  71820. */
  71821. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71822. }
  71823. /**
  71824. * Defines a list of options used by SceneOptimizer
  71825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71826. */
  71827. export class SceneOptimizerOptions {
  71828. /**
  71829. * Defines the target frame rate to reach (60 by default)
  71830. */
  71831. targetFrameRate: number;
  71832. /**
  71833. * Defines the interval between two checkes (2000ms by default)
  71834. */
  71835. trackerDuration: number;
  71836. /**
  71837. * Gets the list of optimizations to apply
  71838. */
  71839. optimizations: SceneOptimization[];
  71840. /**
  71841. * Creates a new list of options used by SceneOptimizer
  71842. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71843. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71844. */
  71845. constructor(
  71846. /**
  71847. * Defines the target frame rate to reach (60 by default)
  71848. */
  71849. targetFrameRate?: number,
  71850. /**
  71851. * Defines the interval between two checkes (2000ms by default)
  71852. */
  71853. trackerDuration?: number);
  71854. /**
  71855. * Add a new optimization
  71856. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71857. * @returns the current SceneOptimizerOptions
  71858. */
  71859. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71860. /**
  71861. * Add a new custom optimization
  71862. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71863. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71864. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71865. * @returns the current SceneOptimizerOptions
  71866. */
  71867. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71868. /**
  71869. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71870. * @param targetFrameRate defines the target frame rate (60 by default)
  71871. * @returns a SceneOptimizerOptions object
  71872. */
  71873. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71874. /**
  71875. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71876. * @param targetFrameRate defines the target frame rate (60 by default)
  71877. * @returns a SceneOptimizerOptions object
  71878. */
  71879. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71880. /**
  71881. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71882. * @param targetFrameRate defines the target frame rate (60 by default)
  71883. * @returns a SceneOptimizerOptions object
  71884. */
  71885. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71886. }
  71887. /**
  71888. * Class used to run optimizations in order to reach a target frame rate
  71889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71890. */
  71891. export class SceneOptimizer implements IDisposable {
  71892. private _isRunning;
  71893. private _options;
  71894. private _scene;
  71895. private _currentPriorityLevel;
  71896. private _targetFrameRate;
  71897. private _trackerDuration;
  71898. private _currentFrameRate;
  71899. private _sceneDisposeObserver;
  71900. private _improvementMode;
  71901. /**
  71902. * Defines an observable called when the optimizer reaches the target frame rate
  71903. */
  71904. onSuccessObservable: Observable<SceneOptimizer>;
  71905. /**
  71906. * Defines an observable called when the optimizer enables an optimization
  71907. */
  71908. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71909. /**
  71910. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71911. */
  71912. onFailureObservable: Observable<SceneOptimizer>;
  71913. /**
  71914. * Gets a boolean indicating if the optimizer is in improvement mode
  71915. */
  71916. get isInImprovementMode(): boolean;
  71917. /**
  71918. * Gets the current priority level (0 at start)
  71919. */
  71920. get currentPriorityLevel(): number;
  71921. /**
  71922. * Gets the current frame rate checked by the SceneOptimizer
  71923. */
  71924. get currentFrameRate(): number;
  71925. /**
  71926. * Gets or sets the current target frame rate (60 by default)
  71927. */
  71928. get targetFrameRate(): number;
  71929. /**
  71930. * Gets or sets the current target frame rate (60 by default)
  71931. */
  71932. set targetFrameRate(value: number);
  71933. /**
  71934. * Gets or sets the current interval between two checks (every 2000ms by default)
  71935. */
  71936. get trackerDuration(): number;
  71937. /**
  71938. * Gets or sets the current interval between two checks (every 2000ms by default)
  71939. */
  71940. set trackerDuration(value: number);
  71941. /**
  71942. * Gets the list of active optimizations
  71943. */
  71944. get optimizations(): SceneOptimization[];
  71945. /**
  71946. * Creates a new SceneOptimizer
  71947. * @param scene defines the scene to work on
  71948. * @param options defines the options to use with the SceneOptimizer
  71949. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71950. * @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)
  71951. */
  71952. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71953. /**
  71954. * Stops the current optimizer
  71955. */
  71956. stop(): void;
  71957. /**
  71958. * Reset the optimizer to initial step (current priority level = 0)
  71959. */
  71960. reset(): void;
  71961. /**
  71962. * Start the optimizer. By default it will try to reach a specific framerate
  71963. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71964. */
  71965. start(): void;
  71966. private _checkCurrentState;
  71967. /**
  71968. * Release all resources
  71969. */
  71970. dispose(): void;
  71971. /**
  71972. * Helper function to create a SceneOptimizer with one single line of code
  71973. * @param scene defines the scene to work on
  71974. * @param options defines the options to use with the SceneOptimizer
  71975. * @param onSuccess defines a callback to call on success
  71976. * @param onFailure defines a callback to call on failure
  71977. * @returns the new SceneOptimizer object
  71978. */
  71979. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71980. }
  71981. }
  71982. declare module "babylonjs/Misc/sceneSerializer" {
  71983. import { Scene } from "babylonjs/scene";
  71984. /**
  71985. * Class used to serialize a scene into a string
  71986. */
  71987. export class SceneSerializer {
  71988. /**
  71989. * Clear cache used by a previous serialization
  71990. */
  71991. static ClearCache(): void;
  71992. /**
  71993. * Serialize a scene into a JSON compatible object
  71994. * @param scene defines the scene to serialize
  71995. * @returns a JSON compatible object
  71996. */
  71997. static Serialize(scene: Scene): any;
  71998. /**
  71999. * Serialize a mesh into a JSON compatible object
  72000. * @param toSerialize defines the mesh to serialize
  72001. * @param withParents defines if parents must be serialized as well
  72002. * @param withChildren defines if children must be serialized as well
  72003. * @returns a JSON compatible object
  72004. */
  72005. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72006. }
  72007. }
  72008. declare module "babylonjs/Misc/textureTools" {
  72009. import { Texture } from "babylonjs/Materials/Textures/texture";
  72010. /**
  72011. * Class used to host texture specific utilities
  72012. */
  72013. export class TextureTools {
  72014. /**
  72015. * Uses the GPU to create a copy texture rescaled at a given size
  72016. * @param texture Texture to copy from
  72017. * @param width defines the desired width
  72018. * @param height defines the desired height
  72019. * @param useBilinearMode defines if bilinear mode has to be used
  72020. * @return the generated texture
  72021. */
  72022. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72023. }
  72024. }
  72025. declare module "babylonjs/Misc/videoRecorder" {
  72026. import { Nullable } from "babylonjs/types";
  72027. import { Engine } from "babylonjs/Engines/engine";
  72028. /**
  72029. * This represents the different options available for the video capture.
  72030. */
  72031. export interface VideoRecorderOptions {
  72032. /** Defines the mime type of the video. */
  72033. mimeType: string;
  72034. /** Defines the FPS the video should be recorded at. */
  72035. fps: number;
  72036. /** Defines the chunk size for the recording data. */
  72037. recordChunckSize: number;
  72038. /** The audio tracks to attach to the recording. */
  72039. audioTracks?: MediaStreamTrack[];
  72040. }
  72041. /**
  72042. * This can help with recording videos from BabylonJS.
  72043. * This is based on the available WebRTC functionalities of the browser.
  72044. *
  72045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72046. */
  72047. export class VideoRecorder {
  72048. private static readonly _defaultOptions;
  72049. /**
  72050. * Returns whether or not the VideoRecorder is available in your browser.
  72051. * @param engine Defines the Babylon Engine.
  72052. * @returns true if supported otherwise false.
  72053. */
  72054. static IsSupported(engine: Engine): boolean;
  72055. private readonly _options;
  72056. private _canvas;
  72057. private _mediaRecorder;
  72058. private _recordedChunks;
  72059. private _fileName;
  72060. private _resolve;
  72061. private _reject;
  72062. /**
  72063. * True when a recording is already in progress.
  72064. */
  72065. get isRecording(): boolean;
  72066. /**
  72067. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72068. * @param engine Defines the BabylonJS Engine you wish to record.
  72069. * @param options Defines options that can be used to customize the capture.
  72070. */
  72071. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72072. /**
  72073. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72074. */
  72075. stopRecording(): void;
  72076. /**
  72077. * Starts recording the canvas for a max duration specified in parameters.
  72078. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72079. * If null no automatic download will start and you can rely on the promise to get the data back.
  72080. * @param maxDuration Defines the maximum recording time in seconds.
  72081. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72082. * @return A promise callback at the end of the recording with the video data in Blob.
  72083. */
  72084. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72085. /**
  72086. * Releases internal resources used during the recording.
  72087. */
  72088. dispose(): void;
  72089. private _handleDataAvailable;
  72090. private _handleError;
  72091. private _handleStop;
  72092. }
  72093. }
  72094. declare module "babylonjs/Misc/screenshotTools" {
  72095. import { Camera } from "babylonjs/Cameras/camera";
  72096. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72097. import { Engine } from "babylonjs/Engines/engine";
  72098. /**
  72099. * Class containing a set of static utilities functions for screenshots
  72100. */
  72101. export class ScreenshotTools {
  72102. /**
  72103. * Captures a screenshot of the current rendering
  72104. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72105. * @param engine defines the rendering engine
  72106. * @param camera defines the source camera
  72107. * @param size This parameter can be set to a single number or to an object with the
  72108. * following (optional) properties: precision, width, height. If a single number is passed,
  72109. * it will be used for both width and height. If an object is passed, the screenshot size
  72110. * will be derived from the parameters. The precision property is a multiplier allowing
  72111. * rendering at a higher or lower resolution
  72112. * @param successCallback defines the callback receives a single parameter which contains the
  72113. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72114. * src parameter of an <img> to display it
  72115. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72116. * Check your browser for supported MIME types
  72117. */
  72118. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72119. /**
  72120. * Captures a screenshot of the current rendering
  72121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72122. * @param engine defines the rendering engine
  72123. * @param camera defines the source camera
  72124. * @param size This parameter can be set to a single number or to an object with the
  72125. * following (optional) properties: precision, width, height. If a single number is passed,
  72126. * it will be used for both width and height. If an object is passed, the screenshot size
  72127. * will be derived from the parameters. The precision property is a multiplier allowing
  72128. * rendering at a higher or lower resolution
  72129. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72130. * Check your browser for supported MIME types
  72131. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72132. * to the src parameter of an <img> to display it
  72133. */
  72134. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72135. /**
  72136. * Generates an image screenshot from the specified camera.
  72137. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72138. * @param engine The engine to use for rendering
  72139. * @param camera The camera to use for rendering
  72140. * @param size This parameter can be set to a single number or to an object with the
  72141. * following (optional) properties: precision, width, height. If a single number is passed,
  72142. * it will be used for both width and height. If an object is passed, the screenshot size
  72143. * will be derived from the parameters. The precision property is a multiplier allowing
  72144. * rendering at a higher or lower resolution
  72145. * @param successCallback The callback receives a single parameter which contains the
  72146. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72147. * src parameter of an <img> to display it
  72148. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72149. * Check your browser for supported MIME types
  72150. * @param samples Texture samples (default: 1)
  72151. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72152. * @param fileName A name for for the downloaded file.
  72153. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72154. */
  72155. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72156. /**
  72157. * Generates an image screenshot from the specified camera.
  72158. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72159. * @param engine The engine to use for rendering
  72160. * @param camera The camera to use for rendering
  72161. * @param size This parameter can be set to a single number or to an object with the
  72162. * following (optional) properties: precision, width, height. If a single number is passed,
  72163. * it will be used for both width and height. If an object is passed, the screenshot size
  72164. * will be derived from the parameters. The precision property is a multiplier allowing
  72165. * rendering at a higher or lower resolution
  72166. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72167. * Check your browser for supported MIME types
  72168. * @param samples Texture samples (default: 1)
  72169. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72170. * @param fileName A name for for the downloaded file.
  72171. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72172. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72173. * to the src parameter of an <img> to display it
  72174. */
  72175. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72176. /**
  72177. * Gets height and width for screenshot size
  72178. * @private
  72179. */
  72180. private static _getScreenshotSize;
  72181. }
  72182. }
  72183. declare module "babylonjs/Misc/dataReader" {
  72184. /**
  72185. * Interface for a data buffer
  72186. */
  72187. export interface IDataBuffer {
  72188. /**
  72189. * Reads bytes from the data buffer.
  72190. * @param byteOffset The byte offset to read
  72191. * @param byteLength The byte length to read
  72192. * @returns A promise that resolves when the bytes are read
  72193. */
  72194. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72195. /**
  72196. * The byte length of the buffer.
  72197. */
  72198. readonly byteLength: number;
  72199. }
  72200. /**
  72201. * Utility class for reading from a data buffer
  72202. */
  72203. export class DataReader {
  72204. /**
  72205. * The data buffer associated with this data reader.
  72206. */
  72207. readonly buffer: IDataBuffer;
  72208. /**
  72209. * The current byte offset from the beginning of the data buffer.
  72210. */
  72211. byteOffset: number;
  72212. private _dataView;
  72213. private _dataByteOffset;
  72214. /**
  72215. * Constructor
  72216. * @param buffer The buffer to read
  72217. */
  72218. constructor(buffer: IDataBuffer);
  72219. /**
  72220. * Loads the given byte length.
  72221. * @param byteLength The byte length to load
  72222. * @returns A promise that resolves when the load is complete
  72223. */
  72224. loadAsync(byteLength: number): Promise<void>;
  72225. /**
  72226. * Read a unsigned 32-bit integer from the currently loaded data range.
  72227. * @returns The 32-bit integer read
  72228. */
  72229. readUint32(): number;
  72230. /**
  72231. * Read a byte array from the currently loaded data range.
  72232. * @param byteLength The byte length to read
  72233. * @returns The byte array read
  72234. */
  72235. readUint8Array(byteLength: number): Uint8Array;
  72236. /**
  72237. * Read a string from the currently loaded data range.
  72238. * @param byteLength The byte length to read
  72239. * @returns The string read
  72240. */
  72241. readString(byteLength: number): string;
  72242. /**
  72243. * Skips the given byte length the currently loaded data range.
  72244. * @param byteLength The byte length to skip
  72245. */
  72246. skipBytes(byteLength: number): void;
  72247. }
  72248. }
  72249. declare module "babylonjs/Misc/index" {
  72250. export * from "babylonjs/Misc/andOrNotEvaluator";
  72251. export * from "babylonjs/Misc/assetsManager";
  72252. export * from "babylonjs/Misc/basis";
  72253. export * from "babylonjs/Misc/dds";
  72254. export * from "babylonjs/Misc/decorators";
  72255. export * from "babylonjs/Misc/deferred";
  72256. export * from "babylonjs/Misc/environmentTextureTools";
  72257. export * from "babylonjs/Misc/meshExploder";
  72258. export * from "babylonjs/Misc/filesInput";
  72259. export * from "babylonjs/Misc/HighDynamicRange/index";
  72260. export * from "babylonjs/Misc/khronosTextureContainer";
  72261. export * from "babylonjs/Misc/observable";
  72262. export * from "babylonjs/Misc/performanceMonitor";
  72263. export * from "babylonjs/Misc/promise";
  72264. export * from "babylonjs/Misc/sceneOptimizer";
  72265. export * from "babylonjs/Misc/sceneSerializer";
  72266. export * from "babylonjs/Misc/smartArray";
  72267. export * from "babylonjs/Misc/stringDictionary";
  72268. export * from "babylonjs/Misc/tags";
  72269. export * from "babylonjs/Misc/textureTools";
  72270. export * from "babylonjs/Misc/tga";
  72271. export * from "babylonjs/Misc/tools";
  72272. export * from "babylonjs/Misc/videoRecorder";
  72273. export * from "babylonjs/Misc/virtualJoystick";
  72274. export * from "babylonjs/Misc/workerPool";
  72275. export * from "babylonjs/Misc/logger";
  72276. export * from "babylonjs/Misc/typeStore";
  72277. export * from "babylonjs/Misc/filesInputStore";
  72278. export * from "babylonjs/Misc/deepCopier";
  72279. export * from "babylonjs/Misc/pivotTools";
  72280. export * from "babylonjs/Misc/precisionDate";
  72281. export * from "babylonjs/Misc/screenshotTools";
  72282. export * from "babylonjs/Misc/typeStore";
  72283. export * from "babylonjs/Misc/webRequest";
  72284. export * from "babylonjs/Misc/iInspectable";
  72285. export * from "babylonjs/Misc/brdfTextureTools";
  72286. export * from "babylonjs/Misc/rgbdTextureTools";
  72287. export * from "babylonjs/Misc/gradients";
  72288. export * from "babylonjs/Misc/perfCounter";
  72289. export * from "babylonjs/Misc/fileRequest";
  72290. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72291. export * from "babylonjs/Misc/retryStrategy";
  72292. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72293. export * from "babylonjs/Misc/canvasGenerator";
  72294. export * from "babylonjs/Misc/fileTools";
  72295. export * from "babylonjs/Misc/stringTools";
  72296. export * from "babylonjs/Misc/dataReader";
  72297. export * from "babylonjs/Misc/minMaxReducer";
  72298. export * from "babylonjs/Misc/depthReducer";
  72299. }
  72300. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72301. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72302. import { Observable } from "babylonjs/Misc/observable";
  72303. import { Matrix } from "babylonjs/Maths/math.vector";
  72304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72305. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72306. /**
  72307. * Options used for hit testing
  72308. */
  72309. export interface IWebXRHitTestOptions {
  72310. /**
  72311. * Only test when user interacted with the scene. Default - hit test every frame
  72312. */
  72313. testOnPointerDownOnly?: boolean;
  72314. /**
  72315. * The node to use to transform the local results to world coordinates
  72316. */
  72317. worldParentNode?: TransformNode;
  72318. }
  72319. /**
  72320. * Interface defining the babylon result of raycasting/hit-test
  72321. */
  72322. export interface IWebXRHitResult {
  72323. /**
  72324. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72325. */
  72326. transformationMatrix: Matrix;
  72327. /**
  72328. * The native hit test result
  72329. */
  72330. xrHitResult: XRHitResult;
  72331. }
  72332. /**
  72333. * The currently-working hit-test module.
  72334. * Hit test (or Ray-casting) is used to interact with the real world.
  72335. * For further information read here - https://github.com/immersive-web/hit-test
  72336. */
  72337. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72338. /**
  72339. * options to use when constructing this feature
  72340. */
  72341. readonly options: IWebXRHitTestOptions;
  72342. private _direction;
  72343. private _mat;
  72344. private _onSelectEnabled;
  72345. private _origin;
  72346. /**
  72347. * The module's name
  72348. */
  72349. static readonly Name: string;
  72350. /**
  72351. * The (Babylon) version of this module.
  72352. * This is an integer representing the implementation version.
  72353. * This number does not correspond to the WebXR specs version
  72354. */
  72355. static readonly Version: number;
  72356. /**
  72357. * Populated with the last native XR Hit Results
  72358. */
  72359. lastNativeXRHitResults: XRHitResult[];
  72360. /**
  72361. * Triggered when new babylon (transformed) hit test results are available
  72362. */
  72363. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72364. /**
  72365. * Creates a new instance of the (legacy version) hit test feature
  72366. * @param _xrSessionManager an instance of WebXRSessionManager
  72367. * @param options options to use when constructing this feature
  72368. */
  72369. constructor(_xrSessionManager: WebXRSessionManager,
  72370. /**
  72371. * options to use when constructing this feature
  72372. */
  72373. options?: IWebXRHitTestOptions);
  72374. /**
  72375. * execute a hit test with an XR Ray
  72376. *
  72377. * @param xrSession a native xrSession that will execute this hit test
  72378. * @param xrRay the ray (position and direction) to use for ray-casting
  72379. * @param referenceSpace native XR reference space to use for the hit-test
  72380. * @param filter filter function that will filter the results
  72381. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72382. */
  72383. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72384. /**
  72385. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72386. * @param event the (select) event to use to select with
  72387. * @param referenceSpace the reference space to use for this hit test
  72388. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72389. */
  72390. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72391. /**
  72392. * attach this feature
  72393. * Will usually be called by the features manager
  72394. *
  72395. * @returns true if successful.
  72396. */
  72397. attach(): boolean;
  72398. /**
  72399. * detach this feature.
  72400. * Will usually be called by the features manager
  72401. *
  72402. * @returns true if successful.
  72403. */
  72404. detach(): boolean;
  72405. /**
  72406. * Dispose this feature and all of the resources attached
  72407. */
  72408. dispose(): void;
  72409. protected _onXRFrame(frame: XRFrame): void;
  72410. private _onHitTestResults;
  72411. private _onSelect;
  72412. }
  72413. }
  72414. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72415. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72416. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72417. import { Observable } from "babylonjs/Misc/observable";
  72418. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72419. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72420. /**
  72421. * Options used in the plane detector module
  72422. */
  72423. export interface IWebXRPlaneDetectorOptions {
  72424. /**
  72425. * The node to use to transform the local results to world coordinates
  72426. */
  72427. worldParentNode?: TransformNode;
  72428. }
  72429. /**
  72430. * A babylon interface for a WebXR plane.
  72431. * A Plane is actually a polygon, built from N points in space
  72432. *
  72433. * Supported in chrome 79, not supported in canary 81 ATM
  72434. */
  72435. export interface IWebXRPlane {
  72436. /**
  72437. * a babylon-assigned ID for this polygon
  72438. */
  72439. id: number;
  72440. /**
  72441. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72442. */
  72443. polygonDefinition: Array<Vector3>;
  72444. /**
  72445. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72446. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72447. */
  72448. transformationMatrix: Matrix;
  72449. /**
  72450. * the native xr-plane object
  72451. */
  72452. xrPlane: XRPlane;
  72453. }
  72454. /**
  72455. * The plane detector is used to detect planes in the real world when in AR
  72456. * For more information see https://github.com/immersive-web/real-world-geometry/
  72457. */
  72458. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72459. private _options;
  72460. private _detectedPlanes;
  72461. private _enabled;
  72462. private _lastFrameDetected;
  72463. /**
  72464. * The module's name
  72465. */
  72466. static readonly Name: string;
  72467. /**
  72468. * The (Babylon) version of this module.
  72469. * This is an integer representing the implementation version.
  72470. * This number does not correspond to the WebXR specs version
  72471. */
  72472. static readonly Version: number;
  72473. /**
  72474. * Observers registered here will be executed when a new plane was added to the session
  72475. */
  72476. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72477. /**
  72478. * Observers registered here will be executed when a plane is no longer detected in the session
  72479. */
  72480. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72481. /**
  72482. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72483. * This can execute N times every frame
  72484. */
  72485. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72486. /**
  72487. * construct a new Plane Detector
  72488. * @param _xrSessionManager an instance of xr Session manager
  72489. * @param _options configuration to use when constructing this feature
  72490. */
  72491. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72492. /**
  72493. * Dispose this feature and all of the resources attached
  72494. */
  72495. dispose(): void;
  72496. protected _onXRFrame(frame: XRFrame): void;
  72497. private _init;
  72498. private _updatePlaneWithXRPlane;
  72499. /**
  72500. * avoiding using Array.find for global support.
  72501. * @param xrPlane the plane to find in the array
  72502. */
  72503. private findIndexInPlaneArray;
  72504. }
  72505. }
  72506. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72507. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72508. import { Observable } from "babylonjs/Misc/observable";
  72509. import { Matrix } from "babylonjs/Maths/math.vector";
  72510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72511. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72512. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72513. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72514. /**
  72515. * Configuration options of the anchor system
  72516. */
  72517. export interface IWebXRAnchorSystemOptions {
  72518. /**
  72519. * Should a new anchor be added every time a select event is triggered
  72520. */
  72521. addAnchorOnSelect?: boolean;
  72522. /**
  72523. * should the anchor system use plane detection.
  72524. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72525. */
  72526. usePlaneDetection?: boolean;
  72527. /**
  72528. * a node that will be used to convert local to world coordinates
  72529. */
  72530. worldParentNode?: TransformNode;
  72531. }
  72532. /**
  72533. * A babylon container for an XR Anchor
  72534. */
  72535. export interface IWebXRAnchor {
  72536. /**
  72537. * A babylon-assigned ID for this anchor
  72538. */
  72539. id: number;
  72540. /**
  72541. * Transformation matrix to apply to an object attached to this anchor
  72542. */
  72543. transformationMatrix: Matrix;
  72544. /**
  72545. * The native anchor object
  72546. */
  72547. xrAnchor: XRAnchor;
  72548. }
  72549. /**
  72550. * An implementation of the anchor system of WebXR.
  72551. * Note that the current documented implementation is not available in any browser. Future implementations
  72552. * will use the frame to create an anchor and not the session or a detected plane
  72553. * For further information see https://github.com/immersive-web/anchors/
  72554. */
  72555. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72556. private _options;
  72557. private _enabled;
  72558. private _hitTestModule;
  72559. private _lastFrameDetected;
  72560. private _onSelect;
  72561. private _planeDetector;
  72562. private _trackedAnchors;
  72563. /**
  72564. * The module's name
  72565. */
  72566. static readonly Name: string;
  72567. /**
  72568. * The (Babylon) version of this module.
  72569. * This is an integer representing the implementation version.
  72570. * This number does not correspond to the WebXR specs version
  72571. */
  72572. static readonly Version: number;
  72573. /**
  72574. * Observers registered here will be executed when a new anchor was added to the session
  72575. */
  72576. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72577. /**
  72578. * Observers registered here will be executed when an anchor was removed from the session
  72579. */
  72580. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72581. /**
  72582. * Observers registered here will be executed when an existing anchor updates
  72583. * This can execute N times every frame
  72584. */
  72585. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72586. /**
  72587. * constructs a new anchor system
  72588. * @param _xrSessionManager an instance of WebXRSessionManager
  72589. * @param _options configuration object for this feature
  72590. */
  72591. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72592. /**
  72593. * Add anchor at a specific XR point.
  72594. *
  72595. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72596. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72597. * @returns a promise the fulfills when the anchor was created
  72598. */
  72599. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72600. /**
  72601. * attach this feature
  72602. * Will usually be called by the features manager
  72603. *
  72604. * @returns true if successful.
  72605. */
  72606. attach(): boolean;
  72607. /**
  72608. * detach this feature.
  72609. * Will usually be called by the features manager
  72610. *
  72611. * @returns true if successful.
  72612. */
  72613. detach(): boolean;
  72614. /**
  72615. * Dispose this feature and all of the resources attached
  72616. */
  72617. dispose(): void;
  72618. /**
  72619. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72620. * @param hitTestModule the hit-test module to use.
  72621. */
  72622. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72623. /**
  72624. * set the plane detector to use in order to create anchors from frames
  72625. * @param planeDetector the plane-detector module to use
  72626. * @param enable enable plane-anchors. default is true
  72627. */
  72628. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72629. protected _onXRFrame(frame: XRFrame): void;
  72630. /**
  72631. * avoiding using Array.find for global support.
  72632. * @param xrAnchor the plane to find in the array
  72633. */
  72634. private _findIndexInAnchorArray;
  72635. private _updateAnchorWithXRFrame;
  72636. }
  72637. }
  72638. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72639. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72641. import { Observable } from "babylonjs/Misc/observable";
  72642. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72643. /**
  72644. * Options interface for the background remover plugin
  72645. */
  72646. export interface IWebXRBackgroundRemoverOptions {
  72647. /**
  72648. * Further background meshes to disable when entering AR
  72649. */
  72650. backgroundMeshes?: AbstractMesh[];
  72651. /**
  72652. * flags to configure the removal of the environment helper.
  72653. * If not set, the entire background will be removed. If set, flags should be set as well.
  72654. */
  72655. environmentHelperRemovalFlags?: {
  72656. /**
  72657. * Should the skybox be removed (default false)
  72658. */
  72659. skyBox?: boolean;
  72660. /**
  72661. * Should the ground be removed (default false)
  72662. */
  72663. ground?: boolean;
  72664. };
  72665. /**
  72666. * don't disable the environment helper
  72667. */
  72668. ignoreEnvironmentHelper?: boolean;
  72669. }
  72670. /**
  72671. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72672. */
  72673. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72674. /**
  72675. * read-only options to be used in this module
  72676. */
  72677. readonly options: IWebXRBackgroundRemoverOptions;
  72678. /**
  72679. * The module's name
  72680. */
  72681. static readonly Name: string;
  72682. /**
  72683. * The (Babylon) version of this module.
  72684. * This is an integer representing the implementation version.
  72685. * This number does not correspond to the WebXR specs version
  72686. */
  72687. static readonly Version: number;
  72688. /**
  72689. * registered observers will be triggered when the background state changes
  72690. */
  72691. onBackgroundStateChangedObservable: Observable<boolean>;
  72692. /**
  72693. * constructs a new background remover module
  72694. * @param _xrSessionManager the session manager for this module
  72695. * @param options read-only options to be used in this module
  72696. */
  72697. constructor(_xrSessionManager: WebXRSessionManager,
  72698. /**
  72699. * read-only options to be used in this module
  72700. */
  72701. options?: IWebXRBackgroundRemoverOptions);
  72702. /**
  72703. * attach this feature
  72704. * Will usually be called by the features manager
  72705. *
  72706. * @returns true if successful.
  72707. */
  72708. attach(): boolean;
  72709. /**
  72710. * detach this feature.
  72711. * Will usually be called by the features manager
  72712. *
  72713. * @returns true if successful.
  72714. */
  72715. detach(): boolean;
  72716. /**
  72717. * Dispose this feature and all of the resources attached
  72718. */
  72719. dispose(): void;
  72720. protected _onXRFrame(_xrFrame: XRFrame): void;
  72721. private _setBackgroundState;
  72722. }
  72723. }
  72724. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72725. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72726. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72727. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72728. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72729. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72730. import { Nullable } from "babylonjs/types";
  72731. /**
  72732. * Options for the controller physics feature
  72733. */
  72734. export class IWebXRControllerPhysicsOptions {
  72735. /**
  72736. * Should the headset get its own impostor
  72737. */
  72738. enableHeadsetImpostor?: boolean;
  72739. /**
  72740. * Optional parameters for the headset impostor
  72741. */
  72742. headsetImpostorParams?: {
  72743. /**
  72744. * The type of impostor to create. Default is sphere
  72745. */
  72746. impostorType: number;
  72747. /**
  72748. * the size of the impostor. Defaults to 10cm
  72749. */
  72750. impostorSize?: number | {
  72751. width: number;
  72752. height: number;
  72753. depth: number;
  72754. };
  72755. /**
  72756. * Friction definitions
  72757. */
  72758. friction?: number;
  72759. /**
  72760. * Restitution
  72761. */
  72762. restitution?: number;
  72763. };
  72764. /**
  72765. * The physics properties of the future impostors
  72766. */
  72767. physicsProperties?: {
  72768. /**
  72769. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72770. * Note that this requires a physics engine that supports mesh impostors!
  72771. */
  72772. useControllerMesh?: boolean;
  72773. /**
  72774. * The type of impostor to create. Default is sphere
  72775. */
  72776. impostorType?: number;
  72777. /**
  72778. * the size of the impostor. Defaults to 10cm
  72779. */
  72780. impostorSize?: number | {
  72781. width: number;
  72782. height: number;
  72783. depth: number;
  72784. };
  72785. /**
  72786. * Friction definitions
  72787. */
  72788. friction?: number;
  72789. /**
  72790. * Restitution
  72791. */
  72792. restitution?: number;
  72793. };
  72794. /**
  72795. * the xr input to use with this pointer selection
  72796. */
  72797. xrInput: WebXRInput;
  72798. }
  72799. /**
  72800. * Add physics impostor to your webxr controllers,
  72801. * including naive calculation of their linear and angular velocity
  72802. */
  72803. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72804. private readonly _options;
  72805. private _attachController;
  72806. private _controllers;
  72807. private _debugMode;
  72808. private _delta;
  72809. private _headsetImpostor?;
  72810. private _headsetMesh?;
  72811. private _lastTimestamp;
  72812. private _tmpQuaternion;
  72813. private _tmpVector;
  72814. /**
  72815. * The module's name
  72816. */
  72817. static readonly Name: string;
  72818. /**
  72819. * The (Babylon) version of this module.
  72820. * This is an integer representing the implementation version.
  72821. * This number does not correspond to the webxr specs version
  72822. */
  72823. static readonly Version: number;
  72824. /**
  72825. * Construct a new Controller Physics Feature
  72826. * @param _xrSessionManager the corresponding xr session manager
  72827. * @param _options options to create this feature with
  72828. */
  72829. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72830. /**
  72831. * @hidden
  72832. * enable debugging - will show console outputs and the impostor mesh
  72833. */
  72834. _enablePhysicsDebug(): void;
  72835. /**
  72836. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72837. * @param xrController the controller to add
  72838. */
  72839. addController(xrController: WebXRInputSource): void;
  72840. /**
  72841. * attach this feature
  72842. * Will usually be called by the features manager
  72843. *
  72844. * @returns true if successful.
  72845. */
  72846. attach(): boolean;
  72847. /**
  72848. * detach this feature.
  72849. * Will usually be called by the features manager
  72850. *
  72851. * @returns true if successful.
  72852. */
  72853. detach(): boolean;
  72854. /**
  72855. * Get the headset impostor, if enabled
  72856. * @returns the impostor
  72857. */
  72858. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72859. /**
  72860. * Get the physics impostor of a specific controller.
  72861. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72862. * @param controller the controller or the controller id of which to get the impostor
  72863. * @returns the impostor or null
  72864. */
  72865. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72866. /**
  72867. * Update the physics properties provided in the constructor
  72868. * @param newProperties the new properties object
  72869. */
  72870. setPhysicsProperties(newProperties: {
  72871. impostorType?: number;
  72872. impostorSize?: number | {
  72873. width: number;
  72874. height: number;
  72875. depth: number;
  72876. };
  72877. friction?: number;
  72878. restitution?: number;
  72879. }): void;
  72880. protected _onXRFrame(_xrFrame: any): void;
  72881. private _detachController;
  72882. }
  72883. }
  72884. declare module "babylonjs/XR/features/index" {
  72885. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72886. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72887. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72888. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72889. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72890. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72891. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72892. }
  72893. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72894. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72896. import { Scene } from "babylonjs/scene";
  72897. /**
  72898. * The motion controller class for all microsoft mixed reality controllers
  72899. */
  72900. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72901. protected readonly _mapping: {
  72902. defaultButton: {
  72903. "valueNodeName": string;
  72904. "unpressedNodeName": string;
  72905. "pressedNodeName": string;
  72906. };
  72907. defaultAxis: {
  72908. "valueNodeName": string;
  72909. "minNodeName": string;
  72910. "maxNodeName": string;
  72911. };
  72912. buttons: {
  72913. "xr-standard-trigger": {
  72914. "rootNodeName": string;
  72915. "componentProperty": string;
  72916. "states": string[];
  72917. };
  72918. "xr-standard-squeeze": {
  72919. "rootNodeName": string;
  72920. "componentProperty": string;
  72921. "states": string[];
  72922. };
  72923. "xr-standard-touchpad": {
  72924. "rootNodeName": string;
  72925. "labelAnchorNodeName": string;
  72926. "touchPointNodeName": string;
  72927. };
  72928. "xr-standard-thumbstick": {
  72929. "rootNodeName": string;
  72930. "componentProperty": string;
  72931. "states": string[];
  72932. };
  72933. };
  72934. axes: {
  72935. "xr-standard-touchpad": {
  72936. "x-axis": {
  72937. "rootNodeName": string;
  72938. };
  72939. "y-axis": {
  72940. "rootNodeName": string;
  72941. };
  72942. };
  72943. "xr-standard-thumbstick": {
  72944. "x-axis": {
  72945. "rootNodeName": string;
  72946. };
  72947. "y-axis": {
  72948. "rootNodeName": string;
  72949. };
  72950. };
  72951. };
  72952. };
  72953. /**
  72954. * The base url used to load the left and right controller models
  72955. */
  72956. static MODEL_BASE_URL: string;
  72957. /**
  72958. * The name of the left controller model file
  72959. */
  72960. static MODEL_LEFT_FILENAME: string;
  72961. /**
  72962. * The name of the right controller model file
  72963. */
  72964. static MODEL_RIGHT_FILENAME: string;
  72965. profileId: string;
  72966. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72967. protected _getFilenameAndPath(): {
  72968. filename: string;
  72969. path: string;
  72970. };
  72971. protected _getModelLoadingConstraints(): boolean;
  72972. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72973. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72974. protected _updateModel(): void;
  72975. }
  72976. }
  72977. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72978. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72980. import { Scene } from "babylonjs/scene";
  72981. /**
  72982. * The motion controller class for oculus touch (quest, rift).
  72983. * This class supports legacy mapping as well the standard xr mapping
  72984. */
  72985. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72986. private _forceLegacyControllers;
  72987. private _modelRootNode;
  72988. /**
  72989. * The base url used to load the left and right controller models
  72990. */
  72991. static MODEL_BASE_URL: string;
  72992. /**
  72993. * The name of the left controller model file
  72994. */
  72995. static MODEL_LEFT_FILENAME: string;
  72996. /**
  72997. * The name of the right controller model file
  72998. */
  72999. static MODEL_RIGHT_FILENAME: string;
  73000. /**
  73001. * Base Url for the Quest controller model.
  73002. */
  73003. static QUEST_MODEL_BASE_URL: string;
  73004. profileId: string;
  73005. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73006. protected _getFilenameAndPath(): {
  73007. filename: string;
  73008. path: string;
  73009. };
  73010. protected _getModelLoadingConstraints(): boolean;
  73011. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73012. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73013. protected _updateModel(): void;
  73014. /**
  73015. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73016. * between the touch and touch 2.
  73017. */
  73018. private _isQuest;
  73019. }
  73020. }
  73021. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73022. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73023. import { Scene } from "babylonjs/scene";
  73024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73025. /**
  73026. * The motion controller class for the standard HTC-Vive controllers
  73027. */
  73028. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73029. private _modelRootNode;
  73030. /**
  73031. * The base url used to load the left and right controller models
  73032. */
  73033. static MODEL_BASE_URL: string;
  73034. /**
  73035. * File name for the controller model.
  73036. */
  73037. static MODEL_FILENAME: string;
  73038. profileId: string;
  73039. /**
  73040. * Create a new Vive motion controller object
  73041. * @param scene the scene to use to create this controller
  73042. * @param gamepadObject the corresponding gamepad object
  73043. * @param handness the handness of the controller
  73044. */
  73045. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73046. protected _getFilenameAndPath(): {
  73047. filename: string;
  73048. path: string;
  73049. };
  73050. protected _getModelLoadingConstraints(): boolean;
  73051. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73052. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73053. protected _updateModel(): void;
  73054. }
  73055. }
  73056. declare module "babylonjs/XR/motionController/index" {
  73057. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73058. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73059. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73060. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73061. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73062. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73063. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73064. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73065. }
  73066. declare module "babylonjs/XR/index" {
  73067. export * from "babylonjs/XR/webXRCamera";
  73068. export * from "babylonjs/XR/webXREnterExitUI";
  73069. export * from "babylonjs/XR/webXRExperienceHelper";
  73070. export * from "babylonjs/XR/webXRInput";
  73071. export * from "babylonjs/XR/webXRInputSource";
  73072. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73073. export * from "babylonjs/XR/webXRTypes";
  73074. export * from "babylonjs/XR/webXRSessionManager";
  73075. export * from "babylonjs/XR/webXRDefaultExperience";
  73076. export * from "babylonjs/XR/webXRFeaturesManager";
  73077. export * from "babylonjs/XR/features/index";
  73078. export * from "babylonjs/XR/motionController/index";
  73079. }
  73080. declare module "babylonjs/index" {
  73081. export * from "babylonjs/abstractScene";
  73082. export * from "babylonjs/Actions/index";
  73083. export * from "babylonjs/Animations/index";
  73084. export * from "babylonjs/assetContainer";
  73085. export * from "babylonjs/Audio/index";
  73086. export * from "babylonjs/Behaviors/index";
  73087. export * from "babylonjs/Bones/index";
  73088. export * from "babylonjs/Cameras/index";
  73089. export * from "babylonjs/Collisions/index";
  73090. export * from "babylonjs/Culling/index";
  73091. export * from "babylonjs/Debug/index";
  73092. export * from "babylonjs/Engines/index";
  73093. export * from "babylonjs/Events/index";
  73094. export * from "babylonjs/Gamepads/index";
  73095. export * from "babylonjs/Gizmos/index";
  73096. export * from "babylonjs/Helpers/index";
  73097. export * from "babylonjs/Instrumentation/index";
  73098. export * from "babylonjs/Layers/index";
  73099. export * from "babylonjs/LensFlares/index";
  73100. export * from "babylonjs/Lights/index";
  73101. export * from "babylonjs/Loading/index";
  73102. export * from "babylonjs/Materials/index";
  73103. export * from "babylonjs/Maths/index";
  73104. export * from "babylonjs/Meshes/index";
  73105. export * from "babylonjs/Morph/index";
  73106. export * from "babylonjs/Navigation/index";
  73107. export * from "babylonjs/node";
  73108. export * from "babylonjs/Offline/index";
  73109. export * from "babylonjs/Particles/index";
  73110. export * from "babylonjs/Physics/index";
  73111. export * from "babylonjs/PostProcesses/index";
  73112. export * from "babylonjs/Probes/index";
  73113. export * from "babylonjs/Rendering/index";
  73114. export * from "babylonjs/scene";
  73115. export * from "babylonjs/sceneComponent";
  73116. export * from "babylonjs/Sprites/index";
  73117. export * from "babylonjs/States/index";
  73118. export * from "babylonjs/Misc/index";
  73119. export * from "babylonjs/XR/index";
  73120. export * from "babylonjs/types";
  73121. }
  73122. declare module "babylonjs/Animations/pathCursor" {
  73123. import { Vector3 } from "babylonjs/Maths/math.vector";
  73124. import { Path2 } from "babylonjs/Maths/math.path";
  73125. /**
  73126. * A cursor which tracks a point on a path
  73127. */
  73128. export class PathCursor {
  73129. private path;
  73130. /**
  73131. * Stores path cursor callbacks for when an onchange event is triggered
  73132. */
  73133. private _onchange;
  73134. /**
  73135. * The value of the path cursor
  73136. */
  73137. value: number;
  73138. /**
  73139. * The animation array of the path cursor
  73140. */
  73141. animations: Animation[];
  73142. /**
  73143. * Initializes the path cursor
  73144. * @param path The path to track
  73145. */
  73146. constructor(path: Path2);
  73147. /**
  73148. * Gets the cursor point on the path
  73149. * @returns A point on the path cursor at the cursor location
  73150. */
  73151. getPoint(): Vector3;
  73152. /**
  73153. * Moves the cursor ahead by the step amount
  73154. * @param step The amount to move the cursor forward
  73155. * @returns This path cursor
  73156. */
  73157. moveAhead(step?: number): PathCursor;
  73158. /**
  73159. * Moves the cursor behind by the step amount
  73160. * @param step The amount to move the cursor back
  73161. * @returns This path cursor
  73162. */
  73163. moveBack(step?: number): PathCursor;
  73164. /**
  73165. * Moves the cursor by the step amount
  73166. * If the step amount is greater than one, an exception is thrown
  73167. * @param step The amount to move the cursor
  73168. * @returns This path cursor
  73169. */
  73170. move(step: number): PathCursor;
  73171. /**
  73172. * Ensures that the value is limited between zero and one
  73173. * @returns This path cursor
  73174. */
  73175. private ensureLimits;
  73176. /**
  73177. * Runs onchange callbacks on change (used by the animation engine)
  73178. * @returns This path cursor
  73179. */
  73180. private raiseOnChange;
  73181. /**
  73182. * Executes a function on change
  73183. * @param f A path cursor onchange callback
  73184. * @returns This path cursor
  73185. */
  73186. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73187. }
  73188. }
  73189. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73190. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73191. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73192. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73193. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73194. }
  73195. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73196. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73197. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73198. }
  73199. declare module "babylonjs/Engines/Processors/index" {
  73200. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73201. export * from "babylonjs/Engines/Processors/Expressions/index";
  73202. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73203. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73204. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73205. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73206. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73207. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73208. }
  73209. declare module "babylonjs/Legacy/legacy" {
  73210. import * as Babylon from "babylonjs/index";
  73211. export * from "babylonjs/index";
  73212. }
  73213. declare module "babylonjs/Shaders/blur.fragment" {
  73214. /** @hidden */
  73215. export var blurPixelShader: {
  73216. name: string;
  73217. shader: string;
  73218. };
  73219. }
  73220. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73221. /** @hidden */
  73222. export var pointCloudVertexDeclaration: {
  73223. name: string;
  73224. shader: string;
  73225. };
  73226. }
  73227. declare module "babylonjs" {
  73228. export * from "babylonjs/Legacy/legacy";
  73229. }
  73230. declare module BABYLON {
  73231. /** Alias type for value that can be null */
  73232. export type Nullable<T> = T | null;
  73233. /**
  73234. * Alias type for number that are floats
  73235. * @ignorenaming
  73236. */
  73237. export type float = number;
  73238. /**
  73239. * Alias type for number that are doubles.
  73240. * @ignorenaming
  73241. */
  73242. export type double = number;
  73243. /**
  73244. * Alias type for number that are integer
  73245. * @ignorenaming
  73246. */
  73247. export type int = number;
  73248. /** Alias type for number array or Float32Array */
  73249. export type FloatArray = number[] | Float32Array;
  73250. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73251. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73252. /**
  73253. * Alias for types that can be used by a Buffer or VertexBuffer.
  73254. */
  73255. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73256. /**
  73257. * Alias type for primitive types
  73258. * @ignorenaming
  73259. */
  73260. type Primitive = undefined | null | boolean | string | number | Function;
  73261. /**
  73262. * Type modifier to make all the properties of an object Readonly
  73263. */
  73264. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73265. /**
  73266. * Type modifier to make all the properties of an object Readonly recursively
  73267. */
  73268. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73269. /**
  73270. * Type modifier to make object properties readonly.
  73271. */
  73272. export type DeepImmutableObject<T> = {
  73273. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73274. };
  73275. /** @hidden */
  73276. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73277. }
  73278. }
  73279. declare module BABYLON {
  73280. /**
  73281. * A class serves as a medium between the observable and its observers
  73282. */
  73283. export class EventState {
  73284. /**
  73285. * Create a new EventState
  73286. * @param mask defines the mask associated with this state
  73287. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73288. * @param target defines the original target of the state
  73289. * @param currentTarget defines the current target of the state
  73290. */
  73291. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73292. /**
  73293. * Initialize the current event state
  73294. * @param mask defines the mask associated with this state
  73295. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73296. * @param target defines the original target of the state
  73297. * @param currentTarget defines the current target of the state
  73298. * @returns the current event state
  73299. */
  73300. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73301. /**
  73302. * An Observer can set this property to true to prevent subsequent observers of being notified
  73303. */
  73304. skipNextObservers: boolean;
  73305. /**
  73306. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73307. */
  73308. mask: number;
  73309. /**
  73310. * The object that originally notified the event
  73311. */
  73312. target?: any;
  73313. /**
  73314. * The current object in the bubbling phase
  73315. */
  73316. currentTarget?: any;
  73317. /**
  73318. * This will be populated with the return value of the last function that was executed.
  73319. * If it is the first function in the callback chain it will be the event data.
  73320. */
  73321. lastReturnValue?: any;
  73322. }
  73323. /**
  73324. * Represent an Observer registered to a given Observable object.
  73325. */
  73326. export class Observer<T> {
  73327. /**
  73328. * Defines the callback to call when the observer is notified
  73329. */
  73330. callback: (eventData: T, eventState: EventState) => void;
  73331. /**
  73332. * Defines the mask of the observer (used to filter notifications)
  73333. */
  73334. mask: number;
  73335. /**
  73336. * Defines the current scope used to restore the JS context
  73337. */
  73338. scope: any;
  73339. /** @hidden */
  73340. _willBeUnregistered: boolean;
  73341. /**
  73342. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73343. */
  73344. unregisterOnNextCall: boolean;
  73345. /**
  73346. * Creates a new observer
  73347. * @param callback defines the callback to call when the observer is notified
  73348. * @param mask defines the mask of the observer (used to filter notifications)
  73349. * @param scope defines the current scope used to restore the JS context
  73350. */
  73351. constructor(
  73352. /**
  73353. * Defines the callback to call when the observer is notified
  73354. */
  73355. callback: (eventData: T, eventState: EventState) => void,
  73356. /**
  73357. * Defines the mask of the observer (used to filter notifications)
  73358. */
  73359. mask: number,
  73360. /**
  73361. * Defines the current scope used to restore the JS context
  73362. */
  73363. scope?: any);
  73364. }
  73365. /**
  73366. * Represent a list of observers registered to multiple Observables object.
  73367. */
  73368. export class MultiObserver<T> {
  73369. private _observers;
  73370. private _observables;
  73371. /**
  73372. * Release associated resources
  73373. */
  73374. dispose(): void;
  73375. /**
  73376. * Raise a callback when one of the observable will notify
  73377. * @param observables defines a list of observables to watch
  73378. * @param callback defines the callback to call on notification
  73379. * @param mask defines the mask used to filter notifications
  73380. * @param scope defines the current scope used to restore the JS context
  73381. * @returns the new MultiObserver
  73382. */
  73383. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73384. }
  73385. /**
  73386. * The Observable class is a simple implementation of the Observable pattern.
  73387. *
  73388. * 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.
  73389. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73390. * 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).
  73391. * 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.
  73392. */
  73393. export class Observable<T> {
  73394. private _observers;
  73395. private _eventState;
  73396. private _onObserverAdded;
  73397. /**
  73398. * Gets the list of observers
  73399. */
  73400. get observers(): Array<Observer<T>>;
  73401. /**
  73402. * Creates a new observable
  73403. * @param onObserverAdded defines a callback to call when a new observer is added
  73404. */
  73405. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73406. /**
  73407. * Create a new Observer with the specified callback
  73408. * @param callback the callback that will be executed for that Observer
  73409. * @param mask the mask used to filter observers
  73410. * @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.
  73411. * @param scope optional scope for the callback to be called from
  73412. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73413. * @returns the new observer created for the callback
  73414. */
  73415. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73416. /**
  73417. * Create a new Observer with the specified callback and unregisters after the next notification
  73418. * @param callback the callback that will be executed for that Observer
  73419. * @returns the new observer created for the callback
  73420. */
  73421. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73422. /**
  73423. * Remove an Observer from the Observable object
  73424. * @param observer the instance of the Observer to remove
  73425. * @returns false if it doesn't belong to this Observable
  73426. */
  73427. remove(observer: Nullable<Observer<T>>): boolean;
  73428. /**
  73429. * Remove a callback from the Observable object
  73430. * @param callback the callback to remove
  73431. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73432. * @returns false if it doesn't belong to this Observable
  73433. */
  73434. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73435. private _deferUnregister;
  73436. private _remove;
  73437. /**
  73438. * Moves the observable to the top of the observer list making it get called first when notified
  73439. * @param observer the observer to move
  73440. */
  73441. makeObserverTopPriority(observer: Observer<T>): void;
  73442. /**
  73443. * Moves the observable to the bottom of the observer list making it get called last when notified
  73444. * @param observer the observer to move
  73445. */
  73446. makeObserverBottomPriority(observer: Observer<T>): void;
  73447. /**
  73448. * Notify all Observers by calling their respective callback with the given data
  73449. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73450. * @param eventData defines the data to send to all observers
  73451. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73452. * @param target defines the original target of the state
  73453. * @param currentTarget defines the current target of the state
  73454. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73455. */
  73456. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73457. /**
  73458. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73459. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73460. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73461. * and it is crucial that all callbacks will be executed.
  73462. * The order of the callbacks is kept, callbacks are not executed parallel.
  73463. *
  73464. * @param eventData The data to be sent to each callback
  73465. * @param mask is used to filter observers defaults to -1
  73466. * @param target defines the callback target (see EventState)
  73467. * @param currentTarget defines he current object in the bubbling phase
  73468. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73469. */
  73470. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73471. /**
  73472. * Notify a specific observer
  73473. * @param observer defines the observer to notify
  73474. * @param eventData defines the data to be sent to each callback
  73475. * @param mask is used to filter observers defaults to -1
  73476. */
  73477. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73478. /**
  73479. * Gets a boolean indicating if the observable has at least one observer
  73480. * @returns true is the Observable has at least one Observer registered
  73481. */
  73482. hasObservers(): boolean;
  73483. /**
  73484. * Clear the list of observers
  73485. */
  73486. clear(): void;
  73487. /**
  73488. * Clone the current observable
  73489. * @returns a new observable
  73490. */
  73491. clone(): Observable<T>;
  73492. /**
  73493. * Does this observable handles observer registered with a given mask
  73494. * @param mask defines the mask to be tested
  73495. * @return whether or not one observer registered with the given mask is handeled
  73496. **/
  73497. hasSpecificMask(mask?: number): boolean;
  73498. }
  73499. }
  73500. declare module BABYLON {
  73501. /**
  73502. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73503. * Babylon.js
  73504. */
  73505. export class DomManagement {
  73506. /**
  73507. * Checks if the window object exists
  73508. * @returns true if the window object exists
  73509. */
  73510. static IsWindowObjectExist(): boolean;
  73511. /**
  73512. * Checks if the navigator object exists
  73513. * @returns true if the navigator object exists
  73514. */
  73515. static IsNavigatorAvailable(): boolean;
  73516. /**
  73517. * Extracts text content from a DOM element hierarchy
  73518. * @param element defines the root element
  73519. * @returns a string
  73520. */
  73521. static GetDOMTextContent(element: HTMLElement): string;
  73522. }
  73523. }
  73524. declare module BABYLON {
  73525. /**
  73526. * Logger used througouht the application to allow configuration of
  73527. * the log level required for the messages.
  73528. */
  73529. export class Logger {
  73530. /**
  73531. * No log
  73532. */
  73533. static readonly NoneLogLevel: number;
  73534. /**
  73535. * Only message logs
  73536. */
  73537. static readonly MessageLogLevel: number;
  73538. /**
  73539. * Only warning logs
  73540. */
  73541. static readonly WarningLogLevel: number;
  73542. /**
  73543. * Only error logs
  73544. */
  73545. static readonly ErrorLogLevel: number;
  73546. /**
  73547. * All logs
  73548. */
  73549. static readonly AllLogLevel: number;
  73550. private static _LogCache;
  73551. /**
  73552. * Gets a value indicating the number of loading errors
  73553. * @ignorenaming
  73554. */
  73555. static errorsCount: number;
  73556. /**
  73557. * Callback called when a new log is added
  73558. */
  73559. static OnNewCacheEntry: (entry: string) => void;
  73560. private static _AddLogEntry;
  73561. private static _FormatMessage;
  73562. private static _LogDisabled;
  73563. private static _LogEnabled;
  73564. private static _WarnDisabled;
  73565. private static _WarnEnabled;
  73566. private static _ErrorDisabled;
  73567. private static _ErrorEnabled;
  73568. /**
  73569. * Log a message to the console
  73570. */
  73571. static Log: (message: string) => void;
  73572. /**
  73573. * Write a warning message to the console
  73574. */
  73575. static Warn: (message: string) => void;
  73576. /**
  73577. * Write an error message to the console
  73578. */
  73579. static Error: (message: string) => void;
  73580. /**
  73581. * Gets current log cache (list of logs)
  73582. */
  73583. static get LogCache(): string;
  73584. /**
  73585. * Clears the log cache
  73586. */
  73587. static ClearLogCache(): void;
  73588. /**
  73589. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73590. */
  73591. static set LogLevels(level: number);
  73592. }
  73593. }
  73594. declare module BABYLON {
  73595. /** @hidden */
  73596. export class _TypeStore {
  73597. /** @hidden */
  73598. static RegisteredTypes: {
  73599. [key: string]: Object;
  73600. };
  73601. /** @hidden */
  73602. static GetClass(fqdn: string): any;
  73603. }
  73604. }
  73605. declare module BABYLON {
  73606. /**
  73607. * Helper to manipulate strings
  73608. */
  73609. export class StringTools {
  73610. /**
  73611. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73612. * @param str Source string
  73613. * @param suffix Suffix to search for in the source string
  73614. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73615. */
  73616. static EndsWith(str: string, suffix: string): boolean;
  73617. /**
  73618. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73619. * @param str Source string
  73620. * @param suffix Suffix to search for in the source string
  73621. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73622. */
  73623. static StartsWith(str: string, suffix: string): boolean;
  73624. /**
  73625. * Decodes a buffer into a string
  73626. * @param buffer The buffer to decode
  73627. * @returns The decoded string
  73628. */
  73629. static Decode(buffer: Uint8Array | Uint16Array): string;
  73630. /**
  73631. * Encode a buffer to a base64 string
  73632. * @param buffer defines the buffer to encode
  73633. * @returns the encoded string
  73634. */
  73635. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73636. }
  73637. }
  73638. declare module BABYLON {
  73639. /**
  73640. * Class containing a set of static utilities functions for deep copy.
  73641. */
  73642. export class DeepCopier {
  73643. /**
  73644. * Tries to copy an object by duplicating every property
  73645. * @param source defines the source object
  73646. * @param destination defines the target object
  73647. * @param doNotCopyList defines a list of properties to avoid
  73648. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73649. */
  73650. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73651. }
  73652. }
  73653. declare module BABYLON {
  73654. /**
  73655. * Class containing a set of static utilities functions for precision date
  73656. */
  73657. export class PrecisionDate {
  73658. /**
  73659. * Gets either window.performance.now() if supported or Date.now() else
  73660. */
  73661. static get Now(): number;
  73662. }
  73663. }
  73664. declare module BABYLON {
  73665. /** @hidden */
  73666. export class _DevTools {
  73667. static WarnImport(name: string): string;
  73668. }
  73669. }
  73670. declare module BABYLON {
  73671. /**
  73672. * Interface used to define the mechanism to get data from the network
  73673. */
  73674. export interface IWebRequest {
  73675. /**
  73676. * Returns client's response url
  73677. */
  73678. responseURL: string;
  73679. /**
  73680. * Returns client's status
  73681. */
  73682. status: number;
  73683. /**
  73684. * Returns client's status as a text
  73685. */
  73686. statusText: string;
  73687. }
  73688. }
  73689. declare module BABYLON {
  73690. /**
  73691. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73692. */
  73693. export class WebRequest implements IWebRequest {
  73694. private _xhr;
  73695. /**
  73696. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73697. * i.e. when loading files, where the server/service expects an Authorization header
  73698. */
  73699. static CustomRequestHeaders: {
  73700. [key: string]: string;
  73701. };
  73702. /**
  73703. * Add callback functions in this array to update all the requests before they get sent to the network
  73704. */
  73705. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73706. private _injectCustomRequestHeaders;
  73707. /**
  73708. * Gets or sets a function to be called when loading progress changes
  73709. */
  73710. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73711. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73712. /**
  73713. * Returns client's state
  73714. */
  73715. get readyState(): number;
  73716. /**
  73717. * Returns client's status
  73718. */
  73719. get status(): number;
  73720. /**
  73721. * Returns client's status as a text
  73722. */
  73723. get statusText(): string;
  73724. /**
  73725. * Returns client's response
  73726. */
  73727. get response(): any;
  73728. /**
  73729. * Returns client's response url
  73730. */
  73731. get responseURL(): string;
  73732. /**
  73733. * Returns client's response as text
  73734. */
  73735. get responseText(): string;
  73736. /**
  73737. * Gets or sets the expected response type
  73738. */
  73739. get responseType(): XMLHttpRequestResponseType;
  73740. set responseType(value: XMLHttpRequestResponseType);
  73741. /** @hidden */
  73742. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73743. /** @hidden */
  73744. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73745. /**
  73746. * Cancels any network activity
  73747. */
  73748. abort(): void;
  73749. /**
  73750. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73751. * @param body defines an optional request body
  73752. */
  73753. send(body?: Document | BodyInit | null): void;
  73754. /**
  73755. * Sets the request method, request URL
  73756. * @param method defines the method to use (GET, POST, etc..)
  73757. * @param url defines the url to connect with
  73758. */
  73759. open(method: string, url: string): void;
  73760. /**
  73761. * Sets the value of a request header.
  73762. * @param name The name of the header whose value is to be set
  73763. * @param value The value to set as the body of the header
  73764. */
  73765. setRequestHeader(name: string, value: string): void;
  73766. /**
  73767. * Get the string containing the text of a particular header's value.
  73768. * @param name The name of the header
  73769. * @returns The string containing the text of the given header name
  73770. */
  73771. getResponseHeader(name: string): Nullable<string>;
  73772. }
  73773. }
  73774. declare module BABYLON {
  73775. /**
  73776. * File request interface
  73777. */
  73778. export interface IFileRequest {
  73779. /**
  73780. * Raised when the request is complete (success or error).
  73781. */
  73782. onCompleteObservable: Observable<IFileRequest>;
  73783. /**
  73784. * Aborts the request for a file.
  73785. */
  73786. abort: () => void;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Define options used to create a render target texture
  73792. */
  73793. export class RenderTargetCreationOptions {
  73794. /**
  73795. * Specifies is mipmaps must be generated
  73796. */
  73797. generateMipMaps?: boolean;
  73798. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73799. generateDepthBuffer?: boolean;
  73800. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73801. generateStencilBuffer?: boolean;
  73802. /** Defines texture type (int by default) */
  73803. type?: number;
  73804. /** Defines sampling mode (trilinear by default) */
  73805. samplingMode?: number;
  73806. /** Defines format (RGBA by default) */
  73807. format?: number;
  73808. }
  73809. }
  73810. declare module BABYLON {
  73811. /** Defines the cross module used constants to avoid circular dependncies */
  73812. export class Constants {
  73813. /** Defines that alpha blending is disabled */
  73814. static readonly ALPHA_DISABLE: number;
  73815. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73816. static readonly ALPHA_ADD: number;
  73817. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73818. static readonly ALPHA_COMBINE: number;
  73819. /** Defines that alpha blending is DEST - SRC * DEST */
  73820. static readonly ALPHA_SUBTRACT: number;
  73821. /** Defines that alpha blending is SRC * DEST */
  73822. static readonly ALPHA_MULTIPLY: number;
  73823. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73824. static readonly ALPHA_MAXIMIZED: number;
  73825. /** Defines that alpha blending is SRC + DEST */
  73826. static readonly ALPHA_ONEONE: number;
  73827. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73828. static readonly ALPHA_PREMULTIPLIED: number;
  73829. /**
  73830. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73831. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73832. */
  73833. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73834. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73835. static readonly ALPHA_INTERPOLATE: number;
  73836. /**
  73837. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73838. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73839. */
  73840. static readonly ALPHA_SCREENMODE: number;
  73841. /**
  73842. * Defines that alpha blending is SRC + DST
  73843. * Alpha will be set to SRC ALPHA + DST ALPHA
  73844. */
  73845. static readonly ALPHA_ONEONE_ONEONE: number;
  73846. /**
  73847. * Defines that alpha blending is SRC * DST ALPHA + DST
  73848. * Alpha will be set to 0
  73849. */
  73850. static readonly ALPHA_ALPHATOCOLOR: number;
  73851. /**
  73852. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73853. */
  73854. static readonly ALPHA_REVERSEONEMINUS: number;
  73855. /**
  73856. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73857. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73858. */
  73859. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73860. /**
  73861. * Defines that alpha blending is SRC + DST
  73862. * Alpha will be set to SRC ALPHA
  73863. */
  73864. static readonly ALPHA_ONEONE_ONEZERO: number;
  73865. /**
  73866. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73867. * Alpha will be set to DST ALPHA
  73868. */
  73869. static readonly ALPHA_EXCLUSION: number;
  73870. /** Defines that alpha blending equation a SUM */
  73871. static readonly ALPHA_EQUATION_ADD: number;
  73872. /** Defines that alpha blending equation a SUBSTRACTION */
  73873. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73874. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73875. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73876. /** Defines that alpha blending equation a MAX operation */
  73877. static readonly ALPHA_EQUATION_MAX: number;
  73878. /** Defines that alpha blending equation a MIN operation */
  73879. static readonly ALPHA_EQUATION_MIN: number;
  73880. /**
  73881. * Defines that alpha blending equation a DARKEN operation:
  73882. * It takes the min of the src and sums the alpha channels.
  73883. */
  73884. static readonly ALPHA_EQUATION_DARKEN: number;
  73885. /** Defines that the ressource is not delayed*/
  73886. static readonly DELAYLOADSTATE_NONE: number;
  73887. /** Defines that the ressource was successfully delay loaded */
  73888. static readonly DELAYLOADSTATE_LOADED: number;
  73889. /** Defines that the ressource is currently delay loading */
  73890. static readonly DELAYLOADSTATE_LOADING: number;
  73891. /** Defines that the ressource is delayed and has not started loading */
  73892. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73893. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73894. static readonly NEVER: number;
  73895. /** 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 */
  73896. static readonly ALWAYS: number;
  73897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73898. static readonly LESS: number;
  73899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73900. static readonly EQUAL: number;
  73901. /** 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 */
  73902. static readonly LEQUAL: number;
  73903. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73904. static readonly GREATER: number;
  73905. /** 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 */
  73906. static readonly GEQUAL: number;
  73907. /** 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 */
  73908. static readonly NOTEQUAL: number;
  73909. /** Passed to stencilOperation to specify that stencil value must be kept */
  73910. static readonly KEEP: number;
  73911. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73912. static readonly REPLACE: number;
  73913. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73914. static readonly INCR: number;
  73915. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73916. static readonly DECR: number;
  73917. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73918. static readonly INVERT: number;
  73919. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73920. static readonly INCR_WRAP: number;
  73921. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73922. static readonly DECR_WRAP: number;
  73923. /** Texture is not repeating outside of 0..1 UVs */
  73924. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73925. /** Texture is repeating outside of 0..1 UVs */
  73926. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73927. /** Texture is repeating and mirrored */
  73928. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73929. /** ALPHA */
  73930. static readonly TEXTUREFORMAT_ALPHA: number;
  73931. /** LUMINANCE */
  73932. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73933. /** LUMINANCE_ALPHA */
  73934. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73935. /** RGB */
  73936. static readonly TEXTUREFORMAT_RGB: number;
  73937. /** RGBA */
  73938. static readonly TEXTUREFORMAT_RGBA: number;
  73939. /** RED */
  73940. static readonly TEXTUREFORMAT_RED: number;
  73941. /** RED (2nd reference) */
  73942. static readonly TEXTUREFORMAT_R: number;
  73943. /** RG */
  73944. static readonly TEXTUREFORMAT_RG: number;
  73945. /** RED_INTEGER */
  73946. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73947. /** RED_INTEGER (2nd reference) */
  73948. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73949. /** RG_INTEGER */
  73950. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73951. /** RGB_INTEGER */
  73952. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73953. /** RGBA_INTEGER */
  73954. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73955. /** UNSIGNED_BYTE */
  73956. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73957. /** UNSIGNED_BYTE (2nd reference) */
  73958. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73959. /** FLOAT */
  73960. static readonly TEXTURETYPE_FLOAT: number;
  73961. /** HALF_FLOAT */
  73962. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73963. /** BYTE */
  73964. static readonly TEXTURETYPE_BYTE: number;
  73965. /** SHORT */
  73966. static readonly TEXTURETYPE_SHORT: number;
  73967. /** UNSIGNED_SHORT */
  73968. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73969. /** INT */
  73970. static readonly TEXTURETYPE_INT: number;
  73971. /** UNSIGNED_INT */
  73972. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73973. /** UNSIGNED_SHORT_4_4_4_4 */
  73974. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73975. /** UNSIGNED_SHORT_5_5_5_1 */
  73976. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73977. /** UNSIGNED_SHORT_5_6_5 */
  73978. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73979. /** UNSIGNED_INT_2_10_10_10_REV */
  73980. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73981. /** UNSIGNED_INT_24_8 */
  73982. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73983. /** UNSIGNED_INT_10F_11F_11F_REV */
  73984. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73985. /** UNSIGNED_INT_5_9_9_9_REV */
  73986. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73987. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73988. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73989. /** nearest is mag = nearest and min = nearest and no mip */
  73990. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73991. /** mag = nearest and min = nearest and mip = none */
  73992. static readonly TEXTURE_NEAREST_NEAREST: number;
  73993. /** Bilinear is mag = linear and min = linear and no mip */
  73994. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73995. /** mag = linear and min = linear and mip = none */
  73996. static readonly TEXTURE_LINEAR_LINEAR: number;
  73997. /** Trilinear is mag = linear and min = linear and mip = linear */
  73998. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73999. /** Trilinear is mag = linear and min = linear and mip = linear */
  74000. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74001. /** mag = nearest and min = nearest and mip = nearest */
  74002. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74003. /** mag = nearest and min = linear and mip = nearest */
  74004. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74005. /** mag = nearest and min = linear and mip = linear */
  74006. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74007. /** mag = nearest and min = linear and mip = none */
  74008. static readonly TEXTURE_NEAREST_LINEAR: number;
  74009. /** nearest is mag = nearest and min = nearest and mip = linear */
  74010. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74011. /** mag = linear and min = nearest and mip = nearest */
  74012. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74013. /** mag = linear and min = nearest and mip = linear */
  74014. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74015. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74016. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74017. /** mag = linear and min = nearest and mip = none */
  74018. static readonly TEXTURE_LINEAR_NEAREST: number;
  74019. /** Explicit coordinates mode */
  74020. static readonly TEXTURE_EXPLICIT_MODE: number;
  74021. /** Spherical coordinates mode */
  74022. static readonly TEXTURE_SPHERICAL_MODE: number;
  74023. /** Planar coordinates mode */
  74024. static readonly TEXTURE_PLANAR_MODE: number;
  74025. /** Cubic coordinates mode */
  74026. static readonly TEXTURE_CUBIC_MODE: number;
  74027. /** Projection coordinates mode */
  74028. static readonly TEXTURE_PROJECTION_MODE: number;
  74029. /** Skybox coordinates mode */
  74030. static readonly TEXTURE_SKYBOX_MODE: number;
  74031. /** Inverse Cubic coordinates mode */
  74032. static readonly TEXTURE_INVCUBIC_MODE: number;
  74033. /** Equirectangular coordinates mode */
  74034. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74035. /** Equirectangular Fixed coordinates mode */
  74036. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74037. /** Equirectangular Fixed Mirrored coordinates mode */
  74038. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74039. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74040. static readonly SCALEMODE_FLOOR: number;
  74041. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74042. static readonly SCALEMODE_NEAREST: number;
  74043. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74044. static readonly SCALEMODE_CEILING: number;
  74045. /**
  74046. * The dirty texture flag value
  74047. */
  74048. static readonly MATERIAL_TextureDirtyFlag: number;
  74049. /**
  74050. * The dirty light flag value
  74051. */
  74052. static readonly MATERIAL_LightDirtyFlag: number;
  74053. /**
  74054. * The dirty fresnel flag value
  74055. */
  74056. static readonly MATERIAL_FresnelDirtyFlag: number;
  74057. /**
  74058. * The dirty attribute flag value
  74059. */
  74060. static readonly MATERIAL_AttributesDirtyFlag: number;
  74061. /**
  74062. * The dirty misc flag value
  74063. */
  74064. static readonly MATERIAL_MiscDirtyFlag: number;
  74065. /**
  74066. * The all dirty flag value
  74067. */
  74068. static readonly MATERIAL_AllDirtyFlag: number;
  74069. /**
  74070. * Returns the triangle fill mode
  74071. */
  74072. static readonly MATERIAL_TriangleFillMode: number;
  74073. /**
  74074. * Returns the wireframe mode
  74075. */
  74076. static readonly MATERIAL_WireFrameFillMode: number;
  74077. /**
  74078. * Returns the point fill mode
  74079. */
  74080. static readonly MATERIAL_PointFillMode: number;
  74081. /**
  74082. * Returns the point list draw mode
  74083. */
  74084. static readonly MATERIAL_PointListDrawMode: number;
  74085. /**
  74086. * Returns the line list draw mode
  74087. */
  74088. static readonly MATERIAL_LineListDrawMode: number;
  74089. /**
  74090. * Returns the line loop draw mode
  74091. */
  74092. static readonly MATERIAL_LineLoopDrawMode: number;
  74093. /**
  74094. * Returns the line strip draw mode
  74095. */
  74096. static readonly MATERIAL_LineStripDrawMode: number;
  74097. /**
  74098. * Returns the triangle strip draw mode
  74099. */
  74100. static readonly MATERIAL_TriangleStripDrawMode: number;
  74101. /**
  74102. * Returns the triangle fan draw mode
  74103. */
  74104. static readonly MATERIAL_TriangleFanDrawMode: number;
  74105. /**
  74106. * Stores the clock-wise side orientation
  74107. */
  74108. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74109. /**
  74110. * Stores the counter clock-wise side orientation
  74111. */
  74112. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74113. /**
  74114. * Nothing
  74115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74116. */
  74117. static readonly ACTION_NothingTrigger: number;
  74118. /**
  74119. * On pick
  74120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74121. */
  74122. static readonly ACTION_OnPickTrigger: number;
  74123. /**
  74124. * On left pick
  74125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74126. */
  74127. static readonly ACTION_OnLeftPickTrigger: number;
  74128. /**
  74129. * On right pick
  74130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74131. */
  74132. static readonly ACTION_OnRightPickTrigger: number;
  74133. /**
  74134. * On center pick
  74135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74136. */
  74137. static readonly ACTION_OnCenterPickTrigger: number;
  74138. /**
  74139. * On pick down
  74140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74141. */
  74142. static readonly ACTION_OnPickDownTrigger: number;
  74143. /**
  74144. * On double pick
  74145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74146. */
  74147. static readonly ACTION_OnDoublePickTrigger: number;
  74148. /**
  74149. * On pick up
  74150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74151. */
  74152. static readonly ACTION_OnPickUpTrigger: number;
  74153. /**
  74154. * On pick out.
  74155. * This trigger will only be raised if you also declared a OnPickDown
  74156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74157. */
  74158. static readonly ACTION_OnPickOutTrigger: number;
  74159. /**
  74160. * On long press
  74161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74162. */
  74163. static readonly ACTION_OnLongPressTrigger: number;
  74164. /**
  74165. * On pointer over
  74166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74167. */
  74168. static readonly ACTION_OnPointerOverTrigger: number;
  74169. /**
  74170. * On pointer out
  74171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74172. */
  74173. static readonly ACTION_OnPointerOutTrigger: number;
  74174. /**
  74175. * On every frame
  74176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74177. */
  74178. static readonly ACTION_OnEveryFrameTrigger: number;
  74179. /**
  74180. * On intersection enter
  74181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74182. */
  74183. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74184. /**
  74185. * On intersection exit
  74186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74187. */
  74188. static readonly ACTION_OnIntersectionExitTrigger: number;
  74189. /**
  74190. * On key down
  74191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74192. */
  74193. static readonly ACTION_OnKeyDownTrigger: number;
  74194. /**
  74195. * On key up
  74196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74197. */
  74198. static readonly ACTION_OnKeyUpTrigger: number;
  74199. /**
  74200. * Billboard mode will only apply to Y axis
  74201. */
  74202. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74203. /**
  74204. * Billboard mode will apply to all axes
  74205. */
  74206. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74207. /**
  74208. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74209. */
  74210. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74211. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74212. * Test order :
  74213. * Is the bounding sphere outside the frustum ?
  74214. * If not, are the bounding box vertices outside the frustum ?
  74215. * It not, then the cullable object is in the frustum.
  74216. */
  74217. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74218. /** Culling strategy : Bounding Sphere Only.
  74219. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74220. * It's also less accurate than the standard because some not visible objects can still be selected.
  74221. * Test : is the bounding sphere outside the frustum ?
  74222. * If not, then the cullable object is in the frustum.
  74223. */
  74224. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74225. /** Culling strategy : Optimistic Inclusion.
  74226. * This in an inclusion test first, then the standard exclusion test.
  74227. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74228. * 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.
  74229. * Anyway, it's as accurate as the standard strategy.
  74230. * Test :
  74231. * Is the cullable object bounding sphere center in the frustum ?
  74232. * If not, apply the default culling strategy.
  74233. */
  74234. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74235. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74236. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74237. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74238. * 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.
  74239. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74240. * Test :
  74241. * Is the cullable object bounding sphere center in the frustum ?
  74242. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74243. */
  74244. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74245. /**
  74246. * No logging while loading
  74247. */
  74248. static readonly SCENELOADER_NO_LOGGING: number;
  74249. /**
  74250. * Minimal logging while loading
  74251. */
  74252. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74253. /**
  74254. * Summary logging while loading
  74255. */
  74256. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74257. /**
  74258. * Detailled logging while loading
  74259. */
  74260. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74261. }
  74262. }
  74263. declare module BABYLON {
  74264. /**
  74265. * This represents the required contract to create a new type of texture loader.
  74266. */
  74267. export interface IInternalTextureLoader {
  74268. /**
  74269. * Defines wether the loader supports cascade loading the different faces.
  74270. */
  74271. supportCascades: boolean;
  74272. /**
  74273. * This returns if the loader support the current file information.
  74274. * @param extension defines the file extension of the file being loaded
  74275. * @returns true if the loader can load the specified file
  74276. */
  74277. canLoad(extension: string): boolean;
  74278. /**
  74279. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74280. * @param data contains the texture data
  74281. * @param texture defines the BabylonJS internal texture
  74282. * @param createPolynomials will be true if polynomials have been requested
  74283. * @param onLoad defines the callback to trigger once the texture is ready
  74284. * @param onError defines the callback to trigger in case of error
  74285. */
  74286. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74287. /**
  74288. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74289. * @param data contains the texture data
  74290. * @param texture defines the BabylonJS internal texture
  74291. * @param callback defines the method to call once ready to upload
  74292. */
  74293. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74294. }
  74295. }
  74296. declare module BABYLON {
  74297. /**
  74298. * Class used to store and describe the pipeline context associated with an effect
  74299. */
  74300. export interface IPipelineContext {
  74301. /**
  74302. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74303. */
  74304. isAsync: boolean;
  74305. /**
  74306. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74307. */
  74308. isReady: boolean;
  74309. /** @hidden */
  74310. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /**
  74315. * Class used to store gfx data (like WebGLBuffer)
  74316. */
  74317. export class DataBuffer {
  74318. /**
  74319. * Gets or sets the number of objects referencing this buffer
  74320. */
  74321. references: number;
  74322. /** Gets or sets the size of the underlying buffer */
  74323. capacity: number;
  74324. /**
  74325. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74326. */
  74327. is32Bits: boolean;
  74328. /**
  74329. * Gets the underlying buffer
  74330. */
  74331. get underlyingResource(): any;
  74332. }
  74333. }
  74334. declare module BABYLON {
  74335. /** @hidden */
  74336. export interface IShaderProcessor {
  74337. attributeProcessor?: (attribute: string) => string;
  74338. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74339. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74340. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74341. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74342. lineProcessor?: (line: string, isFragment: boolean) => string;
  74343. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74344. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74345. }
  74346. }
  74347. declare module BABYLON {
  74348. /** @hidden */
  74349. export interface ProcessingOptions {
  74350. defines: string[];
  74351. indexParameters: any;
  74352. isFragment: boolean;
  74353. shouldUseHighPrecisionShader: boolean;
  74354. supportsUniformBuffers: boolean;
  74355. shadersRepository: string;
  74356. includesShadersStore: {
  74357. [key: string]: string;
  74358. };
  74359. processor?: IShaderProcessor;
  74360. version: string;
  74361. platformName: string;
  74362. lookForClosingBracketForUniformBuffer?: boolean;
  74363. }
  74364. }
  74365. declare module BABYLON {
  74366. /** @hidden */
  74367. export class ShaderCodeNode {
  74368. line: string;
  74369. children: ShaderCodeNode[];
  74370. additionalDefineKey?: string;
  74371. additionalDefineValue?: string;
  74372. isValid(preprocessors: {
  74373. [key: string]: string;
  74374. }): boolean;
  74375. process(preprocessors: {
  74376. [key: string]: string;
  74377. }, options: ProcessingOptions): string;
  74378. }
  74379. }
  74380. declare module BABYLON {
  74381. /** @hidden */
  74382. export class ShaderCodeCursor {
  74383. private _lines;
  74384. lineIndex: number;
  74385. get currentLine(): string;
  74386. get canRead(): boolean;
  74387. set lines(value: string[]);
  74388. }
  74389. }
  74390. declare module BABYLON {
  74391. /** @hidden */
  74392. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74393. process(preprocessors: {
  74394. [key: string]: string;
  74395. }, options: ProcessingOptions): string;
  74396. }
  74397. }
  74398. declare module BABYLON {
  74399. /** @hidden */
  74400. export class ShaderDefineExpression {
  74401. isTrue(preprocessors: {
  74402. [key: string]: string;
  74403. }): boolean;
  74404. }
  74405. }
  74406. declare module BABYLON {
  74407. /** @hidden */
  74408. export class ShaderCodeTestNode extends ShaderCodeNode {
  74409. testExpression: ShaderDefineExpression;
  74410. isValid(preprocessors: {
  74411. [key: string]: string;
  74412. }): boolean;
  74413. }
  74414. }
  74415. declare module BABYLON {
  74416. /** @hidden */
  74417. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74418. define: string;
  74419. not: boolean;
  74420. constructor(define: string, not?: boolean);
  74421. isTrue(preprocessors: {
  74422. [key: string]: string;
  74423. }): boolean;
  74424. }
  74425. }
  74426. declare module BABYLON {
  74427. /** @hidden */
  74428. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74429. leftOperand: ShaderDefineExpression;
  74430. rightOperand: ShaderDefineExpression;
  74431. isTrue(preprocessors: {
  74432. [key: string]: string;
  74433. }): boolean;
  74434. }
  74435. }
  74436. declare module BABYLON {
  74437. /** @hidden */
  74438. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74439. leftOperand: ShaderDefineExpression;
  74440. rightOperand: ShaderDefineExpression;
  74441. isTrue(preprocessors: {
  74442. [key: string]: string;
  74443. }): boolean;
  74444. }
  74445. }
  74446. declare module BABYLON {
  74447. /** @hidden */
  74448. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74449. define: string;
  74450. operand: string;
  74451. testValue: string;
  74452. constructor(define: string, operand: string, testValue: string);
  74453. isTrue(preprocessors: {
  74454. [key: string]: string;
  74455. }): boolean;
  74456. }
  74457. }
  74458. declare module BABYLON {
  74459. /**
  74460. * Class used to enable access to offline support
  74461. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74462. */
  74463. export interface IOfflineProvider {
  74464. /**
  74465. * Gets a boolean indicating if scene must be saved in the database
  74466. */
  74467. enableSceneOffline: boolean;
  74468. /**
  74469. * Gets a boolean indicating if textures must be saved in the database
  74470. */
  74471. enableTexturesOffline: boolean;
  74472. /**
  74473. * Open the offline support and make it available
  74474. * @param successCallback defines the callback to call on success
  74475. * @param errorCallback defines the callback to call on error
  74476. */
  74477. open(successCallback: () => void, errorCallback: () => void): void;
  74478. /**
  74479. * Loads an image from the offline support
  74480. * @param url defines the url to load from
  74481. * @param image defines the target DOM image
  74482. */
  74483. loadImage(url: string, image: HTMLImageElement): void;
  74484. /**
  74485. * Loads a file from offline support
  74486. * @param url defines the URL to load from
  74487. * @param sceneLoaded defines a callback to call on success
  74488. * @param progressCallBack defines a callback to call when progress changed
  74489. * @param errorCallback defines a callback to call on error
  74490. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74491. */
  74492. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74493. }
  74494. }
  74495. declare module BABYLON {
  74496. /**
  74497. * Class used to help managing file picking and drag'n'drop
  74498. * File Storage
  74499. */
  74500. export class FilesInputStore {
  74501. /**
  74502. * List of files ready to be loaded
  74503. */
  74504. static FilesToLoad: {
  74505. [key: string]: File;
  74506. };
  74507. }
  74508. }
  74509. declare module BABYLON {
  74510. /**
  74511. * Class used to define a retry strategy when error happens while loading assets
  74512. */
  74513. export class RetryStrategy {
  74514. /**
  74515. * Function used to defines an exponential back off strategy
  74516. * @param maxRetries defines the maximum number of retries (3 by default)
  74517. * @param baseInterval defines the interval between retries
  74518. * @returns the strategy function to use
  74519. */
  74520. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74521. }
  74522. }
  74523. declare module BABYLON {
  74524. /**
  74525. * @ignore
  74526. * Application error to support additional information when loading a file
  74527. */
  74528. export abstract class BaseError extends Error {
  74529. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74530. }
  74531. }
  74532. declare module BABYLON {
  74533. /** @ignore */
  74534. export class LoadFileError extends BaseError {
  74535. request?: WebRequest;
  74536. file?: File;
  74537. /**
  74538. * Creates a new LoadFileError
  74539. * @param message defines the message of the error
  74540. * @param request defines the optional web request
  74541. * @param file defines the optional file
  74542. */
  74543. constructor(message: string, object?: WebRequest | File);
  74544. }
  74545. /** @ignore */
  74546. export class RequestFileError extends BaseError {
  74547. request: WebRequest;
  74548. /**
  74549. * Creates a new LoadFileError
  74550. * @param message defines the message of the error
  74551. * @param request defines the optional web request
  74552. */
  74553. constructor(message: string, request: WebRequest);
  74554. }
  74555. /** @ignore */
  74556. export class ReadFileError extends BaseError {
  74557. file: File;
  74558. /**
  74559. * Creates a new ReadFileError
  74560. * @param message defines the message of the error
  74561. * @param file defines the optional file
  74562. */
  74563. constructor(message: string, file: File);
  74564. }
  74565. /**
  74566. * @hidden
  74567. */
  74568. export class FileTools {
  74569. /**
  74570. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74571. */
  74572. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74573. /**
  74574. * Gets or sets the base URL to use to load assets
  74575. */
  74576. static BaseUrl: string;
  74577. /**
  74578. * Default behaviour for cors in the application.
  74579. * It can be a string if the expected behavior is identical in the entire app.
  74580. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74581. */
  74582. static CorsBehavior: string | ((url: string | string[]) => string);
  74583. /**
  74584. * Gets or sets a function used to pre-process url before using them to load assets
  74585. */
  74586. static PreprocessUrl: (url: string) => string;
  74587. /**
  74588. * Removes unwanted characters from an url
  74589. * @param url defines the url to clean
  74590. * @returns the cleaned url
  74591. */
  74592. private static _CleanUrl;
  74593. /**
  74594. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74595. * @param url define the url we are trying
  74596. * @param element define the dom element where to configure the cors policy
  74597. */
  74598. static SetCorsBehavior(url: string | string[], element: {
  74599. crossOrigin: string | null;
  74600. }): void;
  74601. /**
  74602. * Loads an image as an HTMLImageElement.
  74603. * @param input url string, ArrayBuffer, or Blob to load
  74604. * @param onLoad callback called when the image successfully loads
  74605. * @param onError callback called when the image fails to load
  74606. * @param offlineProvider offline provider for caching
  74607. * @param mimeType optional mime type
  74608. * @returns the HTMLImageElement of the loaded image
  74609. */
  74610. 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>;
  74611. /**
  74612. * Reads a file from a File object
  74613. * @param file defines the file to load
  74614. * @param onSuccess defines the callback to call when data is loaded
  74615. * @param onProgress defines the callback to call during loading process
  74616. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74617. * @param onError defines the callback to call when an error occurs
  74618. * @returns a file request object
  74619. */
  74620. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74621. /**
  74622. * Loads a file from a url
  74623. * @param url url to load
  74624. * @param onSuccess callback called when the file successfully loads
  74625. * @param onProgress callback called while file is loading (if the server supports this mode)
  74626. * @param offlineProvider defines the offline provider for caching
  74627. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74628. * @param onError callback called when the file fails to load
  74629. * @returns a file request object
  74630. */
  74631. 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;
  74632. /**
  74633. * Loads a file
  74634. * @param url url to load
  74635. * @param onSuccess callback called when the file successfully loads
  74636. * @param onProgress callback called while file is loading (if the server supports this mode)
  74637. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74638. * @param onError callback called when the file fails to load
  74639. * @param onOpened callback called when the web request is opened
  74640. * @returns a file request object
  74641. */
  74642. 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;
  74643. /**
  74644. * Checks if the loaded document was accessed via `file:`-Protocol.
  74645. * @returns boolean
  74646. */
  74647. static IsFileURL(): boolean;
  74648. }
  74649. }
  74650. declare module BABYLON {
  74651. /** @hidden */
  74652. export class ShaderProcessor {
  74653. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74654. private static _ProcessPrecision;
  74655. private static _ExtractOperation;
  74656. private static _BuildSubExpression;
  74657. private static _BuildExpression;
  74658. private static _MoveCursorWithinIf;
  74659. private static _MoveCursor;
  74660. private static _EvaluatePreProcessors;
  74661. private static _PreparePreProcessors;
  74662. private static _ProcessShaderConversion;
  74663. private static _ProcessIncludes;
  74664. /**
  74665. * Loads a file from a url
  74666. * @param url url to load
  74667. * @param onSuccess callback called when the file successfully loads
  74668. * @param onProgress callback called while file is loading (if the server supports this mode)
  74669. * @param offlineProvider defines the offline provider for caching
  74670. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74671. * @param onError callback called when the file fails to load
  74672. * @returns a file request object
  74673. * @hidden
  74674. */
  74675. 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;
  74676. }
  74677. }
  74678. declare module BABYLON {
  74679. /**
  74680. * @hidden
  74681. */
  74682. export interface IColor4Like {
  74683. r: float;
  74684. g: float;
  74685. b: float;
  74686. a: float;
  74687. }
  74688. /**
  74689. * @hidden
  74690. */
  74691. export interface IColor3Like {
  74692. r: float;
  74693. g: float;
  74694. b: float;
  74695. }
  74696. /**
  74697. * @hidden
  74698. */
  74699. export interface IVector4Like {
  74700. x: float;
  74701. y: float;
  74702. z: float;
  74703. w: float;
  74704. }
  74705. /**
  74706. * @hidden
  74707. */
  74708. export interface IVector3Like {
  74709. x: float;
  74710. y: float;
  74711. z: float;
  74712. }
  74713. /**
  74714. * @hidden
  74715. */
  74716. export interface IVector2Like {
  74717. x: float;
  74718. y: float;
  74719. }
  74720. /**
  74721. * @hidden
  74722. */
  74723. export interface IMatrixLike {
  74724. toArray(): DeepImmutable<Float32Array>;
  74725. updateFlag: int;
  74726. }
  74727. /**
  74728. * @hidden
  74729. */
  74730. export interface IViewportLike {
  74731. x: float;
  74732. y: float;
  74733. width: float;
  74734. height: float;
  74735. }
  74736. /**
  74737. * @hidden
  74738. */
  74739. export interface IPlaneLike {
  74740. normal: IVector3Like;
  74741. d: float;
  74742. normalize(): void;
  74743. }
  74744. }
  74745. declare module BABYLON {
  74746. /**
  74747. * Interface used to define common properties for effect fallbacks
  74748. */
  74749. export interface IEffectFallbacks {
  74750. /**
  74751. * Removes the defines that should be removed when falling back.
  74752. * @param currentDefines defines the current define statements for the shader.
  74753. * @param effect defines the current effect we try to compile
  74754. * @returns The resulting defines with defines of the current rank removed.
  74755. */
  74756. reduce(currentDefines: string, effect: Effect): string;
  74757. /**
  74758. * Removes the fallback from the bound mesh.
  74759. */
  74760. unBindMesh(): void;
  74761. /**
  74762. * Checks to see if more fallbacks are still availible.
  74763. */
  74764. hasMoreFallbacks: boolean;
  74765. }
  74766. }
  74767. declare module BABYLON {
  74768. /**
  74769. * Class used to evalaute queries containing `and` and `or` operators
  74770. */
  74771. export class AndOrNotEvaluator {
  74772. /**
  74773. * Evaluate a query
  74774. * @param query defines the query to evaluate
  74775. * @param evaluateCallback defines the callback used to filter result
  74776. * @returns true if the query matches
  74777. */
  74778. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74779. private static _HandleParenthesisContent;
  74780. private static _SimplifyNegation;
  74781. }
  74782. }
  74783. declare module BABYLON {
  74784. /**
  74785. * Class used to store custom tags
  74786. */
  74787. export class Tags {
  74788. /**
  74789. * Adds support for tags on the given object
  74790. * @param obj defines the object to use
  74791. */
  74792. static EnableFor(obj: any): void;
  74793. /**
  74794. * Removes tags support
  74795. * @param obj defines the object to use
  74796. */
  74797. static DisableFor(obj: any): void;
  74798. /**
  74799. * Gets a boolean indicating if the given object has tags
  74800. * @param obj defines the object to use
  74801. * @returns a boolean
  74802. */
  74803. static HasTags(obj: any): boolean;
  74804. /**
  74805. * Gets the tags available on a given object
  74806. * @param obj defines the object to use
  74807. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74808. * @returns the tags
  74809. */
  74810. static GetTags(obj: any, asString?: boolean): any;
  74811. /**
  74812. * Adds tags to an object
  74813. * @param obj defines the object to use
  74814. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74815. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74816. */
  74817. static AddTagsTo(obj: any, tagsString: string): void;
  74818. /**
  74819. * @hidden
  74820. */
  74821. static _AddTagTo(obj: any, tag: string): void;
  74822. /**
  74823. * Removes specific tags from a specific object
  74824. * @param obj defines the object to use
  74825. * @param tagsString defines the tags to remove
  74826. */
  74827. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74828. /**
  74829. * @hidden
  74830. */
  74831. static _RemoveTagFrom(obj: any, tag: string): void;
  74832. /**
  74833. * Defines if tags hosted on an object match a given query
  74834. * @param obj defines the object to use
  74835. * @param tagsQuery defines the tag query
  74836. * @returns a boolean
  74837. */
  74838. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74839. }
  74840. }
  74841. declare module BABYLON {
  74842. /**
  74843. * Scalar computation library
  74844. */
  74845. export class Scalar {
  74846. /**
  74847. * Two pi constants convenient for computation.
  74848. */
  74849. static TwoPi: number;
  74850. /**
  74851. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74852. * @param a number
  74853. * @param b number
  74854. * @param epsilon (default = 1.401298E-45)
  74855. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74856. */
  74857. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74858. /**
  74859. * Returns a string : the upper case translation of the number i to hexadecimal.
  74860. * @param i number
  74861. * @returns the upper case translation of the number i to hexadecimal.
  74862. */
  74863. static ToHex(i: number): string;
  74864. /**
  74865. * Returns -1 if value is negative and +1 is value is positive.
  74866. * @param value the value
  74867. * @returns the value itself if it's equal to zero.
  74868. */
  74869. static Sign(value: number): number;
  74870. /**
  74871. * Returns the value itself if it's between min and max.
  74872. * Returns min if the value is lower than min.
  74873. * Returns max if the value is greater than max.
  74874. * @param value the value to clmap
  74875. * @param min the min value to clamp to (default: 0)
  74876. * @param max the max value to clamp to (default: 1)
  74877. * @returns the clamped value
  74878. */
  74879. static Clamp(value: number, min?: number, max?: number): number;
  74880. /**
  74881. * the log2 of value.
  74882. * @param value the value to compute log2 of
  74883. * @returns the log2 of value.
  74884. */
  74885. static Log2(value: number): number;
  74886. /**
  74887. * Loops the value, so that it is never larger than length and never smaller than 0.
  74888. *
  74889. * This is similar to the modulo operator but it works with floating point numbers.
  74890. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74891. * With t = 5 and length = 2.5, the result would be 0.0.
  74892. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74893. * @param value the value
  74894. * @param length the length
  74895. * @returns the looped value
  74896. */
  74897. static Repeat(value: number, length: number): number;
  74898. /**
  74899. * Normalize the value between 0.0 and 1.0 using min and max values
  74900. * @param value value to normalize
  74901. * @param min max to normalize between
  74902. * @param max min to normalize between
  74903. * @returns the normalized value
  74904. */
  74905. static Normalize(value: number, min: number, max: number): number;
  74906. /**
  74907. * Denormalize the value from 0.0 and 1.0 using min and max values
  74908. * @param normalized value to denormalize
  74909. * @param min max to denormalize between
  74910. * @param max min to denormalize between
  74911. * @returns the denormalized value
  74912. */
  74913. static Denormalize(normalized: number, min: number, max: number): number;
  74914. /**
  74915. * Calculates the shortest difference between two given angles given in degrees.
  74916. * @param current current angle in degrees
  74917. * @param target target angle in degrees
  74918. * @returns the delta
  74919. */
  74920. static DeltaAngle(current: number, target: number): number;
  74921. /**
  74922. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74923. * @param tx value
  74924. * @param length length
  74925. * @returns The returned value will move back and forth between 0 and length
  74926. */
  74927. static PingPong(tx: number, length: number): number;
  74928. /**
  74929. * Interpolates between min and max with smoothing at the limits.
  74930. *
  74931. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74932. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74933. * @param from from
  74934. * @param to to
  74935. * @param tx value
  74936. * @returns the smooth stepped value
  74937. */
  74938. static SmoothStep(from: number, to: number, tx: number): number;
  74939. /**
  74940. * Moves a value current towards target.
  74941. *
  74942. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74943. * Negative values of maxDelta pushes the value away from target.
  74944. * @param current current value
  74945. * @param target target value
  74946. * @param maxDelta max distance to move
  74947. * @returns resulting value
  74948. */
  74949. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74950. /**
  74951. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74952. *
  74953. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74954. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74955. * @param current current value
  74956. * @param target target value
  74957. * @param maxDelta max distance to move
  74958. * @returns resulting angle
  74959. */
  74960. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74961. /**
  74962. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74963. * @param start start value
  74964. * @param end target value
  74965. * @param amount amount to lerp between
  74966. * @returns the lerped value
  74967. */
  74968. static Lerp(start: number, end: number, amount: number): number;
  74969. /**
  74970. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74971. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74972. * @param start start value
  74973. * @param end target value
  74974. * @param amount amount to lerp between
  74975. * @returns the lerped value
  74976. */
  74977. static LerpAngle(start: number, end: number, amount: number): number;
  74978. /**
  74979. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74980. * @param a start value
  74981. * @param b target value
  74982. * @param value value between a and b
  74983. * @returns the inverseLerp value
  74984. */
  74985. static InverseLerp(a: number, b: number, value: number): number;
  74986. /**
  74987. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74988. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74989. * @param value1 spline value
  74990. * @param tangent1 spline value
  74991. * @param value2 spline value
  74992. * @param tangent2 spline value
  74993. * @param amount input value
  74994. * @returns hermite result
  74995. */
  74996. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74997. /**
  74998. * Returns a random float number between and min and max values
  74999. * @param min min value of random
  75000. * @param max max value of random
  75001. * @returns random value
  75002. */
  75003. static RandomRange(min: number, max: number): number;
  75004. /**
  75005. * This function returns percentage of a number in a given range.
  75006. *
  75007. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75008. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75009. * @param number to convert to percentage
  75010. * @param min min range
  75011. * @param max max range
  75012. * @returns the percentage
  75013. */
  75014. static RangeToPercent(number: number, min: number, max: number): number;
  75015. /**
  75016. * This function returns number that corresponds to the percentage in a given range.
  75017. *
  75018. * PercentToRange(0.34,0,100) will return 34.
  75019. * @param percent to convert to number
  75020. * @param min min range
  75021. * @param max max range
  75022. * @returns the number
  75023. */
  75024. static PercentToRange(percent: number, min: number, max: number): number;
  75025. /**
  75026. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75027. * @param angle The angle to normalize in radian.
  75028. * @return The converted angle.
  75029. */
  75030. static NormalizeRadians(angle: number): number;
  75031. }
  75032. }
  75033. declare module BABYLON {
  75034. /**
  75035. * Constant used to convert a value to gamma space
  75036. * @ignorenaming
  75037. */
  75038. export const ToGammaSpace: number;
  75039. /**
  75040. * Constant used to convert a value to linear space
  75041. * @ignorenaming
  75042. */
  75043. export const ToLinearSpace = 2.2;
  75044. /**
  75045. * Constant used to define the minimal number value in Babylon.js
  75046. * @ignorenaming
  75047. */
  75048. let Epsilon: number;
  75049. }
  75050. declare module BABYLON {
  75051. /**
  75052. * Class used to represent a viewport on screen
  75053. */
  75054. export class Viewport {
  75055. /** viewport left coordinate */
  75056. x: number;
  75057. /** viewport top coordinate */
  75058. y: number;
  75059. /**viewport width */
  75060. width: number;
  75061. /** viewport height */
  75062. height: number;
  75063. /**
  75064. * Creates a Viewport object located at (x, y) and sized (width, height)
  75065. * @param x defines viewport left coordinate
  75066. * @param y defines viewport top coordinate
  75067. * @param width defines the viewport width
  75068. * @param height defines the viewport height
  75069. */
  75070. constructor(
  75071. /** viewport left coordinate */
  75072. x: number,
  75073. /** viewport top coordinate */
  75074. y: number,
  75075. /**viewport width */
  75076. width: number,
  75077. /** viewport height */
  75078. height: number);
  75079. /**
  75080. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75081. * @param renderWidth defines the rendering width
  75082. * @param renderHeight defines the rendering height
  75083. * @returns a new Viewport
  75084. */
  75085. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75086. /**
  75087. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75088. * @param renderWidth defines the rendering width
  75089. * @param renderHeight defines the rendering height
  75090. * @param ref defines the target viewport
  75091. * @returns the current viewport
  75092. */
  75093. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75094. /**
  75095. * Returns a new Viewport copied from the current one
  75096. * @returns a new Viewport
  75097. */
  75098. clone(): Viewport;
  75099. }
  75100. }
  75101. declare module BABYLON {
  75102. /**
  75103. * Class containing a set of static utilities functions for arrays.
  75104. */
  75105. export class ArrayTools {
  75106. /**
  75107. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75108. * @param size the number of element to construct and put in the array
  75109. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75110. * @returns a new array filled with new objects
  75111. */
  75112. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75113. }
  75114. }
  75115. declare module BABYLON {
  75116. /**
  75117. * Class representing a vector containing 2 coordinates
  75118. */
  75119. export class Vector2 {
  75120. /** defines the first coordinate */
  75121. x: number;
  75122. /** defines the second coordinate */
  75123. y: number;
  75124. /**
  75125. * Creates a new Vector2 from the given x and y coordinates
  75126. * @param x defines the first coordinate
  75127. * @param y defines the second coordinate
  75128. */
  75129. constructor(
  75130. /** defines the first coordinate */
  75131. x?: number,
  75132. /** defines the second coordinate */
  75133. y?: number);
  75134. /**
  75135. * Gets a string with the Vector2 coordinates
  75136. * @returns a string with the Vector2 coordinates
  75137. */
  75138. toString(): string;
  75139. /**
  75140. * Gets class name
  75141. * @returns the string "Vector2"
  75142. */
  75143. getClassName(): string;
  75144. /**
  75145. * Gets current vector hash code
  75146. * @returns the Vector2 hash code as a number
  75147. */
  75148. getHashCode(): number;
  75149. /**
  75150. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75151. * @param array defines the source array
  75152. * @param index defines the offset in source array
  75153. * @returns the current Vector2
  75154. */
  75155. toArray(array: FloatArray, index?: number): Vector2;
  75156. /**
  75157. * Copy the current vector to an array
  75158. * @returns a new array with 2 elements: the Vector2 coordinates.
  75159. */
  75160. asArray(): number[];
  75161. /**
  75162. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75163. * @param source defines the source Vector2
  75164. * @returns the current updated Vector2
  75165. */
  75166. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75167. /**
  75168. * Sets the Vector2 coordinates with the given floats
  75169. * @param x defines the first coordinate
  75170. * @param y defines the second coordinate
  75171. * @returns the current updated Vector2
  75172. */
  75173. copyFromFloats(x: number, y: number): Vector2;
  75174. /**
  75175. * Sets the Vector2 coordinates with the given floats
  75176. * @param x defines the first coordinate
  75177. * @param y defines the second coordinate
  75178. * @returns the current updated Vector2
  75179. */
  75180. set(x: number, y: number): Vector2;
  75181. /**
  75182. * Add another vector with the current one
  75183. * @param otherVector defines the other vector
  75184. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75185. */
  75186. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75187. /**
  75188. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75189. * @param otherVector defines the other vector
  75190. * @param result defines the target vector
  75191. * @returns the unmodified current Vector2
  75192. */
  75193. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75194. /**
  75195. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75196. * @param otherVector defines the other vector
  75197. * @returns the current updated Vector2
  75198. */
  75199. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75200. /**
  75201. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75202. * @param otherVector defines the other vector
  75203. * @returns a new Vector2
  75204. */
  75205. addVector3(otherVector: Vector3): Vector2;
  75206. /**
  75207. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75208. * @param otherVector defines the other vector
  75209. * @returns a new Vector2
  75210. */
  75211. subtract(otherVector: Vector2): Vector2;
  75212. /**
  75213. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75214. * @param otherVector defines the other vector
  75215. * @param result defines the target vector
  75216. * @returns the unmodified current Vector2
  75217. */
  75218. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75219. /**
  75220. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75221. * @param otherVector defines the other vector
  75222. * @returns the current updated Vector2
  75223. */
  75224. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75225. /**
  75226. * Multiplies in place the current Vector2 coordinates by the given ones
  75227. * @param otherVector defines the other vector
  75228. * @returns the current updated Vector2
  75229. */
  75230. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75231. /**
  75232. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75233. * @param otherVector defines the other vector
  75234. * @returns a new Vector2
  75235. */
  75236. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75237. /**
  75238. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75239. * @param otherVector defines the other vector
  75240. * @param result defines the target vector
  75241. * @returns the unmodified current Vector2
  75242. */
  75243. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75244. /**
  75245. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75246. * @param x defines the first coordinate
  75247. * @param y defines the second coordinate
  75248. * @returns a new Vector2
  75249. */
  75250. multiplyByFloats(x: number, y: number): Vector2;
  75251. /**
  75252. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75253. * @param otherVector defines the other vector
  75254. * @returns a new Vector2
  75255. */
  75256. divide(otherVector: Vector2): Vector2;
  75257. /**
  75258. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75259. * @param otherVector defines the other vector
  75260. * @param result defines the target vector
  75261. * @returns the unmodified current Vector2
  75262. */
  75263. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75264. /**
  75265. * Divides the current Vector2 coordinates by the given ones
  75266. * @param otherVector defines the other vector
  75267. * @returns the current updated Vector2
  75268. */
  75269. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75270. /**
  75271. * Gets a new Vector2 with current Vector2 negated coordinates
  75272. * @returns a new Vector2
  75273. */
  75274. negate(): Vector2;
  75275. /**
  75276. * Negate this vector in place
  75277. * @returns this
  75278. */
  75279. negateInPlace(): Vector2;
  75280. /**
  75281. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75282. * @param result defines the Vector3 object where to store the result
  75283. * @returns the current Vector2
  75284. */
  75285. negateToRef(result: Vector2): Vector2;
  75286. /**
  75287. * Multiply the Vector2 coordinates by scale
  75288. * @param scale defines the scaling factor
  75289. * @returns the current updated Vector2
  75290. */
  75291. scaleInPlace(scale: number): Vector2;
  75292. /**
  75293. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75294. * @param scale defines the scaling factor
  75295. * @returns a new Vector2
  75296. */
  75297. scale(scale: number): Vector2;
  75298. /**
  75299. * Scale the current Vector2 values by a factor to a given Vector2
  75300. * @param scale defines the scale factor
  75301. * @param result defines the Vector2 object where to store the result
  75302. * @returns the unmodified current Vector2
  75303. */
  75304. scaleToRef(scale: number, result: Vector2): Vector2;
  75305. /**
  75306. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75307. * @param scale defines the scale factor
  75308. * @param result defines the Vector2 object where to store the result
  75309. * @returns the unmodified current Vector2
  75310. */
  75311. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75312. /**
  75313. * Gets a boolean if two vectors are equals
  75314. * @param otherVector defines the other vector
  75315. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75316. */
  75317. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75318. /**
  75319. * Gets a boolean if two vectors are equals (using an epsilon value)
  75320. * @param otherVector defines the other vector
  75321. * @param epsilon defines the minimal distance to consider equality
  75322. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75323. */
  75324. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75325. /**
  75326. * Gets a new Vector2 from current Vector2 floored values
  75327. * @returns a new Vector2
  75328. */
  75329. floor(): Vector2;
  75330. /**
  75331. * Gets a new Vector2 from current Vector2 floored values
  75332. * @returns a new Vector2
  75333. */
  75334. fract(): Vector2;
  75335. /**
  75336. * Gets the length of the vector
  75337. * @returns the vector length (float)
  75338. */
  75339. length(): number;
  75340. /**
  75341. * Gets the vector squared length
  75342. * @returns the vector squared length (float)
  75343. */
  75344. lengthSquared(): number;
  75345. /**
  75346. * Normalize the vector
  75347. * @returns the current updated Vector2
  75348. */
  75349. normalize(): Vector2;
  75350. /**
  75351. * Gets a new Vector2 copied from the Vector2
  75352. * @returns a new Vector2
  75353. */
  75354. clone(): Vector2;
  75355. /**
  75356. * Gets a new Vector2(0, 0)
  75357. * @returns a new Vector2
  75358. */
  75359. static Zero(): Vector2;
  75360. /**
  75361. * Gets a new Vector2(1, 1)
  75362. * @returns a new Vector2
  75363. */
  75364. static One(): Vector2;
  75365. /**
  75366. * Gets a new Vector2 set from the given index element of the given array
  75367. * @param array defines the data source
  75368. * @param offset defines the offset in the data source
  75369. * @returns a new Vector2
  75370. */
  75371. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75372. /**
  75373. * Sets "result" from the given index element of the given array
  75374. * @param array defines the data source
  75375. * @param offset defines the offset in the data source
  75376. * @param result defines the target vector
  75377. */
  75378. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75379. /**
  75380. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75381. * @param value1 defines 1st point of control
  75382. * @param value2 defines 2nd point of control
  75383. * @param value3 defines 3rd point of control
  75384. * @param value4 defines 4th point of control
  75385. * @param amount defines the interpolation factor
  75386. * @returns a new Vector2
  75387. */
  75388. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75389. /**
  75390. * 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".
  75391. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75392. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75393. * @param value defines the value to clamp
  75394. * @param min defines the lower limit
  75395. * @param max defines the upper limit
  75396. * @returns a new Vector2
  75397. */
  75398. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75399. /**
  75400. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75401. * @param value1 defines the 1st control point
  75402. * @param tangent1 defines the outgoing tangent
  75403. * @param value2 defines the 2nd control point
  75404. * @param tangent2 defines the incoming tangent
  75405. * @param amount defines the interpolation factor
  75406. * @returns a new Vector2
  75407. */
  75408. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75409. /**
  75410. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75411. * @param start defines the start vector
  75412. * @param end defines the end vector
  75413. * @param amount defines the interpolation factor
  75414. * @returns a new Vector2
  75415. */
  75416. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75417. /**
  75418. * Gets the dot product of the vector "left" and the vector "right"
  75419. * @param left defines first vector
  75420. * @param right defines second vector
  75421. * @returns the dot product (float)
  75422. */
  75423. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75424. /**
  75425. * Returns a new Vector2 equal to the normalized given vector
  75426. * @param vector defines the vector to normalize
  75427. * @returns a new Vector2
  75428. */
  75429. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75430. /**
  75431. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75432. * @param left defines 1st vector
  75433. * @param right defines 2nd vector
  75434. * @returns a new Vector2
  75435. */
  75436. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75437. /**
  75438. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75439. * @param left defines 1st vector
  75440. * @param right defines 2nd vector
  75441. * @returns a new Vector2
  75442. */
  75443. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75444. /**
  75445. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75446. * @param vector defines the vector to transform
  75447. * @param transformation defines the matrix to apply
  75448. * @returns a new Vector2
  75449. */
  75450. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75451. /**
  75452. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75453. * @param vector defines the vector to transform
  75454. * @param transformation defines the matrix to apply
  75455. * @param result defines the target vector
  75456. */
  75457. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75458. /**
  75459. * Determines if a given vector is included in a triangle
  75460. * @param p defines the vector to test
  75461. * @param p0 defines 1st triangle point
  75462. * @param p1 defines 2nd triangle point
  75463. * @param p2 defines 3rd triangle point
  75464. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75465. */
  75466. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75467. /**
  75468. * Gets the distance between the vectors "value1" and "value2"
  75469. * @param value1 defines first vector
  75470. * @param value2 defines second vector
  75471. * @returns the distance between vectors
  75472. */
  75473. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75474. /**
  75475. * Returns the squared distance between the vectors "value1" and "value2"
  75476. * @param value1 defines first vector
  75477. * @param value2 defines second vector
  75478. * @returns the squared distance between vectors
  75479. */
  75480. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75481. /**
  75482. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75483. * @param value1 defines first vector
  75484. * @param value2 defines second vector
  75485. * @returns a new Vector2
  75486. */
  75487. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75488. /**
  75489. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75490. * @param p defines the middle point
  75491. * @param segA defines one point of the segment
  75492. * @param segB defines the other point of the segment
  75493. * @returns the shortest distance
  75494. */
  75495. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75496. }
  75497. /**
  75498. * Class used to store (x,y,z) vector representation
  75499. * A Vector3 is the main object used in 3D geometry
  75500. * It can represent etiher the coordinates of a point the space, either a direction
  75501. * Reminder: js uses a left handed forward facing system
  75502. */
  75503. export class Vector3 {
  75504. /**
  75505. * Defines the first coordinates (on X axis)
  75506. */
  75507. x: number;
  75508. /**
  75509. * Defines the second coordinates (on Y axis)
  75510. */
  75511. y: number;
  75512. /**
  75513. * Defines the third coordinates (on Z axis)
  75514. */
  75515. z: number;
  75516. private static _UpReadOnly;
  75517. private static _ZeroReadOnly;
  75518. /**
  75519. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75520. * @param x defines the first coordinates (on X axis)
  75521. * @param y defines the second coordinates (on Y axis)
  75522. * @param z defines the third coordinates (on Z axis)
  75523. */
  75524. constructor(
  75525. /**
  75526. * Defines the first coordinates (on X axis)
  75527. */
  75528. x?: number,
  75529. /**
  75530. * Defines the second coordinates (on Y axis)
  75531. */
  75532. y?: number,
  75533. /**
  75534. * Defines the third coordinates (on Z axis)
  75535. */
  75536. z?: number);
  75537. /**
  75538. * Creates a string representation of the Vector3
  75539. * @returns a string with the Vector3 coordinates.
  75540. */
  75541. toString(): string;
  75542. /**
  75543. * Gets the class name
  75544. * @returns the string "Vector3"
  75545. */
  75546. getClassName(): string;
  75547. /**
  75548. * Creates the Vector3 hash code
  75549. * @returns a number which tends to be unique between Vector3 instances
  75550. */
  75551. getHashCode(): number;
  75552. /**
  75553. * Creates an array containing three elements : the coordinates of the Vector3
  75554. * @returns a new array of numbers
  75555. */
  75556. asArray(): number[];
  75557. /**
  75558. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75559. * @param array defines the destination array
  75560. * @param index defines the offset in the destination array
  75561. * @returns the current Vector3
  75562. */
  75563. toArray(array: FloatArray, index?: number): Vector3;
  75564. /**
  75565. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75566. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75567. */
  75568. toQuaternion(): Quaternion;
  75569. /**
  75570. * Adds the given vector to the current Vector3
  75571. * @param otherVector defines the second operand
  75572. * @returns the current updated Vector3
  75573. */
  75574. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75575. /**
  75576. * Adds the given coordinates to the current Vector3
  75577. * @param x defines the x coordinate of the operand
  75578. * @param y defines the y coordinate of the operand
  75579. * @param z defines the z coordinate of the operand
  75580. * @returns the current updated Vector3
  75581. */
  75582. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75583. /**
  75584. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75585. * @param otherVector defines the second operand
  75586. * @returns the resulting Vector3
  75587. */
  75588. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75589. /**
  75590. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75591. * @param otherVector defines the second operand
  75592. * @param result defines the Vector3 object where to store the result
  75593. * @returns the current Vector3
  75594. */
  75595. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75596. /**
  75597. * Subtract the given vector from the current Vector3
  75598. * @param otherVector defines the second operand
  75599. * @returns the current updated Vector3
  75600. */
  75601. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75602. /**
  75603. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75604. * @param otherVector defines the second operand
  75605. * @returns the resulting Vector3
  75606. */
  75607. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75608. /**
  75609. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75610. * @param otherVector defines the second operand
  75611. * @param result defines the Vector3 object where to store the result
  75612. * @returns the current Vector3
  75613. */
  75614. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75615. /**
  75616. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75617. * @param x defines the x coordinate of the operand
  75618. * @param y defines the y coordinate of the operand
  75619. * @param z defines the z coordinate of the operand
  75620. * @returns the resulting Vector3
  75621. */
  75622. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75623. /**
  75624. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75625. * @param x defines the x coordinate of the operand
  75626. * @param y defines the y coordinate of the operand
  75627. * @param z defines the z coordinate of the operand
  75628. * @param result defines the Vector3 object where to store the result
  75629. * @returns the current Vector3
  75630. */
  75631. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75632. /**
  75633. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75634. * @returns a new Vector3
  75635. */
  75636. negate(): Vector3;
  75637. /**
  75638. * Negate this vector in place
  75639. * @returns this
  75640. */
  75641. negateInPlace(): Vector3;
  75642. /**
  75643. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75644. * @param result defines the Vector3 object where to store the result
  75645. * @returns the current Vector3
  75646. */
  75647. negateToRef(result: Vector3): Vector3;
  75648. /**
  75649. * Multiplies the Vector3 coordinates by the float "scale"
  75650. * @param scale defines the multiplier factor
  75651. * @returns the current updated Vector3
  75652. */
  75653. scaleInPlace(scale: number): Vector3;
  75654. /**
  75655. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75656. * @param scale defines the multiplier factor
  75657. * @returns a new Vector3
  75658. */
  75659. scale(scale: number): Vector3;
  75660. /**
  75661. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75662. * @param scale defines the multiplier factor
  75663. * @param result defines the Vector3 object where to store the result
  75664. * @returns the current Vector3
  75665. */
  75666. scaleToRef(scale: number, result: Vector3): Vector3;
  75667. /**
  75668. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75669. * @param scale defines the scale factor
  75670. * @param result defines the Vector3 object where to store the result
  75671. * @returns the unmodified current Vector3
  75672. */
  75673. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75674. /**
  75675. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75676. * @param otherVector defines the second operand
  75677. * @returns true if both vectors are equals
  75678. */
  75679. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75680. /**
  75681. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75682. * @param otherVector defines the second operand
  75683. * @param epsilon defines the minimal distance to define values as equals
  75684. * @returns true if both vectors are distant less than epsilon
  75685. */
  75686. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75687. /**
  75688. * Returns true if the current Vector3 coordinates equals the given floats
  75689. * @param x defines the x coordinate of the operand
  75690. * @param y defines the y coordinate of the operand
  75691. * @param z defines the z coordinate of the operand
  75692. * @returns true if both vectors are equals
  75693. */
  75694. equalsToFloats(x: number, y: number, z: number): boolean;
  75695. /**
  75696. * Multiplies the current Vector3 coordinates by the given ones
  75697. * @param otherVector defines the second operand
  75698. * @returns the current updated Vector3
  75699. */
  75700. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75701. /**
  75702. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75703. * @param otherVector defines the second operand
  75704. * @returns the new Vector3
  75705. */
  75706. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75707. /**
  75708. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75709. * @param otherVector defines the second operand
  75710. * @param result defines the Vector3 object where to store the result
  75711. * @returns the current Vector3
  75712. */
  75713. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75714. /**
  75715. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75716. * @param x defines the x coordinate of the operand
  75717. * @param y defines the y coordinate of the operand
  75718. * @param z defines the z coordinate of the operand
  75719. * @returns the new Vector3
  75720. */
  75721. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75722. /**
  75723. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75724. * @param otherVector defines the second operand
  75725. * @returns the new Vector3
  75726. */
  75727. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75728. /**
  75729. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75730. * @param otherVector defines the second operand
  75731. * @param result defines the Vector3 object where to store the result
  75732. * @returns the current Vector3
  75733. */
  75734. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75735. /**
  75736. * Divides the current Vector3 coordinates by the given ones.
  75737. * @param otherVector defines the second operand
  75738. * @returns the current updated Vector3
  75739. */
  75740. divideInPlace(otherVector: Vector3): Vector3;
  75741. /**
  75742. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75743. * @param other defines the second operand
  75744. * @returns the current updated Vector3
  75745. */
  75746. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75747. /**
  75748. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75749. * @param other defines the second operand
  75750. * @returns the current updated Vector3
  75751. */
  75752. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75753. /**
  75754. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75755. * @param x defines the x coordinate of the operand
  75756. * @param y defines the y coordinate of the operand
  75757. * @param z defines the z coordinate of the operand
  75758. * @returns the current updated Vector3
  75759. */
  75760. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75761. /**
  75762. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75763. * @param x defines the x coordinate of the operand
  75764. * @param y defines the y coordinate of the operand
  75765. * @param z defines the z coordinate of the operand
  75766. * @returns the current updated Vector3
  75767. */
  75768. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75769. /**
  75770. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75771. * Check if is non uniform within a certain amount of decimal places to account for this
  75772. * @param epsilon the amount the values can differ
  75773. * @returns if the the vector is non uniform to a certain number of decimal places
  75774. */
  75775. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75776. /**
  75777. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75778. */
  75779. get isNonUniform(): boolean;
  75780. /**
  75781. * Gets a new Vector3 from current Vector3 floored values
  75782. * @returns a new Vector3
  75783. */
  75784. floor(): Vector3;
  75785. /**
  75786. * Gets a new Vector3 from current Vector3 floored values
  75787. * @returns a new Vector3
  75788. */
  75789. fract(): Vector3;
  75790. /**
  75791. * Gets the length of the Vector3
  75792. * @returns the length of the Vector3
  75793. */
  75794. length(): number;
  75795. /**
  75796. * Gets the squared length of the Vector3
  75797. * @returns squared length of the Vector3
  75798. */
  75799. lengthSquared(): number;
  75800. /**
  75801. * Normalize the current Vector3.
  75802. * Please note that this is an in place operation.
  75803. * @returns the current updated Vector3
  75804. */
  75805. normalize(): Vector3;
  75806. /**
  75807. * Reorders the x y z properties of the vector in place
  75808. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75809. * @returns the current updated vector
  75810. */
  75811. reorderInPlace(order: string): this;
  75812. /**
  75813. * Rotates the vector around 0,0,0 by a quaternion
  75814. * @param quaternion the rotation quaternion
  75815. * @param result vector to store the result
  75816. * @returns the resulting vector
  75817. */
  75818. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75819. /**
  75820. * Rotates a vector around a given point
  75821. * @param quaternion the rotation quaternion
  75822. * @param point the point to rotate around
  75823. * @param result vector to store the result
  75824. * @returns the resulting vector
  75825. */
  75826. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75827. /**
  75828. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75829. * The cross product is then orthogonal to both current and "other"
  75830. * @param other defines the right operand
  75831. * @returns the cross product
  75832. */
  75833. cross(other: Vector3): Vector3;
  75834. /**
  75835. * Normalize the current Vector3 with the given input length.
  75836. * Please note that this is an in place operation.
  75837. * @param len the length of the vector
  75838. * @returns the current updated Vector3
  75839. */
  75840. normalizeFromLength(len: number): Vector3;
  75841. /**
  75842. * Normalize the current Vector3 to a new vector
  75843. * @returns the new Vector3
  75844. */
  75845. normalizeToNew(): Vector3;
  75846. /**
  75847. * Normalize the current Vector3 to the reference
  75848. * @param reference define the Vector3 to update
  75849. * @returns the updated Vector3
  75850. */
  75851. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75852. /**
  75853. * Creates a new Vector3 copied from the current Vector3
  75854. * @returns the new Vector3
  75855. */
  75856. clone(): Vector3;
  75857. /**
  75858. * Copies the given vector coordinates to the current Vector3 ones
  75859. * @param source defines the source Vector3
  75860. * @returns the current updated Vector3
  75861. */
  75862. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75863. /**
  75864. * Copies the given floats to the current Vector3 coordinates
  75865. * @param x defines the x coordinate of the operand
  75866. * @param y defines the y coordinate of the operand
  75867. * @param z defines the z coordinate of the operand
  75868. * @returns the current updated Vector3
  75869. */
  75870. copyFromFloats(x: number, y: number, z: number): Vector3;
  75871. /**
  75872. * Copies the given floats to the current Vector3 coordinates
  75873. * @param x defines the x coordinate of the operand
  75874. * @param y defines the y coordinate of the operand
  75875. * @param z defines the z coordinate of the operand
  75876. * @returns the current updated Vector3
  75877. */
  75878. set(x: number, y: number, z: number): Vector3;
  75879. /**
  75880. * Copies the given float to the current Vector3 coordinates
  75881. * @param v defines the x, y and z coordinates of the operand
  75882. * @returns the current updated Vector3
  75883. */
  75884. setAll(v: number): Vector3;
  75885. /**
  75886. * Get the clip factor between two vectors
  75887. * @param vector0 defines the first operand
  75888. * @param vector1 defines the second operand
  75889. * @param axis defines the axis to use
  75890. * @param size defines the size along the axis
  75891. * @returns the clip factor
  75892. */
  75893. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75894. /**
  75895. * Get angle between two vectors
  75896. * @param vector0 angle between vector0 and vector1
  75897. * @param vector1 angle between vector0 and vector1
  75898. * @param normal direction of the normal
  75899. * @return the angle between vector0 and vector1
  75900. */
  75901. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75902. /**
  75903. * Returns a new Vector3 set from the index "offset" of the given array
  75904. * @param array defines the source array
  75905. * @param offset defines the offset in the source array
  75906. * @returns the new Vector3
  75907. */
  75908. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75909. /**
  75910. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75911. * @param array defines the source array
  75912. * @param offset defines the offset in the source array
  75913. * @returns the new Vector3
  75914. * @deprecated Please use FromArray instead.
  75915. */
  75916. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75917. /**
  75918. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75919. * @param array defines the source array
  75920. * @param offset defines the offset in the source array
  75921. * @param result defines the Vector3 where to store the result
  75922. */
  75923. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75924. /**
  75925. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75926. * @param array defines the source array
  75927. * @param offset defines the offset in the source array
  75928. * @param result defines the Vector3 where to store the result
  75929. * @deprecated Please use FromArrayToRef instead.
  75930. */
  75931. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75932. /**
  75933. * Sets the given vector "result" with the given floats.
  75934. * @param x defines the x coordinate of the source
  75935. * @param y defines the y coordinate of the source
  75936. * @param z defines the z coordinate of the source
  75937. * @param result defines the Vector3 where to store the result
  75938. */
  75939. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75940. /**
  75941. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75942. * @returns a new empty Vector3
  75943. */
  75944. static Zero(): Vector3;
  75945. /**
  75946. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75947. * @returns a new unit Vector3
  75948. */
  75949. static One(): Vector3;
  75950. /**
  75951. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75952. * @returns a new up Vector3
  75953. */
  75954. static Up(): Vector3;
  75955. /**
  75956. * Gets a up Vector3 that must not be updated
  75957. */
  75958. static get UpReadOnly(): DeepImmutable<Vector3>;
  75959. /**
  75960. * Gets a zero Vector3 that must not be updated
  75961. */
  75962. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75963. /**
  75964. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75965. * @returns a new down Vector3
  75966. */
  75967. static Down(): Vector3;
  75968. /**
  75969. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75970. * @returns a new forward Vector3
  75971. */
  75972. static Forward(): Vector3;
  75973. /**
  75974. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75975. * @returns a new forward Vector3
  75976. */
  75977. static Backward(): Vector3;
  75978. /**
  75979. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75980. * @returns a new right Vector3
  75981. */
  75982. static Right(): Vector3;
  75983. /**
  75984. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75985. * @returns a new left Vector3
  75986. */
  75987. static Left(): Vector3;
  75988. /**
  75989. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75990. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75991. * @param vector defines the Vector3 to transform
  75992. * @param transformation defines the transformation matrix
  75993. * @returns the transformed Vector3
  75994. */
  75995. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75996. /**
  75997. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75998. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75999. * @param vector defines the Vector3 to transform
  76000. * @param transformation defines the transformation matrix
  76001. * @param result defines the Vector3 where to store the result
  76002. */
  76003. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76004. /**
  76005. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76006. * This method computes tranformed coordinates only, not transformed direction vectors
  76007. * @param x define the x coordinate of the source vector
  76008. * @param y define the y coordinate of the source vector
  76009. * @param z define the z coordinate of the source vector
  76010. * @param transformation defines the transformation matrix
  76011. * @param result defines the Vector3 where to store the result
  76012. */
  76013. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76014. /**
  76015. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76016. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76017. * @param vector defines the Vector3 to transform
  76018. * @param transformation defines the transformation matrix
  76019. * @returns the new Vector3
  76020. */
  76021. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76022. /**
  76023. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76024. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76025. * @param vector defines the Vector3 to transform
  76026. * @param transformation defines the transformation matrix
  76027. * @param result defines the Vector3 where to store the result
  76028. */
  76029. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76030. /**
  76031. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76032. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76033. * @param x define the x coordinate of the source vector
  76034. * @param y define the y coordinate of the source vector
  76035. * @param z define the z coordinate of the source vector
  76036. * @param transformation defines the transformation matrix
  76037. * @param result defines the Vector3 where to store the result
  76038. */
  76039. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76040. /**
  76041. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76042. * @param value1 defines the first control point
  76043. * @param value2 defines the second control point
  76044. * @param value3 defines the third control point
  76045. * @param value4 defines the fourth control point
  76046. * @param amount defines the amount on the spline to use
  76047. * @returns the new Vector3
  76048. */
  76049. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76050. /**
  76051. * 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"
  76052. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76053. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76054. * @param value defines the current value
  76055. * @param min defines the lower range value
  76056. * @param max defines the upper range value
  76057. * @returns the new Vector3
  76058. */
  76059. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76060. /**
  76061. * 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"
  76062. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76063. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76064. * @param value defines the current value
  76065. * @param min defines the lower range value
  76066. * @param max defines the upper range value
  76067. * @param result defines the Vector3 where to store the result
  76068. */
  76069. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76070. /**
  76071. * Checks if a given vector is inside a specific range
  76072. * @param v defines the vector to test
  76073. * @param min defines the minimum range
  76074. * @param max defines the maximum range
  76075. */
  76076. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76077. /**
  76078. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76079. * @param value1 defines the first control point
  76080. * @param tangent1 defines the first tangent vector
  76081. * @param value2 defines the second control point
  76082. * @param tangent2 defines the second tangent vector
  76083. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76084. * @returns the new Vector3
  76085. */
  76086. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76087. /**
  76088. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76089. * @param start defines the start value
  76090. * @param end defines the end value
  76091. * @param amount max defines amount between both (between 0 and 1)
  76092. * @returns the new Vector3
  76093. */
  76094. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76095. /**
  76096. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76097. * @param start defines the start value
  76098. * @param end defines the end value
  76099. * @param amount max defines amount between both (between 0 and 1)
  76100. * @param result defines the Vector3 where to store the result
  76101. */
  76102. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76103. /**
  76104. * Returns the dot product (float) between the vectors "left" and "right"
  76105. * @param left defines the left operand
  76106. * @param right defines the right operand
  76107. * @returns the dot product
  76108. */
  76109. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76110. /**
  76111. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76112. * The cross product is then orthogonal to both "left" and "right"
  76113. * @param left defines the left operand
  76114. * @param right defines the right operand
  76115. * @returns the cross product
  76116. */
  76117. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76118. /**
  76119. * Sets the given vector "result" with the cross product of "left" and "right"
  76120. * The cross product is then orthogonal to both "left" and "right"
  76121. * @param left defines the left operand
  76122. * @param right defines the right operand
  76123. * @param result defines the Vector3 where to store the result
  76124. */
  76125. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76126. /**
  76127. * Returns a new Vector3 as the normalization of the given vector
  76128. * @param vector defines the Vector3 to normalize
  76129. * @returns the new Vector3
  76130. */
  76131. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76132. /**
  76133. * Sets the given vector "result" with the normalization of the given first vector
  76134. * @param vector defines the Vector3 to normalize
  76135. * @param result defines the Vector3 where to store the result
  76136. */
  76137. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76138. /**
  76139. * Project a Vector3 onto screen space
  76140. * @param vector defines the Vector3 to project
  76141. * @param world defines the world matrix to use
  76142. * @param transform defines the transform (view x projection) matrix to use
  76143. * @param viewport defines the screen viewport to use
  76144. * @returns the new Vector3
  76145. */
  76146. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76147. /** @hidden */
  76148. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76149. /**
  76150. * Unproject from screen space to object space
  76151. * @param source defines the screen space Vector3 to use
  76152. * @param viewportWidth defines the current width of the viewport
  76153. * @param viewportHeight defines the current height of the viewport
  76154. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76155. * @param transform defines the transform (view x projection) matrix to use
  76156. * @returns the new Vector3
  76157. */
  76158. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76159. /**
  76160. * Unproject from screen space to object space
  76161. * @param source defines the screen space Vector3 to use
  76162. * @param viewportWidth defines the current width of the viewport
  76163. * @param viewportHeight defines the current height of the viewport
  76164. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76165. * @param view defines the view matrix to use
  76166. * @param projection defines the projection matrix to use
  76167. * @returns the new Vector3
  76168. */
  76169. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76170. /**
  76171. * Unproject from screen space to object space
  76172. * @param source defines the screen space Vector3 to use
  76173. * @param viewportWidth defines the current width of the viewport
  76174. * @param viewportHeight defines the current height of the viewport
  76175. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76176. * @param view defines the view matrix to use
  76177. * @param projection defines the projection matrix to use
  76178. * @param result defines the Vector3 where to store the result
  76179. */
  76180. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76181. /**
  76182. * Unproject from screen space to object space
  76183. * @param sourceX defines the screen space x coordinate to use
  76184. * @param sourceY defines the screen space y coordinate to use
  76185. * @param sourceZ defines the screen space z coordinate to use
  76186. * @param viewportWidth defines the current width of the viewport
  76187. * @param viewportHeight defines the current height of the viewport
  76188. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76189. * @param view defines the view matrix to use
  76190. * @param projection defines the projection matrix to use
  76191. * @param result defines the Vector3 where to store the result
  76192. */
  76193. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76194. /**
  76195. * Gets the minimal coordinate values between two Vector3
  76196. * @param left defines the first operand
  76197. * @param right defines the second operand
  76198. * @returns the new Vector3
  76199. */
  76200. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76201. /**
  76202. * Gets the maximal coordinate values between two Vector3
  76203. * @param left defines the first operand
  76204. * @param right defines the second operand
  76205. * @returns the new Vector3
  76206. */
  76207. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76208. /**
  76209. * Returns the distance between the vectors "value1" and "value2"
  76210. * @param value1 defines the first operand
  76211. * @param value2 defines the second operand
  76212. * @returns the distance
  76213. */
  76214. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76215. /**
  76216. * Returns the squared distance between the vectors "value1" and "value2"
  76217. * @param value1 defines the first operand
  76218. * @param value2 defines the second operand
  76219. * @returns the squared distance
  76220. */
  76221. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76222. /**
  76223. * Returns a new Vector3 located at the center between "value1" and "value2"
  76224. * @param value1 defines the first operand
  76225. * @param value2 defines the second operand
  76226. * @returns the new Vector3
  76227. */
  76228. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76229. /**
  76230. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76231. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76232. * to something in order to rotate it from its local system to the given target system
  76233. * Note: axis1, axis2 and axis3 are normalized during this operation
  76234. * @param axis1 defines the first axis
  76235. * @param axis2 defines the second axis
  76236. * @param axis3 defines the third axis
  76237. * @returns a new Vector3
  76238. */
  76239. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76240. /**
  76241. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76242. * @param axis1 defines the first axis
  76243. * @param axis2 defines the second axis
  76244. * @param axis3 defines the third axis
  76245. * @param ref defines the Vector3 where to store the result
  76246. */
  76247. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76248. }
  76249. /**
  76250. * Vector4 class created for EulerAngle class conversion to Quaternion
  76251. */
  76252. export class Vector4 {
  76253. /** x value of the vector */
  76254. x: number;
  76255. /** y value of the vector */
  76256. y: number;
  76257. /** z value of the vector */
  76258. z: number;
  76259. /** w value of the vector */
  76260. w: number;
  76261. /**
  76262. * Creates a Vector4 object from the given floats.
  76263. * @param x x value of the vector
  76264. * @param y y value of the vector
  76265. * @param z z value of the vector
  76266. * @param w w value of the vector
  76267. */
  76268. constructor(
  76269. /** x value of the vector */
  76270. x: number,
  76271. /** y value of the vector */
  76272. y: number,
  76273. /** z value of the vector */
  76274. z: number,
  76275. /** w value of the vector */
  76276. w: number);
  76277. /**
  76278. * Returns the string with the Vector4 coordinates.
  76279. * @returns a string containing all the vector values
  76280. */
  76281. toString(): string;
  76282. /**
  76283. * Returns the string "Vector4".
  76284. * @returns "Vector4"
  76285. */
  76286. getClassName(): string;
  76287. /**
  76288. * Returns the Vector4 hash code.
  76289. * @returns a unique hash code
  76290. */
  76291. getHashCode(): number;
  76292. /**
  76293. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76294. * @returns the resulting array
  76295. */
  76296. asArray(): number[];
  76297. /**
  76298. * Populates the given array from the given index with the Vector4 coordinates.
  76299. * @param array array to populate
  76300. * @param index index of the array to start at (default: 0)
  76301. * @returns the Vector4.
  76302. */
  76303. toArray(array: FloatArray, index?: number): Vector4;
  76304. /**
  76305. * Adds the given vector to the current Vector4.
  76306. * @param otherVector the vector to add
  76307. * @returns the updated Vector4.
  76308. */
  76309. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76310. /**
  76311. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76312. * @param otherVector the vector to add
  76313. * @returns the resulting vector
  76314. */
  76315. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76316. /**
  76317. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76318. * @param otherVector the vector to add
  76319. * @param result the vector to store the result
  76320. * @returns the current Vector4.
  76321. */
  76322. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76323. /**
  76324. * Subtract in place the given vector from the current Vector4.
  76325. * @param otherVector the vector to subtract
  76326. * @returns the updated Vector4.
  76327. */
  76328. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76329. /**
  76330. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76331. * @param otherVector the vector to add
  76332. * @returns the new vector with the result
  76333. */
  76334. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76335. /**
  76336. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76337. * @param otherVector the vector to subtract
  76338. * @param result the vector to store the result
  76339. * @returns the current Vector4.
  76340. */
  76341. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76342. /**
  76343. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76344. */
  76345. /**
  76346. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76347. * @param x value to subtract
  76348. * @param y value to subtract
  76349. * @param z value to subtract
  76350. * @param w value to subtract
  76351. * @returns new vector containing the result
  76352. */
  76353. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76354. /**
  76355. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76356. * @param x value to subtract
  76357. * @param y value to subtract
  76358. * @param z value to subtract
  76359. * @param w value to subtract
  76360. * @param result the vector to store the result in
  76361. * @returns the current Vector4.
  76362. */
  76363. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76364. /**
  76365. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76366. * @returns a new vector with the negated values
  76367. */
  76368. negate(): Vector4;
  76369. /**
  76370. * Negate this vector in place
  76371. * @returns this
  76372. */
  76373. negateInPlace(): Vector4;
  76374. /**
  76375. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76376. * @param result defines the Vector3 object where to store the result
  76377. * @returns the current Vector4
  76378. */
  76379. negateToRef(result: Vector4): Vector4;
  76380. /**
  76381. * Multiplies the current Vector4 coordinates by scale (float).
  76382. * @param scale the number to scale with
  76383. * @returns the updated Vector4.
  76384. */
  76385. scaleInPlace(scale: number): Vector4;
  76386. /**
  76387. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76388. * @param scale the number to scale with
  76389. * @returns a new vector with the result
  76390. */
  76391. scale(scale: number): Vector4;
  76392. /**
  76393. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76394. * @param scale the number to scale with
  76395. * @param result a vector to store the result in
  76396. * @returns the current Vector4.
  76397. */
  76398. scaleToRef(scale: number, result: Vector4): Vector4;
  76399. /**
  76400. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76401. * @param scale defines the scale factor
  76402. * @param result defines the Vector4 object where to store the result
  76403. * @returns the unmodified current Vector4
  76404. */
  76405. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76406. /**
  76407. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76408. * @param otherVector the vector to compare against
  76409. * @returns true if they are equal
  76410. */
  76411. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76412. /**
  76413. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76414. * @param otherVector vector to compare against
  76415. * @param epsilon (Default: very small number)
  76416. * @returns true if they are equal
  76417. */
  76418. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76419. /**
  76420. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76421. * @param x x value to compare against
  76422. * @param y y value to compare against
  76423. * @param z z value to compare against
  76424. * @param w w value to compare against
  76425. * @returns true if equal
  76426. */
  76427. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76428. /**
  76429. * Multiplies in place the current Vector4 by the given one.
  76430. * @param otherVector vector to multiple with
  76431. * @returns the updated Vector4.
  76432. */
  76433. multiplyInPlace(otherVector: Vector4): Vector4;
  76434. /**
  76435. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76436. * @param otherVector vector to multiple with
  76437. * @returns resulting new vector
  76438. */
  76439. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76440. /**
  76441. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76442. * @param otherVector vector to multiple with
  76443. * @param result vector to store the result
  76444. * @returns the current Vector4.
  76445. */
  76446. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76447. /**
  76448. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76449. * @param x x value multiply with
  76450. * @param y y value multiply with
  76451. * @param z z value multiply with
  76452. * @param w w value multiply with
  76453. * @returns resulting new vector
  76454. */
  76455. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76456. /**
  76457. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76458. * @param otherVector vector to devide with
  76459. * @returns resulting new vector
  76460. */
  76461. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76462. /**
  76463. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76464. * @param otherVector vector to devide with
  76465. * @param result vector to store the result
  76466. * @returns the current Vector4.
  76467. */
  76468. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76469. /**
  76470. * Divides the current Vector3 coordinates by the given ones.
  76471. * @param otherVector vector to devide with
  76472. * @returns the updated Vector3.
  76473. */
  76474. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76475. /**
  76476. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76477. * @param other defines the second operand
  76478. * @returns the current updated Vector4
  76479. */
  76480. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76481. /**
  76482. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76483. * @param other defines the second operand
  76484. * @returns the current updated Vector4
  76485. */
  76486. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76487. /**
  76488. * Gets a new Vector4 from current Vector4 floored values
  76489. * @returns a new Vector4
  76490. */
  76491. floor(): Vector4;
  76492. /**
  76493. * Gets a new Vector4 from current Vector3 floored values
  76494. * @returns a new Vector4
  76495. */
  76496. fract(): Vector4;
  76497. /**
  76498. * Returns the Vector4 length (float).
  76499. * @returns the length
  76500. */
  76501. length(): number;
  76502. /**
  76503. * Returns the Vector4 squared length (float).
  76504. * @returns the length squared
  76505. */
  76506. lengthSquared(): number;
  76507. /**
  76508. * Normalizes in place the Vector4.
  76509. * @returns the updated Vector4.
  76510. */
  76511. normalize(): Vector4;
  76512. /**
  76513. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76514. * @returns this converted to a new vector3
  76515. */
  76516. toVector3(): Vector3;
  76517. /**
  76518. * Returns a new Vector4 copied from the current one.
  76519. * @returns the new cloned vector
  76520. */
  76521. clone(): Vector4;
  76522. /**
  76523. * Updates the current Vector4 with the given one coordinates.
  76524. * @param source the source vector to copy from
  76525. * @returns the updated Vector4.
  76526. */
  76527. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76528. /**
  76529. * Updates the current Vector4 coordinates with the given floats.
  76530. * @param x float to copy from
  76531. * @param y float to copy from
  76532. * @param z float to copy from
  76533. * @param w float to copy from
  76534. * @returns the updated Vector4.
  76535. */
  76536. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76537. /**
  76538. * Updates the current Vector4 coordinates with the given floats.
  76539. * @param x float to set from
  76540. * @param y float to set from
  76541. * @param z float to set from
  76542. * @param w float to set from
  76543. * @returns the updated Vector4.
  76544. */
  76545. set(x: number, y: number, z: number, w: number): Vector4;
  76546. /**
  76547. * Copies the given float to the current Vector3 coordinates
  76548. * @param v defines the x, y, z and w coordinates of the operand
  76549. * @returns the current updated Vector3
  76550. */
  76551. setAll(v: number): Vector4;
  76552. /**
  76553. * Returns a new Vector4 set from the starting index of the given array.
  76554. * @param array the array to pull values from
  76555. * @param offset the offset into the array to start at
  76556. * @returns the new vector
  76557. */
  76558. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76559. /**
  76560. * Updates the given vector "result" from the starting index of the given array.
  76561. * @param array the array to pull values from
  76562. * @param offset the offset into the array to start at
  76563. * @param result the vector to store the result in
  76564. */
  76565. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76566. /**
  76567. * Updates the given vector "result" from the starting index of the given Float32Array.
  76568. * @param array the array to pull values from
  76569. * @param offset the offset into the array to start at
  76570. * @param result the vector to store the result in
  76571. */
  76572. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76573. /**
  76574. * Updates the given vector "result" coordinates from the given floats.
  76575. * @param x float to set from
  76576. * @param y float to set from
  76577. * @param z float to set from
  76578. * @param w float to set from
  76579. * @param result the vector to the floats in
  76580. */
  76581. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76582. /**
  76583. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76584. * @returns the new vector
  76585. */
  76586. static Zero(): Vector4;
  76587. /**
  76588. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76589. * @returns the new vector
  76590. */
  76591. static One(): Vector4;
  76592. /**
  76593. * Returns a new normalized Vector4 from the given one.
  76594. * @param vector the vector to normalize
  76595. * @returns the vector
  76596. */
  76597. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76598. /**
  76599. * Updates the given vector "result" from the normalization of the given one.
  76600. * @param vector the vector to normalize
  76601. * @param result the vector to store the result in
  76602. */
  76603. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76604. /**
  76605. * Returns a vector with the minimum values from the left and right vectors
  76606. * @param left left vector to minimize
  76607. * @param right right vector to minimize
  76608. * @returns a new vector with the minimum of the left and right vector values
  76609. */
  76610. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76611. /**
  76612. * Returns a vector with the maximum values from the left and right vectors
  76613. * @param left left vector to maximize
  76614. * @param right right vector to maximize
  76615. * @returns a new vector with the maximum of the left and right vector values
  76616. */
  76617. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76618. /**
  76619. * Returns the distance (float) between the vectors "value1" and "value2".
  76620. * @param value1 value to calulate the distance between
  76621. * @param value2 value to calulate the distance between
  76622. * @return the distance between the two vectors
  76623. */
  76624. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76625. /**
  76626. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76627. * @param value1 value to calulate the distance between
  76628. * @param value2 value to calulate the distance between
  76629. * @return the distance between the two vectors squared
  76630. */
  76631. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76632. /**
  76633. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76634. * @param value1 value to calulate the center between
  76635. * @param value2 value to calulate the center between
  76636. * @return the center between the two vectors
  76637. */
  76638. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76639. /**
  76640. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76641. * This methods computes transformed normalized direction vectors only.
  76642. * @param vector the vector to transform
  76643. * @param transformation the transformation matrix to apply
  76644. * @returns the new vector
  76645. */
  76646. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76647. /**
  76648. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76649. * This methods computes transformed normalized direction vectors only.
  76650. * @param vector the vector to transform
  76651. * @param transformation the transformation matrix to apply
  76652. * @param result the vector to store the result in
  76653. */
  76654. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76655. /**
  76656. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76657. * This methods computes transformed normalized direction vectors only.
  76658. * @param x value to transform
  76659. * @param y value to transform
  76660. * @param z value to transform
  76661. * @param w value to transform
  76662. * @param transformation the transformation matrix to apply
  76663. * @param result the vector to store the results in
  76664. */
  76665. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76666. /**
  76667. * Creates a new Vector4 from a Vector3
  76668. * @param source defines the source data
  76669. * @param w defines the 4th component (default is 0)
  76670. * @returns a new Vector4
  76671. */
  76672. static FromVector3(source: Vector3, w?: number): Vector4;
  76673. }
  76674. /**
  76675. * Class used to store quaternion data
  76676. * @see https://en.wikipedia.org/wiki/Quaternion
  76677. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76678. */
  76679. export class Quaternion {
  76680. /** defines the first component (0 by default) */
  76681. x: number;
  76682. /** defines the second component (0 by default) */
  76683. y: number;
  76684. /** defines the third component (0 by default) */
  76685. z: number;
  76686. /** defines the fourth component (1.0 by default) */
  76687. w: number;
  76688. /**
  76689. * Creates a new Quaternion from the given floats
  76690. * @param x defines the first component (0 by default)
  76691. * @param y defines the second component (0 by default)
  76692. * @param z defines the third component (0 by default)
  76693. * @param w defines the fourth component (1.0 by default)
  76694. */
  76695. constructor(
  76696. /** defines the first component (0 by default) */
  76697. x?: number,
  76698. /** defines the second component (0 by default) */
  76699. y?: number,
  76700. /** defines the third component (0 by default) */
  76701. z?: number,
  76702. /** defines the fourth component (1.0 by default) */
  76703. w?: number);
  76704. /**
  76705. * Gets a string representation for the current quaternion
  76706. * @returns a string with the Quaternion coordinates
  76707. */
  76708. toString(): string;
  76709. /**
  76710. * Gets the class name of the quaternion
  76711. * @returns the string "Quaternion"
  76712. */
  76713. getClassName(): string;
  76714. /**
  76715. * Gets a hash code for this quaternion
  76716. * @returns the quaternion hash code
  76717. */
  76718. getHashCode(): number;
  76719. /**
  76720. * Copy the quaternion to an array
  76721. * @returns a new array populated with 4 elements from the quaternion coordinates
  76722. */
  76723. asArray(): number[];
  76724. /**
  76725. * Check if two quaternions are equals
  76726. * @param otherQuaternion defines the second operand
  76727. * @return true if the current quaternion and the given one coordinates are strictly equals
  76728. */
  76729. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76730. /**
  76731. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76732. * @param otherQuaternion defines the other quaternion
  76733. * @param epsilon defines the minimal distance to consider equality
  76734. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76735. */
  76736. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76737. /**
  76738. * Clone the current quaternion
  76739. * @returns a new quaternion copied from the current one
  76740. */
  76741. clone(): Quaternion;
  76742. /**
  76743. * Copy a quaternion to the current one
  76744. * @param other defines the other quaternion
  76745. * @returns the updated current quaternion
  76746. */
  76747. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76748. /**
  76749. * Updates the current quaternion with the given float coordinates
  76750. * @param x defines the x coordinate
  76751. * @param y defines the y coordinate
  76752. * @param z defines the z coordinate
  76753. * @param w defines the w coordinate
  76754. * @returns the updated current quaternion
  76755. */
  76756. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76757. /**
  76758. * Updates the current quaternion from the given float coordinates
  76759. * @param x defines the x coordinate
  76760. * @param y defines the y coordinate
  76761. * @param z defines the z coordinate
  76762. * @param w defines the w coordinate
  76763. * @returns the updated current quaternion
  76764. */
  76765. set(x: number, y: number, z: number, w: number): Quaternion;
  76766. /**
  76767. * Adds two quaternions
  76768. * @param other defines the second operand
  76769. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76770. */
  76771. add(other: DeepImmutable<Quaternion>): Quaternion;
  76772. /**
  76773. * Add a quaternion to the current one
  76774. * @param other defines the quaternion to add
  76775. * @returns the current quaternion
  76776. */
  76777. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76778. /**
  76779. * Subtract two quaternions
  76780. * @param other defines the second operand
  76781. * @returns a new quaternion as the subtraction result of the given one from the current one
  76782. */
  76783. subtract(other: Quaternion): Quaternion;
  76784. /**
  76785. * Multiplies the current quaternion by a scale factor
  76786. * @param value defines the scale factor
  76787. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76788. */
  76789. scale(value: number): Quaternion;
  76790. /**
  76791. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76792. * @param scale defines the scale factor
  76793. * @param result defines the Quaternion object where to store the result
  76794. * @returns the unmodified current quaternion
  76795. */
  76796. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76797. /**
  76798. * Multiplies in place the current quaternion by a scale factor
  76799. * @param value defines the scale factor
  76800. * @returns the current modified quaternion
  76801. */
  76802. scaleInPlace(value: number): Quaternion;
  76803. /**
  76804. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76805. * @param scale defines the scale factor
  76806. * @param result defines the Quaternion object where to store the result
  76807. * @returns the unmodified current quaternion
  76808. */
  76809. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76810. /**
  76811. * Multiplies two quaternions
  76812. * @param q1 defines the second operand
  76813. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76814. */
  76815. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76816. /**
  76817. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76818. * @param q1 defines the second operand
  76819. * @param result defines the target quaternion
  76820. * @returns the current quaternion
  76821. */
  76822. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76823. /**
  76824. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76825. * @param q1 defines the second operand
  76826. * @returns the currentupdated quaternion
  76827. */
  76828. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76829. /**
  76830. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76831. * @param ref defines the target quaternion
  76832. * @returns the current quaternion
  76833. */
  76834. conjugateToRef(ref: Quaternion): Quaternion;
  76835. /**
  76836. * Conjugates in place (1-q) the current quaternion
  76837. * @returns the current updated quaternion
  76838. */
  76839. conjugateInPlace(): Quaternion;
  76840. /**
  76841. * Conjugates in place (1-q) the current quaternion
  76842. * @returns a new quaternion
  76843. */
  76844. conjugate(): Quaternion;
  76845. /**
  76846. * Gets length of current quaternion
  76847. * @returns the quaternion length (float)
  76848. */
  76849. length(): number;
  76850. /**
  76851. * Normalize in place the current quaternion
  76852. * @returns the current updated quaternion
  76853. */
  76854. normalize(): Quaternion;
  76855. /**
  76856. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76857. * @param order is a reserved parameter and is ignore for now
  76858. * @returns a new Vector3 containing the Euler angles
  76859. */
  76860. toEulerAngles(order?: string): Vector3;
  76861. /**
  76862. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76863. * @param result defines the vector which will be filled with the Euler angles
  76864. * @param order is a reserved parameter and is ignore for now
  76865. * @returns the current unchanged quaternion
  76866. */
  76867. toEulerAnglesToRef(result: Vector3): Quaternion;
  76868. /**
  76869. * Updates the given rotation matrix with the current quaternion values
  76870. * @param result defines the target matrix
  76871. * @returns the current unchanged quaternion
  76872. */
  76873. toRotationMatrix(result: Matrix): Quaternion;
  76874. /**
  76875. * Updates the current quaternion from the given rotation matrix values
  76876. * @param matrix defines the source matrix
  76877. * @returns the current updated quaternion
  76878. */
  76879. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76880. /**
  76881. * Creates a new quaternion from a rotation matrix
  76882. * @param matrix defines the source matrix
  76883. * @returns a new quaternion created from the given rotation matrix values
  76884. */
  76885. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76886. /**
  76887. * Updates the given quaternion with the given rotation matrix values
  76888. * @param matrix defines the source matrix
  76889. * @param result defines the target quaternion
  76890. */
  76891. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76892. /**
  76893. * Returns the dot product (float) between the quaternions "left" and "right"
  76894. * @param left defines the left operand
  76895. * @param right defines the right operand
  76896. * @returns the dot product
  76897. */
  76898. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76899. /**
  76900. * Checks if the two quaternions are close to each other
  76901. * @param quat0 defines the first quaternion to check
  76902. * @param quat1 defines the second quaternion to check
  76903. * @returns true if the two quaternions are close to each other
  76904. */
  76905. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76906. /**
  76907. * Creates an empty quaternion
  76908. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76909. */
  76910. static Zero(): Quaternion;
  76911. /**
  76912. * Inverse a given quaternion
  76913. * @param q defines the source quaternion
  76914. * @returns a new quaternion as the inverted current quaternion
  76915. */
  76916. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76917. /**
  76918. * Inverse a given quaternion
  76919. * @param q defines the source quaternion
  76920. * @param result the quaternion the result will be stored in
  76921. * @returns the result quaternion
  76922. */
  76923. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76924. /**
  76925. * Creates an identity quaternion
  76926. * @returns the identity quaternion
  76927. */
  76928. static Identity(): Quaternion;
  76929. /**
  76930. * Gets a boolean indicating if the given quaternion is identity
  76931. * @param quaternion defines the quaternion to check
  76932. * @returns true if the quaternion is identity
  76933. */
  76934. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76935. /**
  76936. * Creates a quaternion from a rotation around an axis
  76937. * @param axis defines the axis to use
  76938. * @param angle defines the angle to use
  76939. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76940. */
  76941. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76942. /**
  76943. * Creates a rotation around an axis and stores it into the given quaternion
  76944. * @param axis defines the axis to use
  76945. * @param angle defines the angle to use
  76946. * @param result defines the target quaternion
  76947. * @returns the target quaternion
  76948. */
  76949. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76950. /**
  76951. * Creates a new quaternion from data stored into an array
  76952. * @param array defines the data source
  76953. * @param offset defines the offset in the source array where the data starts
  76954. * @returns a new quaternion
  76955. */
  76956. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76957. /**
  76958. * Create a quaternion from Euler rotation angles
  76959. * @param x Pitch
  76960. * @param y Yaw
  76961. * @param z Roll
  76962. * @returns the new Quaternion
  76963. */
  76964. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76965. /**
  76966. * Updates a quaternion from Euler rotation angles
  76967. * @param x Pitch
  76968. * @param y Yaw
  76969. * @param z Roll
  76970. * @param result the quaternion to store the result
  76971. * @returns the updated quaternion
  76972. */
  76973. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76974. /**
  76975. * Create a quaternion from Euler rotation vector
  76976. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76977. * @returns the new Quaternion
  76978. */
  76979. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76980. /**
  76981. * Updates a quaternion from Euler rotation vector
  76982. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76983. * @param result the quaternion to store the result
  76984. * @returns the updated quaternion
  76985. */
  76986. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76987. /**
  76988. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76989. * @param yaw defines the rotation around Y axis
  76990. * @param pitch defines the rotation around X axis
  76991. * @param roll defines the rotation around Z axis
  76992. * @returns the new quaternion
  76993. */
  76994. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76995. /**
  76996. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76997. * @param yaw defines the rotation around Y axis
  76998. * @param pitch defines the rotation around X axis
  76999. * @param roll defines the rotation around Z axis
  77000. * @param result defines the target quaternion
  77001. */
  77002. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77003. /**
  77004. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77005. * @param alpha defines the rotation around first axis
  77006. * @param beta defines the rotation around second axis
  77007. * @param gamma defines the rotation around third axis
  77008. * @returns the new quaternion
  77009. */
  77010. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77011. /**
  77012. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77013. * @param alpha defines the rotation around first axis
  77014. * @param beta defines the rotation around second axis
  77015. * @param gamma defines the rotation around third axis
  77016. * @param result defines the target quaternion
  77017. */
  77018. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77019. /**
  77020. * 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)
  77021. * @param axis1 defines the first axis
  77022. * @param axis2 defines the second axis
  77023. * @param axis3 defines the third axis
  77024. * @returns the new quaternion
  77025. */
  77026. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77027. /**
  77028. * 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
  77029. * @param axis1 defines the first axis
  77030. * @param axis2 defines the second axis
  77031. * @param axis3 defines the third axis
  77032. * @param ref defines the target quaternion
  77033. */
  77034. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77035. /**
  77036. * Interpolates between two quaternions
  77037. * @param left defines first quaternion
  77038. * @param right defines second quaternion
  77039. * @param amount defines the gradient to use
  77040. * @returns the new interpolated quaternion
  77041. */
  77042. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77043. /**
  77044. * Interpolates between two quaternions and stores it into a target quaternion
  77045. * @param left defines first quaternion
  77046. * @param right defines second quaternion
  77047. * @param amount defines the gradient to use
  77048. * @param result defines the target quaternion
  77049. */
  77050. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77051. /**
  77052. * Interpolate between two quaternions using Hermite interpolation
  77053. * @param value1 defines first quaternion
  77054. * @param tangent1 defines the incoming tangent
  77055. * @param value2 defines second quaternion
  77056. * @param tangent2 defines the outgoing tangent
  77057. * @param amount defines the target quaternion
  77058. * @returns the new interpolated quaternion
  77059. */
  77060. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77061. }
  77062. /**
  77063. * Class used to store matrix data (4x4)
  77064. */
  77065. export class Matrix {
  77066. private static _updateFlagSeed;
  77067. private static _identityReadOnly;
  77068. private _isIdentity;
  77069. private _isIdentityDirty;
  77070. private _isIdentity3x2;
  77071. private _isIdentity3x2Dirty;
  77072. /**
  77073. * Gets the update flag of the matrix which is an unique number for the matrix.
  77074. * It will be incremented every time the matrix data change.
  77075. * You can use it to speed the comparison between two versions of the same matrix.
  77076. */
  77077. updateFlag: number;
  77078. private readonly _m;
  77079. /**
  77080. * Gets the internal data of the matrix
  77081. */
  77082. get m(): DeepImmutable<Float32Array>;
  77083. /** @hidden */
  77084. _markAsUpdated(): void;
  77085. /** @hidden */
  77086. private _updateIdentityStatus;
  77087. /**
  77088. * Creates an empty matrix (filled with zeros)
  77089. */
  77090. constructor();
  77091. /**
  77092. * Check if the current matrix is identity
  77093. * @returns true is the matrix is the identity matrix
  77094. */
  77095. isIdentity(): boolean;
  77096. /**
  77097. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77098. * @returns true is the matrix is the identity matrix
  77099. */
  77100. isIdentityAs3x2(): boolean;
  77101. /**
  77102. * Gets the determinant of the matrix
  77103. * @returns the matrix determinant
  77104. */
  77105. determinant(): number;
  77106. /**
  77107. * Returns the matrix as a Float32Array
  77108. * @returns the matrix underlying array
  77109. */
  77110. toArray(): DeepImmutable<Float32Array>;
  77111. /**
  77112. * Returns the matrix as a Float32Array
  77113. * @returns the matrix underlying array.
  77114. */
  77115. asArray(): DeepImmutable<Float32Array>;
  77116. /**
  77117. * Inverts the current matrix in place
  77118. * @returns the current inverted matrix
  77119. */
  77120. invert(): Matrix;
  77121. /**
  77122. * Sets all the matrix elements to zero
  77123. * @returns the current matrix
  77124. */
  77125. reset(): Matrix;
  77126. /**
  77127. * Adds the current matrix with a second one
  77128. * @param other defines the matrix to add
  77129. * @returns a new matrix as the addition of the current matrix and the given one
  77130. */
  77131. add(other: DeepImmutable<Matrix>): Matrix;
  77132. /**
  77133. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77134. * @param other defines the matrix to add
  77135. * @param result defines the target matrix
  77136. * @returns the current matrix
  77137. */
  77138. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77139. /**
  77140. * Adds in place the given matrix to the current matrix
  77141. * @param other defines the second operand
  77142. * @returns the current updated matrix
  77143. */
  77144. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77145. /**
  77146. * Sets the given matrix to the current inverted Matrix
  77147. * @param other defines the target matrix
  77148. * @returns the unmodified current matrix
  77149. */
  77150. invertToRef(other: Matrix): Matrix;
  77151. /**
  77152. * add a value at the specified position in the current Matrix
  77153. * @param index the index of the value within the matrix. between 0 and 15.
  77154. * @param value the value to be added
  77155. * @returns the current updated matrix
  77156. */
  77157. addAtIndex(index: number, value: number): Matrix;
  77158. /**
  77159. * mutiply the specified position in the current Matrix by a value
  77160. * @param index the index of the value within the matrix. between 0 and 15.
  77161. * @param value the value to be added
  77162. * @returns the current updated matrix
  77163. */
  77164. multiplyAtIndex(index: number, value: number): Matrix;
  77165. /**
  77166. * Inserts the translation vector (using 3 floats) in the current matrix
  77167. * @param x defines the 1st component of the translation
  77168. * @param y defines the 2nd component of the translation
  77169. * @param z defines the 3rd component of the translation
  77170. * @returns the current updated matrix
  77171. */
  77172. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77173. /**
  77174. * Adds the translation vector (using 3 floats) in the current matrix
  77175. * @param x defines the 1st component of the translation
  77176. * @param y defines the 2nd component of the translation
  77177. * @param z defines the 3rd component of the translation
  77178. * @returns the current updated matrix
  77179. */
  77180. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77181. /**
  77182. * Inserts the translation vector in the current matrix
  77183. * @param vector3 defines the translation to insert
  77184. * @returns the current updated matrix
  77185. */
  77186. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77187. /**
  77188. * Gets the translation value of the current matrix
  77189. * @returns a new Vector3 as the extracted translation from the matrix
  77190. */
  77191. getTranslation(): Vector3;
  77192. /**
  77193. * Fill a Vector3 with the extracted translation from the matrix
  77194. * @param result defines the Vector3 where to store the translation
  77195. * @returns the current matrix
  77196. */
  77197. getTranslationToRef(result: Vector3): Matrix;
  77198. /**
  77199. * Remove rotation and scaling part from the matrix
  77200. * @returns the updated matrix
  77201. */
  77202. removeRotationAndScaling(): Matrix;
  77203. /**
  77204. * Multiply two matrices
  77205. * @param other defines the second operand
  77206. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77207. */
  77208. multiply(other: DeepImmutable<Matrix>): Matrix;
  77209. /**
  77210. * Copy the current matrix from the given one
  77211. * @param other defines the source matrix
  77212. * @returns the current updated matrix
  77213. */
  77214. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77215. /**
  77216. * Populates the given array from the starting index with the current matrix values
  77217. * @param array defines the target array
  77218. * @param offset defines the offset in the target array where to start storing values
  77219. * @returns the current matrix
  77220. */
  77221. copyToArray(array: Float32Array, offset?: number): Matrix;
  77222. /**
  77223. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77224. * @param other defines the second operand
  77225. * @param result defines the matrix where to store the multiplication
  77226. * @returns the current matrix
  77227. */
  77228. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77229. /**
  77230. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77231. * @param other defines the second operand
  77232. * @param result defines the array where to store the multiplication
  77233. * @param offset defines the offset in the target array where to start storing values
  77234. * @returns the current matrix
  77235. */
  77236. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77237. /**
  77238. * Check equality between this matrix and a second one
  77239. * @param value defines the second matrix to compare
  77240. * @returns true is the current matrix and the given one values are strictly equal
  77241. */
  77242. equals(value: DeepImmutable<Matrix>): boolean;
  77243. /**
  77244. * Clone the current matrix
  77245. * @returns a new matrix from the current matrix
  77246. */
  77247. clone(): Matrix;
  77248. /**
  77249. * Returns the name of the current matrix class
  77250. * @returns the string "Matrix"
  77251. */
  77252. getClassName(): string;
  77253. /**
  77254. * Gets the hash code of the current matrix
  77255. * @returns the hash code
  77256. */
  77257. getHashCode(): number;
  77258. /**
  77259. * Decomposes the current Matrix into a translation, rotation and scaling components
  77260. * @param scale defines the scale vector3 given as a reference to update
  77261. * @param rotation defines the rotation quaternion given as a reference to update
  77262. * @param translation defines the translation vector3 given as a reference to update
  77263. * @returns true if operation was successful
  77264. */
  77265. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77266. /**
  77267. * Gets specific row of the matrix
  77268. * @param index defines the number of the row to get
  77269. * @returns the index-th row of the current matrix as a new Vector4
  77270. */
  77271. getRow(index: number): Nullable<Vector4>;
  77272. /**
  77273. * Sets the index-th row of the current matrix to the vector4 values
  77274. * @param index defines the number of the row to set
  77275. * @param row defines the target vector4
  77276. * @returns the updated current matrix
  77277. */
  77278. setRow(index: number, row: Vector4): Matrix;
  77279. /**
  77280. * Compute the transpose of the matrix
  77281. * @returns the new transposed matrix
  77282. */
  77283. transpose(): Matrix;
  77284. /**
  77285. * Compute the transpose of the matrix and store it in a given matrix
  77286. * @param result defines the target matrix
  77287. * @returns the current matrix
  77288. */
  77289. transposeToRef(result: Matrix): Matrix;
  77290. /**
  77291. * Sets the index-th row of the current matrix with the given 4 x float values
  77292. * @param index defines the row index
  77293. * @param x defines the x component to set
  77294. * @param y defines the y component to set
  77295. * @param z defines the z component to set
  77296. * @param w defines the w component to set
  77297. * @returns the updated current matrix
  77298. */
  77299. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77300. /**
  77301. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77302. * @param scale defines the scale factor
  77303. * @returns a new matrix
  77304. */
  77305. scale(scale: number): Matrix;
  77306. /**
  77307. * Scale the current matrix values by a factor to a given result matrix
  77308. * @param scale defines the scale factor
  77309. * @param result defines the matrix to store the result
  77310. * @returns the current matrix
  77311. */
  77312. scaleToRef(scale: number, result: Matrix): Matrix;
  77313. /**
  77314. * Scale the current matrix values by a factor and add the result to a given matrix
  77315. * @param scale defines the scale factor
  77316. * @param result defines the Matrix to store the result
  77317. * @returns the current matrix
  77318. */
  77319. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77320. /**
  77321. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77322. * @param ref matrix to store the result
  77323. */
  77324. toNormalMatrix(ref: Matrix): void;
  77325. /**
  77326. * Gets only rotation part of the current matrix
  77327. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77328. */
  77329. getRotationMatrix(): Matrix;
  77330. /**
  77331. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77332. * @param result defines the target matrix to store data to
  77333. * @returns the current matrix
  77334. */
  77335. getRotationMatrixToRef(result: Matrix): Matrix;
  77336. /**
  77337. * Toggles model matrix from being right handed to left handed in place and vice versa
  77338. */
  77339. toggleModelMatrixHandInPlace(): void;
  77340. /**
  77341. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77342. */
  77343. toggleProjectionMatrixHandInPlace(): void;
  77344. /**
  77345. * Creates a matrix from an array
  77346. * @param array defines the source array
  77347. * @param offset defines an offset in the source array
  77348. * @returns a new Matrix set from the starting index of the given array
  77349. */
  77350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77351. /**
  77352. * Copy the content of an array into a given matrix
  77353. * @param array defines the source array
  77354. * @param offset defines an offset in the source array
  77355. * @param result defines the target matrix
  77356. */
  77357. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77358. /**
  77359. * Stores an array into a matrix after having multiplied each component by a given factor
  77360. * @param array defines the source array
  77361. * @param offset defines the offset in the source array
  77362. * @param scale defines the scaling factor
  77363. * @param result defines the target matrix
  77364. */
  77365. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77366. /**
  77367. * Gets an identity matrix that must not be updated
  77368. */
  77369. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77370. /**
  77371. * Stores a list of values (16) inside a given matrix
  77372. * @param initialM11 defines 1st value of 1st row
  77373. * @param initialM12 defines 2nd value of 1st row
  77374. * @param initialM13 defines 3rd value of 1st row
  77375. * @param initialM14 defines 4th value of 1st row
  77376. * @param initialM21 defines 1st value of 2nd row
  77377. * @param initialM22 defines 2nd value of 2nd row
  77378. * @param initialM23 defines 3rd value of 2nd row
  77379. * @param initialM24 defines 4th value of 2nd row
  77380. * @param initialM31 defines 1st value of 3rd row
  77381. * @param initialM32 defines 2nd value of 3rd row
  77382. * @param initialM33 defines 3rd value of 3rd row
  77383. * @param initialM34 defines 4th value of 3rd row
  77384. * @param initialM41 defines 1st value of 4th row
  77385. * @param initialM42 defines 2nd value of 4th row
  77386. * @param initialM43 defines 3rd value of 4th row
  77387. * @param initialM44 defines 4th value of 4th row
  77388. * @param result defines the target matrix
  77389. */
  77390. 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;
  77391. /**
  77392. * Creates new matrix from a list of values (16)
  77393. * @param initialM11 defines 1st value of 1st row
  77394. * @param initialM12 defines 2nd value of 1st row
  77395. * @param initialM13 defines 3rd value of 1st row
  77396. * @param initialM14 defines 4th value of 1st row
  77397. * @param initialM21 defines 1st value of 2nd row
  77398. * @param initialM22 defines 2nd value of 2nd row
  77399. * @param initialM23 defines 3rd value of 2nd row
  77400. * @param initialM24 defines 4th value of 2nd row
  77401. * @param initialM31 defines 1st value of 3rd row
  77402. * @param initialM32 defines 2nd value of 3rd row
  77403. * @param initialM33 defines 3rd value of 3rd row
  77404. * @param initialM34 defines 4th value of 3rd row
  77405. * @param initialM41 defines 1st value of 4th row
  77406. * @param initialM42 defines 2nd value of 4th row
  77407. * @param initialM43 defines 3rd value of 4th row
  77408. * @param initialM44 defines 4th value of 4th row
  77409. * @returns the new matrix
  77410. */
  77411. 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;
  77412. /**
  77413. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77414. * @param scale defines the scale vector3
  77415. * @param rotation defines the rotation quaternion
  77416. * @param translation defines the translation vector3
  77417. * @returns a new matrix
  77418. */
  77419. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77420. /**
  77421. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77422. * @param scale defines the scale vector3
  77423. * @param rotation defines the rotation quaternion
  77424. * @param translation defines the translation vector3
  77425. * @param result defines the target matrix
  77426. */
  77427. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77428. /**
  77429. * Creates a new identity matrix
  77430. * @returns a new identity matrix
  77431. */
  77432. static Identity(): Matrix;
  77433. /**
  77434. * Creates a new identity matrix and stores the result in a given matrix
  77435. * @param result defines the target matrix
  77436. */
  77437. static IdentityToRef(result: Matrix): void;
  77438. /**
  77439. * Creates a new zero matrix
  77440. * @returns a new zero matrix
  77441. */
  77442. static Zero(): Matrix;
  77443. /**
  77444. * Creates a new rotation matrix for "angle" radians around the X axis
  77445. * @param angle defines the angle (in radians) to use
  77446. * @return the new matrix
  77447. */
  77448. static RotationX(angle: number): Matrix;
  77449. /**
  77450. * Creates a new matrix as the invert of a given matrix
  77451. * @param source defines the source matrix
  77452. * @returns the new matrix
  77453. */
  77454. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77455. /**
  77456. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77457. * @param angle defines the angle (in radians) to use
  77458. * @param result defines the target matrix
  77459. */
  77460. static RotationXToRef(angle: number, result: Matrix): void;
  77461. /**
  77462. * Creates a new rotation matrix for "angle" radians around the Y axis
  77463. * @param angle defines the angle (in radians) to use
  77464. * @return the new matrix
  77465. */
  77466. static RotationY(angle: number): Matrix;
  77467. /**
  77468. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77469. * @param angle defines the angle (in radians) to use
  77470. * @param result defines the target matrix
  77471. */
  77472. static RotationYToRef(angle: number, result: Matrix): void;
  77473. /**
  77474. * Creates a new rotation matrix for "angle" radians around the Z axis
  77475. * @param angle defines the angle (in radians) to use
  77476. * @return the new matrix
  77477. */
  77478. static RotationZ(angle: number): Matrix;
  77479. /**
  77480. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77481. * @param angle defines the angle (in radians) to use
  77482. * @param result defines the target matrix
  77483. */
  77484. static RotationZToRef(angle: number, result: Matrix): void;
  77485. /**
  77486. * Creates a new rotation matrix for "angle" radians around the given axis
  77487. * @param axis defines the axis to use
  77488. * @param angle defines the angle (in radians) to use
  77489. * @return the new matrix
  77490. */
  77491. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77492. /**
  77493. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77494. * @param axis defines the axis to use
  77495. * @param angle defines the angle (in radians) to use
  77496. * @param result defines the target matrix
  77497. */
  77498. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77499. /**
  77500. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77501. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77502. * @param from defines the vector to align
  77503. * @param to defines the vector to align to
  77504. * @param result defines the target matrix
  77505. */
  77506. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77507. /**
  77508. * Creates a rotation matrix
  77509. * @param yaw defines the yaw angle in radians (Y axis)
  77510. * @param pitch defines the pitch angle in radians (X axis)
  77511. * @param roll defines the roll angle in radians (X axis)
  77512. * @returns the new rotation matrix
  77513. */
  77514. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77515. /**
  77516. * Creates a rotation matrix and stores it in a given matrix
  77517. * @param yaw defines the yaw angle in radians (Y axis)
  77518. * @param pitch defines the pitch angle in radians (X axis)
  77519. * @param roll defines the roll angle in radians (X axis)
  77520. * @param result defines the target matrix
  77521. */
  77522. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77523. /**
  77524. * Creates a scaling matrix
  77525. * @param x defines the scale factor on X axis
  77526. * @param y defines the scale factor on Y axis
  77527. * @param z defines the scale factor on Z axis
  77528. * @returns the new matrix
  77529. */
  77530. static Scaling(x: number, y: number, z: number): Matrix;
  77531. /**
  77532. * Creates a scaling matrix and stores it in a given matrix
  77533. * @param x defines the scale factor on X axis
  77534. * @param y defines the scale factor on Y axis
  77535. * @param z defines the scale factor on Z axis
  77536. * @param result defines the target matrix
  77537. */
  77538. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77539. /**
  77540. * Creates a translation matrix
  77541. * @param x defines the translation on X axis
  77542. * @param y defines the translation on Y axis
  77543. * @param z defines the translationon Z axis
  77544. * @returns the new matrix
  77545. */
  77546. static Translation(x: number, y: number, z: number): Matrix;
  77547. /**
  77548. * Creates a translation matrix and stores it in a given matrix
  77549. * @param x defines the translation on X axis
  77550. * @param y defines the translation on Y axis
  77551. * @param z defines the translationon Z axis
  77552. * @param result defines the target matrix
  77553. */
  77554. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77555. /**
  77556. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77557. * @param startValue defines the start value
  77558. * @param endValue defines the end value
  77559. * @param gradient defines the gradient factor
  77560. * @returns the new matrix
  77561. */
  77562. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77563. /**
  77564. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77565. * @param startValue defines the start value
  77566. * @param endValue defines the end value
  77567. * @param gradient defines the gradient factor
  77568. * @param result defines the Matrix object where to store data
  77569. */
  77570. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77571. /**
  77572. * Builds a new matrix whose values are computed by:
  77573. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77574. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77575. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77576. * @param startValue defines the first matrix
  77577. * @param endValue defines the second matrix
  77578. * @param gradient defines the gradient between the two matrices
  77579. * @returns the new matrix
  77580. */
  77581. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77582. /**
  77583. * Update a matrix to values which are computed by:
  77584. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77585. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77586. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77587. * @param startValue defines the first matrix
  77588. * @param endValue defines the second matrix
  77589. * @param gradient defines the gradient between the two matrices
  77590. * @param result defines the target matrix
  77591. */
  77592. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77593. /**
  77594. * 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"
  77595. * This function works in left handed mode
  77596. * @param eye defines the final position of the entity
  77597. * @param target defines where the entity should look at
  77598. * @param up defines the up vector for the entity
  77599. * @returns the new matrix
  77600. */
  77601. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77602. /**
  77603. * 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".
  77604. * This function works in left handed mode
  77605. * @param eye defines the final position of the entity
  77606. * @param target defines where the entity should look at
  77607. * @param up defines the up vector for the entity
  77608. * @param result defines the target matrix
  77609. */
  77610. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77611. /**
  77612. * 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"
  77613. * This function works in right handed mode
  77614. * @param eye defines the final position of the entity
  77615. * @param target defines where the entity should look at
  77616. * @param up defines the up vector for the entity
  77617. * @returns the new matrix
  77618. */
  77619. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77620. /**
  77621. * 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".
  77622. * This function works in right handed mode
  77623. * @param eye defines the final position of the entity
  77624. * @param target defines where the entity should look at
  77625. * @param up defines the up vector for the entity
  77626. * @param result defines the target matrix
  77627. */
  77628. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77629. /**
  77630. * Create a left-handed orthographic projection matrix
  77631. * @param width defines the viewport width
  77632. * @param height defines the viewport height
  77633. * @param znear defines the near clip plane
  77634. * @param zfar defines the far clip plane
  77635. * @returns a new matrix as a left-handed orthographic projection matrix
  77636. */
  77637. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77638. /**
  77639. * Store a left-handed orthographic projection to a given matrix
  77640. * @param width defines the viewport width
  77641. * @param height defines the viewport height
  77642. * @param znear defines the near clip plane
  77643. * @param zfar defines the far clip plane
  77644. * @param result defines the target matrix
  77645. */
  77646. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77647. /**
  77648. * Create a left-handed orthographic projection matrix
  77649. * @param left defines the viewport left coordinate
  77650. * @param right defines the viewport right coordinate
  77651. * @param bottom defines the viewport bottom coordinate
  77652. * @param top defines the viewport top coordinate
  77653. * @param znear defines the near clip plane
  77654. * @param zfar defines the far clip plane
  77655. * @returns a new matrix as a left-handed orthographic projection matrix
  77656. */
  77657. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77658. /**
  77659. * Stores a left-handed orthographic projection into a given matrix
  77660. * @param left defines the viewport left coordinate
  77661. * @param right defines the viewport right coordinate
  77662. * @param bottom defines the viewport bottom coordinate
  77663. * @param top defines the viewport top coordinate
  77664. * @param znear defines the near clip plane
  77665. * @param zfar defines the far clip plane
  77666. * @param result defines the target matrix
  77667. */
  77668. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77669. /**
  77670. * Creates a right-handed orthographic projection matrix
  77671. * @param left defines the viewport left coordinate
  77672. * @param right defines the viewport right coordinate
  77673. * @param bottom defines the viewport bottom coordinate
  77674. * @param top defines the viewport top coordinate
  77675. * @param znear defines the near clip plane
  77676. * @param zfar defines the far clip plane
  77677. * @returns a new matrix as a right-handed orthographic projection matrix
  77678. */
  77679. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77680. /**
  77681. * Stores a right-handed orthographic projection into a given matrix
  77682. * @param left defines the viewport left coordinate
  77683. * @param right defines the viewport right coordinate
  77684. * @param bottom defines the viewport bottom coordinate
  77685. * @param top defines the viewport top coordinate
  77686. * @param znear defines the near clip plane
  77687. * @param zfar defines the far clip plane
  77688. * @param result defines the target matrix
  77689. */
  77690. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77691. /**
  77692. * Creates a left-handed perspective projection matrix
  77693. * @param width defines the viewport width
  77694. * @param height defines the viewport height
  77695. * @param znear defines the near clip plane
  77696. * @param zfar defines the far clip plane
  77697. * @returns a new matrix as a left-handed perspective projection matrix
  77698. */
  77699. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77700. /**
  77701. * Creates a left-handed perspective projection matrix
  77702. * @param fov defines the horizontal field of view
  77703. * @param aspect defines the aspect ratio
  77704. * @param znear defines the near clip plane
  77705. * @param zfar defines the far clip plane
  77706. * @returns a new matrix as a left-handed perspective projection matrix
  77707. */
  77708. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77709. /**
  77710. * Stores a left-handed perspective projection into a given matrix
  77711. * @param fov defines the horizontal field of view
  77712. * @param aspect defines the aspect ratio
  77713. * @param znear defines the near clip plane
  77714. * @param zfar defines the far clip plane
  77715. * @param result defines the target matrix
  77716. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77717. */
  77718. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77719. /**
  77720. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77721. * @param fov defines the horizontal field of view
  77722. * @param aspect defines the aspect ratio
  77723. * @param znear defines the near clip plane
  77724. * @param zfar not used as infinity is used as far clip
  77725. * @param result defines the target matrix
  77726. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77727. */
  77728. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77729. /**
  77730. * Creates a right-handed perspective projection matrix
  77731. * @param fov defines the horizontal field of view
  77732. * @param aspect defines the aspect ratio
  77733. * @param znear defines the near clip plane
  77734. * @param zfar defines the far clip plane
  77735. * @returns a new matrix as a right-handed perspective projection matrix
  77736. */
  77737. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77738. /**
  77739. * Stores a right-handed perspective projection into a given matrix
  77740. * @param fov defines the horizontal field of view
  77741. * @param aspect defines the aspect ratio
  77742. * @param znear defines the near clip plane
  77743. * @param zfar defines the far clip plane
  77744. * @param result defines the target matrix
  77745. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77746. */
  77747. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77748. /**
  77749. * Stores a right-handed perspective projection into a given matrix
  77750. * @param fov defines the horizontal field of view
  77751. * @param aspect defines the aspect ratio
  77752. * @param znear defines the near clip plane
  77753. * @param zfar not used as infinity is used as far clip
  77754. * @param result defines the target matrix
  77755. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77756. */
  77757. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77758. /**
  77759. * Stores a perspective projection for WebVR info a given matrix
  77760. * @param fov defines the field of view
  77761. * @param znear defines the near clip plane
  77762. * @param zfar defines the far clip plane
  77763. * @param result defines the target matrix
  77764. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77765. */
  77766. static PerspectiveFovWebVRToRef(fov: {
  77767. upDegrees: number;
  77768. downDegrees: number;
  77769. leftDegrees: number;
  77770. rightDegrees: number;
  77771. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77772. /**
  77773. * Computes a complete transformation matrix
  77774. * @param viewport defines the viewport to use
  77775. * @param world defines the world matrix
  77776. * @param view defines the view matrix
  77777. * @param projection defines the projection matrix
  77778. * @param zmin defines the near clip plane
  77779. * @param zmax defines the far clip plane
  77780. * @returns the transformation matrix
  77781. */
  77782. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77783. /**
  77784. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77785. * @param matrix defines the matrix to use
  77786. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77787. */
  77788. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77789. /**
  77790. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77791. * @param matrix defines the matrix to use
  77792. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77793. */
  77794. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77795. /**
  77796. * Compute the transpose of a given matrix
  77797. * @param matrix defines the matrix to transpose
  77798. * @returns the new matrix
  77799. */
  77800. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77801. /**
  77802. * Compute the transpose of a matrix and store it in a target matrix
  77803. * @param matrix defines the matrix to transpose
  77804. * @param result defines the target matrix
  77805. */
  77806. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77807. /**
  77808. * Computes a reflection matrix from a plane
  77809. * @param plane defines the reflection plane
  77810. * @returns a new matrix
  77811. */
  77812. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77813. /**
  77814. * Computes a reflection matrix from a plane
  77815. * @param plane defines the reflection plane
  77816. * @param result defines the target matrix
  77817. */
  77818. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77819. /**
  77820. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77821. * @param xaxis defines the value of the 1st axis
  77822. * @param yaxis defines the value of the 2nd axis
  77823. * @param zaxis defines the value of the 3rd axis
  77824. * @param result defines the target matrix
  77825. */
  77826. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77827. /**
  77828. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77829. * @param quat defines the quaternion to use
  77830. * @param result defines the target matrix
  77831. */
  77832. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77833. }
  77834. /**
  77835. * @hidden
  77836. */
  77837. export class TmpVectors {
  77838. static Vector2: Vector2[];
  77839. static Vector3: Vector3[];
  77840. static Vector4: Vector4[];
  77841. static Quaternion: Quaternion[];
  77842. static Matrix: Matrix[];
  77843. }
  77844. }
  77845. declare module BABYLON {
  77846. /**
  77847. * Defines potential orientation for back face culling
  77848. */
  77849. export enum Orientation {
  77850. /**
  77851. * Clockwise
  77852. */
  77853. CW = 0,
  77854. /** Counter clockwise */
  77855. CCW = 1
  77856. }
  77857. /** Class used to represent a Bezier curve */
  77858. export class BezierCurve {
  77859. /**
  77860. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77861. * @param t defines the time
  77862. * @param x1 defines the left coordinate on X axis
  77863. * @param y1 defines the left coordinate on Y axis
  77864. * @param x2 defines the right coordinate on X axis
  77865. * @param y2 defines the right coordinate on Y axis
  77866. * @returns the interpolated value
  77867. */
  77868. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77869. }
  77870. /**
  77871. * Defines angle representation
  77872. */
  77873. export class Angle {
  77874. private _radians;
  77875. /**
  77876. * Creates an Angle object of "radians" radians (float).
  77877. * @param radians the angle in radians
  77878. */
  77879. constructor(radians: number);
  77880. /**
  77881. * Get value in degrees
  77882. * @returns the Angle value in degrees (float)
  77883. */
  77884. degrees(): number;
  77885. /**
  77886. * Get value in radians
  77887. * @returns the Angle value in radians (float)
  77888. */
  77889. radians(): number;
  77890. /**
  77891. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77892. * @param a defines first vector
  77893. * @param b defines second vector
  77894. * @returns a new Angle
  77895. */
  77896. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77897. /**
  77898. * Gets a new Angle object from the given float in radians
  77899. * @param radians defines the angle value in radians
  77900. * @returns a new Angle
  77901. */
  77902. static FromRadians(radians: number): Angle;
  77903. /**
  77904. * Gets a new Angle object from the given float in degrees
  77905. * @param degrees defines the angle value in degrees
  77906. * @returns a new Angle
  77907. */
  77908. static FromDegrees(degrees: number): Angle;
  77909. }
  77910. /**
  77911. * This represents an arc in a 2d space.
  77912. */
  77913. export class Arc2 {
  77914. /** Defines the start point of the arc */
  77915. startPoint: Vector2;
  77916. /** Defines the mid point of the arc */
  77917. midPoint: Vector2;
  77918. /** Defines the end point of the arc */
  77919. endPoint: Vector2;
  77920. /**
  77921. * Defines the center point of the arc.
  77922. */
  77923. centerPoint: Vector2;
  77924. /**
  77925. * Defines the radius of the arc.
  77926. */
  77927. radius: number;
  77928. /**
  77929. * Defines the angle of the arc (from mid point to end point).
  77930. */
  77931. angle: Angle;
  77932. /**
  77933. * Defines the start angle of the arc (from start point to middle point).
  77934. */
  77935. startAngle: Angle;
  77936. /**
  77937. * Defines the orientation of the arc (clock wise/counter clock wise).
  77938. */
  77939. orientation: Orientation;
  77940. /**
  77941. * Creates an Arc object from the three given points : start, middle and end.
  77942. * @param startPoint Defines the start point of the arc
  77943. * @param midPoint Defines the midlle point of the arc
  77944. * @param endPoint Defines the end point of the arc
  77945. */
  77946. constructor(
  77947. /** Defines the start point of the arc */
  77948. startPoint: Vector2,
  77949. /** Defines the mid point of the arc */
  77950. midPoint: Vector2,
  77951. /** Defines the end point of the arc */
  77952. endPoint: Vector2);
  77953. }
  77954. /**
  77955. * Represents a 2D path made up of multiple 2D points
  77956. */
  77957. export class Path2 {
  77958. private _points;
  77959. private _length;
  77960. /**
  77961. * If the path start and end point are the same
  77962. */
  77963. closed: boolean;
  77964. /**
  77965. * Creates a Path2 object from the starting 2D coordinates x and y.
  77966. * @param x the starting points x value
  77967. * @param y the starting points y value
  77968. */
  77969. constructor(x: number, y: number);
  77970. /**
  77971. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77972. * @param x the added points x value
  77973. * @param y the added points y value
  77974. * @returns the updated Path2.
  77975. */
  77976. addLineTo(x: number, y: number): Path2;
  77977. /**
  77978. * 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.
  77979. * @param midX middle point x value
  77980. * @param midY middle point y value
  77981. * @param endX end point x value
  77982. * @param endY end point y value
  77983. * @param numberOfSegments (default: 36)
  77984. * @returns the updated Path2.
  77985. */
  77986. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77987. /**
  77988. * Closes the Path2.
  77989. * @returns the Path2.
  77990. */
  77991. close(): Path2;
  77992. /**
  77993. * Gets the sum of the distance between each sequential point in the path
  77994. * @returns the Path2 total length (float).
  77995. */
  77996. length(): number;
  77997. /**
  77998. * Gets the points which construct the path
  77999. * @returns the Path2 internal array of points.
  78000. */
  78001. getPoints(): Vector2[];
  78002. /**
  78003. * Retreives the point at the distance aways from the starting point
  78004. * @param normalizedLengthPosition the length along the path to retreive the point from
  78005. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78006. */
  78007. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78008. /**
  78009. * Creates a new path starting from an x and y position
  78010. * @param x starting x value
  78011. * @param y starting y value
  78012. * @returns a new Path2 starting at the coordinates (x, y).
  78013. */
  78014. static StartingAt(x: number, y: number): Path2;
  78015. }
  78016. /**
  78017. * Represents a 3D path made up of multiple 3D points
  78018. */
  78019. export class Path3D {
  78020. /**
  78021. * an array of Vector3, the curve axis of the Path3D
  78022. */
  78023. path: Vector3[];
  78024. private _curve;
  78025. private _distances;
  78026. private _tangents;
  78027. private _normals;
  78028. private _binormals;
  78029. private _raw;
  78030. private _alignTangentsWithPath;
  78031. private readonly _pointAtData;
  78032. /**
  78033. * new Path3D(path, normal, raw)
  78034. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78035. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78036. * @param path an array of Vector3, the curve axis of the Path3D
  78037. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78038. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78039. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78040. */
  78041. constructor(
  78042. /**
  78043. * an array of Vector3, the curve axis of the Path3D
  78044. */
  78045. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78046. /**
  78047. * Returns the Path3D array of successive Vector3 designing its curve.
  78048. * @returns the Path3D array of successive Vector3 designing its curve.
  78049. */
  78050. getCurve(): Vector3[];
  78051. /**
  78052. * Returns the Path3D array of successive Vector3 designing its curve.
  78053. * @returns the Path3D array of successive Vector3 designing its curve.
  78054. */
  78055. getPoints(): Vector3[];
  78056. /**
  78057. * @returns the computed length (float) of the path.
  78058. */
  78059. length(): number;
  78060. /**
  78061. * Returns an array populated with tangent vectors on each Path3D curve point.
  78062. * @returns an array populated with tangent vectors on each Path3D curve point.
  78063. */
  78064. getTangents(): Vector3[];
  78065. /**
  78066. * Returns an array populated with normal vectors on each Path3D curve point.
  78067. * @returns an array populated with normal vectors on each Path3D curve point.
  78068. */
  78069. getNormals(): Vector3[];
  78070. /**
  78071. * Returns an array populated with binormal vectors on each Path3D curve point.
  78072. * @returns an array populated with binormal vectors on each Path3D curve point.
  78073. */
  78074. getBinormals(): Vector3[];
  78075. /**
  78076. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78077. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78078. */
  78079. getDistances(): number[];
  78080. /**
  78081. * Returns an interpolated point along this path
  78082. * @param position the position of the point along this path, from 0.0 to 1.0
  78083. * @returns a new Vector3 as the point
  78084. */
  78085. getPointAt(position: number): Vector3;
  78086. /**
  78087. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78088. * @param position the position of the point along this path, from 0.0 to 1.0
  78089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78090. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78091. */
  78092. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78093. /**
  78094. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78095. * @param position the position of the point along this path, from 0.0 to 1.0
  78096. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78097. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78098. */
  78099. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78100. /**
  78101. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78102. * @param position the position of the point along this path, from 0.0 to 1.0
  78103. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78104. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78105. */
  78106. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78107. /**
  78108. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78109. * @param position the position of the point along this path, from 0.0 to 1.0
  78110. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78111. */
  78112. getDistanceAt(position: number): number;
  78113. /**
  78114. * Returns the array index of the previous point of an interpolated point along this path
  78115. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78116. * @returns the array index
  78117. */
  78118. getPreviousPointIndexAt(position: number): number;
  78119. /**
  78120. * 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)
  78121. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78122. * @returns the sub position
  78123. */
  78124. getSubPositionAt(position: number): number;
  78125. /**
  78126. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78127. * @param target the vector of which to get the closest position to
  78128. * @returns the position of the closest virtual point on this path to the target vector
  78129. */
  78130. getClosestPositionTo(target: Vector3): number;
  78131. /**
  78132. * Returns a sub path (slice) of this path
  78133. * @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
  78134. * @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
  78135. * @returns a sub path (slice) of this path
  78136. */
  78137. slice(start?: number, end?: number): Path3D;
  78138. /**
  78139. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78140. * @param path path which all values are copied into the curves points
  78141. * @param firstNormal which should be projected onto the curve
  78142. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78143. * @returns the same object updated.
  78144. */
  78145. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78146. private _compute;
  78147. private _getFirstNonNullVector;
  78148. private _getLastNonNullVector;
  78149. private _normalVector;
  78150. /**
  78151. * Updates the point at data for an interpolated point along this curve
  78152. * @param position the position of the point along this curve, from 0.0 to 1.0
  78153. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78154. * @returns the (updated) point at data
  78155. */
  78156. private _updatePointAtData;
  78157. /**
  78158. * Updates the point at data from the specified parameters
  78159. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78160. * @param point the interpolated point
  78161. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78162. */
  78163. private _setPointAtData;
  78164. /**
  78165. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78166. */
  78167. private _updateInterpolationMatrix;
  78168. }
  78169. /**
  78170. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78171. * A Curve3 is designed from a series of successive Vector3.
  78172. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78173. */
  78174. export class Curve3 {
  78175. private _points;
  78176. private _length;
  78177. /**
  78178. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78179. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78180. * @param v1 (Vector3) the control point
  78181. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78182. * @param nbPoints (integer) the wanted number of points in the curve
  78183. * @returns the created Curve3
  78184. */
  78185. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78186. /**
  78187. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78188. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78189. * @param v1 (Vector3) the first control point
  78190. * @param v2 (Vector3) the second control point
  78191. * @param v3 (Vector3) the end point of the Cubic Bezier
  78192. * @param nbPoints (integer) the wanted number of points in the curve
  78193. * @returns the created Curve3
  78194. */
  78195. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78196. /**
  78197. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78198. * @param p1 (Vector3) the origin point of the Hermite Spline
  78199. * @param t1 (Vector3) the tangent vector at the origin point
  78200. * @param p2 (Vector3) the end point of the Hermite Spline
  78201. * @param t2 (Vector3) the tangent vector at the end point
  78202. * @param nbPoints (integer) the wanted number of points in the curve
  78203. * @returns the created Curve3
  78204. */
  78205. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78206. /**
  78207. * Returns a Curve3 object along a CatmullRom Spline curve :
  78208. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78209. * @param nbPoints (integer) the wanted number of points between each curve control points
  78210. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78211. * @returns the created Curve3
  78212. */
  78213. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78214. /**
  78215. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78216. * A Curve3 is designed from a series of successive Vector3.
  78217. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78218. * @param points points which make up the curve
  78219. */
  78220. constructor(points: Vector3[]);
  78221. /**
  78222. * @returns the Curve3 stored array of successive Vector3
  78223. */
  78224. getPoints(): Vector3[];
  78225. /**
  78226. * @returns the computed length (float) of the curve.
  78227. */
  78228. length(): number;
  78229. /**
  78230. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78231. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78232. * curveA and curveB keep unchanged.
  78233. * @param curve the curve to continue from this curve
  78234. * @returns the newly constructed curve
  78235. */
  78236. continue(curve: DeepImmutable<Curve3>): Curve3;
  78237. private _computeLength;
  78238. }
  78239. }
  78240. declare module BABYLON {
  78241. /**
  78242. * This represents the main contract an easing function should follow.
  78243. * Easing functions are used throughout the animation system.
  78244. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78245. */
  78246. export interface IEasingFunction {
  78247. /**
  78248. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78249. * of the easing function.
  78250. * The link below provides some of the most common examples of easing functions.
  78251. * @see https://easings.net/
  78252. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78253. * @returns the corresponding value on the curve defined by the easing function
  78254. */
  78255. ease(gradient: number): number;
  78256. }
  78257. /**
  78258. * Base class used for every default easing function.
  78259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78260. */
  78261. export class EasingFunction implements IEasingFunction {
  78262. /**
  78263. * Interpolation follows the mathematical formula associated with the easing function.
  78264. */
  78265. static readonly EASINGMODE_EASEIN: number;
  78266. /**
  78267. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78268. */
  78269. static readonly EASINGMODE_EASEOUT: number;
  78270. /**
  78271. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78272. */
  78273. static readonly EASINGMODE_EASEINOUT: number;
  78274. private _easingMode;
  78275. /**
  78276. * Sets the easing mode of the current function.
  78277. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78278. */
  78279. setEasingMode(easingMode: number): void;
  78280. /**
  78281. * Gets the current easing mode.
  78282. * @returns the easing mode
  78283. */
  78284. getEasingMode(): number;
  78285. /**
  78286. * @hidden
  78287. */
  78288. easeInCore(gradient: number): number;
  78289. /**
  78290. * Given an input gradient between 0 and 1, this returns the corresponding value
  78291. * of the easing function.
  78292. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78293. * @returns the corresponding value on the curve defined by the easing function
  78294. */
  78295. ease(gradient: number): number;
  78296. }
  78297. /**
  78298. * Easing function with a circle shape (see link below).
  78299. * @see https://easings.net/#easeInCirc
  78300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78301. */
  78302. export class CircleEase extends EasingFunction implements IEasingFunction {
  78303. /** @hidden */
  78304. easeInCore(gradient: number): number;
  78305. }
  78306. /**
  78307. * Easing function with a ease back shape (see link below).
  78308. * @see https://easings.net/#easeInBack
  78309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78310. */
  78311. export class BackEase extends EasingFunction implements IEasingFunction {
  78312. /** Defines the amplitude of the function */
  78313. amplitude: number;
  78314. /**
  78315. * Instantiates a back ease easing
  78316. * @see https://easings.net/#easeInBack
  78317. * @param amplitude Defines the amplitude of the function
  78318. */
  78319. constructor(
  78320. /** Defines the amplitude of the function */
  78321. amplitude?: number);
  78322. /** @hidden */
  78323. easeInCore(gradient: number): number;
  78324. }
  78325. /**
  78326. * Easing function with a bouncing shape (see link below).
  78327. * @see https://easings.net/#easeInBounce
  78328. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78329. */
  78330. export class BounceEase extends EasingFunction implements IEasingFunction {
  78331. /** Defines the number of bounces */
  78332. bounces: number;
  78333. /** Defines the amplitude of the bounce */
  78334. bounciness: number;
  78335. /**
  78336. * Instantiates a bounce easing
  78337. * @see https://easings.net/#easeInBounce
  78338. * @param bounces Defines the number of bounces
  78339. * @param bounciness Defines the amplitude of the bounce
  78340. */
  78341. constructor(
  78342. /** Defines the number of bounces */
  78343. bounces?: number,
  78344. /** Defines the amplitude of the bounce */
  78345. bounciness?: number);
  78346. /** @hidden */
  78347. easeInCore(gradient: number): number;
  78348. }
  78349. /**
  78350. * Easing function with a power of 3 shape (see link below).
  78351. * @see https://easings.net/#easeInCubic
  78352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78353. */
  78354. export class CubicEase extends EasingFunction implements IEasingFunction {
  78355. /** @hidden */
  78356. easeInCore(gradient: number): number;
  78357. }
  78358. /**
  78359. * Easing function with an elastic shape (see link below).
  78360. * @see https://easings.net/#easeInElastic
  78361. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78362. */
  78363. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78364. /** Defines the number of oscillations*/
  78365. oscillations: number;
  78366. /** Defines the amplitude of the oscillations*/
  78367. springiness: number;
  78368. /**
  78369. * Instantiates an elastic easing function
  78370. * @see https://easings.net/#easeInElastic
  78371. * @param oscillations Defines the number of oscillations
  78372. * @param springiness Defines the amplitude of the oscillations
  78373. */
  78374. constructor(
  78375. /** Defines the number of oscillations*/
  78376. oscillations?: number,
  78377. /** Defines the amplitude of the oscillations*/
  78378. springiness?: number);
  78379. /** @hidden */
  78380. easeInCore(gradient: number): number;
  78381. }
  78382. /**
  78383. * Easing function with an exponential shape (see link below).
  78384. * @see https://easings.net/#easeInExpo
  78385. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78386. */
  78387. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78388. /** Defines the exponent of the function */
  78389. exponent: number;
  78390. /**
  78391. * Instantiates an exponential easing function
  78392. * @see https://easings.net/#easeInExpo
  78393. * @param exponent Defines the exponent of the function
  78394. */
  78395. constructor(
  78396. /** Defines the exponent of the function */
  78397. exponent?: number);
  78398. /** @hidden */
  78399. easeInCore(gradient: number): number;
  78400. }
  78401. /**
  78402. * Easing function with a power shape (see link below).
  78403. * @see https://easings.net/#easeInQuad
  78404. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78405. */
  78406. export class PowerEase extends EasingFunction implements IEasingFunction {
  78407. /** Defines the power of the function */
  78408. power: number;
  78409. /**
  78410. * Instantiates an power base easing function
  78411. * @see https://easings.net/#easeInQuad
  78412. * @param power Defines the power of the function
  78413. */
  78414. constructor(
  78415. /** Defines the power of the function */
  78416. power?: number);
  78417. /** @hidden */
  78418. easeInCore(gradient: number): number;
  78419. }
  78420. /**
  78421. * Easing function with a power of 2 shape (see link below).
  78422. * @see https://easings.net/#easeInQuad
  78423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78424. */
  78425. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78426. /** @hidden */
  78427. easeInCore(gradient: number): number;
  78428. }
  78429. /**
  78430. * Easing function with a power of 4 shape (see link below).
  78431. * @see https://easings.net/#easeInQuart
  78432. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78433. */
  78434. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78435. /** @hidden */
  78436. easeInCore(gradient: number): number;
  78437. }
  78438. /**
  78439. * Easing function with a power of 5 shape (see link below).
  78440. * @see https://easings.net/#easeInQuint
  78441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78442. */
  78443. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78444. /** @hidden */
  78445. easeInCore(gradient: number): number;
  78446. }
  78447. /**
  78448. * Easing function with a sin shape (see link below).
  78449. * @see https://easings.net/#easeInSine
  78450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78451. */
  78452. export class SineEase extends EasingFunction implements IEasingFunction {
  78453. /** @hidden */
  78454. easeInCore(gradient: number): number;
  78455. }
  78456. /**
  78457. * Easing function with a bezier shape (see link below).
  78458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78459. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78460. */
  78461. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78462. /** Defines the x component of the start tangent in the bezier curve */
  78463. x1: number;
  78464. /** Defines the y component of the start tangent in the bezier curve */
  78465. y1: number;
  78466. /** Defines the x component of the end tangent in the bezier curve */
  78467. x2: number;
  78468. /** Defines the y component of the end tangent in the bezier curve */
  78469. y2: number;
  78470. /**
  78471. * Instantiates a bezier function
  78472. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78473. * @param x1 Defines the x component of the start tangent in the bezier curve
  78474. * @param y1 Defines the y component of the start tangent in the bezier curve
  78475. * @param x2 Defines the x component of the end tangent in the bezier curve
  78476. * @param y2 Defines the y component of the end tangent in the bezier curve
  78477. */
  78478. constructor(
  78479. /** Defines the x component of the start tangent in the bezier curve */
  78480. x1?: number,
  78481. /** Defines the y component of the start tangent in the bezier curve */
  78482. y1?: number,
  78483. /** Defines the x component of the end tangent in the bezier curve */
  78484. x2?: number,
  78485. /** Defines the y component of the end tangent in the bezier curve */
  78486. y2?: number);
  78487. /** @hidden */
  78488. easeInCore(gradient: number): number;
  78489. }
  78490. }
  78491. declare module BABYLON {
  78492. /**
  78493. * Class used to hold a RBG color
  78494. */
  78495. export class Color3 {
  78496. /**
  78497. * Defines the red component (between 0 and 1, default is 0)
  78498. */
  78499. r: number;
  78500. /**
  78501. * Defines the green component (between 0 and 1, default is 0)
  78502. */
  78503. g: number;
  78504. /**
  78505. * Defines the blue component (between 0 and 1, default is 0)
  78506. */
  78507. b: number;
  78508. /**
  78509. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78510. * @param r defines the red component (between 0 and 1, default is 0)
  78511. * @param g defines the green component (between 0 and 1, default is 0)
  78512. * @param b defines the blue component (between 0 and 1, default is 0)
  78513. */
  78514. constructor(
  78515. /**
  78516. * Defines the red component (between 0 and 1, default is 0)
  78517. */
  78518. r?: number,
  78519. /**
  78520. * Defines the green component (between 0 and 1, default is 0)
  78521. */
  78522. g?: number,
  78523. /**
  78524. * Defines the blue component (between 0 and 1, default is 0)
  78525. */
  78526. b?: number);
  78527. /**
  78528. * Creates a string with the Color3 current values
  78529. * @returns the string representation of the Color3 object
  78530. */
  78531. toString(): string;
  78532. /**
  78533. * Returns the string "Color3"
  78534. * @returns "Color3"
  78535. */
  78536. getClassName(): string;
  78537. /**
  78538. * Compute the Color3 hash code
  78539. * @returns an unique number that can be used to hash Color3 objects
  78540. */
  78541. getHashCode(): number;
  78542. /**
  78543. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78544. * @param array defines the array where to store the r,g,b components
  78545. * @param index defines an optional index in the target array to define where to start storing values
  78546. * @returns the current Color3 object
  78547. */
  78548. toArray(array: FloatArray, index?: number): Color3;
  78549. /**
  78550. * Returns a new Color4 object from the current Color3 and the given alpha
  78551. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78552. * @returns a new Color4 object
  78553. */
  78554. toColor4(alpha?: number): Color4;
  78555. /**
  78556. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78557. * @returns the new array
  78558. */
  78559. asArray(): number[];
  78560. /**
  78561. * Returns the luminance value
  78562. * @returns a float value
  78563. */
  78564. toLuminance(): number;
  78565. /**
  78566. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78567. * @param otherColor defines the second operand
  78568. * @returns the new Color3 object
  78569. */
  78570. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78571. /**
  78572. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78573. * @param otherColor defines the second operand
  78574. * @param result defines the Color3 object where to store the result
  78575. * @returns the current Color3
  78576. */
  78577. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78578. /**
  78579. * Determines equality between Color3 objects
  78580. * @param otherColor defines the second operand
  78581. * @returns true if the rgb values are equal to the given ones
  78582. */
  78583. equals(otherColor: DeepImmutable<Color3>): boolean;
  78584. /**
  78585. * Determines equality between the current Color3 object and a set of r,b,g values
  78586. * @param r defines the red component to check
  78587. * @param g defines the green component to check
  78588. * @param b defines the blue component to check
  78589. * @returns true if the rgb values are equal to the given ones
  78590. */
  78591. equalsFloats(r: number, g: number, b: number): boolean;
  78592. /**
  78593. * Multiplies in place each rgb value by scale
  78594. * @param scale defines the scaling factor
  78595. * @returns the updated Color3
  78596. */
  78597. scale(scale: number): Color3;
  78598. /**
  78599. * Multiplies the rgb values by scale and stores the result into "result"
  78600. * @param scale defines the scaling factor
  78601. * @param result defines the Color3 object where to store the result
  78602. * @returns the unmodified current Color3
  78603. */
  78604. scaleToRef(scale: number, result: Color3): Color3;
  78605. /**
  78606. * Scale the current Color3 values by a factor and add the result to a given Color3
  78607. * @param scale defines the scale factor
  78608. * @param result defines color to store the result into
  78609. * @returns the unmodified current Color3
  78610. */
  78611. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78612. /**
  78613. * Clamps the rgb values by the min and max values and stores the result into "result"
  78614. * @param min defines minimum clamping value (default is 0)
  78615. * @param max defines maximum clamping value (default is 1)
  78616. * @param result defines color to store the result into
  78617. * @returns the original Color3
  78618. */
  78619. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78620. /**
  78621. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78622. * @param otherColor defines the second operand
  78623. * @returns the new Color3
  78624. */
  78625. add(otherColor: DeepImmutable<Color3>): Color3;
  78626. /**
  78627. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78628. * @param otherColor defines the second operand
  78629. * @param result defines Color3 object to store the result into
  78630. * @returns the unmodified current Color3
  78631. */
  78632. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78633. /**
  78634. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78635. * @param otherColor defines the second operand
  78636. * @returns the new Color3
  78637. */
  78638. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78639. /**
  78640. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78641. * @param otherColor defines the second operand
  78642. * @param result defines Color3 object to store the result into
  78643. * @returns the unmodified current Color3
  78644. */
  78645. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78646. /**
  78647. * Copy the current object
  78648. * @returns a new Color3 copied the current one
  78649. */
  78650. clone(): Color3;
  78651. /**
  78652. * Copies the rgb values from the source in the current Color3
  78653. * @param source defines the source Color3 object
  78654. * @returns the updated Color3 object
  78655. */
  78656. copyFrom(source: DeepImmutable<Color3>): Color3;
  78657. /**
  78658. * Updates the Color3 rgb values from the given floats
  78659. * @param r defines the red component to read from
  78660. * @param g defines the green component to read from
  78661. * @param b defines the blue component to read from
  78662. * @returns the current Color3 object
  78663. */
  78664. copyFromFloats(r: number, g: number, b: number): Color3;
  78665. /**
  78666. * Updates the Color3 rgb values from the given floats
  78667. * @param r defines the red component to read from
  78668. * @param g defines the green component to read from
  78669. * @param b defines the blue component to read from
  78670. * @returns the current Color3 object
  78671. */
  78672. set(r: number, g: number, b: number): Color3;
  78673. /**
  78674. * Compute the Color3 hexadecimal code as a string
  78675. * @returns a string containing the hexadecimal representation of the Color3 object
  78676. */
  78677. toHexString(): string;
  78678. /**
  78679. * Computes a new Color3 converted from the current one to linear space
  78680. * @returns a new Color3 object
  78681. */
  78682. toLinearSpace(): Color3;
  78683. /**
  78684. * Converts current color in rgb space to HSV values
  78685. * @returns a new color3 representing the HSV values
  78686. */
  78687. toHSV(): Color3;
  78688. /**
  78689. * Converts current color in rgb space to HSV values
  78690. * @param result defines the Color3 where to store the HSV values
  78691. */
  78692. toHSVToRef(result: Color3): void;
  78693. /**
  78694. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78695. * @param convertedColor defines the Color3 object where to store the linear space version
  78696. * @returns the unmodified Color3
  78697. */
  78698. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78699. /**
  78700. * Computes a new Color3 converted from the current one to gamma space
  78701. * @returns a new Color3 object
  78702. */
  78703. toGammaSpace(): Color3;
  78704. /**
  78705. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78706. * @param convertedColor defines the Color3 object where to store the gamma space version
  78707. * @returns the unmodified Color3
  78708. */
  78709. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78710. private static _BlackReadOnly;
  78711. /**
  78712. * Convert Hue, saturation and value to a Color3 (RGB)
  78713. * @param hue defines the hue
  78714. * @param saturation defines the saturation
  78715. * @param value defines the value
  78716. * @param result defines the Color3 where to store the RGB values
  78717. */
  78718. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78719. /**
  78720. * Creates a new Color3 from the string containing valid hexadecimal values
  78721. * @param hex defines a string containing valid hexadecimal values
  78722. * @returns a new Color3 object
  78723. */
  78724. static FromHexString(hex: string): Color3;
  78725. /**
  78726. * Creates a new Color3 from the starting index of the given array
  78727. * @param array defines the source array
  78728. * @param offset defines an offset in the source array
  78729. * @returns a new Color3 object
  78730. */
  78731. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78732. /**
  78733. * Creates a new Color3 from integer values (< 256)
  78734. * @param r defines the red component to read from (value between 0 and 255)
  78735. * @param g defines the green component to read from (value between 0 and 255)
  78736. * @param b defines the blue component to read from (value between 0 and 255)
  78737. * @returns a new Color3 object
  78738. */
  78739. static FromInts(r: number, g: number, b: number): Color3;
  78740. /**
  78741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78742. * @param start defines the start Color3 value
  78743. * @param end defines the end Color3 value
  78744. * @param amount defines the gradient value between start and end
  78745. * @returns a new Color3 object
  78746. */
  78747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78748. /**
  78749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78750. * @param left defines the start value
  78751. * @param right defines the end value
  78752. * @param amount defines the gradient factor
  78753. * @param result defines the Color3 object where to store the result
  78754. */
  78755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78756. /**
  78757. * Returns a Color3 value containing a red color
  78758. * @returns a new Color3 object
  78759. */
  78760. static Red(): Color3;
  78761. /**
  78762. * Returns a Color3 value containing a green color
  78763. * @returns a new Color3 object
  78764. */
  78765. static Green(): Color3;
  78766. /**
  78767. * Returns a Color3 value containing a blue color
  78768. * @returns a new Color3 object
  78769. */
  78770. static Blue(): Color3;
  78771. /**
  78772. * Returns a Color3 value containing a black color
  78773. * @returns a new Color3 object
  78774. */
  78775. static Black(): Color3;
  78776. /**
  78777. * Gets a Color3 value containing a black color that must not be updated
  78778. */
  78779. static get BlackReadOnly(): DeepImmutable<Color3>;
  78780. /**
  78781. * Returns a Color3 value containing a white color
  78782. * @returns a new Color3 object
  78783. */
  78784. static White(): Color3;
  78785. /**
  78786. * Returns a Color3 value containing a purple color
  78787. * @returns a new Color3 object
  78788. */
  78789. static Purple(): Color3;
  78790. /**
  78791. * Returns a Color3 value containing a magenta color
  78792. * @returns a new Color3 object
  78793. */
  78794. static Magenta(): Color3;
  78795. /**
  78796. * Returns a Color3 value containing a yellow color
  78797. * @returns a new Color3 object
  78798. */
  78799. static Yellow(): Color3;
  78800. /**
  78801. * Returns a Color3 value containing a gray color
  78802. * @returns a new Color3 object
  78803. */
  78804. static Gray(): Color3;
  78805. /**
  78806. * Returns a Color3 value containing a teal color
  78807. * @returns a new Color3 object
  78808. */
  78809. static Teal(): Color3;
  78810. /**
  78811. * Returns a Color3 value containing a random color
  78812. * @returns a new Color3 object
  78813. */
  78814. static Random(): Color3;
  78815. }
  78816. /**
  78817. * Class used to hold a RBGA color
  78818. */
  78819. export class Color4 {
  78820. /**
  78821. * Defines the red component (between 0 and 1, default is 0)
  78822. */
  78823. r: number;
  78824. /**
  78825. * Defines the green component (between 0 and 1, default is 0)
  78826. */
  78827. g: number;
  78828. /**
  78829. * Defines the blue component (between 0 and 1, default is 0)
  78830. */
  78831. b: number;
  78832. /**
  78833. * Defines the alpha component (between 0 and 1, default is 1)
  78834. */
  78835. a: number;
  78836. /**
  78837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78838. * @param r defines the red component (between 0 and 1, default is 0)
  78839. * @param g defines the green component (between 0 and 1, default is 0)
  78840. * @param b defines the blue component (between 0 and 1, default is 0)
  78841. * @param a defines the alpha component (between 0 and 1, default is 1)
  78842. */
  78843. constructor(
  78844. /**
  78845. * Defines the red component (between 0 and 1, default is 0)
  78846. */
  78847. r?: number,
  78848. /**
  78849. * Defines the green component (between 0 and 1, default is 0)
  78850. */
  78851. g?: number,
  78852. /**
  78853. * Defines the blue component (between 0 and 1, default is 0)
  78854. */
  78855. b?: number,
  78856. /**
  78857. * Defines the alpha component (between 0 and 1, default is 1)
  78858. */
  78859. a?: number);
  78860. /**
  78861. * Adds in place the given Color4 values to the current Color4 object
  78862. * @param right defines the second operand
  78863. * @returns the current updated Color4 object
  78864. */
  78865. addInPlace(right: DeepImmutable<Color4>): Color4;
  78866. /**
  78867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78868. * @returns the new array
  78869. */
  78870. asArray(): number[];
  78871. /**
  78872. * Stores from the starting index in the given array the Color4 successive values
  78873. * @param array defines the array where to store the r,g,b components
  78874. * @param index defines an optional index in the target array to define where to start storing values
  78875. * @returns the current Color4 object
  78876. */
  78877. toArray(array: number[], index?: number): Color4;
  78878. /**
  78879. * Determines equality between Color4 objects
  78880. * @param otherColor defines the second operand
  78881. * @returns true if the rgba values are equal to the given ones
  78882. */
  78883. equals(otherColor: DeepImmutable<Color4>): boolean;
  78884. /**
  78885. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78886. * @param right defines the second operand
  78887. * @returns a new Color4 object
  78888. */
  78889. add(right: DeepImmutable<Color4>): Color4;
  78890. /**
  78891. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78892. * @param right defines the second operand
  78893. * @returns a new Color4 object
  78894. */
  78895. subtract(right: DeepImmutable<Color4>): Color4;
  78896. /**
  78897. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78898. * @param right defines the second operand
  78899. * @param result defines the Color4 object where to store the result
  78900. * @returns the current Color4 object
  78901. */
  78902. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78903. /**
  78904. * Creates a new Color4 with the current Color4 values multiplied by scale
  78905. * @param scale defines the scaling factor to apply
  78906. * @returns a new Color4 object
  78907. */
  78908. scale(scale: number): Color4;
  78909. /**
  78910. * Multiplies the current Color4 values by scale and stores the result in "result"
  78911. * @param scale defines the scaling factor to apply
  78912. * @param result defines the Color4 object where to store the result
  78913. * @returns the current unmodified Color4
  78914. */
  78915. scaleToRef(scale: number, result: Color4): Color4;
  78916. /**
  78917. * Scale the current Color4 values by a factor and add the result to a given Color4
  78918. * @param scale defines the scale factor
  78919. * @param result defines the Color4 object where to store the result
  78920. * @returns the unmodified current Color4
  78921. */
  78922. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78923. /**
  78924. * Clamps the rgb values by the min and max values and stores the result into "result"
  78925. * @param min defines minimum clamping value (default is 0)
  78926. * @param max defines maximum clamping value (default is 1)
  78927. * @param result defines color to store the result into.
  78928. * @returns the cuurent Color4
  78929. */
  78930. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78931. /**
  78932. * Multipy an Color4 value by another and return a new Color4 object
  78933. * @param color defines the Color4 value to multiply by
  78934. * @returns a new Color4 object
  78935. */
  78936. multiply(color: Color4): Color4;
  78937. /**
  78938. * Multipy a Color4 value by another and push the result in a reference value
  78939. * @param color defines the Color4 value to multiply by
  78940. * @param result defines the Color4 to fill the result in
  78941. * @returns the result Color4
  78942. */
  78943. multiplyToRef(color: Color4, result: Color4): Color4;
  78944. /**
  78945. * Creates a string with the Color4 current values
  78946. * @returns the string representation of the Color4 object
  78947. */
  78948. toString(): string;
  78949. /**
  78950. * Returns the string "Color4"
  78951. * @returns "Color4"
  78952. */
  78953. getClassName(): string;
  78954. /**
  78955. * Compute the Color4 hash code
  78956. * @returns an unique number that can be used to hash Color4 objects
  78957. */
  78958. getHashCode(): number;
  78959. /**
  78960. * Creates a new Color4 copied from the current one
  78961. * @returns a new Color4 object
  78962. */
  78963. clone(): Color4;
  78964. /**
  78965. * Copies the given Color4 values into the current one
  78966. * @param source defines the source Color4 object
  78967. * @returns the current updated Color4 object
  78968. */
  78969. copyFrom(source: Color4): Color4;
  78970. /**
  78971. * Copies the given float values into the current one
  78972. * @param r defines the red component to read from
  78973. * @param g defines the green component to read from
  78974. * @param b defines the blue component to read from
  78975. * @param a defines the alpha component to read from
  78976. * @returns the current updated Color4 object
  78977. */
  78978. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78979. /**
  78980. * Copies the given float values into the current one
  78981. * @param r defines the red component to read from
  78982. * @param g defines the green component to read from
  78983. * @param b defines the blue component to read from
  78984. * @param a defines the alpha component to read from
  78985. * @returns the current updated Color4 object
  78986. */
  78987. set(r: number, g: number, b: number, a: number): Color4;
  78988. /**
  78989. * Compute the Color4 hexadecimal code as a string
  78990. * @returns a string containing the hexadecimal representation of the Color4 object
  78991. */
  78992. toHexString(): string;
  78993. /**
  78994. * Computes a new Color4 converted from the current one to linear space
  78995. * @returns a new Color4 object
  78996. */
  78997. toLinearSpace(): Color4;
  78998. /**
  78999. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79000. * @param convertedColor defines the Color4 object where to store the linear space version
  79001. * @returns the unmodified Color4
  79002. */
  79003. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79004. /**
  79005. * Computes a new Color4 converted from the current one to gamma space
  79006. * @returns a new Color4 object
  79007. */
  79008. toGammaSpace(): Color4;
  79009. /**
  79010. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79011. * @param convertedColor defines the Color4 object where to store the gamma space version
  79012. * @returns the unmodified Color4
  79013. */
  79014. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79015. /**
  79016. * Creates a new Color4 from the string containing valid hexadecimal values
  79017. * @param hex defines a string containing valid hexadecimal values
  79018. * @returns a new Color4 object
  79019. */
  79020. static FromHexString(hex: string): Color4;
  79021. /**
  79022. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79023. * @param left defines the start value
  79024. * @param right defines the end value
  79025. * @param amount defines the gradient factor
  79026. * @returns a new Color4 object
  79027. */
  79028. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79029. /**
  79030. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79031. * @param left defines the start value
  79032. * @param right defines the end value
  79033. * @param amount defines the gradient factor
  79034. * @param result defines the Color4 object where to store data
  79035. */
  79036. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79037. /**
  79038. * Creates a new Color4 from a Color3 and an alpha value
  79039. * @param color3 defines the source Color3 to read from
  79040. * @param alpha defines the alpha component (1.0 by default)
  79041. * @returns a new Color4 object
  79042. */
  79043. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79044. /**
  79045. * Creates a new Color4 from the starting index element of the given array
  79046. * @param array defines the source array to read from
  79047. * @param offset defines the offset in the source array
  79048. * @returns a new Color4 object
  79049. */
  79050. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79051. /**
  79052. * Creates a new Color3 from integer values (< 256)
  79053. * @param r defines the red component to read from (value between 0 and 255)
  79054. * @param g defines the green component to read from (value between 0 and 255)
  79055. * @param b defines the blue component to read from (value between 0 and 255)
  79056. * @param a defines the alpha component to read from (value between 0 and 255)
  79057. * @returns a new Color3 object
  79058. */
  79059. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79060. /**
  79061. * Check the content of a given array and convert it to an array containing RGBA data
  79062. * If the original array was already containing count * 4 values then it is returned directly
  79063. * @param colors defines the array to check
  79064. * @param count defines the number of RGBA data to expect
  79065. * @returns an array containing count * 4 values (RGBA)
  79066. */
  79067. static CheckColors4(colors: number[], count: number): number[];
  79068. }
  79069. /**
  79070. * @hidden
  79071. */
  79072. export class TmpColors {
  79073. static Color3: Color3[];
  79074. static Color4: Color4[];
  79075. }
  79076. }
  79077. declare module BABYLON {
  79078. /**
  79079. * Defines an interface which represents an animation key frame
  79080. */
  79081. export interface IAnimationKey {
  79082. /**
  79083. * Frame of the key frame
  79084. */
  79085. frame: number;
  79086. /**
  79087. * Value at the specifies key frame
  79088. */
  79089. value: any;
  79090. /**
  79091. * The input tangent for the cubic hermite spline
  79092. */
  79093. inTangent?: any;
  79094. /**
  79095. * The output tangent for the cubic hermite spline
  79096. */
  79097. outTangent?: any;
  79098. /**
  79099. * The animation interpolation type
  79100. */
  79101. interpolation?: AnimationKeyInterpolation;
  79102. }
  79103. /**
  79104. * Enum for the animation key frame interpolation type
  79105. */
  79106. export enum AnimationKeyInterpolation {
  79107. /**
  79108. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79109. */
  79110. STEP = 1
  79111. }
  79112. }
  79113. declare module BABYLON {
  79114. /**
  79115. * Represents the range of an animation
  79116. */
  79117. export class AnimationRange {
  79118. /**The name of the animation range**/
  79119. name: string;
  79120. /**The starting frame of the animation */
  79121. from: number;
  79122. /**The ending frame of the animation*/
  79123. to: number;
  79124. /**
  79125. * Initializes the range of an animation
  79126. * @param name The name of the animation range
  79127. * @param from The starting frame of the animation
  79128. * @param to The ending frame of the animation
  79129. */
  79130. constructor(
  79131. /**The name of the animation range**/
  79132. name: string,
  79133. /**The starting frame of the animation */
  79134. from: number,
  79135. /**The ending frame of the animation*/
  79136. to: number);
  79137. /**
  79138. * Makes a copy of the animation range
  79139. * @returns A copy of the animation range
  79140. */
  79141. clone(): AnimationRange;
  79142. }
  79143. }
  79144. declare module BABYLON {
  79145. /**
  79146. * Composed of a frame, and an action function
  79147. */
  79148. export class AnimationEvent {
  79149. /** The frame for which the event is triggered **/
  79150. frame: number;
  79151. /** The event to perform when triggered **/
  79152. action: (currentFrame: number) => void;
  79153. /** Specifies if the event should be triggered only once**/
  79154. onlyOnce?: boolean | undefined;
  79155. /**
  79156. * Specifies if the animation event is done
  79157. */
  79158. isDone: boolean;
  79159. /**
  79160. * Initializes the animation event
  79161. * @param frame The frame for which the event is triggered
  79162. * @param action The event to perform when triggered
  79163. * @param onlyOnce Specifies if the event should be triggered only once
  79164. */
  79165. constructor(
  79166. /** The frame for which the event is triggered **/
  79167. frame: number,
  79168. /** The event to perform when triggered **/
  79169. action: (currentFrame: number) => void,
  79170. /** Specifies if the event should be triggered only once**/
  79171. onlyOnce?: boolean | undefined);
  79172. /** @hidden */
  79173. _clone(): AnimationEvent;
  79174. }
  79175. }
  79176. declare module BABYLON {
  79177. /**
  79178. * Interface used to define a behavior
  79179. */
  79180. export interface Behavior<T> {
  79181. /** gets or sets behavior's name */
  79182. name: string;
  79183. /**
  79184. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79185. */
  79186. init(): void;
  79187. /**
  79188. * Called when the behavior is attached to a target
  79189. * @param target defines the target where the behavior is attached to
  79190. */
  79191. attach(target: T): void;
  79192. /**
  79193. * Called when the behavior is detached from its target
  79194. */
  79195. detach(): void;
  79196. }
  79197. /**
  79198. * Interface implemented by classes supporting behaviors
  79199. */
  79200. export interface IBehaviorAware<T> {
  79201. /**
  79202. * Attach a behavior
  79203. * @param behavior defines the behavior to attach
  79204. * @returns the current host
  79205. */
  79206. addBehavior(behavior: Behavior<T>): T;
  79207. /**
  79208. * Remove a behavior from the current object
  79209. * @param behavior defines the behavior to detach
  79210. * @returns the current host
  79211. */
  79212. removeBehavior(behavior: Behavior<T>): T;
  79213. /**
  79214. * Gets a behavior using its name to search
  79215. * @param name defines the name to search
  79216. * @returns the behavior or null if not found
  79217. */
  79218. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79219. }
  79220. }
  79221. declare module BABYLON {
  79222. /**
  79223. * Defines an array and its length.
  79224. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79225. */
  79226. export interface ISmartArrayLike<T> {
  79227. /**
  79228. * The data of the array.
  79229. */
  79230. data: Array<T>;
  79231. /**
  79232. * The active length of the array.
  79233. */
  79234. length: number;
  79235. }
  79236. /**
  79237. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79238. */
  79239. export class SmartArray<T> implements ISmartArrayLike<T> {
  79240. /**
  79241. * The full set of data from the array.
  79242. */
  79243. data: Array<T>;
  79244. /**
  79245. * The active length of the array.
  79246. */
  79247. length: number;
  79248. protected _id: number;
  79249. /**
  79250. * Instantiates a Smart Array.
  79251. * @param capacity defines the default capacity of the array.
  79252. */
  79253. constructor(capacity: number);
  79254. /**
  79255. * Pushes a value at the end of the active data.
  79256. * @param value defines the object to push in the array.
  79257. */
  79258. push(value: T): void;
  79259. /**
  79260. * Iterates over the active data and apply the lambda to them.
  79261. * @param func defines the action to apply on each value.
  79262. */
  79263. forEach(func: (content: T) => void): void;
  79264. /**
  79265. * Sorts the full sets of data.
  79266. * @param compareFn defines the comparison function to apply.
  79267. */
  79268. sort(compareFn: (a: T, b: T) => number): void;
  79269. /**
  79270. * Resets the active data to an empty array.
  79271. */
  79272. reset(): void;
  79273. /**
  79274. * Releases all the data from the array as well as the array.
  79275. */
  79276. dispose(): void;
  79277. /**
  79278. * Concats the active data with a given array.
  79279. * @param array defines the data to concatenate with.
  79280. */
  79281. concat(array: any): void;
  79282. /**
  79283. * Returns the position of a value in the active data.
  79284. * @param value defines the value to find the index for
  79285. * @returns the index if found in the active data otherwise -1
  79286. */
  79287. indexOf(value: T): number;
  79288. /**
  79289. * Returns whether an element is part of the active data.
  79290. * @param value defines the value to look for
  79291. * @returns true if found in the active data otherwise false
  79292. */
  79293. contains(value: T): boolean;
  79294. private static _GlobalId;
  79295. }
  79296. /**
  79297. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79298. * The data in this array can only be present once
  79299. */
  79300. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79301. private _duplicateId;
  79302. /**
  79303. * Pushes a value at the end of the active data.
  79304. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79305. * @param value defines the object to push in the array.
  79306. */
  79307. push(value: T): void;
  79308. /**
  79309. * Pushes a value at the end of the active data.
  79310. * If the data is already present, it won t be added again
  79311. * @param value defines the object to push in the array.
  79312. * @returns true if added false if it was already present
  79313. */
  79314. pushNoDuplicate(value: T): boolean;
  79315. /**
  79316. * Resets the active data to an empty array.
  79317. */
  79318. reset(): void;
  79319. /**
  79320. * Concats the active data with a given array.
  79321. * This ensures no dupplicate will be present in the result.
  79322. * @param array defines the data to concatenate with.
  79323. */
  79324. concatWithNoDuplicate(array: any): void;
  79325. }
  79326. }
  79327. declare module BABYLON {
  79328. /**
  79329. * @ignore
  79330. * This is a list of all the different input types that are available in the application.
  79331. * Fo instance: ArcRotateCameraGamepadInput...
  79332. */
  79333. export var CameraInputTypes: {};
  79334. /**
  79335. * This is the contract to implement in order to create a new input class.
  79336. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79337. */
  79338. export interface ICameraInput<TCamera extends Camera> {
  79339. /**
  79340. * Defines the camera the input is attached to.
  79341. */
  79342. camera: Nullable<TCamera>;
  79343. /**
  79344. * Gets the class name of the current intput.
  79345. * @returns the class name
  79346. */
  79347. getClassName(): string;
  79348. /**
  79349. * Get the friendly name associated with the input class.
  79350. * @returns the input friendly name
  79351. */
  79352. getSimpleName(): string;
  79353. /**
  79354. * Attach the input controls to a specific dom element to get the input from.
  79355. * @param element Defines the element the controls should be listened from
  79356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79357. */
  79358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79359. /**
  79360. * Detach the current controls from the specified dom element.
  79361. * @param element Defines the element to stop listening the inputs from
  79362. */
  79363. detachControl(element: Nullable<HTMLElement>): void;
  79364. /**
  79365. * Update the current camera state depending on the inputs that have been used this frame.
  79366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79367. */
  79368. checkInputs?: () => void;
  79369. }
  79370. /**
  79371. * Represents a map of input types to input instance or input index to input instance.
  79372. */
  79373. export interface CameraInputsMap<TCamera extends Camera> {
  79374. /**
  79375. * Accessor to the input by input type.
  79376. */
  79377. [name: string]: ICameraInput<TCamera>;
  79378. /**
  79379. * Accessor to the input by input index.
  79380. */
  79381. [idx: number]: ICameraInput<TCamera>;
  79382. }
  79383. /**
  79384. * This represents the input manager used within a camera.
  79385. * It helps dealing with all the different kind of input attached to a camera.
  79386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79387. */
  79388. export class CameraInputsManager<TCamera extends Camera> {
  79389. /**
  79390. * Defines the list of inputs attahed to the camera.
  79391. */
  79392. attached: CameraInputsMap<TCamera>;
  79393. /**
  79394. * Defines the dom element the camera is collecting inputs from.
  79395. * This is null if the controls have not been attached.
  79396. */
  79397. attachedElement: Nullable<HTMLElement>;
  79398. /**
  79399. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79400. */
  79401. noPreventDefault: boolean;
  79402. /**
  79403. * Defined the camera the input manager belongs to.
  79404. */
  79405. camera: TCamera;
  79406. /**
  79407. * Update the current camera state depending on the inputs that have been used this frame.
  79408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79409. */
  79410. checkInputs: () => void;
  79411. /**
  79412. * Instantiate a new Camera Input Manager.
  79413. * @param camera Defines the camera the input manager blongs to
  79414. */
  79415. constructor(camera: TCamera);
  79416. /**
  79417. * Add an input method to a camera
  79418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79419. * @param input camera input method
  79420. */
  79421. add(input: ICameraInput<TCamera>): void;
  79422. /**
  79423. * Remove a specific input method from a camera
  79424. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79425. * @param inputToRemove camera input method
  79426. */
  79427. remove(inputToRemove: ICameraInput<TCamera>): void;
  79428. /**
  79429. * Remove a specific input type from a camera
  79430. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79431. * @param inputType the type of the input to remove
  79432. */
  79433. removeByType(inputType: string): void;
  79434. private _addCheckInputs;
  79435. /**
  79436. * Attach the input controls to the currently attached dom element to listen the events from.
  79437. * @param input Defines the input to attach
  79438. */
  79439. attachInput(input: ICameraInput<TCamera>): void;
  79440. /**
  79441. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79442. * @param element Defines the dom element to collect the events from
  79443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79444. */
  79445. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79446. /**
  79447. * Detach the current manager inputs controls from a specific dom element.
  79448. * @param element Defines the dom element to collect the events from
  79449. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79450. */
  79451. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79452. /**
  79453. * Rebuild the dynamic inputCheck function from the current list of
  79454. * defined inputs in the manager.
  79455. */
  79456. rebuildInputCheck(): void;
  79457. /**
  79458. * Remove all attached input methods from a camera
  79459. */
  79460. clear(): void;
  79461. /**
  79462. * Serialize the current input manager attached to a camera.
  79463. * This ensures than once parsed,
  79464. * the input associated to the camera will be identical to the current ones
  79465. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79466. */
  79467. serialize(serializedCamera: any): void;
  79468. /**
  79469. * Parses an input manager serialized JSON to restore the previous list of inputs
  79470. * and states associated to a camera.
  79471. * @param parsedCamera Defines the JSON to parse
  79472. */
  79473. parse(parsedCamera: any): void;
  79474. }
  79475. }
  79476. declare module BABYLON {
  79477. /**
  79478. * Class used to store data that will be store in GPU memory
  79479. */
  79480. export class Buffer {
  79481. private _engine;
  79482. private _buffer;
  79483. /** @hidden */
  79484. _data: Nullable<DataArray>;
  79485. private _updatable;
  79486. private _instanced;
  79487. private _divisor;
  79488. /**
  79489. * Gets the byte stride.
  79490. */
  79491. readonly byteStride: number;
  79492. /**
  79493. * Constructor
  79494. * @param engine the engine
  79495. * @param data the data to use for this buffer
  79496. * @param updatable whether the data is updatable
  79497. * @param stride the stride (optional)
  79498. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79499. * @param instanced whether the buffer is instanced (optional)
  79500. * @param useBytes set to true if the stride in in bytes (optional)
  79501. * @param divisor sets an optional divisor for instances (1 by default)
  79502. */
  79503. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79504. /**
  79505. * Create a new VertexBuffer based on the current buffer
  79506. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79507. * @param offset defines offset in the buffer (0 by default)
  79508. * @param size defines the size in floats of attributes (position is 3 for instance)
  79509. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79510. * @param instanced defines if the vertex buffer contains indexed data
  79511. * @param useBytes defines if the offset and stride are in bytes *
  79512. * @param divisor sets an optional divisor for instances (1 by default)
  79513. * @returns the new vertex buffer
  79514. */
  79515. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79516. /**
  79517. * Gets a boolean indicating if the Buffer is updatable?
  79518. * @returns true if the buffer is updatable
  79519. */
  79520. isUpdatable(): boolean;
  79521. /**
  79522. * Gets current buffer's data
  79523. * @returns a DataArray or null
  79524. */
  79525. getData(): Nullable<DataArray>;
  79526. /**
  79527. * Gets underlying native buffer
  79528. * @returns underlying native buffer
  79529. */
  79530. getBuffer(): Nullable<DataBuffer>;
  79531. /**
  79532. * Gets the stride in float32 units (i.e. byte stride / 4).
  79533. * May not be an integer if the byte stride is not divisible by 4.
  79534. * @returns the stride in float32 units
  79535. * @deprecated Please use byteStride instead.
  79536. */
  79537. getStrideSize(): number;
  79538. /**
  79539. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79540. * @param data defines the data to store
  79541. */
  79542. create(data?: Nullable<DataArray>): void;
  79543. /** @hidden */
  79544. _rebuild(): void;
  79545. /**
  79546. * Update current buffer data
  79547. * @param data defines the data to store
  79548. */
  79549. update(data: DataArray): void;
  79550. /**
  79551. * Updates the data directly.
  79552. * @param data the new data
  79553. * @param offset the new offset
  79554. * @param vertexCount the vertex count (optional)
  79555. * @param useBytes set to true if the offset is in bytes
  79556. */
  79557. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79558. /**
  79559. * Release all resources
  79560. */
  79561. dispose(): void;
  79562. }
  79563. /**
  79564. * Specialized buffer used to store vertex data
  79565. */
  79566. export class VertexBuffer {
  79567. /** @hidden */
  79568. _buffer: Buffer;
  79569. private _kind;
  79570. private _size;
  79571. private _ownsBuffer;
  79572. private _instanced;
  79573. private _instanceDivisor;
  79574. /**
  79575. * The byte type.
  79576. */
  79577. static readonly BYTE: number;
  79578. /**
  79579. * The unsigned byte type.
  79580. */
  79581. static readonly UNSIGNED_BYTE: number;
  79582. /**
  79583. * The short type.
  79584. */
  79585. static readonly SHORT: number;
  79586. /**
  79587. * The unsigned short type.
  79588. */
  79589. static readonly UNSIGNED_SHORT: number;
  79590. /**
  79591. * The integer type.
  79592. */
  79593. static readonly INT: number;
  79594. /**
  79595. * The unsigned integer type.
  79596. */
  79597. static readonly UNSIGNED_INT: number;
  79598. /**
  79599. * The float type.
  79600. */
  79601. static readonly FLOAT: number;
  79602. /**
  79603. * Gets or sets the instance divisor when in instanced mode
  79604. */
  79605. get instanceDivisor(): number;
  79606. set instanceDivisor(value: number);
  79607. /**
  79608. * Gets the byte stride.
  79609. */
  79610. readonly byteStride: number;
  79611. /**
  79612. * Gets the byte offset.
  79613. */
  79614. readonly byteOffset: number;
  79615. /**
  79616. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79617. */
  79618. readonly normalized: boolean;
  79619. /**
  79620. * Gets the data type of each component in the array.
  79621. */
  79622. readonly type: number;
  79623. /**
  79624. * Constructor
  79625. * @param engine the engine
  79626. * @param data the data to use for this vertex buffer
  79627. * @param kind the vertex buffer kind
  79628. * @param updatable whether the data is updatable
  79629. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79630. * @param stride the stride (optional)
  79631. * @param instanced whether the buffer is instanced (optional)
  79632. * @param offset the offset of the data (optional)
  79633. * @param size the number of components (optional)
  79634. * @param type the type of the component (optional)
  79635. * @param normalized whether the data contains normalized data (optional)
  79636. * @param useBytes set to true if stride and offset are in bytes (optional)
  79637. * @param divisor defines the instance divisor to use (1 by default)
  79638. */
  79639. 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);
  79640. /** @hidden */
  79641. _rebuild(): void;
  79642. /**
  79643. * Returns the kind of the VertexBuffer (string)
  79644. * @returns a string
  79645. */
  79646. getKind(): string;
  79647. /**
  79648. * Gets a boolean indicating if the VertexBuffer is updatable?
  79649. * @returns true if the buffer is updatable
  79650. */
  79651. isUpdatable(): boolean;
  79652. /**
  79653. * Gets current buffer's data
  79654. * @returns a DataArray or null
  79655. */
  79656. getData(): Nullable<DataArray>;
  79657. /**
  79658. * Gets underlying native buffer
  79659. * @returns underlying native buffer
  79660. */
  79661. getBuffer(): Nullable<DataBuffer>;
  79662. /**
  79663. * Gets the stride in float32 units (i.e. byte stride / 4).
  79664. * May not be an integer if the byte stride is not divisible by 4.
  79665. * @returns the stride in float32 units
  79666. * @deprecated Please use byteStride instead.
  79667. */
  79668. getStrideSize(): number;
  79669. /**
  79670. * Returns the offset as a multiple of the type byte length.
  79671. * @returns the offset in bytes
  79672. * @deprecated Please use byteOffset instead.
  79673. */
  79674. getOffset(): number;
  79675. /**
  79676. * Returns the number of components per vertex attribute (integer)
  79677. * @returns the size in float
  79678. */
  79679. getSize(): number;
  79680. /**
  79681. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79682. * @returns true if this buffer is instanced
  79683. */
  79684. getIsInstanced(): boolean;
  79685. /**
  79686. * Returns the instancing divisor, zero for non-instanced (integer).
  79687. * @returns a number
  79688. */
  79689. getInstanceDivisor(): number;
  79690. /**
  79691. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79692. * @param data defines the data to store
  79693. */
  79694. create(data?: DataArray): void;
  79695. /**
  79696. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79697. * This function will create a new buffer if the current one is not updatable
  79698. * @param data defines the data to store
  79699. */
  79700. update(data: DataArray): void;
  79701. /**
  79702. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79703. * Returns the directly updated WebGLBuffer.
  79704. * @param data the new data
  79705. * @param offset the new offset
  79706. * @param useBytes set to true if the offset is in bytes
  79707. */
  79708. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79709. /**
  79710. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79711. */
  79712. dispose(): void;
  79713. /**
  79714. * Enumerates each value of this vertex buffer as numbers.
  79715. * @param count the number of values to enumerate
  79716. * @param callback the callback function called for each value
  79717. */
  79718. forEach(count: number, callback: (value: number, index: number) => void): void;
  79719. /**
  79720. * Positions
  79721. */
  79722. static readonly PositionKind: string;
  79723. /**
  79724. * Normals
  79725. */
  79726. static readonly NormalKind: string;
  79727. /**
  79728. * Tangents
  79729. */
  79730. static readonly TangentKind: string;
  79731. /**
  79732. * Texture coordinates
  79733. */
  79734. static readonly UVKind: string;
  79735. /**
  79736. * Texture coordinates 2
  79737. */
  79738. static readonly UV2Kind: string;
  79739. /**
  79740. * Texture coordinates 3
  79741. */
  79742. static readonly UV3Kind: string;
  79743. /**
  79744. * Texture coordinates 4
  79745. */
  79746. static readonly UV4Kind: string;
  79747. /**
  79748. * Texture coordinates 5
  79749. */
  79750. static readonly UV5Kind: string;
  79751. /**
  79752. * Texture coordinates 6
  79753. */
  79754. static readonly UV6Kind: string;
  79755. /**
  79756. * Colors
  79757. */
  79758. static readonly ColorKind: string;
  79759. /**
  79760. * Matrix indices (for bones)
  79761. */
  79762. static readonly MatricesIndicesKind: string;
  79763. /**
  79764. * Matrix weights (for bones)
  79765. */
  79766. static readonly MatricesWeightsKind: string;
  79767. /**
  79768. * Additional matrix indices (for bones)
  79769. */
  79770. static readonly MatricesIndicesExtraKind: string;
  79771. /**
  79772. * Additional matrix weights (for bones)
  79773. */
  79774. static readonly MatricesWeightsExtraKind: string;
  79775. /**
  79776. * Deduces the stride given a kind.
  79777. * @param kind The kind string to deduce
  79778. * @returns The deduced stride
  79779. */
  79780. static DeduceStride(kind: string): number;
  79781. /**
  79782. * Gets the byte length of the given type.
  79783. * @param type the type
  79784. * @returns the number of bytes
  79785. */
  79786. static GetTypeByteLength(type: number): number;
  79787. /**
  79788. * Enumerates each value of the given parameters as numbers.
  79789. * @param data the data to enumerate
  79790. * @param byteOffset the byte offset of the data
  79791. * @param byteStride the byte stride of the data
  79792. * @param componentCount the number of components per element
  79793. * @param componentType the type of the component
  79794. * @param count the number of values to enumerate
  79795. * @param normalized whether the data is normalized
  79796. * @param callback the callback function called for each value
  79797. */
  79798. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79799. private static _GetFloatValue;
  79800. }
  79801. }
  79802. declare module BABYLON {
  79803. /**
  79804. * @hidden
  79805. */
  79806. export class IntersectionInfo {
  79807. bu: Nullable<number>;
  79808. bv: Nullable<number>;
  79809. distance: number;
  79810. faceId: number;
  79811. subMeshId: number;
  79812. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79813. }
  79814. }
  79815. declare module BABYLON {
  79816. /**
  79817. * Represens a plane by the equation ax + by + cz + d = 0
  79818. */
  79819. export class Plane {
  79820. private static _TmpMatrix;
  79821. /**
  79822. * Normal of the plane (a,b,c)
  79823. */
  79824. normal: Vector3;
  79825. /**
  79826. * d component of the plane
  79827. */
  79828. d: number;
  79829. /**
  79830. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79831. * @param a a component of the plane
  79832. * @param b b component of the plane
  79833. * @param c c component of the plane
  79834. * @param d d component of the plane
  79835. */
  79836. constructor(a: number, b: number, c: number, d: number);
  79837. /**
  79838. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79839. */
  79840. asArray(): number[];
  79841. /**
  79842. * @returns a new plane copied from the current Plane.
  79843. */
  79844. clone(): Plane;
  79845. /**
  79846. * @returns the string "Plane".
  79847. */
  79848. getClassName(): string;
  79849. /**
  79850. * @returns the Plane hash code.
  79851. */
  79852. getHashCode(): number;
  79853. /**
  79854. * Normalize the current Plane in place.
  79855. * @returns the updated Plane.
  79856. */
  79857. normalize(): Plane;
  79858. /**
  79859. * Applies a transformation the plane and returns the result
  79860. * @param transformation the transformation matrix to be applied to the plane
  79861. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79862. */
  79863. transform(transformation: DeepImmutable<Matrix>): Plane;
  79864. /**
  79865. * Calcualtte the dot product between the point and the plane normal
  79866. * @param point point to calculate the dot product with
  79867. * @returns the dot product (float) of the point coordinates and the plane normal.
  79868. */
  79869. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79870. /**
  79871. * Updates the current Plane from the plane defined by the three given points.
  79872. * @param point1 one of the points used to contruct the plane
  79873. * @param point2 one of the points used to contruct the plane
  79874. * @param point3 one of the points used to contruct the plane
  79875. * @returns the updated Plane.
  79876. */
  79877. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79878. /**
  79879. * Checks if the plane is facing a given direction
  79880. * @param direction the direction to check if the plane is facing
  79881. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79882. * @returns True is the vector "direction" is the same side than the plane normal.
  79883. */
  79884. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79885. /**
  79886. * Calculates the distance to a point
  79887. * @param point point to calculate distance to
  79888. * @returns the signed distance (float) from the given point to the Plane.
  79889. */
  79890. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79891. /**
  79892. * Creates a plane from an array
  79893. * @param array the array to create a plane from
  79894. * @returns a new Plane from the given array.
  79895. */
  79896. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79897. /**
  79898. * Creates a plane from three points
  79899. * @param point1 point used to create the plane
  79900. * @param point2 point used to create the plane
  79901. * @param point3 point used to create the plane
  79902. * @returns a new Plane defined by the three given points.
  79903. */
  79904. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79905. /**
  79906. * Creates a plane from an origin point and a normal
  79907. * @param origin origin of the plane to be constructed
  79908. * @param normal normal of the plane to be constructed
  79909. * @returns a new Plane the normal vector to this plane at the given origin point.
  79910. * Note : the vector "normal" is updated because normalized.
  79911. */
  79912. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79913. /**
  79914. * Calculates the distance from a plane and a point
  79915. * @param origin origin of the plane to be constructed
  79916. * @param normal normal of the plane to be constructed
  79917. * @param point point to calculate distance to
  79918. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79919. */
  79920. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79921. }
  79922. }
  79923. declare module BABYLON {
  79924. /**
  79925. * Class used to store bounding sphere information
  79926. */
  79927. export class BoundingSphere {
  79928. /**
  79929. * Gets the center of the bounding sphere in local space
  79930. */
  79931. readonly center: Vector3;
  79932. /**
  79933. * Radius of the bounding sphere in local space
  79934. */
  79935. radius: number;
  79936. /**
  79937. * Gets the center of the bounding sphere in world space
  79938. */
  79939. readonly centerWorld: Vector3;
  79940. /**
  79941. * Radius of the bounding sphere in world space
  79942. */
  79943. radiusWorld: number;
  79944. /**
  79945. * Gets the minimum vector in local space
  79946. */
  79947. readonly minimum: Vector3;
  79948. /**
  79949. * Gets the maximum vector in local space
  79950. */
  79951. readonly maximum: Vector3;
  79952. private _worldMatrix;
  79953. private static readonly TmpVector3;
  79954. /**
  79955. * Creates a new bounding sphere
  79956. * @param min defines the minimum vector (in local space)
  79957. * @param max defines the maximum vector (in local space)
  79958. * @param worldMatrix defines the new world matrix
  79959. */
  79960. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79961. /**
  79962. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79963. * @param min defines the new minimum vector (in local space)
  79964. * @param max defines the new maximum vector (in local space)
  79965. * @param worldMatrix defines the new world matrix
  79966. */
  79967. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79968. /**
  79969. * Scale the current bounding sphere by applying a scale factor
  79970. * @param factor defines the scale factor to apply
  79971. * @returns the current bounding box
  79972. */
  79973. scale(factor: number): BoundingSphere;
  79974. /**
  79975. * Gets the world matrix of the bounding box
  79976. * @returns a matrix
  79977. */
  79978. getWorldMatrix(): DeepImmutable<Matrix>;
  79979. /** @hidden */
  79980. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79981. /**
  79982. * Tests if the bounding sphere is intersecting the frustum planes
  79983. * @param frustumPlanes defines the frustum planes to test
  79984. * @returns true if there is an intersection
  79985. */
  79986. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79987. /**
  79988. * Tests if the bounding sphere center is in between the frustum planes.
  79989. * Used for optimistic fast inclusion.
  79990. * @param frustumPlanes defines the frustum planes to test
  79991. * @returns true if the sphere center is in between the frustum planes
  79992. */
  79993. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79994. /**
  79995. * Tests if a point is inside the bounding sphere
  79996. * @param point defines the point to test
  79997. * @returns true if the point is inside the bounding sphere
  79998. */
  79999. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80000. /**
  80001. * Checks if two sphere intersct
  80002. * @param sphere0 sphere 0
  80003. * @param sphere1 sphere 1
  80004. * @returns true if the speres intersect
  80005. */
  80006. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80007. }
  80008. }
  80009. declare module BABYLON {
  80010. /**
  80011. * Class used to store bounding box information
  80012. */
  80013. export class BoundingBox implements ICullable {
  80014. /**
  80015. * Gets the 8 vectors representing the bounding box in local space
  80016. */
  80017. readonly vectors: Vector3[];
  80018. /**
  80019. * Gets the center of the bounding box in local space
  80020. */
  80021. readonly center: Vector3;
  80022. /**
  80023. * Gets the center of the bounding box in world space
  80024. */
  80025. readonly centerWorld: Vector3;
  80026. /**
  80027. * Gets the extend size in local space
  80028. */
  80029. readonly extendSize: Vector3;
  80030. /**
  80031. * Gets the extend size in world space
  80032. */
  80033. readonly extendSizeWorld: Vector3;
  80034. /**
  80035. * Gets the OBB (object bounding box) directions
  80036. */
  80037. readonly directions: Vector3[];
  80038. /**
  80039. * Gets the 8 vectors representing the bounding box in world space
  80040. */
  80041. readonly vectorsWorld: Vector3[];
  80042. /**
  80043. * Gets the minimum vector in world space
  80044. */
  80045. readonly minimumWorld: Vector3;
  80046. /**
  80047. * Gets the maximum vector in world space
  80048. */
  80049. readonly maximumWorld: Vector3;
  80050. /**
  80051. * Gets the minimum vector in local space
  80052. */
  80053. readonly minimum: Vector3;
  80054. /**
  80055. * Gets the maximum vector in local space
  80056. */
  80057. readonly maximum: Vector3;
  80058. private _worldMatrix;
  80059. private static readonly TmpVector3;
  80060. /**
  80061. * @hidden
  80062. */
  80063. _tag: number;
  80064. /**
  80065. * Creates a new bounding box
  80066. * @param min defines the minimum vector (in local space)
  80067. * @param max defines the maximum vector (in local space)
  80068. * @param worldMatrix defines the new world matrix
  80069. */
  80070. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80071. /**
  80072. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80073. * @param min defines the new minimum vector (in local space)
  80074. * @param max defines the new maximum vector (in local space)
  80075. * @param worldMatrix defines the new world matrix
  80076. */
  80077. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80078. /**
  80079. * Scale the current bounding box by applying a scale factor
  80080. * @param factor defines the scale factor to apply
  80081. * @returns the current bounding box
  80082. */
  80083. scale(factor: number): BoundingBox;
  80084. /**
  80085. * Gets the world matrix of the bounding box
  80086. * @returns a matrix
  80087. */
  80088. getWorldMatrix(): DeepImmutable<Matrix>;
  80089. /** @hidden */
  80090. _update(world: DeepImmutable<Matrix>): void;
  80091. /**
  80092. * Tests if the bounding box is intersecting the frustum planes
  80093. * @param frustumPlanes defines the frustum planes to test
  80094. * @returns true if there is an intersection
  80095. */
  80096. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80097. /**
  80098. * Tests if the bounding box is entirely inside the frustum planes
  80099. * @param frustumPlanes defines the frustum planes to test
  80100. * @returns true if there is an inclusion
  80101. */
  80102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80103. /**
  80104. * Tests if a point is inside the bounding box
  80105. * @param point defines the point to test
  80106. * @returns true if the point is inside the bounding box
  80107. */
  80108. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80109. /**
  80110. * Tests if the bounding box intersects with a bounding sphere
  80111. * @param sphere defines the sphere to test
  80112. * @returns true if there is an intersection
  80113. */
  80114. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80115. /**
  80116. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80117. * @param min defines the min vector to use
  80118. * @param max defines the max vector to use
  80119. * @returns true if there is an intersection
  80120. */
  80121. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80122. /**
  80123. * Tests if two bounding boxes are intersections
  80124. * @param box0 defines the first box to test
  80125. * @param box1 defines the second box to test
  80126. * @returns true if there is an intersection
  80127. */
  80128. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80129. /**
  80130. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80131. * @param minPoint defines the minimum vector of the bounding box
  80132. * @param maxPoint defines the maximum vector of the bounding box
  80133. * @param sphereCenter defines the sphere center
  80134. * @param sphereRadius defines the sphere radius
  80135. * @returns true if there is an intersection
  80136. */
  80137. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80138. /**
  80139. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80140. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80141. * @param frustumPlanes defines the frustum planes to test
  80142. * @return true if there is an inclusion
  80143. */
  80144. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80145. /**
  80146. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80147. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80148. * @param frustumPlanes defines the frustum planes to test
  80149. * @return true if there is an intersection
  80150. */
  80151. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80152. }
  80153. }
  80154. declare module BABYLON {
  80155. /** @hidden */
  80156. export class Collider {
  80157. /** Define if a collision was found */
  80158. collisionFound: boolean;
  80159. /**
  80160. * Define last intersection point in local space
  80161. */
  80162. intersectionPoint: Vector3;
  80163. /**
  80164. * Define last collided mesh
  80165. */
  80166. collidedMesh: Nullable<AbstractMesh>;
  80167. private _collisionPoint;
  80168. private _planeIntersectionPoint;
  80169. private _tempVector;
  80170. private _tempVector2;
  80171. private _tempVector3;
  80172. private _tempVector4;
  80173. private _edge;
  80174. private _baseToVertex;
  80175. private _destinationPoint;
  80176. private _slidePlaneNormal;
  80177. private _displacementVector;
  80178. /** @hidden */
  80179. _radius: Vector3;
  80180. /** @hidden */
  80181. _retry: number;
  80182. private _velocity;
  80183. private _basePoint;
  80184. private _epsilon;
  80185. /** @hidden */
  80186. _velocityWorldLength: number;
  80187. /** @hidden */
  80188. _basePointWorld: Vector3;
  80189. private _velocityWorld;
  80190. private _normalizedVelocity;
  80191. /** @hidden */
  80192. _initialVelocity: Vector3;
  80193. /** @hidden */
  80194. _initialPosition: Vector3;
  80195. private _nearestDistance;
  80196. private _collisionMask;
  80197. get collisionMask(): number;
  80198. set collisionMask(mask: number);
  80199. /**
  80200. * Gets the plane normal used to compute the sliding response (in local space)
  80201. */
  80202. get slidePlaneNormal(): Vector3;
  80203. /** @hidden */
  80204. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80205. /** @hidden */
  80206. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80207. /** @hidden */
  80208. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80209. /** @hidden */
  80210. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80211. /** @hidden */
  80212. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80213. /** @hidden */
  80214. _getResponse(pos: Vector3, vel: Vector3): void;
  80215. }
  80216. }
  80217. declare module BABYLON {
  80218. /**
  80219. * Interface for cullable objects
  80220. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80221. */
  80222. export interface ICullable {
  80223. /**
  80224. * Checks if the object or part of the object is in the frustum
  80225. * @param frustumPlanes Camera near/planes
  80226. * @returns true if the object is in frustum otherwise false
  80227. */
  80228. isInFrustum(frustumPlanes: Plane[]): boolean;
  80229. /**
  80230. * Checks if a cullable object (mesh...) is in the camera frustum
  80231. * Unlike isInFrustum this cheks the full bounding box
  80232. * @param frustumPlanes Camera near/planes
  80233. * @returns true if the object is in frustum otherwise false
  80234. */
  80235. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80236. }
  80237. /**
  80238. * Info for a bounding data of a mesh
  80239. */
  80240. export class BoundingInfo implements ICullable {
  80241. /**
  80242. * Bounding box for the mesh
  80243. */
  80244. readonly boundingBox: BoundingBox;
  80245. /**
  80246. * Bounding sphere for the mesh
  80247. */
  80248. readonly boundingSphere: BoundingSphere;
  80249. private _isLocked;
  80250. private static readonly TmpVector3;
  80251. /**
  80252. * Constructs bounding info
  80253. * @param minimum min vector of the bounding box/sphere
  80254. * @param maximum max vector of the bounding box/sphere
  80255. * @param worldMatrix defines the new world matrix
  80256. */
  80257. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80258. /**
  80259. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80260. * @param min defines the new minimum vector (in local space)
  80261. * @param max defines the new maximum vector (in local space)
  80262. * @param worldMatrix defines the new world matrix
  80263. */
  80264. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80265. /**
  80266. * min vector of the bounding box/sphere
  80267. */
  80268. get minimum(): Vector3;
  80269. /**
  80270. * max vector of the bounding box/sphere
  80271. */
  80272. get maximum(): Vector3;
  80273. /**
  80274. * If the info is locked and won't be updated to avoid perf overhead
  80275. */
  80276. get isLocked(): boolean;
  80277. set isLocked(value: boolean);
  80278. /**
  80279. * Updates the bounding sphere and box
  80280. * @param world world matrix to be used to update
  80281. */
  80282. update(world: DeepImmutable<Matrix>): void;
  80283. /**
  80284. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80285. * @param center New center of the bounding info
  80286. * @param extend New extend of the bounding info
  80287. * @returns the current bounding info
  80288. */
  80289. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80290. /**
  80291. * Scale the current bounding info by applying a scale factor
  80292. * @param factor defines the scale factor to apply
  80293. * @returns the current bounding info
  80294. */
  80295. scale(factor: number): BoundingInfo;
  80296. /**
  80297. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80298. * @param frustumPlanes defines the frustum to test
  80299. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80300. * @returns true if the bounding info is in the frustum planes
  80301. */
  80302. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80303. /**
  80304. * Gets the world distance between the min and max points of the bounding box
  80305. */
  80306. get diagonalLength(): number;
  80307. /**
  80308. * Checks if a cullable object (mesh...) is in the camera frustum
  80309. * Unlike isInFrustum this cheks the full bounding box
  80310. * @param frustumPlanes Camera near/planes
  80311. * @returns true if the object is in frustum otherwise false
  80312. */
  80313. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80314. /** @hidden */
  80315. _checkCollision(collider: Collider): boolean;
  80316. /**
  80317. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80318. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80319. * @param point the point to check intersection with
  80320. * @returns if the point intersects
  80321. */
  80322. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80323. /**
  80324. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80325. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80326. * @param boundingInfo the bounding info to check intersection with
  80327. * @param precise if the intersection should be done using OBB
  80328. * @returns if the bounding info intersects
  80329. */
  80330. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /**
  80335. * Extracts minimum and maximum values from a list of indexed positions
  80336. * @param positions defines the positions to use
  80337. * @param indices defines the indices to the positions
  80338. * @param indexStart defines the start index
  80339. * @param indexCount defines the end index
  80340. * @param bias defines bias value to add to the result
  80341. * @return minimum and maximum values
  80342. */
  80343. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80344. minimum: Vector3;
  80345. maximum: Vector3;
  80346. };
  80347. /**
  80348. * Extracts minimum and maximum values from a list of positions
  80349. * @param positions defines the positions to use
  80350. * @param start defines the start index in the positions array
  80351. * @param count defines the number of positions to handle
  80352. * @param bias defines bias value to add to the result
  80353. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80354. * @return minimum and maximum values
  80355. */
  80356. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80357. minimum: Vector3;
  80358. maximum: Vector3;
  80359. };
  80360. }
  80361. declare module BABYLON {
  80362. /** @hidden */
  80363. export class WebGLDataBuffer extends DataBuffer {
  80364. private _buffer;
  80365. constructor(resource: WebGLBuffer);
  80366. get underlyingResource(): any;
  80367. }
  80368. }
  80369. declare module BABYLON {
  80370. /** @hidden */
  80371. export class WebGLPipelineContext implements IPipelineContext {
  80372. engine: ThinEngine;
  80373. program: Nullable<WebGLProgram>;
  80374. context?: WebGLRenderingContext;
  80375. vertexShader?: WebGLShader;
  80376. fragmentShader?: WebGLShader;
  80377. isParallelCompiled: boolean;
  80378. onCompiled?: () => void;
  80379. transformFeedback?: WebGLTransformFeedback | null;
  80380. vertexCompilationError: Nullable<string>;
  80381. fragmentCompilationError: Nullable<string>;
  80382. programLinkError: Nullable<string>;
  80383. programValidationError: Nullable<string>;
  80384. get isAsync(): boolean;
  80385. get isReady(): boolean;
  80386. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80387. }
  80388. }
  80389. declare module BABYLON {
  80390. interface ThinEngine {
  80391. /**
  80392. * Create an uniform buffer
  80393. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80394. * @param elements defines the content of the uniform buffer
  80395. * @returns the webGL uniform buffer
  80396. */
  80397. createUniformBuffer(elements: FloatArray): DataBuffer;
  80398. /**
  80399. * Create a dynamic uniform buffer
  80400. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80401. * @param elements defines the content of the uniform buffer
  80402. * @returns the webGL uniform buffer
  80403. */
  80404. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80405. /**
  80406. * Update an existing uniform buffer
  80407. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80408. * @param uniformBuffer defines the target uniform buffer
  80409. * @param elements defines the content to update
  80410. * @param offset defines the offset in the uniform buffer where update should start
  80411. * @param count defines the size of the data to update
  80412. */
  80413. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80414. /**
  80415. * Bind an uniform buffer to the current webGL context
  80416. * @param buffer defines the buffer to bind
  80417. */
  80418. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80419. /**
  80420. * Bind a buffer to the current webGL context at a given location
  80421. * @param buffer defines the buffer to bind
  80422. * @param location defines the index where to bind the buffer
  80423. */
  80424. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80425. /**
  80426. * Bind a specific block at a given index in a specific shader program
  80427. * @param pipelineContext defines the pipeline context to use
  80428. * @param blockName defines the block name
  80429. * @param index defines the index where to bind the block
  80430. */
  80431. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80432. }
  80433. }
  80434. declare module BABYLON {
  80435. /**
  80436. * Uniform buffer objects.
  80437. *
  80438. * Handles blocks of uniform on the GPU.
  80439. *
  80440. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80441. *
  80442. * For more information, please refer to :
  80443. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80444. */
  80445. export class UniformBuffer {
  80446. private _engine;
  80447. private _buffer;
  80448. private _data;
  80449. private _bufferData;
  80450. private _dynamic?;
  80451. private _uniformLocations;
  80452. private _uniformSizes;
  80453. private _uniformLocationPointer;
  80454. private _needSync;
  80455. private _noUBO;
  80456. private _currentEffect;
  80457. /** @hidden */
  80458. _alreadyBound: boolean;
  80459. private static _MAX_UNIFORM_SIZE;
  80460. private static _tempBuffer;
  80461. /**
  80462. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80463. * This is dynamic to allow compat with webgl 1 and 2.
  80464. * You will need to pass the name of the uniform as well as the value.
  80465. */
  80466. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80467. /**
  80468. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80469. * This is dynamic to allow compat with webgl 1 and 2.
  80470. * You will need to pass the name of the uniform as well as the value.
  80471. */
  80472. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80473. /**
  80474. * Lambda to Update a single float in a uniform buffer.
  80475. * This is dynamic to allow compat with webgl 1 and 2.
  80476. * You will need to pass the name of the uniform as well as the value.
  80477. */
  80478. updateFloat: (name: string, x: number) => void;
  80479. /**
  80480. * Lambda to Update a vec2 of float in a uniform buffer.
  80481. * This is dynamic to allow compat with webgl 1 and 2.
  80482. * You will need to pass the name of the uniform as well as the value.
  80483. */
  80484. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80485. /**
  80486. * Lambda to Update a vec3 of float in a uniform buffer.
  80487. * This is dynamic to allow compat with webgl 1 and 2.
  80488. * You will need to pass the name of the uniform as well as the value.
  80489. */
  80490. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80491. /**
  80492. * Lambda to Update a vec4 of float in a uniform buffer.
  80493. * This is dynamic to allow compat with webgl 1 and 2.
  80494. * You will need to pass the name of the uniform as well as the value.
  80495. */
  80496. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80497. /**
  80498. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80499. * This is dynamic to allow compat with webgl 1 and 2.
  80500. * You will need to pass the name of the uniform as well as the value.
  80501. */
  80502. updateMatrix: (name: string, mat: Matrix) => void;
  80503. /**
  80504. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80505. * This is dynamic to allow compat with webgl 1 and 2.
  80506. * You will need to pass the name of the uniform as well as the value.
  80507. */
  80508. updateVector3: (name: string, vector: Vector3) => void;
  80509. /**
  80510. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80511. * This is dynamic to allow compat with webgl 1 and 2.
  80512. * You will need to pass the name of the uniform as well as the value.
  80513. */
  80514. updateVector4: (name: string, vector: Vector4) => void;
  80515. /**
  80516. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80517. * This is dynamic to allow compat with webgl 1 and 2.
  80518. * You will need to pass the name of the uniform as well as the value.
  80519. */
  80520. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80521. /**
  80522. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80523. * This is dynamic to allow compat with webgl 1 and 2.
  80524. * You will need to pass the name of the uniform as well as the value.
  80525. */
  80526. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80527. /**
  80528. * Instantiates a new Uniform buffer objects.
  80529. *
  80530. * Handles blocks of uniform on the GPU.
  80531. *
  80532. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80533. *
  80534. * For more information, please refer to :
  80535. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80536. * @param engine Define the engine the buffer is associated with
  80537. * @param data Define the data contained in the buffer
  80538. * @param dynamic Define if the buffer is updatable
  80539. */
  80540. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80541. /**
  80542. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80543. * or just falling back on setUniformXXX calls.
  80544. */
  80545. get useUbo(): boolean;
  80546. /**
  80547. * Indicates if the WebGL underlying uniform buffer is in sync
  80548. * with the javascript cache data.
  80549. */
  80550. get isSync(): boolean;
  80551. /**
  80552. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80553. * Also, a dynamic UniformBuffer will disable cache verification and always
  80554. * update the underlying WebGL uniform buffer to the GPU.
  80555. * @returns if Dynamic, otherwise false
  80556. */
  80557. isDynamic(): boolean;
  80558. /**
  80559. * The data cache on JS side.
  80560. * @returns the underlying data as a float array
  80561. */
  80562. getData(): Float32Array;
  80563. /**
  80564. * The underlying WebGL Uniform buffer.
  80565. * @returns the webgl buffer
  80566. */
  80567. getBuffer(): Nullable<DataBuffer>;
  80568. /**
  80569. * std140 layout specifies how to align data within an UBO structure.
  80570. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80571. * for specs.
  80572. */
  80573. private _fillAlignment;
  80574. /**
  80575. * Adds an uniform in the buffer.
  80576. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80577. * for the layout to be correct !
  80578. * @param name Name of the uniform, as used in the uniform block in the shader.
  80579. * @param size Data size, or data directly.
  80580. */
  80581. addUniform(name: string, size: number | number[]): void;
  80582. /**
  80583. * Adds a Matrix 4x4 to the uniform buffer.
  80584. * @param name Name of the uniform, as used in the uniform block in the shader.
  80585. * @param mat A 4x4 matrix.
  80586. */
  80587. addMatrix(name: string, mat: Matrix): void;
  80588. /**
  80589. * Adds a vec2 to the uniform buffer.
  80590. * @param name Name of the uniform, as used in the uniform block in the shader.
  80591. * @param x Define the x component value of the vec2
  80592. * @param y Define the y component value of the vec2
  80593. */
  80594. addFloat2(name: string, x: number, y: number): void;
  80595. /**
  80596. * Adds a vec3 to the uniform buffer.
  80597. * @param name Name of the uniform, as used in the uniform block in the shader.
  80598. * @param x Define the x component value of the vec3
  80599. * @param y Define the y component value of the vec3
  80600. * @param z Define the z component value of the vec3
  80601. */
  80602. addFloat3(name: string, x: number, y: number, z: number): void;
  80603. /**
  80604. * Adds a vec3 to the uniform buffer.
  80605. * @param name Name of the uniform, as used in the uniform block in the shader.
  80606. * @param color Define the vec3 from a Color
  80607. */
  80608. addColor3(name: string, color: Color3): void;
  80609. /**
  80610. * Adds a vec4 to the uniform buffer.
  80611. * @param name Name of the uniform, as used in the uniform block in the shader.
  80612. * @param color Define the rgb components from a Color
  80613. * @param alpha Define the a component of the vec4
  80614. */
  80615. addColor4(name: string, color: Color3, alpha: number): void;
  80616. /**
  80617. * Adds a vec3 to the uniform buffer.
  80618. * @param name Name of the uniform, as used in the uniform block in the shader.
  80619. * @param vector Define the vec3 components from a Vector
  80620. */
  80621. addVector3(name: string, vector: Vector3): void;
  80622. /**
  80623. * Adds a Matrix 3x3 to the uniform buffer.
  80624. * @param name Name of the uniform, as used in the uniform block in the shader.
  80625. */
  80626. addMatrix3x3(name: string): void;
  80627. /**
  80628. * Adds a Matrix 2x2 to the uniform buffer.
  80629. * @param name Name of the uniform, as used in the uniform block in the shader.
  80630. */
  80631. addMatrix2x2(name: string): void;
  80632. /**
  80633. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80634. */
  80635. create(): void;
  80636. /** @hidden */
  80637. _rebuild(): void;
  80638. /**
  80639. * Updates the WebGL Uniform Buffer on the GPU.
  80640. * If the `dynamic` flag is set to true, no cache comparison is done.
  80641. * Otherwise, the buffer will be updated only if the cache differs.
  80642. */
  80643. update(): void;
  80644. /**
  80645. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80646. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80647. * @param data Define the flattened data
  80648. * @param size Define the size of the data.
  80649. */
  80650. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80651. private _valueCache;
  80652. private _cacheMatrix;
  80653. private _updateMatrix3x3ForUniform;
  80654. private _updateMatrix3x3ForEffect;
  80655. private _updateMatrix2x2ForEffect;
  80656. private _updateMatrix2x2ForUniform;
  80657. private _updateFloatForEffect;
  80658. private _updateFloatForUniform;
  80659. private _updateFloat2ForEffect;
  80660. private _updateFloat2ForUniform;
  80661. private _updateFloat3ForEffect;
  80662. private _updateFloat3ForUniform;
  80663. private _updateFloat4ForEffect;
  80664. private _updateFloat4ForUniform;
  80665. private _updateMatrixForEffect;
  80666. private _updateMatrixForUniform;
  80667. private _updateVector3ForEffect;
  80668. private _updateVector3ForUniform;
  80669. private _updateVector4ForEffect;
  80670. private _updateVector4ForUniform;
  80671. private _updateColor3ForEffect;
  80672. private _updateColor3ForUniform;
  80673. private _updateColor4ForEffect;
  80674. private _updateColor4ForUniform;
  80675. /**
  80676. * Sets a sampler uniform on the effect.
  80677. * @param name Define the name of the sampler.
  80678. * @param texture Define the texture to set in the sampler
  80679. */
  80680. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80681. /**
  80682. * Directly updates the value of the uniform in the cache AND on the GPU.
  80683. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80684. * @param data Define the flattened data
  80685. */
  80686. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80687. /**
  80688. * Binds this uniform buffer to an effect.
  80689. * @param effect Define the effect to bind the buffer to
  80690. * @param name Name of the uniform block in the shader.
  80691. */
  80692. bindToEffect(effect: Effect, name: string): void;
  80693. /**
  80694. * Disposes the uniform buffer.
  80695. */
  80696. dispose(): void;
  80697. }
  80698. }
  80699. declare module BABYLON {
  80700. /**
  80701. * Enum that determines the text-wrapping mode to use.
  80702. */
  80703. export enum InspectableType {
  80704. /**
  80705. * Checkbox for booleans
  80706. */
  80707. Checkbox = 0,
  80708. /**
  80709. * Sliders for numbers
  80710. */
  80711. Slider = 1,
  80712. /**
  80713. * Vector3
  80714. */
  80715. Vector3 = 2,
  80716. /**
  80717. * Quaternions
  80718. */
  80719. Quaternion = 3,
  80720. /**
  80721. * Color3
  80722. */
  80723. Color3 = 4,
  80724. /**
  80725. * String
  80726. */
  80727. String = 5
  80728. }
  80729. /**
  80730. * Interface used to define custom inspectable properties.
  80731. * This interface is used by the inspector to display custom property grids
  80732. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80733. */
  80734. export interface IInspectable {
  80735. /**
  80736. * Gets the label to display
  80737. */
  80738. label: string;
  80739. /**
  80740. * Gets the name of the property to edit
  80741. */
  80742. propertyName: string;
  80743. /**
  80744. * Gets the type of the editor to use
  80745. */
  80746. type: InspectableType;
  80747. /**
  80748. * Gets the minimum value of the property when using in "slider" mode
  80749. */
  80750. min?: number;
  80751. /**
  80752. * Gets the maximum value of the property when using in "slider" mode
  80753. */
  80754. max?: number;
  80755. /**
  80756. * Gets the setp to use when using in "slider" mode
  80757. */
  80758. step?: number;
  80759. }
  80760. }
  80761. declare module BABYLON {
  80762. /**
  80763. * Class used to provide helper for timing
  80764. */
  80765. export class TimingTools {
  80766. /**
  80767. * Polyfill for setImmediate
  80768. * @param action defines the action to execute after the current execution block
  80769. */
  80770. static SetImmediate(action: () => void): void;
  80771. }
  80772. }
  80773. declare module BABYLON {
  80774. /**
  80775. * Class used to enable instatition of objects by class name
  80776. */
  80777. export class InstantiationTools {
  80778. /**
  80779. * Use this object to register external classes like custom textures or material
  80780. * to allow the laoders to instantiate them
  80781. */
  80782. static RegisteredExternalClasses: {
  80783. [key: string]: Object;
  80784. };
  80785. /**
  80786. * Tries to instantiate a new object from a given class name
  80787. * @param className defines the class name to instantiate
  80788. * @returns the new object or null if the system was not able to do the instantiation
  80789. */
  80790. static Instantiate(className: string): any;
  80791. }
  80792. }
  80793. declare module BABYLON {
  80794. /**
  80795. * Define options used to create a depth texture
  80796. */
  80797. export class DepthTextureCreationOptions {
  80798. /** Specifies whether or not a stencil should be allocated in the texture */
  80799. generateStencil?: boolean;
  80800. /** Specifies whether or not bilinear filtering is enable on the texture */
  80801. bilinearFiltering?: boolean;
  80802. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80803. comparisonFunction?: number;
  80804. /** Specifies if the created texture is a cube texture */
  80805. isCube?: boolean;
  80806. }
  80807. }
  80808. declare module BABYLON {
  80809. interface ThinEngine {
  80810. /**
  80811. * Creates a depth stencil cube texture.
  80812. * This is only available in WebGL 2.
  80813. * @param size The size of face edge in the cube texture.
  80814. * @param options The options defining the cube texture.
  80815. * @returns The cube texture
  80816. */
  80817. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80818. /**
  80819. * Creates a cube texture
  80820. * @param rootUrl defines the url where the files to load is located
  80821. * @param scene defines the current scene
  80822. * @param files defines the list of files to load (1 per face)
  80823. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80824. * @param onLoad defines an optional callback raised when the texture is loaded
  80825. * @param onError defines an optional callback raised if there is an issue to load the texture
  80826. * @param format defines the format of the data
  80827. * @param forcedExtension defines the extension to use to pick the right loader
  80828. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80829. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80830. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80831. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80832. * @returns the cube texture as an InternalTexture
  80833. */
  80834. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  80835. /**
  80836. * Creates a cube texture
  80837. * @param rootUrl defines the url where the files to load is located
  80838. * @param scene defines the current scene
  80839. * @param files defines the list of files to load (1 per face)
  80840. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80841. * @param onLoad defines an optional callback raised when the texture is loaded
  80842. * @param onError defines an optional callback raised if there is an issue to load the texture
  80843. * @param format defines the format of the data
  80844. * @param forcedExtension defines the extension to use to pick the right loader
  80845. * @returns the cube texture as an InternalTexture
  80846. */
  80847. 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;
  80848. /**
  80849. * Creates a cube texture
  80850. * @param rootUrl defines the url where the files to load is located
  80851. * @param scene defines the current scene
  80852. * @param files defines the list of files to load (1 per face)
  80853. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80854. * @param onLoad defines an optional callback raised when the texture is loaded
  80855. * @param onError defines an optional callback raised if there is an issue to load the texture
  80856. * @param format defines the format of the data
  80857. * @param forcedExtension defines the extension to use to pick the right loader
  80858. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80859. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80860. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80861. * @returns the cube texture as an InternalTexture
  80862. */
  80863. 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;
  80864. /** @hidden */
  80865. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80866. /** @hidden */
  80867. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80868. /** @hidden */
  80869. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80870. /** @hidden */
  80871. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80872. /**
  80873. * @hidden
  80874. */
  80875. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80876. }
  80877. }
  80878. declare module BABYLON {
  80879. /**
  80880. * Class for creating a cube texture
  80881. */
  80882. export class CubeTexture extends BaseTexture {
  80883. private _delayedOnLoad;
  80884. /**
  80885. * Observable triggered once the texture has been loaded.
  80886. */
  80887. onLoadObservable: Observable<CubeTexture>;
  80888. /**
  80889. * The url of the texture
  80890. */
  80891. url: string;
  80892. /**
  80893. * Gets or sets the center of the bounding box associated with the cube texture.
  80894. * It must define where the camera used to render the texture was set
  80895. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80896. */
  80897. boundingBoxPosition: Vector3;
  80898. private _boundingBoxSize;
  80899. /**
  80900. * Gets or sets the size of the bounding box associated with the cube texture
  80901. * When defined, the cubemap will switch to local mode
  80902. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80903. * @example https://www.babylonjs-playground.com/#RNASML
  80904. */
  80905. set boundingBoxSize(value: Vector3);
  80906. /**
  80907. * Returns the bounding box size
  80908. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80909. */
  80910. get boundingBoxSize(): Vector3;
  80911. protected _rotationY: number;
  80912. /**
  80913. * Sets texture matrix rotation angle around Y axis in radians.
  80914. */
  80915. set rotationY(value: number);
  80916. /**
  80917. * Gets texture matrix rotation angle around Y axis radians.
  80918. */
  80919. get rotationY(): number;
  80920. /**
  80921. * Are mip maps generated for this texture or not.
  80922. */
  80923. get noMipmap(): boolean;
  80924. private _noMipmap;
  80925. private _files;
  80926. protected _forcedExtension: Nullable<string>;
  80927. private _extensions;
  80928. private _textureMatrix;
  80929. private _format;
  80930. private _createPolynomials;
  80931. /** @hidden */
  80932. _prefiltered: boolean;
  80933. /**
  80934. * Creates a cube texture from an array of image urls
  80935. * @param files defines an array of image urls
  80936. * @param scene defines the hosting scene
  80937. * @param noMipmap specifies if mip maps are not used
  80938. * @returns a cube texture
  80939. */
  80940. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80941. /**
  80942. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80943. * @param url defines the url of the prefiltered texture
  80944. * @param scene defines the scene the texture is attached to
  80945. * @param forcedExtension defines the extension of the file if different from the url
  80946. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80947. * @return the prefiltered texture
  80948. */
  80949. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80950. /**
  80951. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80952. * as prefiltered data.
  80953. * @param rootUrl defines the url of the texture or the root name of the six images
  80954. * @param scene defines the scene the texture is attached to
  80955. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80956. * @param noMipmap defines if mipmaps should be created or not
  80957. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80958. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80959. * @param onError defines a callback triggered in case of error during load
  80960. * @param format defines the internal format to use for the texture once loaded
  80961. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80962. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80963. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80964. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80965. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80966. * @return the cube texture
  80967. */
  80968. 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);
  80969. /**
  80970. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80971. */
  80972. get isPrefiltered(): boolean;
  80973. /**
  80974. * Get the current class name of the texture useful for serialization or dynamic coding.
  80975. * @returns "CubeTexture"
  80976. */
  80977. getClassName(): string;
  80978. /**
  80979. * Update the url (and optional buffer) of this texture if url was null during construction.
  80980. * @param url the url of the texture
  80981. * @param forcedExtension defines the extension to use
  80982. * @param onLoad callback called when the texture is loaded (defaults to null)
  80983. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80984. */
  80985. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80986. /**
  80987. * Delays loading of the cube texture
  80988. * @param forcedExtension defines the extension to use
  80989. */
  80990. delayLoad(forcedExtension?: string): void;
  80991. /**
  80992. * Returns the reflection texture matrix
  80993. * @returns the reflection texture matrix
  80994. */
  80995. getReflectionTextureMatrix(): Matrix;
  80996. /**
  80997. * Sets the reflection texture matrix
  80998. * @param value Reflection texture matrix
  80999. */
  81000. setReflectionTextureMatrix(value: Matrix): void;
  81001. /**
  81002. * Parses text to create a cube texture
  81003. * @param parsedTexture define the serialized text to read from
  81004. * @param scene defines the hosting scene
  81005. * @param rootUrl defines the root url of the cube texture
  81006. * @returns a cube texture
  81007. */
  81008. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81009. /**
  81010. * Makes a clone, or deep copy, of the cube texture
  81011. * @returns a new cube texture
  81012. */
  81013. clone(): CubeTexture;
  81014. }
  81015. }
  81016. declare module BABYLON {
  81017. /**
  81018. * Manages the defines for the Material
  81019. */
  81020. export class MaterialDefines {
  81021. /** @hidden */
  81022. protected _keys: string[];
  81023. private _isDirty;
  81024. /** @hidden */
  81025. _renderId: number;
  81026. /** @hidden */
  81027. _areLightsDirty: boolean;
  81028. /** @hidden */
  81029. _areLightsDisposed: boolean;
  81030. /** @hidden */
  81031. _areAttributesDirty: boolean;
  81032. /** @hidden */
  81033. _areTexturesDirty: boolean;
  81034. /** @hidden */
  81035. _areFresnelDirty: boolean;
  81036. /** @hidden */
  81037. _areMiscDirty: boolean;
  81038. /** @hidden */
  81039. _areImageProcessingDirty: boolean;
  81040. /** @hidden */
  81041. _normals: boolean;
  81042. /** @hidden */
  81043. _uvs: boolean;
  81044. /** @hidden */
  81045. _needNormals: boolean;
  81046. /** @hidden */
  81047. _needUVs: boolean;
  81048. [id: string]: any;
  81049. /**
  81050. * Specifies if the material needs to be re-calculated
  81051. */
  81052. get isDirty(): boolean;
  81053. /**
  81054. * Marks the material to indicate that it has been re-calculated
  81055. */
  81056. markAsProcessed(): void;
  81057. /**
  81058. * Marks the material to indicate that it needs to be re-calculated
  81059. */
  81060. markAsUnprocessed(): void;
  81061. /**
  81062. * Marks the material to indicate all of its defines need to be re-calculated
  81063. */
  81064. markAllAsDirty(): void;
  81065. /**
  81066. * Marks the material to indicate that image processing needs to be re-calculated
  81067. */
  81068. markAsImageProcessingDirty(): void;
  81069. /**
  81070. * Marks the material to indicate the lights need to be re-calculated
  81071. * @param disposed Defines whether the light is dirty due to dispose or not
  81072. */
  81073. markAsLightDirty(disposed?: boolean): void;
  81074. /**
  81075. * Marks the attribute state as changed
  81076. */
  81077. markAsAttributesDirty(): void;
  81078. /**
  81079. * Marks the texture state as changed
  81080. */
  81081. markAsTexturesDirty(): void;
  81082. /**
  81083. * Marks the fresnel state as changed
  81084. */
  81085. markAsFresnelDirty(): void;
  81086. /**
  81087. * Marks the misc state as changed
  81088. */
  81089. markAsMiscDirty(): void;
  81090. /**
  81091. * Rebuilds the material defines
  81092. */
  81093. rebuild(): void;
  81094. /**
  81095. * Specifies if two material defines are equal
  81096. * @param other - A material define instance to compare to
  81097. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81098. */
  81099. isEqual(other: MaterialDefines): boolean;
  81100. /**
  81101. * Clones this instance's defines to another instance
  81102. * @param other - material defines to clone values to
  81103. */
  81104. cloneTo(other: MaterialDefines): void;
  81105. /**
  81106. * Resets the material define values
  81107. */
  81108. reset(): void;
  81109. /**
  81110. * Converts the material define values to a string
  81111. * @returns - String of material define information
  81112. */
  81113. toString(): string;
  81114. }
  81115. }
  81116. declare module BABYLON {
  81117. /**
  81118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81120. * 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;
  81121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81122. */
  81123. export class ColorCurves {
  81124. private _dirty;
  81125. private _tempColor;
  81126. private _globalCurve;
  81127. private _highlightsCurve;
  81128. private _midtonesCurve;
  81129. private _shadowsCurve;
  81130. private _positiveCurve;
  81131. private _negativeCurve;
  81132. private _globalHue;
  81133. private _globalDensity;
  81134. private _globalSaturation;
  81135. private _globalExposure;
  81136. /**
  81137. * Gets the global Hue value.
  81138. * 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).
  81139. */
  81140. get globalHue(): number;
  81141. /**
  81142. * Sets the global Hue value.
  81143. * 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).
  81144. */
  81145. set globalHue(value: number);
  81146. /**
  81147. * Gets the global Density value.
  81148. * 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.
  81149. * Values less than zero provide a filter of opposite hue.
  81150. */
  81151. get globalDensity(): number;
  81152. /**
  81153. * Sets the global Density value.
  81154. * 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.
  81155. * Values less than zero provide a filter of opposite hue.
  81156. */
  81157. set globalDensity(value: number);
  81158. /**
  81159. * Gets the global Saturation value.
  81160. * 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.
  81161. */
  81162. get globalSaturation(): number;
  81163. /**
  81164. * Sets the global Saturation value.
  81165. * 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.
  81166. */
  81167. set globalSaturation(value: number);
  81168. /**
  81169. * Gets the global Exposure value.
  81170. * 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.
  81171. */
  81172. get globalExposure(): number;
  81173. /**
  81174. * Sets the global Exposure value.
  81175. * 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.
  81176. */
  81177. set globalExposure(value: number);
  81178. private _highlightsHue;
  81179. private _highlightsDensity;
  81180. private _highlightsSaturation;
  81181. private _highlightsExposure;
  81182. /**
  81183. * Gets the highlights Hue value.
  81184. * 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).
  81185. */
  81186. get highlightsHue(): number;
  81187. /**
  81188. * Sets the highlights Hue value.
  81189. * 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).
  81190. */
  81191. set highlightsHue(value: number);
  81192. /**
  81193. * Gets the highlights Density value.
  81194. * 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.
  81195. * Values less than zero provide a filter of opposite hue.
  81196. */
  81197. get highlightsDensity(): number;
  81198. /**
  81199. * Sets the highlights Density value.
  81200. * 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.
  81201. * Values less than zero provide a filter of opposite hue.
  81202. */
  81203. set highlightsDensity(value: number);
  81204. /**
  81205. * Gets the highlights Saturation value.
  81206. * 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.
  81207. */
  81208. get highlightsSaturation(): number;
  81209. /**
  81210. * Sets the highlights Saturation value.
  81211. * 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.
  81212. */
  81213. set highlightsSaturation(value: number);
  81214. /**
  81215. * Gets the highlights Exposure value.
  81216. * 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.
  81217. */
  81218. get highlightsExposure(): number;
  81219. /**
  81220. * Sets the highlights Exposure value.
  81221. * 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.
  81222. */
  81223. set highlightsExposure(value: number);
  81224. private _midtonesHue;
  81225. private _midtonesDensity;
  81226. private _midtonesSaturation;
  81227. private _midtonesExposure;
  81228. /**
  81229. * Gets the midtones Hue value.
  81230. * 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).
  81231. */
  81232. get midtonesHue(): number;
  81233. /**
  81234. * Sets the midtones Hue value.
  81235. * 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).
  81236. */
  81237. set midtonesHue(value: number);
  81238. /**
  81239. * Gets the midtones Density value.
  81240. * 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.
  81241. * Values less than zero provide a filter of opposite hue.
  81242. */
  81243. get midtonesDensity(): number;
  81244. /**
  81245. * Sets the midtones Density value.
  81246. * 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.
  81247. * Values less than zero provide a filter of opposite hue.
  81248. */
  81249. set midtonesDensity(value: number);
  81250. /**
  81251. * Gets the midtones Saturation value.
  81252. * 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.
  81253. */
  81254. get midtonesSaturation(): number;
  81255. /**
  81256. * Sets the midtones Saturation value.
  81257. * 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.
  81258. */
  81259. set midtonesSaturation(value: number);
  81260. /**
  81261. * Gets the midtones Exposure value.
  81262. * 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.
  81263. */
  81264. get midtonesExposure(): number;
  81265. /**
  81266. * Sets the midtones Exposure value.
  81267. * 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.
  81268. */
  81269. set midtonesExposure(value: number);
  81270. private _shadowsHue;
  81271. private _shadowsDensity;
  81272. private _shadowsSaturation;
  81273. private _shadowsExposure;
  81274. /**
  81275. * Gets the shadows Hue value.
  81276. * 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).
  81277. */
  81278. get shadowsHue(): number;
  81279. /**
  81280. * Sets the shadows Hue value.
  81281. * 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).
  81282. */
  81283. set shadowsHue(value: number);
  81284. /**
  81285. * Gets the shadows Density value.
  81286. * 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.
  81287. * Values less than zero provide a filter of opposite hue.
  81288. */
  81289. get shadowsDensity(): number;
  81290. /**
  81291. * Sets the shadows Density value.
  81292. * 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.
  81293. * Values less than zero provide a filter of opposite hue.
  81294. */
  81295. set shadowsDensity(value: number);
  81296. /**
  81297. * Gets the shadows Saturation value.
  81298. * 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.
  81299. */
  81300. get shadowsSaturation(): number;
  81301. /**
  81302. * Sets the shadows Saturation value.
  81303. * 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.
  81304. */
  81305. set shadowsSaturation(value: number);
  81306. /**
  81307. * Gets the shadows Exposure value.
  81308. * 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.
  81309. */
  81310. get shadowsExposure(): number;
  81311. /**
  81312. * Sets the shadows Exposure value.
  81313. * 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.
  81314. */
  81315. set shadowsExposure(value: number);
  81316. /**
  81317. * Returns the class name
  81318. * @returns The class name
  81319. */
  81320. getClassName(): string;
  81321. /**
  81322. * Binds the color curves to the shader.
  81323. * @param colorCurves The color curve to bind
  81324. * @param effect The effect to bind to
  81325. * @param positiveUniform The positive uniform shader parameter
  81326. * @param neutralUniform The neutral uniform shader parameter
  81327. * @param negativeUniform The negative uniform shader parameter
  81328. */
  81329. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81330. /**
  81331. * Prepare the list of uniforms associated with the ColorCurves effects.
  81332. * @param uniformsList The list of uniforms used in the effect
  81333. */
  81334. static PrepareUniforms(uniformsList: string[]): void;
  81335. /**
  81336. * Returns color grading data based on a hue, density, saturation and exposure value.
  81337. * @param filterHue The hue of the color filter.
  81338. * @param filterDensity The density of the color filter.
  81339. * @param saturation The saturation.
  81340. * @param exposure The exposure.
  81341. * @param result The result data container.
  81342. */
  81343. private getColorGradingDataToRef;
  81344. /**
  81345. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81346. * @param value The input slider value in range [-100,100].
  81347. * @returns Adjusted value.
  81348. */
  81349. private static applyColorGradingSliderNonlinear;
  81350. /**
  81351. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81352. * @param hue The hue (H) input.
  81353. * @param saturation The saturation (S) input.
  81354. * @param brightness The brightness (B) input.
  81355. * @result An RGBA color represented as Vector4.
  81356. */
  81357. private static fromHSBToRef;
  81358. /**
  81359. * Returns a value clamped between min and max
  81360. * @param value The value to clamp
  81361. * @param min The minimum of value
  81362. * @param max The maximum of value
  81363. * @returns The clamped value.
  81364. */
  81365. private static clamp;
  81366. /**
  81367. * Clones the current color curve instance.
  81368. * @return The cloned curves
  81369. */
  81370. clone(): ColorCurves;
  81371. /**
  81372. * Serializes the current color curve instance to a json representation.
  81373. * @return a JSON representation
  81374. */
  81375. serialize(): any;
  81376. /**
  81377. * Parses the color curve from a json representation.
  81378. * @param source the JSON source to parse
  81379. * @return The parsed curves
  81380. */
  81381. static Parse(source: any): ColorCurves;
  81382. }
  81383. }
  81384. declare module BABYLON {
  81385. /**
  81386. * Interface to follow in your material defines to integrate easily the
  81387. * Image proccessing functions.
  81388. * @hidden
  81389. */
  81390. export interface IImageProcessingConfigurationDefines {
  81391. IMAGEPROCESSING: boolean;
  81392. VIGNETTE: boolean;
  81393. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81394. VIGNETTEBLENDMODEOPAQUE: boolean;
  81395. TONEMAPPING: boolean;
  81396. TONEMAPPING_ACES: boolean;
  81397. CONTRAST: boolean;
  81398. EXPOSURE: boolean;
  81399. COLORCURVES: boolean;
  81400. COLORGRADING: boolean;
  81401. COLORGRADING3D: boolean;
  81402. SAMPLER3DGREENDEPTH: boolean;
  81403. SAMPLER3DBGRMAP: boolean;
  81404. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81405. }
  81406. /**
  81407. * @hidden
  81408. */
  81409. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81410. IMAGEPROCESSING: boolean;
  81411. VIGNETTE: boolean;
  81412. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81413. VIGNETTEBLENDMODEOPAQUE: boolean;
  81414. TONEMAPPING: boolean;
  81415. TONEMAPPING_ACES: boolean;
  81416. CONTRAST: boolean;
  81417. COLORCURVES: boolean;
  81418. COLORGRADING: boolean;
  81419. COLORGRADING3D: boolean;
  81420. SAMPLER3DGREENDEPTH: boolean;
  81421. SAMPLER3DBGRMAP: boolean;
  81422. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81423. EXPOSURE: boolean;
  81424. constructor();
  81425. }
  81426. /**
  81427. * This groups together the common properties used for image processing either in direct forward pass
  81428. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81429. * or not.
  81430. */
  81431. export class ImageProcessingConfiguration {
  81432. /**
  81433. * Default tone mapping applied in BabylonJS.
  81434. */
  81435. static readonly TONEMAPPING_STANDARD: number;
  81436. /**
  81437. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81438. * to other engines rendering to increase portability.
  81439. */
  81440. static readonly TONEMAPPING_ACES: number;
  81441. /**
  81442. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81443. */
  81444. colorCurves: Nullable<ColorCurves>;
  81445. private _colorCurvesEnabled;
  81446. /**
  81447. * Gets wether the color curves effect is enabled.
  81448. */
  81449. get colorCurvesEnabled(): boolean;
  81450. /**
  81451. * Sets wether the color curves effect is enabled.
  81452. */
  81453. set colorCurvesEnabled(value: boolean);
  81454. private _colorGradingTexture;
  81455. /**
  81456. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81457. */
  81458. get colorGradingTexture(): Nullable<BaseTexture>;
  81459. /**
  81460. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81461. */
  81462. set colorGradingTexture(value: Nullable<BaseTexture>);
  81463. private _colorGradingEnabled;
  81464. /**
  81465. * Gets wether the color grading effect is enabled.
  81466. */
  81467. get colorGradingEnabled(): boolean;
  81468. /**
  81469. * Sets wether the color grading effect is enabled.
  81470. */
  81471. set colorGradingEnabled(value: boolean);
  81472. private _colorGradingWithGreenDepth;
  81473. /**
  81474. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81475. */
  81476. get colorGradingWithGreenDepth(): boolean;
  81477. /**
  81478. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81479. */
  81480. set colorGradingWithGreenDepth(value: boolean);
  81481. private _colorGradingBGR;
  81482. /**
  81483. * Gets wether the color grading texture contains BGR values.
  81484. */
  81485. get colorGradingBGR(): boolean;
  81486. /**
  81487. * Sets wether the color grading texture contains BGR values.
  81488. */
  81489. set colorGradingBGR(value: boolean);
  81490. /** @hidden */
  81491. _exposure: number;
  81492. /**
  81493. * Gets the Exposure used in the effect.
  81494. */
  81495. get exposure(): number;
  81496. /**
  81497. * Sets the Exposure used in the effect.
  81498. */
  81499. set exposure(value: number);
  81500. private _toneMappingEnabled;
  81501. /**
  81502. * Gets wether the tone mapping effect is enabled.
  81503. */
  81504. get toneMappingEnabled(): boolean;
  81505. /**
  81506. * Sets wether the tone mapping effect is enabled.
  81507. */
  81508. set toneMappingEnabled(value: boolean);
  81509. private _toneMappingType;
  81510. /**
  81511. * Gets the type of tone mapping effect.
  81512. */
  81513. get toneMappingType(): number;
  81514. /**
  81515. * Sets the type of tone mapping effect used in BabylonJS.
  81516. */
  81517. set toneMappingType(value: number);
  81518. protected _contrast: number;
  81519. /**
  81520. * Gets the contrast used in the effect.
  81521. */
  81522. get contrast(): number;
  81523. /**
  81524. * Sets the contrast used in the effect.
  81525. */
  81526. set contrast(value: number);
  81527. /**
  81528. * Vignette stretch size.
  81529. */
  81530. vignetteStretch: number;
  81531. /**
  81532. * Vignette centre X Offset.
  81533. */
  81534. vignetteCentreX: number;
  81535. /**
  81536. * Vignette centre Y Offset.
  81537. */
  81538. vignetteCentreY: number;
  81539. /**
  81540. * Vignette weight or intensity of the vignette effect.
  81541. */
  81542. vignetteWeight: number;
  81543. /**
  81544. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81545. * if vignetteEnabled is set to true.
  81546. */
  81547. vignetteColor: Color4;
  81548. /**
  81549. * Camera field of view used by the Vignette effect.
  81550. */
  81551. vignetteCameraFov: number;
  81552. private _vignetteBlendMode;
  81553. /**
  81554. * Gets the vignette blend mode allowing different kind of effect.
  81555. */
  81556. get vignetteBlendMode(): number;
  81557. /**
  81558. * Sets the vignette blend mode allowing different kind of effect.
  81559. */
  81560. set vignetteBlendMode(value: number);
  81561. private _vignetteEnabled;
  81562. /**
  81563. * Gets wether the vignette effect is enabled.
  81564. */
  81565. get vignetteEnabled(): boolean;
  81566. /**
  81567. * Sets wether the vignette effect is enabled.
  81568. */
  81569. set vignetteEnabled(value: boolean);
  81570. private _applyByPostProcess;
  81571. /**
  81572. * Gets wether the image processing is applied through a post process or not.
  81573. */
  81574. get applyByPostProcess(): boolean;
  81575. /**
  81576. * Sets wether the image processing is applied through a post process or not.
  81577. */
  81578. set applyByPostProcess(value: boolean);
  81579. private _isEnabled;
  81580. /**
  81581. * Gets wether the image processing is enabled or not.
  81582. */
  81583. get isEnabled(): boolean;
  81584. /**
  81585. * Sets wether the image processing is enabled or not.
  81586. */
  81587. set isEnabled(value: boolean);
  81588. /**
  81589. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81590. */
  81591. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81592. /**
  81593. * Method called each time the image processing information changes requires to recompile the effect.
  81594. */
  81595. protected _updateParameters(): void;
  81596. /**
  81597. * Gets the current class name.
  81598. * @return "ImageProcessingConfiguration"
  81599. */
  81600. getClassName(): string;
  81601. /**
  81602. * Prepare the list of uniforms associated with the Image Processing effects.
  81603. * @param uniforms The list of uniforms used in the effect
  81604. * @param defines the list of defines currently in use
  81605. */
  81606. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81607. /**
  81608. * Prepare the list of samplers associated with the Image Processing effects.
  81609. * @param samplersList The list of uniforms used in the effect
  81610. * @param defines the list of defines currently in use
  81611. */
  81612. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81613. /**
  81614. * Prepare the list of defines associated to the shader.
  81615. * @param defines the list of defines to complete
  81616. * @param forPostProcess Define if we are currently in post process mode or not
  81617. */
  81618. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81619. /**
  81620. * Returns true if all the image processing information are ready.
  81621. * @returns True if ready, otherwise, false
  81622. */
  81623. isReady(): boolean;
  81624. /**
  81625. * Binds the image processing to the shader.
  81626. * @param effect The effect to bind to
  81627. * @param overrideAspectRatio Override the aspect ratio of the effect
  81628. */
  81629. bind(effect: Effect, overrideAspectRatio?: number): void;
  81630. /**
  81631. * Clones the current image processing instance.
  81632. * @return The cloned image processing
  81633. */
  81634. clone(): ImageProcessingConfiguration;
  81635. /**
  81636. * Serializes the current image processing instance to a json representation.
  81637. * @return a JSON representation
  81638. */
  81639. serialize(): any;
  81640. /**
  81641. * Parses the image processing from a json representation.
  81642. * @param source the JSON source to parse
  81643. * @return The parsed image processing
  81644. */
  81645. static Parse(source: any): ImageProcessingConfiguration;
  81646. private static _VIGNETTEMODE_MULTIPLY;
  81647. private static _VIGNETTEMODE_OPAQUE;
  81648. /**
  81649. * Used to apply the vignette as a mix with the pixel color.
  81650. */
  81651. static get VIGNETTEMODE_MULTIPLY(): number;
  81652. /**
  81653. * Used to apply the vignette as a replacement of the pixel color.
  81654. */
  81655. static get VIGNETTEMODE_OPAQUE(): number;
  81656. }
  81657. }
  81658. declare module BABYLON {
  81659. /** @hidden */
  81660. export var postprocessVertexShader: {
  81661. name: string;
  81662. shader: string;
  81663. };
  81664. }
  81665. declare module BABYLON {
  81666. interface ThinEngine {
  81667. /**
  81668. * Creates a new render target texture
  81669. * @param size defines the size of the texture
  81670. * @param options defines the options used to create the texture
  81671. * @returns a new render target texture stored in an InternalTexture
  81672. */
  81673. createRenderTargetTexture(size: number | {
  81674. width: number;
  81675. height: number;
  81676. layers?: number;
  81677. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81678. /**
  81679. * Creates a depth stencil texture.
  81680. * This is only available in WebGL 2 or with the depth texture extension available.
  81681. * @param size The size of face edge in the texture.
  81682. * @param options The options defining the texture.
  81683. * @returns The texture
  81684. */
  81685. createDepthStencilTexture(size: number | {
  81686. width: number;
  81687. height: number;
  81688. layers?: number;
  81689. }, options: DepthTextureCreationOptions): InternalTexture;
  81690. /** @hidden */
  81691. _createDepthStencilTexture(size: number | {
  81692. width: number;
  81693. height: number;
  81694. layers?: number;
  81695. }, options: DepthTextureCreationOptions): InternalTexture;
  81696. }
  81697. }
  81698. declare module BABYLON {
  81699. /** Defines supported spaces */
  81700. export enum Space {
  81701. /** Local (object) space */
  81702. LOCAL = 0,
  81703. /** World space */
  81704. WORLD = 1,
  81705. /** Bone space */
  81706. BONE = 2
  81707. }
  81708. /** Defines the 3 main axes */
  81709. export class Axis {
  81710. /** X axis */
  81711. static X: Vector3;
  81712. /** Y axis */
  81713. static Y: Vector3;
  81714. /** Z axis */
  81715. static Z: Vector3;
  81716. }
  81717. }
  81718. declare module BABYLON {
  81719. /**
  81720. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81721. * This is the base of the follow, arc rotate cameras and Free camera
  81722. * @see http://doc.babylonjs.com/features/cameras
  81723. */
  81724. export class TargetCamera extends Camera {
  81725. private static _RigCamTransformMatrix;
  81726. private static _TargetTransformMatrix;
  81727. private static _TargetFocalPoint;
  81728. /**
  81729. * Define the current direction the camera is moving to
  81730. */
  81731. cameraDirection: Vector3;
  81732. /**
  81733. * Define the current rotation the camera is rotating to
  81734. */
  81735. cameraRotation: Vector2;
  81736. /**
  81737. * When set, the up vector of the camera will be updated by the rotation of the camera
  81738. */
  81739. updateUpVectorFromRotation: boolean;
  81740. private _tmpQuaternion;
  81741. /**
  81742. * Define the current rotation of the camera
  81743. */
  81744. rotation: Vector3;
  81745. /**
  81746. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81747. */
  81748. rotationQuaternion: Quaternion;
  81749. /**
  81750. * Define the current speed of the camera
  81751. */
  81752. speed: number;
  81753. /**
  81754. * Add constraint to the camera to prevent it to move freely in all directions and
  81755. * around all axis.
  81756. */
  81757. noRotationConstraint: boolean;
  81758. /**
  81759. * Define the current target of the camera as an object or a position.
  81760. */
  81761. lockedTarget: any;
  81762. /** @hidden */
  81763. _currentTarget: Vector3;
  81764. /** @hidden */
  81765. _initialFocalDistance: number;
  81766. /** @hidden */
  81767. _viewMatrix: Matrix;
  81768. /** @hidden */
  81769. _camMatrix: Matrix;
  81770. /** @hidden */
  81771. _cameraTransformMatrix: Matrix;
  81772. /** @hidden */
  81773. _cameraRotationMatrix: Matrix;
  81774. /** @hidden */
  81775. _referencePoint: Vector3;
  81776. /** @hidden */
  81777. _transformedReferencePoint: Vector3;
  81778. protected _globalCurrentTarget: Vector3;
  81779. protected _globalCurrentUpVector: Vector3;
  81780. /** @hidden */
  81781. _reset: () => void;
  81782. private _defaultUp;
  81783. /**
  81784. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81785. * This is the base of the follow, arc rotate cameras and Free camera
  81786. * @see http://doc.babylonjs.com/features/cameras
  81787. * @param name Defines the name of the camera in the scene
  81788. * @param position Defines the start position of the camera in the scene
  81789. * @param scene Defines the scene the camera belongs to
  81790. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81791. */
  81792. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81793. /**
  81794. * Gets the position in front of the camera at a given distance.
  81795. * @param distance The distance from the camera we want the position to be
  81796. * @returns the position
  81797. */
  81798. getFrontPosition(distance: number): Vector3;
  81799. /** @hidden */
  81800. _getLockedTargetPosition(): Nullable<Vector3>;
  81801. private _storedPosition;
  81802. private _storedRotation;
  81803. private _storedRotationQuaternion;
  81804. /**
  81805. * Store current camera state of the camera (fov, position, rotation, etc..)
  81806. * @returns the camera
  81807. */
  81808. storeState(): Camera;
  81809. /**
  81810. * Restored camera state. You must call storeState() first
  81811. * @returns whether it was successful or not
  81812. * @hidden
  81813. */
  81814. _restoreStateValues(): boolean;
  81815. /** @hidden */
  81816. _initCache(): void;
  81817. /** @hidden */
  81818. _updateCache(ignoreParentClass?: boolean): void;
  81819. /** @hidden */
  81820. _isSynchronizedViewMatrix(): boolean;
  81821. /** @hidden */
  81822. _computeLocalCameraSpeed(): number;
  81823. /**
  81824. * Defines the target the camera should look at.
  81825. * @param target Defines the new target as a Vector or a mesh
  81826. */
  81827. setTarget(target: Vector3): void;
  81828. /**
  81829. * Return the current target position of the camera. This value is expressed in local space.
  81830. * @returns the target position
  81831. */
  81832. getTarget(): Vector3;
  81833. /** @hidden */
  81834. _decideIfNeedsToMove(): boolean;
  81835. /** @hidden */
  81836. _updatePosition(): void;
  81837. /** @hidden */
  81838. _checkInputs(): void;
  81839. protected _updateCameraRotationMatrix(): void;
  81840. /**
  81841. * 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)
  81842. * @returns the current camera
  81843. */
  81844. private _rotateUpVectorWithCameraRotationMatrix;
  81845. private _cachedRotationZ;
  81846. private _cachedQuaternionRotationZ;
  81847. /** @hidden */
  81848. _getViewMatrix(): Matrix;
  81849. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81850. /**
  81851. * @hidden
  81852. */
  81853. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81854. /**
  81855. * @hidden
  81856. */
  81857. _updateRigCameras(): void;
  81858. private _getRigCamPositionAndTarget;
  81859. /**
  81860. * Gets the current object class name.
  81861. * @return the class name
  81862. */
  81863. getClassName(): string;
  81864. }
  81865. }
  81866. declare module BABYLON {
  81867. /**
  81868. * Gather the list of keyboard event types as constants.
  81869. */
  81870. export class KeyboardEventTypes {
  81871. /**
  81872. * The keydown event is fired when a key becomes active (pressed).
  81873. */
  81874. static readonly KEYDOWN: number;
  81875. /**
  81876. * The keyup event is fired when a key has been released.
  81877. */
  81878. static readonly KEYUP: number;
  81879. }
  81880. /**
  81881. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81882. */
  81883. export class KeyboardInfo {
  81884. /**
  81885. * Defines the type of event (KeyboardEventTypes)
  81886. */
  81887. type: number;
  81888. /**
  81889. * Defines the related dom event
  81890. */
  81891. event: KeyboardEvent;
  81892. /**
  81893. * Instantiates a new keyboard info.
  81894. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81895. * @param type Defines the type of event (KeyboardEventTypes)
  81896. * @param event Defines the related dom event
  81897. */
  81898. constructor(
  81899. /**
  81900. * Defines the type of event (KeyboardEventTypes)
  81901. */
  81902. type: number,
  81903. /**
  81904. * Defines the related dom event
  81905. */
  81906. event: KeyboardEvent);
  81907. }
  81908. /**
  81909. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81910. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81911. */
  81912. export class KeyboardInfoPre extends KeyboardInfo {
  81913. /**
  81914. * Defines the type of event (KeyboardEventTypes)
  81915. */
  81916. type: number;
  81917. /**
  81918. * Defines the related dom event
  81919. */
  81920. event: KeyboardEvent;
  81921. /**
  81922. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81923. */
  81924. skipOnPointerObservable: boolean;
  81925. /**
  81926. * Instantiates a new keyboard pre info.
  81927. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81928. * @param type Defines the type of event (KeyboardEventTypes)
  81929. * @param event Defines the related dom event
  81930. */
  81931. constructor(
  81932. /**
  81933. * Defines the type of event (KeyboardEventTypes)
  81934. */
  81935. type: number,
  81936. /**
  81937. * Defines the related dom event
  81938. */
  81939. event: KeyboardEvent);
  81940. }
  81941. }
  81942. declare module BABYLON {
  81943. /**
  81944. * Manage the keyboard inputs to control the movement of a free camera.
  81945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81946. */
  81947. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81948. /**
  81949. * Defines the camera the input is attached to.
  81950. */
  81951. camera: FreeCamera;
  81952. /**
  81953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81954. */
  81955. keysUp: number[];
  81956. /**
  81957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81958. */
  81959. keysDown: number[];
  81960. /**
  81961. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81962. */
  81963. keysLeft: number[];
  81964. /**
  81965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81966. */
  81967. keysRight: number[];
  81968. private _keys;
  81969. private _onCanvasBlurObserver;
  81970. private _onKeyboardObserver;
  81971. private _engine;
  81972. private _scene;
  81973. /**
  81974. * Attach the input controls to a specific dom element to get the input from.
  81975. * @param element Defines the element the controls should be listened from
  81976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81977. */
  81978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81979. /**
  81980. * Detach the current controls from the specified dom element.
  81981. * @param element Defines the element to stop listening the inputs from
  81982. */
  81983. detachControl(element: Nullable<HTMLElement>): void;
  81984. /**
  81985. * Update the current camera state depending on the inputs that have been used this frame.
  81986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81987. */
  81988. checkInputs(): void;
  81989. /**
  81990. * Gets the class name of the current intput.
  81991. * @returns the class name
  81992. */
  81993. getClassName(): string;
  81994. /** @hidden */
  81995. _onLostFocus(): void;
  81996. /**
  81997. * Get the friendly name associated with the input class.
  81998. * @returns the input friendly name
  81999. */
  82000. getSimpleName(): string;
  82001. }
  82002. }
  82003. declare module BABYLON {
  82004. /**
  82005. * Interface describing all the common properties and methods a shadow light needs to implement.
  82006. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82007. * as well as binding the different shadow properties to the effects.
  82008. */
  82009. export interface IShadowLight extends Light {
  82010. /**
  82011. * The light id in the scene (used in scene.findLighById for instance)
  82012. */
  82013. id: string;
  82014. /**
  82015. * The position the shdow will be casted from.
  82016. */
  82017. position: Vector3;
  82018. /**
  82019. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82020. */
  82021. direction: Vector3;
  82022. /**
  82023. * The transformed position. Position of the light in world space taking parenting in account.
  82024. */
  82025. transformedPosition: Vector3;
  82026. /**
  82027. * The transformed direction. Direction of the light in world space taking parenting in account.
  82028. */
  82029. transformedDirection: Vector3;
  82030. /**
  82031. * The friendly name of the light in the scene.
  82032. */
  82033. name: string;
  82034. /**
  82035. * Defines the shadow projection clipping minimum z value.
  82036. */
  82037. shadowMinZ: number;
  82038. /**
  82039. * Defines the shadow projection clipping maximum z value.
  82040. */
  82041. shadowMaxZ: number;
  82042. /**
  82043. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82044. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82045. */
  82046. computeTransformedInformation(): boolean;
  82047. /**
  82048. * Gets the scene the light belongs to.
  82049. * @returns The scene
  82050. */
  82051. getScene(): Scene;
  82052. /**
  82053. * Callback defining a custom Projection Matrix Builder.
  82054. * This can be used to override the default projection matrix computation.
  82055. */
  82056. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82057. /**
  82058. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82059. * @param matrix The materix to updated with the projection information
  82060. * @param viewMatrix The transform matrix of the light
  82061. * @param renderList The list of mesh to render in the map
  82062. * @returns The current light
  82063. */
  82064. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82065. /**
  82066. * Gets the current depth scale used in ESM.
  82067. * @returns The scale
  82068. */
  82069. getDepthScale(): number;
  82070. /**
  82071. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82072. * @returns true if a cube texture needs to be use
  82073. */
  82074. needCube(): boolean;
  82075. /**
  82076. * Detects if the projection matrix requires to be recomputed this frame.
  82077. * @returns true if it requires to be recomputed otherwise, false.
  82078. */
  82079. needProjectionMatrixCompute(): boolean;
  82080. /**
  82081. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82082. */
  82083. forceProjectionMatrixCompute(): void;
  82084. /**
  82085. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82086. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82087. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82088. */
  82089. getShadowDirection(faceIndex?: number): Vector3;
  82090. /**
  82091. * Gets the minZ used for shadow according to both the scene and the light.
  82092. * @param activeCamera The camera we are returning the min for
  82093. * @returns the depth min z
  82094. */
  82095. getDepthMinZ(activeCamera: Camera): number;
  82096. /**
  82097. * Gets the maxZ used for shadow according to both the scene and the light.
  82098. * @param activeCamera The camera we are returning the max for
  82099. * @returns the depth max z
  82100. */
  82101. getDepthMaxZ(activeCamera: Camera): number;
  82102. }
  82103. /**
  82104. * Base implementation IShadowLight
  82105. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82106. */
  82107. export abstract class ShadowLight extends Light implements IShadowLight {
  82108. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82109. protected _position: Vector3;
  82110. protected _setPosition(value: Vector3): void;
  82111. /**
  82112. * Sets the position the shadow will be casted from. Also use as the light position for both
  82113. * point and spot lights.
  82114. */
  82115. get position(): Vector3;
  82116. /**
  82117. * Sets the position the shadow will be casted from. Also use as the light position for both
  82118. * point and spot lights.
  82119. */
  82120. set position(value: Vector3);
  82121. protected _direction: Vector3;
  82122. protected _setDirection(value: Vector3): void;
  82123. /**
  82124. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82125. * Also use as the light direction on spot and directional lights.
  82126. */
  82127. get direction(): Vector3;
  82128. /**
  82129. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82130. * Also use as the light direction on spot and directional lights.
  82131. */
  82132. set direction(value: Vector3);
  82133. protected _shadowMinZ: number;
  82134. /**
  82135. * Gets the shadow projection clipping minimum z value.
  82136. */
  82137. get shadowMinZ(): number;
  82138. /**
  82139. * Sets the shadow projection clipping minimum z value.
  82140. */
  82141. set shadowMinZ(value: number);
  82142. protected _shadowMaxZ: number;
  82143. /**
  82144. * Sets the shadow projection clipping maximum z value.
  82145. */
  82146. get shadowMaxZ(): number;
  82147. /**
  82148. * Gets the shadow projection clipping maximum z value.
  82149. */
  82150. set shadowMaxZ(value: number);
  82151. /**
  82152. * Callback defining a custom Projection Matrix Builder.
  82153. * This can be used to override the default projection matrix computation.
  82154. */
  82155. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82156. /**
  82157. * The transformed position. Position of the light in world space taking parenting in account.
  82158. */
  82159. transformedPosition: Vector3;
  82160. /**
  82161. * The transformed direction. Direction of the light in world space taking parenting in account.
  82162. */
  82163. transformedDirection: Vector3;
  82164. private _needProjectionMatrixCompute;
  82165. /**
  82166. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82167. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82168. */
  82169. computeTransformedInformation(): boolean;
  82170. /**
  82171. * Return the depth scale used for the shadow map.
  82172. * @returns the depth scale.
  82173. */
  82174. getDepthScale(): number;
  82175. /**
  82176. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82177. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82178. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82179. */
  82180. getShadowDirection(faceIndex?: number): Vector3;
  82181. /**
  82182. * Returns the ShadowLight absolute position in the World.
  82183. * @returns the position vector in world space
  82184. */
  82185. getAbsolutePosition(): Vector3;
  82186. /**
  82187. * Sets the ShadowLight direction toward the passed target.
  82188. * @param target The point to target in local space
  82189. * @returns the updated ShadowLight direction
  82190. */
  82191. setDirectionToTarget(target: Vector3): Vector3;
  82192. /**
  82193. * Returns the light rotation in euler definition.
  82194. * @returns the x y z rotation in local space.
  82195. */
  82196. getRotation(): Vector3;
  82197. /**
  82198. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82199. * @returns true if a cube texture needs to be use
  82200. */
  82201. needCube(): boolean;
  82202. /**
  82203. * Detects if the projection matrix requires to be recomputed this frame.
  82204. * @returns true if it requires to be recomputed otherwise, false.
  82205. */
  82206. needProjectionMatrixCompute(): boolean;
  82207. /**
  82208. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82209. */
  82210. forceProjectionMatrixCompute(): void;
  82211. /** @hidden */
  82212. _initCache(): void;
  82213. /** @hidden */
  82214. _isSynchronized(): boolean;
  82215. /**
  82216. * Computes the world matrix of the node
  82217. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82218. * @returns the world matrix
  82219. */
  82220. computeWorldMatrix(force?: boolean): Matrix;
  82221. /**
  82222. * Gets the minZ used for shadow according to both the scene and the light.
  82223. * @param activeCamera The camera we are returning the min for
  82224. * @returns the depth min z
  82225. */
  82226. getDepthMinZ(activeCamera: Camera): number;
  82227. /**
  82228. * Gets the maxZ used for shadow according to both the scene and the light.
  82229. * @param activeCamera The camera we are returning the max for
  82230. * @returns the depth max z
  82231. */
  82232. getDepthMaxZ(activeCamera: Camera): number;
  82233. /**
  82234. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82235. * @param matrix The materix to updated with the projection information
  82236. * @param viewMatrix The transform matrix of the light
  82237. * @param renderList The list of mesh to render in the map
  82238. * @returns The current light
  82239. */
  82240. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82241. }
  82242. }
  82243. declare module BABYLON {
  82244. /**
  82245. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82246. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82247. */
  82248. export class EffectFallbacks implements IEffectFallbacks {
  82249. private _defines;
  82250. private _currentRank;
  82251. private _maxRank;
  82252. private _mesh;
  82253. /**
  82254. * Removes the fallback from the bound mesh.
  82255. */
  82256. unBindMesh(): void;
  82257. /**
  82258. * Adds a fallback on the specified property.
  82259. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82260. * @param define The name of the define in the shader
  82261. */
  82262. addFallback(rank: number, define: string): void;
  82263. /**
  82264. * Sets the mesh to use CPU skinning when needing to fallback.
  82265. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82266. * @param mesh The mesh to use the fallbacks.
  82267. */
  82268. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82269. /**
  82270. * Checks to see if more fallbacks are still availible.
  82271. */
  82272. get hasMoreFallbacks(): boolean;
  82273. /**
  82274. * Removes the defines that should be removed when falling back.
  82275. * @param currentDefines defines the current define statements for the shader.
  82276. * @param effect defines the current effect we try to compile
  82277. * @returns The resulting defines with defines of the current rank removed.
  82278. */
  82279. reduce(currentDefines: string, effect: Effect): string;
  82280. }
  82281. }
  82282. declare module BABYLON {
  82283. /**
  82284. * "Static Class" containing the most commonly used helper while dealing with material for
  82285. * rendering purpose.
  82286. *
  82287. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82288. *
  82289. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82290. */
  82291. export class MaterialHelper {
  82292. /**
  82293. * Bind the current view position to an effect.
  82294. * @param effect The effect to be bound
  82295. * @param scene The scene the eyes position is used from
  82296. */
  82297. static BindEyePosition(effect: Effect, scene: Scene): void;
  82298. /**
  82299. * Helps preparing the defines values about the UVs in used in the effect.
  82300. * UVs are shared as much as we can accross channels in the shaders.
  82301. * @param texture The texture we are preparing the UVs for
  82302. * @param defines The defines to update
  82303. * @param key The channel key "diffuse", "specular"... used in the shader
  82304. */
  82305. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82306. /**
  82307. * Binds a texture matrix value to its corrsponding uniform
  82308. * @param texture The texture to bind the matrix for
  82309. * @param uniformBuffer The uniform buffer receivin the data
  82310. * @param key The channel key "diffuse", "specular"... used in the shader
  82311. */
  82312. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82313. /**
  82314. * Gets the current status of the fog (should it be enabled?)
  82315. * @param mesh defines the mesh to evaluate for fog support
  82316. * @param scene defines the hosting scene
  82317. * @returns true if fog must be enabled
  82318. */
  82319. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82320. /**
  82321. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82322. * @param mesh defines the current mesh
  82323. * @param scene defines the current scene
  82324. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82325. * @param pointsCloud defines if point cloud rendering has to be turned on
  82326. * @param fogEnabled defines if fog has to be turned on
  82327. * @param alphaTest defines if alpha testing has to be turned on
  82328. * @param defines defines the current list of defines
  82329. */
  82330. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82331. /**
  82332. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82333. * @param scene defines the current scene
  82334. * @param engine defines the current engine
  82335. * @param defines specifies the list of active defines
  82336. * @param useInstances defines if instances have to be turned on
  82337. * @param useClipPlane defines if clip plane have to be turned on
  82338. */
  82339. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82340. /**
  82341. * Prepares the defines for bones
  82342. * @param mesh The mesh containing the geometry data we will draw
  82343. * @param defines The defines to update
  82344. */
  82345. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82346. /**
  82347. * Prepares the defines for morph targets
  82348. * @param mesh The mesh containing the geometry data we will draw
  82349. * @param defines The defines to update
  82350. */
  82351. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82352. /**
  82353. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82354. * @param mesh The mesh containing the geometry data we will draw
  82355. * @param defines The defines to update
  82356. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82357. * @param useBones Precise whether bones should be used or not (override mesh info)
  82358. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82359. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82360. * @returns false if defines are considered not dirty and have not been checked
  82361. */
  82362. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82363. /**
  82364. * Prepares the defines related to multiview
  82365. * @param scene The scene we are intending to draw
  82366. * @param defines The defines to update
  82367. */
  82368. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82369. /**
  82370. * Prepares the defines related to the light information passed in parameter
  82371. * @param scene The scene we are intending to draw
  82372. * @param mesh The mesh the effect is compiling for
  82373. * @param light The light the effect is compiling for
  82374. * @param lightIndex The index of the light
  82375. * @param defines The defines to update
  82376. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82377. * @param state Defines the current state regarding what is needed (normals, etc...)
  82378. */
  82379. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82380. needNormals: boolean;
  82381. needRebuild: boolean;
  82382. shadowEnabled: boolean;
  82383. specularEnabled: boolean;
  82384. lightmapMode: boolean;
  82385. }): void;
  82386. /**
  82387. * Prepares the defines related to the light information passed in parameter
  82388. * @param scene The scene we are intending to draw
  82389. * @param mesh The mesh the effect is compiling for
  82390. * @param defines The defines to update
  82391. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82392. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82393. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82394. * @returns true if normals will be required for the rest of the effect
  82395. */
  82396. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82397. /**
  82398. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82399. * @param lightIndex defines the light index
  82400. * @param uniformsList The uniform list
  82401. * @param samplersList The sampler list
  82402. * @param projectedLightTexture defines if projected texture must be used
  82403. * @param uniformBuffersList defines an optional list of uniform buffers
  82404. */
  82405. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82406. /**
  82407. * Prepares the uniforms and samplers list to be used in the effect
  82408. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82409. * @param samplersList The sampler list
  82410. * @param defines The defines helping in the list generation
  82411. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82412. */
  82413. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82414. /**
  82415. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82416. * @param defines The defines to update while falling back
  82417. * @param fallbacks The authorized effect fallbacks
  82418. * @param maxSimultaneousLights The maximum number of lights allowed
  82419. * @param rank the current rank of the Effect
  82420. * @returns The newly affected rank
  82421. */
  82422. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82423. private static _TmpMorphInfluencers;
  82424. /**
  82425. * Prepares the list of attributes required for morph targets according to the effect defines.
  82426. * @param attribs The current list of supported attribs
  82427. * @param mesh The mesh to prepare the morph targets attributes for
  82428. * @param influencers The number of influencers
  82429. */
  82430. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82431. /**
  82432. * Prepares the list of attributes required for morph targets according to the effect defines.
  82433. * @param attribs The current list of supported attribs
  82434. * @param mesh The mesh to prepare the morph targets attributes for
  82435. * @param defines The current Defines of the effect
  82436. */
  82437. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82438. /**
  82439. * Prepares the list of attributes required for bones according to the effect defines.
  82440. * @param attribs The current list of supported attribs
  82441. * @param mesh The mesh to prepare the bones attributes for
  82442. * @param defines The current Defines of the effect
  82443. * @param fallbacks The current efffect fallback strategy
  82444. */
  82445. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82446. /**
  82447. * Check and prepare the list of attributes required for instances according to the effect defines.
  82448. * @param attribs The current list of supported attribs
  82449. * @param defines The current MaterialDefines of the effect
  82450. */
  82451. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82452. /**
  82453. * Add the list of attributes required for instances to the attribs array.
  82454. * @param attribs The current list of supported attribs
  82455. */
  82456. static PushAttributesForInstances(attribs: string[]): void;
  82457. /**
  82458. * Binds the light information to the effect.
  82459. * @param light The light containing the generator
  82460. * @param effect The effect we are binding the data to
  82461. * @param lightIndex The light index in the effect used to render
  82462. */
  82463. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82464. /**
  82465. * Binds the lights information from the scene to the effect for the given mesh.
  82466. * @param light Light to bind
  82467. * @param lightIndex Light index
  82468. * @param scene The scene where the light belongs to
  82469. * @param effect The effect we are binding the data to
  82470. * @param useSpecular Defines if specular is supported
  82471. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82472. */
  82473. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82474. /**
  82475. * Binds the lights information from the scene to the effect for the given mesh.
  82476. * @param scene The scene the lights belongs to
  82477. * @param mesh The mesh we are binding the information to render
  82478. * @param effect The effect we are binding the data to
  82479. * @param defines The generated defines for the effect
  82480. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82481. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82482. */
  82483. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82484. private static _tempFogColor;
  82485. /**
  82486. * Binds the fog information from the scene to the effect for the given mesh.
  82487. * @param scene The scene the lights belongs to
  82488. * @param mesh The mesh we are binding the information to render
  82489. * @param effect The effect we are binding the data to
  82490. * @param linearSpace Defines if the fog effect is applied in linear space
  82491. */
  82492. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82493. /**
  82494. * Binds the bones information from the mesh to the effect.
  82495. * @param mesh The mesh we are binding the information to render
  82496. * @param effect The effect we are binding the data to
  82497. */
  82498. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82499. /**
  82500. * Binds the morph targets information from the mesh to the effect.
  82501. * @param abstractMesh The mesh we are binding the information to render
  82502. * @param effect The effect we are binding the data to
  82503. */
  82504. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82505. /**
  82506. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82507. * @param defines The generated defines used in the effect
  82508. * @param effect The effect we are binding the data to
  82509. * @param scene The scene we are willing to render with logarithmic scale for
  82510. */
  82511. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82512. /**
  82513. * Binds the clip plane information from the scene to the effect.
  82514. * @param scene The scene the clip plane information are extracted from
  82515. * @param effect The effect we are binding the data to
  82516. */
  82517. static BindClipPlane(effect: Effect, scene: Scene): void;
  82518. }
  82519. }
  82520. declare module BABYLON {
  82521. /** @hidden */
  82522. export var packingFunctions: {
  82523. name: string;
  82524. shader: string;
  82525. };
  82526. }
  82527. declare module BABYLON {
  82528. /** @hidden */
  82529. export var clipPlaneFragmentDeclaration: {
  82530. name: string;
  82531. shader: string;
  82532. };
  82533. }
  82534. declare module BABYLON {
  82535. /** @hidden */
  82536. export var clipPlaneFragment: {
  82537. name: string;
  82538. shader: string;
  82539. };
  82540. }
  82541. declare module BABYLON {
  82542. /** @hidden */
  82543. export var shadowMapPixelShader: {
  82544. name: string;
  82545. shader: string;
  82546. };
  82547. }
  82548. declare module BABYLON {
  82549. /** @hidden */
  82550. export var bonesDeclaration: {
  82551. name: string;
  82552. shader: string;
  82553. };
  82554. }
  82555. declare module BABYLON {
  82556. /** @hidden */
  82557. export var morphTargetsVertexGlobalDeclaration: {
  82558. name: string;
  82559. shader: string;
  82560. };
  82561. }
  82562. declare module BABYLON {
  82563. /** @hidden */
  82564. export var morphTargetsVertexDeclaration: {
  82565. name: string;
  82566. shader: string;
  82567. };
  82568. }
  82569. declare module BABYLON {
  82570. /** @hidden */
  82571. export var instancesDeclaration: {
  82572. name: string;
  82573. shader: string;
  82574. };
  82575. }
  82576. declare module BABYLON {
  82577. /** @hidden */
  82578. export var helperFunctions: {
  82579. name: string;
  82580. shader: string;
  82581. };
  82582. }
  82583. declare module BABYLON {
  82584. /** @hidden */
  82585. export var clipPlaneVertexDeclaration: {
  82586. name: string;
  82587. shader: string;
  82588. };
  82589. }
  82590. declare module BABYLON {
  82591. /** @hidden */
  82592. export var morphTargetsVertex: {
  82593. name: string;
  82594. shader: string;
  82595. };
  82596. }
  82597. declare module BABYLON {
  82598. /** @hidden */
  82599. export var instancesVertex: {
  82600. name: string;
  82601. shader: string;
  82602. };
  82603. }
  82604. declare module BABYLON {
  82605. /** @hidden */
  82606. export var bonesVertex: {
  82607. name: string;
  82608. shader: string;
  82609. };
  82610. }
  82611. declare module BABYLON {
  82612. /** @hidden */
  82613. export var clipPlaneVertex: {
  82614. name: string;
  82615. shader: string;
  82616. };
  82617. }
  82618. declare module BABYLON {
  82619. /** @hidden */
  82620. export var shadowMapVertexShader: {
  82621. name: string;
  82622. shader: string;
  82623. };
  82624. }
  82625. declare module BABYLON {
  82626. /** @hidden */
  82627. export var depthBoxBlurPixelShader: {
  82628. name: string;
  82629. shader: string;
  82630. };
  82631. }
  82632. declare module BABYLON {
  82633. /**
  82634. * Class representing a ray with position and direction
  82635. */
  82636. export class Ray {
  82637. /** origin point */
  82638. origin: Vector3;
  82639. /** direction */
  82640. direction: Vector3;
  82641. /** length of the ray */
  82642. length: number;
  82643. private static readonly TmpVector3;
  82644. private _tmpRay;
  82645. /**
  82646. * Creates a new ray
  82647. * @param origin origin point
  82648. * @param direction direction
  82649. * @param length length of the ray
  82650. */
  82651. constructor(
  82652. /** origin point */
  82653. origin: Vector3,
  82654. /** direction */
  82655. direction: Vector3,
  82656. /** length of the ray */
  82657. length?: number);
  82658. /**
  82659. * Checks if the ray intersects a box
  82660. * @param minimum bound of the box
  82661. * @param maximum bound of the box
  82662. * @param intersectionTreshold extra extend to be added to the box in all direction
  82663. * @returns if the box was hit
  82664. */
  82665. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82666. /**
  82667. * Checks if the ray intersects a box
  82668. * @param box the bounding box to check
  82669. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82670. * @returns if the box was hit
  82671. */
  82672. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82673. /**
  82674. * If the ray hits a sphere
  82675. * @param sphere the bounding sphere to check
  82676. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82677. * @returns true if it hits the sphere
  82678. */
  82679. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82680. /**
  82681. * If the ray hits a triange
  82682. * @param vertex0 triangle vertex
  82683. * @param vertex1 triangle vertex
  82684. * @param vertex2 triangle vertex
  82685. * @returns intersection information if hit
  82686. */
  82687. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82688. /**
  82689. * Checks if ray intersects a plane
  82690. * @param plane the plane to check
  82691. * @returns the distance away it was hit
  82692. */
  82693. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82694. /**
  82695. * Calculate the intercept of a ray on a given axis
  82696. * @param axis to check 'x' | 'y' | 'z'
  82697. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82698. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82699. */
  82700. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82701. /**
  82702. * Checks if ray intersects a mesh
  82703. * @param mesh the mesh to check
  82704. * @param fastCheck if only the bounding box should checked
  82705. * @returns picking info of the intersecton
  82706. */
  82707. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82708. /**
  82709. * Checks if ray intersects a mesh
  82710. * @param meshes the meshes to check
  82711. * @param fastCheck if only the bounding box should checked
  82712. * @param results array to store result in
  82713. * @returns Array of picking infos
  82714. */
  82715. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82716. private _comparePickingInfo;
  82717. private static smallnum;
  82718. private static rayl;
  82719. /**
  82720. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82721. * @param sega the first point of the segment to test the intersection against
  82722. * @param segb the second point of the segment to test the intersection against
  82723. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82724. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82725. */
  82726. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82727. /**
  82728. * Update the ray from viewport position
  82729. * @param x position
  82730. * @param y y position
  82731. * @param viewportWidth viewport width
  82732. * @param viewportHeight viewport height
  82733. * @param world world matrix
  82734. * @param view view matrix
  82735. * @param projection projection matrix
  82736. * @returns this ray updated
  82737. */
  82738. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82739. /**
  82740. * Creates a ray with origin and direction of 0,0,0
  82741. * @returns the new ray
  82742. */
  82743. static Zero(): Ray;
  82744. /**
  82745. * Creates a new ray from screen space and viewport
  82746. * @param x position
  82747. * @param y y position
  82748. * @param viewportWidth viewport width
  82749. * @param viewportHeight viewport height
  82750. * @param world world matrix
  82751. * @param view view matrix
  82752. * @param projection projection matrix
  82753. * @returns new ray
  82754. */
  82755. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82756. /**
  82757. * 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
  82758. * transformed to the given world matrix.
  82759. * @param origin The origin point
  82760. * @param end The end point
  82761. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82762. * @returns the new ray
  82763. */
  82764. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82765. /**
  82766. * Transforms a ray by a matrix
  82767. * @param ray ray to transform
  82768. * @param matrix matrix to apply
  82769. * @returns the resulting new ray
  82770. */
  82771. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82772. /**
  82773. * Transforms a ray by a matrix
  82774. * @param ray ray to transform
  82775. * @param matrix matrix to apply
  82776. * @param result ray to store result in
  82777. */
  82778. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82779. /**
  82780. * Unproject a ray from screen space to object space
  82781. * @param sourceX defines the screen space x coordinate to use
  82782. * @param sourceY defines the screen space y coordinate to use
  82783. * @param viewportWidth defines the current width of the viewport
  82784. * @param viewportHeight defines the current height of the viewport
  82785. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82786. * @param view defines the view matrix to use
  82787. * @param projection defines the projection matrix to use
  82788. */
  82789. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82790. }
  82791. /**
  82792. * Type used to define predicate used to select faces when a mesh intersection is detected
  82793. */
  82794. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82795. interface Scene {
  82796. /** @hidden */
  82797. _tempPickingRay: Nullable<Ray>;
  82798. /** @hidden */
  82799. _cachedRayForTransform: Ray;
  82800. /** @hidden */
  82801. _pickWithRayInverseMatrix: Matrix;
  82802. /** @hidden */
  82803. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82804. /** @hidden */
  82805. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82806. }
  82807. }
  82808. declare module BABYLON {
  82809. /**
  82810. * Groups all the scene component constants in one place to ease maintenance.
  82811. * @hidden
  82812. */
  82813. export class SceneComponentConstants {
  82814. static readonly NAME_EFFECTLAYER: string;
  82815. static readonly NAME_LAYER: string;
  82816. static readonly NAME_LENSFLARESYSTEM: string;
  82817. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82818. static readonly NAME_PARTICLESYSTEM: string;
  82819. static readonly NAME_GAMEPAD: string;
  82820. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82821. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82822. static readonly NAME_DEPTHRENDERER: string;
  82823. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82824. static readonly NAME_SPRITE: string;
  82825. static readonly NAME_OUTLINERENDERER: string;
  82826. static readonly NAME_PROCEDURALTEXTURE: string;
  82827. static readonly NAME_SHADOWGENERATOR: string;
  82828. static readonly NAME_OCTREE: string;
  82829. static readonly NAME_PHYSICSENGINE: string;
  82830. static readonly NAME_AUDIO: string;
  82831. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82832. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82833. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82834. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82835. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82836. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82837. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82838. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82839. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82840. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82841. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82842. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82843. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82844. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82845. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82846. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82847. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82848. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82849. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82850. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82851. static readonly STEP_AFTERRENDER_AUDIO: number;
  82852. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82853. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82854. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82855. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82856. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82857. static readonly STEP_POINTERMOVE_SPRITE: number;
  82858. static readonly STEP_POINTERDOWN_SPRITE: number;
  82859. static readonly STEP_POINTERUP_SPRITE: number;
  82860. }
  82861. /**
  82862. * This represents a scene component.
  82863. *
  82864. * This is used to decouple the dependency the scene is having on the different workloads like
  82865. * layers, post processes...
  82866. */
  82867. export interface ISceneComponent {
  82868. /**
  82869. * The name of the component. Each component must have a unique name.
  82870. */
  82871. name: string;
  82872. /**
  82873. * The scene the component belongs to.
  82874. */
  82875. scene: Scene;
  82876. /**
  82877. * Register the component to one instance of a scene.
  82878. */
  82879. register(): void;
  82880. /**
  82881. * Rebuilds the elements related to this component in case of
  82882. * context lost for instance.
  82883. */
  82884. rebuild(): void;
  82885. /**
  82886. * Disposes the component and the associated ressources.
  82887. */
  82888. dispose(): void;
  82889. }
  82890. /**
  82891. * This represents a SERIALIZABLE scene component.
  82892. *
  82893. * This extends Scene Component to add Serialization methods on top.
  82894. */
  82895. export interface ISceneSerializableComponent extends ISceneComponent {
  82896. /**
  82897. * Adds all the elements from the container to the scene
  82898. * @param container the container holding the elements
  82899. */
  82900. addFromContainer(container: AbstractScene): void;
  82901. /**
  82902. * Removes all the elements in the container from the scene
  82903. * @param container contains the elements to remove
  82904. * @param dispose if the removed element should be disposed (default: false)
  82905. */
  82906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82907. /**
  82908. * Serializes the component data to the specified json object
  82909. * @param serializationObject The object to serialize to
  82910. */
  82911. serialize(serializationObject: any): void;
  82912. }
  82913. /**
  82914. * Strong typing of a Mesh related stage step action
  82915. */
  82916. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82917. /**
  82918. * Strong typing of a Evaluate Sub Mesh related stage step action
  82919. */
  82920. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82921. /**
  82922. * Strong typing of a Active Mesh related stage step action
  82923. */
  82924. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82925. /**
  82926. * Strong typing of a Camera related stage step action
  82927. */
  82928. export type CameraStageAction = (camera: Camera) => void;
  82929. /**
  82930. * Strong typing of a Camera Frame buffer related stage step action
  82931. */
  82932. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82933. /**
  82934. * Strong typing of a Render Target related stage step action
  82935. */
  82936. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82937. /**
  82938. * Strong typing of a RenderingGroup related stage step action
  82939. */
  82940. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82941. /**
  82942. * Strong typing of a Mesh Render related stage step action
  82943. */
  82944. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82945. /**
  82946. * Strong typing of a simple stage step action
  82947. */
  82948. export type SimpleStageAction = () => void;
  82949. /**
  82950. * Strong typing of a render target action.
  82951. */
  82952. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82953. /**
  82954. * Strong typing of a pointer move action.
  82955. */
  82956. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82957. /**
  82958. * Strong typing of a pointer up/down action.
  82959. */
  82960. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82961. /**
  82962. * Representation of a stage in the scene (Basically a list of ordered steps)
  82963. * @hidden
  82964. */
  82965. export class Stage<T extends Function> extends Array<{
  82966. index: number;
  82967. component: ISceneComponent;
  82968. action: T;
  82969. }> {
  82970. /**
  82971. * Hide ctor from the rest of the world.
  82972. * @param items The items to add.
  82973. */
  82974. private constructor();
  82975. /**
  82976. * Creates a new Stage.
  82977. * @returns A new instance of a Stage
  82978. */
  82979. static Create<T extends Function>(): Stage<T>;
  82980. /**
  82981. * Registers a step in an ordered way in the targeted stage.
  82982. * @param index Defines the position to register the step in
  82983. * @param component Defines the component attached to the step
  82984. * @param action Defines the action to launch during the step
  82985. */
  82986. registerStep(index: number, component: ISceneComponent, action: T): void;
  82987. /**
  82988. * Clears all the steps from the stage.
  82989. */
  82990. clear(): void;
  82991. }
  82992. }
  82993. declare module BABYLON {
  82994. interface Scene {
  82995. /** @hidden */
  82996. _pointerOverSprite: Nullable<Sprite>;
  82997. /** @hidden */
  82998. _pickedDownSprite: Nullable<Sprite>;
  82999. /** @hidden */
  83000. _tempSpritePickingRay: Nullable<Ray>;
  83001. /**
  83002. * All of the sprite managers added to this scene
  83003. * @see http://doc.babylonjs.com/babylon101/sprites
  83004. */
  83005. spriteManagers: Array<ISpriteManager>;
  83006. /**
  83007. * An event triggered when sprites rendering is about to start
  83008. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83009. */
  83010. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83011. /**
  83012. * An event triggered when sprites rendering is done
  83013. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83014. */
  83015. onAfterSpritesRenderingObservable: Observable<Scene>;
  83016. /** @hidden */
  83017. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83018. /** Launch a ray to try to pick a sprite in the scene
  83019. * @param x position on screen
  83020. * @param y position on screen
  83021. * @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
  83022. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83023. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83024. * @returns a PickingInfo
  83025. */
  83026. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83027. /** Use the given ray to pick a sprite in the scene
  83028. * @param ray The ray (in world space) to use to pick meshes
  83029. * @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
  83030. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83031. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83032. * @returns a PickingInfo
  83033. */
  83034. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83035. /** @hidden */
  83036. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83037. /** Launch a ray to try to pick sprites in the scene
  83038. * @param x position on screen
  83039. * @param y position on screen
  83040. * @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
  83041. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83042. * @returns a PickingInfo array
  83043. */
  83044. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83045. /** Use the given ray to pick sprites in the scene
  83046. * @param ray The ray (in world space) to use to pick meshes
  83047. * @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
  83048. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83049. * @returns a PickingInfo array
  83050. */
  83051. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83052. /**
  83053. * Force the sprite under the pointer
  83054. * @param sprite defines the sprite to use
  83055. */
  83056. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83057. /**
  83058. * Gets the sprite under the pointer
  83059. * @returns a Sprite or null if no sprite is under the pointer
  83060. */
  83061. getPointerOverSprite(): Nullable<Sprite>;
  83062. }
  83063. /**
  83064. * Defines the sprite scene component responsible to manage sprites
  83065. * in a given scene.
  83066. */
  83067. export class SpriteSceneComponent implements ISceneComponent {
  83068. /**
  83069. * The component name helpfull to identify the component in the list of scene components.
  83070. */
  83071. readonly name: string;
  83072. /**
  83073. * The scene the component belongs to.
  83074. */
  83075. scene: Scene;
  83076. /** @hidden */
  83077. private _spritePredicate;
  83078. /**
  83079. * Creates a new instance of the component for the given scene
  83080. * @param scene Defines the scene to register the component in
  83081. */
  83082. constructor(scene: Scene);
  83083. /**
  83084. * Registers the component in a given scene
  83085. */
  83086. register(): void;
  83087. /**
  83088. * Rebuilds the elements related to this component in case of
  83089. * context lost for instance.
  83090. */
  83091. rebuild(): void;
  83092. /**
  83093. * Disposes the component and the associated ressources.
  83094. */
  83095. dispose(): void;
  83096. private _pickSpriteButKeepRay;
  83097. private _pointerMove;
  83098. private _pointerDown;
  83099. private _pointerUp;
  83100. }
  83101. }
  83102. declare module BABYLON {
  83103. /** @hidden */
  83104. export var fogFragmentDeclaration: {
  83105. name: string;
  83106. shader: string;
  83107. };
  83108. }
  83109. declare module BABYLON {
  83110. /** @hidden */
  83111. export var fogFragment: {
  83112. name: string;
  83113. shader: string;
  83114. };
  83115. }
  83116. declare module BABYLON {
  83117. /** @hidden */
  83118. export var spritesPixelShader: {
  83119. name: string;
  83120. shader: string;
  83121. };
  83122. }
  83123. declare module BABYLON {
  83124. /** @hidden */
  83125. export var fogVertexDeclaration: {
  83126. name: string;
  83127. shader: string;
  83128. };
  83129. }
  83130. declare module BABYLON {
  83131. /** @hidden */
  83132. export var spritesVertexShader: {
  83133. name: string;
  83134. shader: string;
  83135. };
  83136. }
  83137. declare module BABYLON {
  83138. /**
  83139. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83140. */
  83141. export interface ISpriteManager extends IDisposable {
  83142. /**
  83143. * Restricts the camera to viewing objects with the same layerMask.
  83144. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83145. */
  83146. layerMask: number;
  83147. /**
  83148. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83149. */
  83150. isPickable: boolean;
  83151. /**
  83152. * Specifies the rendering group id for this mesh (0 by default)
  83153. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83154. */
  83155. renderingGroupId: number;
  83156. /**
  83157. * Defines the list of sprites managed by the manager.
  83158. */
  83159. sprites: Array<Sprite>;
  83160. /**
  83161. * Tests the intersection of a sprite with a specific ray.
  83162. * @param ray The ray we are sending to test the collision
  83163. * @param camera The camera space we are sending rays in
  83164. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83165. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83166. * @returns picking info or null.
  83167. */
  83168. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83169. /**
  83170. * Intersects the sprites with a ray
  83171. * @param ray defines the ray to intersect with
  83172. * @param camera defines the current active camera
  83173. * @param predicate defines a predicate used to select candidate sprites
  83174. * @returns null if no hit or a PickingInfo array
  83175. */
  83176. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83177. /**
  83178. * Renders the list of sprites on screen.
  83179. */
  83180. render(): void;
  83181. }
  83182. /**
  83183. * Class used to manage multiple sprites on the same spritesheet
  83184. * @see http://doc.babylonjs.com/babylon101/sprites
  83185. */
  83186. export class SpriteManager implements ISpriteManager {
  83187. /** defines the manager's name */
  83188. name: string;
  83189. /** Gets the list of sprites */
  83190. sprites: Sprite[];
  83191. /** Gets or sets the rendering group id (0 by default) */
  83192. renderingGroupId: number;
  83193. /** Gets or sets camera layer mask */
  83194. layerMask: number;
  83195. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83196. fogEnabled: boolean;
  83197. /** Gets or sets a boolean indicating if the sprites are pickable */
  83198. isPickable: boolean;
  83199. /** Defines the default width of a cell in the spritesheet */
  83200. cellWidth: number;
  83201. /** Defines the default height of a cell in the spritesheet */
  83202. cellHeight: number;
  83203. /** Associative array from JSON sprite data file */
  83204. private _cellData;
  83205. /** Array of sprite names from JSON sprite data file */
  83206. private _spriteMap;
  83207. /** True when packed cell data from JSON file is ready*/
  83208. private _packedAndReady;
  83209. /**
  83210. * An event triggered when the manager is disposed.
  83211. */
  83212. onDisposeObservable: Observable<SpriteManager>;
  83213. private _onDisposeObserver;
  83214. /**
  83215. * Callback called when the manager is disposed
  83216. */
  83217. set onDispose(callback: () => void);
  83218. private _capacity;
  83219. private _fromPacked;
  83220. private _spriteTexture;
  83221. private _epsilon;
  83222. private _scene;
  83223. private _vertexData;
  83224. private _buffer;
  83225. private _vertexBuffers;
  83226. private _indexBuffer;
  83227. private _effectBase;
  83228. private _effectFog;
  83229. /**
  83230. * Gets or sets the spritesheet texture
  83231. */
  83232. get texture(): Texture;
  83233. set texture(value: Texture);
  83234. private _blendMode;
  83235. /**
  83236. * Blend mode use to render the particle, it can be any of
  83237. * the static Constants.ALPHA_x properties provided in this class.
  83238. * Default value is Constants.ALPHA_COMBINE
  83239. */
  83240. get blendMode(): number;
  83241. set blendMode(blendMode: number);
  83242. /** Disables writing to the depth buffer when rendering the sprites.
  83243. * It can be handy to disable depth writing when using textures without alpha channel
  83244. * and setting some specific blend modes.
  83245. */
  83246. disableDepthWrite: boolean;
  83247. /**
  83248. * Creates a new sprite manager
  83249. * @param name defines the manager's name
  83250. * @param imgUrl defines the sprite sheet url
  83251. * @param capacity defines the maximum allowed number of sprites
  83252. * @param cellSize defines the size of a sprite cell
  83253. * @param scene defines the hosting scene
  83254. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83255. * @param samplingMode defines the smapling mode to use with spritesheet
  83256. * @param fromPacked set to false; do not alter
  83257. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83258. */
  83259. constructor(
  83260. /** defines the manager's name */
  83261. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83262. private _makePacked;
  83263. private _appendSpriteVertex;
  83264. /**
  83265. * Intersects the sprites with a ray
  83266. * @param ray defines the ray to intersect with
  83267. * @param camera defines the current active camera
  83268. * @param predicate defines a predicate used to select candidate sprites
  83269. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83270. * @returns null if no hit or a PickingInfo
  83271. */
  83272. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83273. /**
  83274. * Intersects the sprites with a ray
  83275. * @param ray defines the ray to intersect with
  83276. * @param camera defines the current active camera
  83277. * @param predicate defines a predicate used to select candidate sprites
  83278. * @returns null if no hit or a PickingInfo array
  83279. */
  83280. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83281. /**
  83282. * Render all child sprites
  83283. */
  83284. render(): void;
  83285. /**
  83286. * Release associated resources
  83287. */
  83288. dispose(): void;
  83289. }
  83290. }
  83291. declare module BABYLON {
  83292. /** Interface used by value gradients (color, factor, ...) */
  83293. export interface IValueGradient {
  83294. /**
  83295. * Gets or sets the gradient value (between 0 and 1)
  83296. */
  83297. gradient: number;
  83298. }
  83299. /** Class used to store color4 gradient */
  83300. export class ColorGradient implements IValueGradient {
  83301. /**
  83302. * Gets or sets the gradient value (between 0 and 1)
  83303. */
  83304. gradient: number;
  83305. /**
  83306. * Gets or sets first associated color
  83307. */
  83308. color1: Color4;
  83309. /**
  83310. * Gets or sets second associated color
  83311. */
  83312. color2?: Color4;
  83313. /**
  83314. * Will get a color picked randomly between color1 and color2.
  83315. * If color2 is undefined then color1 will be used
  83316. * @param result defines the target Color4 to store the result in
  83317. */
  83318. getColorToRef(result: Color4): void;
  83319. }
  83320. /** Class used to store color 3 gradient */
  83321. export class Color3Gradient implements IValueGradient {
  83322. /**
  83323. * Gets or sets the gradient value (between 0 and 1)
  83324. */
  83325. gradient: number;
  83326. /**
  83327. * Gets or sets the associated color
  83328. */
  83329. color: Color3;
  83330. }
  83331. /** Class used to store factor gradient */
  83332. export class FactorGradient implements IValueGradient {
  83333. /**
  83334. * Gets or sets the gradient value (between 0 and 1)
  83335. */
  83336. gradient: number;
  83337. /**
  83338. * Gets or sets first associated factor
  83339. */
  83340. factor1: number;
  83341. /**
  83342. * Gets or sets second associated factor
  83343. */
  83344. factor2?: number;
  83345. /**
  83346. * Will get a number picked randomly between factor1 and factor2.
  83347. * If factor2 is undefined then factor1 will be used
  83348. * @returns the picked number
  83349. */
  83350. getFactor(): number;
  83351. }
  83352. /**
  83353. * Helper used to simplify some generic gradient tasks
  83354. */
  83355. export class GradientHelper {
  83356. /**
  83357. * Gets the current gradient from an array of IValueGradient
  83358. * @param ratio defines the current ratio to get
  83359. * @param gradients defines the array of IValueGradient
  83360. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83361. */
  83362. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83363. }
  83364. }
  83365. declare module BABYLON {
  83366. /**
  83367. * Interface for the size containing width and height
  83368. */
  83369. export interface ISize {
  83370. /**
  83371. * Width
  83372. */
  83373. width: number;
  83374. /**
  83375. * Heighht
  83376. */
  83377. height: number;
  83378. }
  83379. /**
  83380. * Size containing widht and height
  83381. */
  83382. export class Size implements ISize {
  83383. /**
  83384. * Width
  83385. */
  83386. width: number;
  83387. /**
  83388. * Height
  83389. */
  83390. height: number;
  83391. /**
  83392. * Creates a Size object from the given width and height (floats).
  83393. * @param width width of the new size
  83394. * @param height height of the new size
  83395. */
  83396. constructor(width: number, height: number);
  83397. /**
  83398. * Returns a string with the Size width and height
  83399. * @returns a string with the Size width and height
  83400. */
  83401. toString(): string;
  83402. /**
  83403. * "Size"
  83404. * @returns the string "Size"
  83405. */
  83406. getClassName(): string;
  83407. /**
  83408. * Returns the Size hash code.
  83409. * @returns a hash code for a unique width and height
  83410. */
  83411. getHashCode(): number;
  83412. /**
  83413. * Updates the current size from the given one.
  83414. * @param src the given size
  83415. */
  83416. copyFrom(src: Size): void;
  83417. /**
  83418. * Updates in place the current Size from the given floats.
  83419. * @param width width of the new size
  83420. * @param height height of the new size
  83421. * @returns the updated Size.
  83422. */
  83423. copyFromFloats(width: number, height: number): Size;
  83424. /**
  83425. * Updates in place the current Size from the given floats.
  83426. * @param width width to set
  83427. * @param height height to set
  83428. * @returns the updated Size.
  83429. */
  83430. set(width: number, height: number): Size;
  83431. /**
  83432. * Multiplies the width and height by numbers
  83433. * @param w factor to multiple the width by
  83434. * @param h factor to multiple the height by
  83435. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83436. */
  83437. multiplyByFloats(w: number, h: number): Size;
  83438. /**
  83439. * Clones the size
  83440. * @returns a new Size copied from the given one.
  83441. */
  83442. clone(): Size;
  83443. /**
  83444. * True if the current Size and the given one width and height are strictly equal.
  83445. * @param other the other size to compare against
  83446. * @returns True if the current Size and the given one width and height are strictly equal.
  83447. */
  83448. equals(other: Size): boolean;
  83449. /**
  83450. * The surface of the Size : width * height (float).
  83451. */
  83452. get surface(): number;
  83453. /**
  83454. * Create a new size of zero
  83455. * @returns a new Size set to (0.0, 0.0)
  83456. */
  83457. static Zero(): Size;
  83458. /**
  83459. * Sums the width and height of two sizes
  83460. * @param otherSize size to add to this size
  83461. * @returns a new Size set as the addition result of the current Size and the given one.
  83462. */
  83463. add(otherSize: Size): Size;
  83464. /**
  83465. * Subtracts the width and height of two
  83466. * @param otherSize size to subtract to this size
  83467. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83468. */
  83469. subtract(otherSize: Size): Size;
  83470. /**
  83471. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83472. * @param start starting size to lerp between
  83473. * @param end end size to lerp between
  83474. * @param amount amount to lerp between the start and end values
  83475. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83476. */
  83477. static Lerp(start: Size, end: Size, amount: number): Size;
  83478. }
  83479. }
  83480. declare module BABYLON {
  83481. interface ThinEngine {
  83482. /**
  83483. * Creates a dynamic texture
  83484. * @param width defines the width of the texture
  83485. * @param height defines the height of the texture
  83486. * @param generateMipMaps defines if the engine should generate the mip levels
  83487. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83488. * @returns the dynamic texture inside an InternalTexture
  83489. */
  83490. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83491. /**
  83492. * Update the content of a dynamic texture
  83493. * @param texture defines the texture to update
  83494. * @param canvas defines the canvas containing the source
  83495. * @param invertY defines if data must be stored with Y axis inverted
  83496. * @param premulAlpha defines if alpha is stored as premultiplied
  83497. * @param format defines the format of the data
  83498. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83499. */
  83500. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83501. }
  83502. }
  83503. declare module BABYLON {
  83504. /**
  83505. * Helper class used to generate a canvas to manipulate images
  83506. */
  83507. export class CanvasGenerator {
  83508. /**
  83509. * Create a new canvas (or offscreen canvas depending on the context)
  83510. * @param width defines the expected width
  83511. * @param height defines the expected height
  83512. * @return a new canvas or offscreen canvas
  83513. */
  83514. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83515. }
  83516. }
  83517. declare module BABYLON {
  83518. /**
  83519. * A class extending Texture allowing drawing on a texture
  83520. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83521. */
  83522. export class DynamicTexture extends Texture {
  83523. private _generateMipMaps;
  83524. private _canvas;
  83525. private _context;
  83526. private _engine;
  83527. /**
  83528. * Creates a DynamicTexture
  83529. * @param name defines the name of the texture
  83530. * @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
  83531. * @param scene defines the scene where you want the texture
  83532. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83533. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83534. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83535. */
  83536. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83537. /**
  83538. * Get the current class name of the texture useful for serialization or dynamic coding.
  83539. * @returns "DynamicTexture"
  83540. */
  83541. getClassName(): string;
  83542. /**
  83543. * Gets the current state of canRescale
  83544. */
  83545. get canRescale(): boolean;
  83546. private _recreate;
  83547. /**
  83548. * Scales the texture
  83549. * @param ratio the scale factor to apply to both width and height
  83550. */
  83551. scale(ratio: number): void;
  83552. /**
  83553. * Resizes the texture
  83554. * @param width the new width
  83555. * @param height the new height
  83556. */
  83557. scaleTo(width: number, height: number): void;
  83558. /**
  83559. * Gets the context of the canvas used by the texture
  83560. * @returns the canvas context of the dynamic texture
  83561. */
  83562. getContext(): CanvasRenderingContext2D;
  83563. /**
  83564. * Clears the texture
  83565. */
  83566. clear(): void;
  83567. /**
  83568. * Updates the texture
  83569. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83570. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83571. */
  83572. update(invertY?: boolean, premulAlpha?: boolean): void;
  83573. /**
  83574. * Draws text onto the texture
  83575. * @param text defines the text to be drawn
  83576. * @param x defines the placement of the text from the left
  83577. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83578. * @param font defines the font to be used with font-style, font-size, font-name
  83579. * @param color defines the color used for the text
  83580. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83581. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83582. * @param update defines whether texture is immediately update (default is true)
  83583. */
  83584. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83585. /**
  83586. * Clones the texture
  83587. * @returns the clone of the texture.
  83588. */
  83589. clone(): DynamicTexture;
  83590. /**
  83591. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83592. * @returns a serialized dynamic texture object
  83593. */
  83594. serialize(): any;
  83595. /** @hidden */
  83596. _rebuild(): void;
  83597. }
  83598. }
  83599. declare module BABYLON {
  83600. interface Engine {
  83601. /**
  83602. * Creates a raw texture
  83603. * @param data defines the data to store in the texture
  83604. * @param width defines the width of the texture
  83605. * @param height defines the height of the texture
  83606. * @param format defines the format of the data
  83607. * @param generateMipMaps defines if the engine should generate the mip levels
  83608. * @param invertY defines if data must be stored with Y axis inverted
  83609. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83610. * @param compression defines the compression used (null by default)
  83611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83612. * @returns the raw texture inside an InternalTexture
  83613. */
  83614. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83615. /**
  83616. * Update a raw texture
  83617. * @param texture defines the texture to update
  83618. * @param data defines the data to store in the texture
  83619. * @param format defines the format of the data
  83620. * @param invertY defines if data must be stored with Y axis inverted
  83621. */
  83622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83623. /**
  83624. * Update a raw texture
  83625. * @param texture defines the texture to update
  83626. * @param data defines the data to store in the texture
  83627. * @param format defines the format of the data
  83628. * @param invertY defines if data must be stored with Y axis inverted
  83629. * @param compression defines the compression used (null by default)
  83630. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83631. */
  83632. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83633. /**
  83634. * Creates a new raw cube texture
  83635. * @param data defines the array of data to use to create each face
  83636. * @param size defines the size of the textures
  83637. * @param format defines the format of the data
  83638. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83639. * @param generateMipMaps defines if the engine should generate the mip levels
  83640. * @param invertY defines if data must be stored with Y axis inverted
  83641. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83642. * @param compression defines the compression used (null by default)
  83643. * @returns the cube texture as an InternalTexture
  83644. */
  83645. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83646. /**
  83647. * Update a raw cube texture
  83648. * @param texture defines the texture to udpdate
  83649. * @param data defines the data to store
  83650. * @param format defines the data format
  83651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83652. * @param invertY defines if data must be stored with Y axis inverted
  83653. */
  83654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83655. /**
  83656. * Update a raw cube texture
  83657. * @param texture defines the texture to udpdate
  83658. * @param data defines the data to store
  83659. * @param format defines the data format
  83660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83661. * @param invertY defines if data must be stored with Y axis inverted
  83662. * @param compression defines the compression used (null by default)
  83663. */
  83664. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83665. /**
  83666. * Update a raw cube texture
  83667. * @param texture defines the texture to udpdate
  83668. * @param data defines the data to store
  83669. * @param format defines the data format
  83670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83671. * @param invertY defines if data must be stored with Y axis inverted
  83672. * @param compression defines the compression used (null by default)
  83673. * @param level defines which level of the texture to update
  83674. */
  83675. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83676. /**
  83677. * Creates a new raw cube texture from a specified url
  83678. * @param url defines the url where the data is located
  83679. * @param scene defines the current scene
  83680. * @param size defines the size of the textures
  83681. * @param format defines the format of the data
  83682. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83683. * @param noMipmap defines if the engine should avoid generating the mip levels
  83684. * @param callback defines a callback used to extract texture data from loaded data
  83685. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83686. * @param onLoad defines a callback called when texture is loaded
  83687. * @param onError defines a callback called if there is an error
  83688. * @returns the cube texture as an InternalTexture
  83689. */
  83690. 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;
  83691. /**
  83692. * Creates a new raw cube texture from a specified url
  83693. * @param url defines the url where the data is located
  83694. * @param scene defines the current scene
  83695. * @param size defines the size of the textures
  83696. * @param format defines the format of the data
  83697. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83698. * @param noMipmap defines if the engine should avoid generating the mip levels
  83699. * @param callback defines a callback used to extract texture data from loaded data
  83700. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83701. * @param onLoad defines a callback called when texture is loaded
  83702. * @param onError defines a callback called if there is an error
  83703. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83704. * @param invertY defines if data must be stored with Y axis inverted
  83705. * @returns the cube texture as an InternalTexture
  83706. */
  83707. 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;
  83708. /**
  83709. * Creates a new raw 3D texture
  83710. * @param data defines the data used to create the texture
  83711. * @param width defines the width of the texture
  83712. * @param height defines the height of the texture
  83713. * @param depth defines the depth of the texture
  83714. * @param format defines the format of the texture
  83715. * @param generateMipMaps defines if the engine must generate mip levels
  83716. * @param invertY defines if data must be stored with Y axis inverted
  83717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83718. * @param compression defines the compressed used (can be null)
  83719. * @param textureType defines the compressed used (can be null)
  83720. * @returns a new raw 3D texture (stored in an InternalTexture)
  83721. */
  83722. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83723. /**
  83724. * Update a raw 3D texture
  83725. * @param texture defines the texture to update
  83726. * @param data defines the data to store
  83727. * @param format defines the data format
  83728. * @param invertY defines if data must be stored with Y axis inverted
  83729. */
  83730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83731. /**
  83732. * Update a raw 3D texture
  83733. * @param texture defines the texture to update
  83734. * @param data defines the data to store
  83735. * @param format defines the data format
  83736. * @param invertY defines if data must be stored with Y axis inverted
  83737. * @param compression defines the used compression (can be null)
  83738. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83739. */
  83740. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83741. /**
  83742. * Creates a new raw 2D array texture
  83743. * @param data defines the data used to create the texture
  83744. * @param width defines the width of the texture
  83745. * @param height defines the height of the texture
  83746. * @param depth defines the number of layers of the texture
  83747. * @param format defines the format of the texture
  83748. * @param generateMipMaps defines if the engine must generate mip levels
  83749. * @param invertY defines if data must be stored with Y axis inverted
  83750. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83751. * @param compression defines the compressed used (can be null)
  83752. * @param textureType defines the compressed used (can be null)
  83753. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83754. */
  83755. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83756. /**
  83757. * Update a raw 2D array texture
  83758. * @param texture defines the texture to update
  83759. * @param data defines the data to store
  83760. * @param format defines the data format
  83761. * @param invertY defines if data must be stored with Y axis inverted
  83762. */
  83763. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83764. /**
  83765. * Update a raw 2D array texture
  83766. * @param texture defines the texture to update
  83767. * @param data defines the data to store
  83768. * @param format defines the data format
  83769. * @param invertY defines if data must be stored with Y axis inverted
  83770. * @param compression defines the used compression (can be null)
  83771. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83772. */
  83773. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83774. }
  83775. }
  83776. declare module BABYLON {
  83777. /**
  83778. * Raw texture can help creating a texture directly from an array of data.
  83779. * This can be super useful if you either get the data from an uncompressed source or
  83780. * if you wish to create your texture pixel by pixel.
  83781. */
  83782. export class RawTexture extends Texture {
  83783. /**
  83784. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83785. */
  83786. format: number;
  83787. private _engine;
  83788. /**
  83789. * Instantiates a new RawTexture.
  83790. * Raw texture can help creating a texture directly from an array of data.
  83791. * This can be super useful if you either get the data from an uncompressed source or
  83792. * if you wish to create your texture pixel by pixel.
  83793. * @param data define the array of data to use to create the texture
  83794. * @param width define the width of the texture
  83795. * @param height define the height of the texture
  83796. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83797. * @param scene define the scene the texture belongs to
  83798. * @param generateMipMaps define whether mip maps should be generated or not
  83799. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83800. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83801. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83802. */
  83803. constructor(data: ArrayBufferView, width: number, height: number,
  83804. /**
  83805. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83806. */
  83807. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83808. /**
  83809. * Updates the texture underlying data.
  83810. * @param data Define the new data of the texture
  83811. */
  83812. update(data: ArrayBufferView): void;
  83813. /**
  83814. * Creates a luminance texture from some data.
  83815. * @param data Define the texture data
  83816. * @param width Define the width of the texture
  83817. * @param height Define the height of the texture
  83818. * @param scene Define the scene the texture belongs to
  83819. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83820. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83821. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83822. * @returns the luminance texture
  83823. */
  83824. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83825. /**
  83826. * Creates a luminance alpha texture from some data.
  83827. * @param data Define the texture data
  83828. * @param width Define the width of the texture
  83829. * @param height Define the height of the texture
  83830. * @param scene Define the scene the texture belongs to
  83831. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83832. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83833. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83834. * @returns the luminance alpha texture
  83835. */
  83836. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83837. /**
  83838. * Creates an alpha texture from some data.
  83839. * @param data Define the texture data
  83840. * @param width Define the width of the texture
  83841. * @param height Define the height of the texture
  83842. * @param scene Define the scene the texture belongs to
  83843. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83844. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83845. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83846. * @returns the alpha texture
  83847. */
  83848. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83849. /**
  83850. * Creates a RGB texture from some data.
  83851. * @param data Define the texture data
  83852. * @param width Define the width of the texture
  83853. * @param height Define the height of the texture
  83854. * @param scene Define the scene the texture belongs to
  83855. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83856. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83857. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83858. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83859. * @returns the RGB alpha texture
  83860. */
  83861. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83862. /**
  83863. * Creates a RGBA texture from some data.
  83864. * @param data Define the texture data
  83865. * @param width Define the width of the texture
  83866. * @param height Define the height of the texture
  83867. * @param scene Define the scene the texture belongs to
  83868. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83869. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83870. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83871. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83872. * @returns the RGBA texture
  83873. */
  83874. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83875. /**
  83876. * Creates a R texture from some data.
  83877. * @param data Define the texture data
  83878. * @param width Define the width of the texture
  83879. * @param height Define the height of the texture
  83880. * @param scene Define the scene the texture belongs to
  83881. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83884. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83885. * @returns the R texture
  83886. */
  83887. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83888. }
  83889. }
  83890. declare module BABYLON {
  83891. interface AbstractScene {
  83892. /**
  83893. * The list of procedural textures added to the scene
  83894. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83895. */
  83896. proceduralTextures: Array<ProceduralTexture>;
  83897. }
  83898. /**
  83899. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83900. * in a given scene.
  83901. */
  83902. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83903. /**
  83904. * The component name helpfull to identify the component in the list of scene components.
  83905. */
  83906. readonly name: string;
  83907. /**
  83908. * The scene the component belongs to.
  83909. */
  83910. scene: Scene;
  83911. /**
  83912. * Creates a new instance of the component for the given scene
  83913. * @param scene Defines the scene to register the component in
  83914. */
  83915. constructor(scene: Scene);
  83916. /**
  83917. * Registers the component in a given scene
  83918. */
  83919. register(): void;
  83920. /**
  83921. * Rebuilds the elements related to this component in case of
  83922. * context lost for instance.
  83923. */
  83924. rebuild(): void;
  83925. /**
  83926. * Disposes the component and the associated ressources.
  83927. */
  83928. dispose(): void;
  83929. private _beforeClear;
  83930. }
  83931. }
  83932. declare module BABYLON {
  83933. interface ThinEngine {
  83934. /**
  83935. * Creates a new render target cube texture
  83936. * @param size defines the size of the texture
  83937. * @param options defines the options used to create the texture
  83938. * @returns a new render target cube texture stored in an InternalTexture
  83939. */
  83940. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83941. }
  83942. }
  83943. declare module BABYLON {
  83944. /** @hidden */
  83945. export var proceduralVertexShader: {
  83946. name: string;
  83947. shader: string;
  83948. };
  83949. }
  83950. declare module BABYLON {
  83951. /**
  83952. * 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.
  83953. * This is the base class of any Procedural texture and contains most of the shareable code.
  83954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83955. */
  83956. export class ProceduralTexture extends Texture {
  83957. isCube: boolean;
  83958. /**
  83959. * Define if the texture is enabled or not (disabled texture will not render)
  83960. */
  83961. isEnabled: boolean;
  83962. /**
  83963. * Define if the texture must be cleared before rendering (default is true)
  83964. */
  83965. autoClear: boolean;
  83966. /**
  83967. * Callback called when the texture is generated
  83968. */
  83969. onGenerated: () => void;
  83970. /**
  83971. * Event raised when the texture is generated
  83972. */
  83973. onGeneratedObservable: Observable<ProceduralTexture>;
  83974. /** @hidden */
  83975. _generateMipMaps: boolean;
  83976. /** @hidden **/
  83977. _effect: Effect;
  83978. /** @hidden */
  83979. _textures: {
  83980. [key: string]: Texture;
  83981. };
  83982. private _size;
  83983. private _currentRefreshId;
  83984. private _frameId;
  83985. private _refreshRate;
  83986. private _vertexBuffers;
  83987. private _indexBuffer;
  83988. private _uniforms;
  83989. private _samplers;
  83990. private _fragment;
  83991. private _floats;
  83992. private _ints;
  83993. private _floatsArrays;
  83994. private _colors3;
  83995. private _colors4;
  83996. private _vectors2;
  83997. private _vectors3;
  83998. private _matrices;
  83999. private _fallbackTexture;
  84000. private _fallbackTextureUsed;
  84001. private _engine;
  84002. private _cachedDefines;
  84003. private _contentUpdateId;
  84004. private _contentData;
  84005. /**
  84006. * Instantiates a new procedural texture.
  84007. * 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.
  84008. * This is the base class of any Procedural texture and contains most of the shareable code.
  84009. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84010. * @param name Define the name of the texture
  84011. * @param size Define the size of the texture to create
  84012. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84013. * @param scene Define the scene the texture belongs to
  84014. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84015. * @param generateMipMaps Define if the texture should creates mip maps or not
  84016. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84017. */
  84018. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84019. /**
  84020. * The effect that is created when initializing the post process.
  84021. * @returns The created effect corresponding the the postprocess.
  84022. */
  84023. getEffect(): Effect;
  84024. /**
  84025. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84026. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84027. */
  84028. getContent(): Nullable<ArrayBufferView>;
  84029. private _createIndexBuffer;
  84030. /** @hidden */
  84031. _rebuild(): void;
  84032. /**
  84033. * Resets the texture in order to recreate its associated resources.
  84034. * This can be called in case of context loss
  84035. */
  84036. reset(): void;
  84037. protected _getDefines(): string;
  84038. /**
  84039. * Is the texture ready to be used ? (rendered at least once)
  84040. * @returns true if ready, otherwise, false.
  84041. */
  84042. isReady(): boolean;
  84043. /**
  84044. * Resets the refresh counter of the texture and start bak from scratch.
  84045. * Could be useful to regenerate the texture if it is setup to render only once.
  84046. */
  84047. resetRefreshCounter(): void;
  84048. /**
  84049. * Set the fragment shader to use in order to render the texture.
  84050. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84051. */
  84052. setFragment(fragment: any): void;
  84053. /**
  84054. * Define the refresh rate of the texture or the rendering frequency.
  84055. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84056. */
  84057. get refreshRate(): number;
  84058. set refreshRate(value: number);
  84059. /** @hidden */
  84060. _shouldRender(): boolean;
  84061. /**
  84062. * Get the size the texture is rendering at.
  84063. * @returns the size (texture is always squared)
  84064. */
  84065. getRenderSize(): number;
  84066. /**
  84067. * Resize the texture to new value.
  84068. * @param size Define the new size the texture should have
  84069. * @param generateMipMaps Define whether the new texture should create mip maps
  84070. */
  84071. resize(size: number, generateMipMaps: boolean): void;
  84072. private _checkUniform;
  84073. /**
  84074. * Set a texture in the shader program used to render.
  84075. * @param name Define the name of the uniform samplers as defined in the shader
  84076. * @param texture Define the texture to bind to this sampler
  84077. * @return the texture itself allowing "fluent" like uniform updates
  84078. */
  84079. setTexture(name: string, texture: Texture): ProceduralTexture;
  84080. /**
  84081. * Set a float in the shader.
  84082. * @param name Define the name of the uniform as defined in the shader
  84083. * @param value Define the value to give to the uniform
  84084. * @return the texture itself allowing "fluent" like uniform updates
  84085. */
  84086. setFloat(name: string, value: number): ProceduralTexture;
  84087. /**
  84088. * Set a int in the shader.
  84089. * @param name Define the name of the uniform as defined in the shader
  84090. * @param value Define the value to give to the uniform
  84091. * @return the texture itself allowing "fluent" like uniform updates
  84092. */
  84093. setInt(name: string, value: number): ProceduralTexture;
  84094. /**
  84095. * Set an array of floats in the shader.
  84096. * @param name Define the name of the uniform as defined in the shader
  84097. * @param value Define the value to give to the uniform
  84098. * @return the texture itself allowing "fluent" like uniform updates
  84099. */
  84100. setFloats(name: string, value: number[]): ProceduralTexture;
  84101. /**
  84102. * Set a vec3 in the shader from a Color3.
  84103. * @param name Define the name of the uniform as defined in the shader
  84104. * @param value Define the value to give to the uniform
  84105. * @return the texture itself allowing "fluent" like uniform updates
  84106. */
  84107. setColor3(name: string, value: Color3): ProceduralTexture;
  84108. /**
  84109. * Set a vec4 in the shader from a Color4.
  84110. * @param name Define the name of the uniform as defined in the shader
  84111. * @param value Define the value to give to the uniform
  84112. * @return the texture itself allowing "fluent" like uniform updates
  84113. */
  84114. setColor4(name: string, value: Color4): ProceduralTexture;
  84115. /**
  84116. * Set a vec2 in the shader from a Vector2.
  84117. * @param name Define the name of the uniform as defined in the shader
  84118. * @param value Define the value to give to the uniform
  84119. * @return the texture itself allowing "fluent" like uniform updates
  84120. */
  84121. setVector2(name: string, value: Vector2): ProceduralTexture;
  84122. /**
  84123. * Set a vec3 in the shader from a Vector3.
  84124. * @param name Define the name of the uniform as defined in the shader
  84125. * @param value Define the value to give to the uniform
  84126. * @return the texture itself allowing "fluent" like uniform updates
  84127. */
  84128. setVector3(name: string, value: Vector3): ProceduralTexture;
  84129. /**
  84130. * Set a mat4 in the shader from a MAtrix.
  84131. * @param name Define the name of the uniform as defined in the shader
  84132. * @param value Define the value to give to the uniform
  84133. * @return the texture itself allowing "fluent" like uniform updates
  84134. */
  84135. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84136. /**
  84137. * Render the texture to its associated render target.
  84138. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84139. */
  84140. render(useCameraPostProcess?: boolean): void;
  84141. /**
  84142. * Clone the texture.
  84143. * @returns the cloned texture
  84144. */
  84145. clone(): ProceduralTexture;
  84146. /**
  84147. * Dispose the texture and release its asoociated resources.
  84148. */
  84149. dispose(): void;
  84150. }
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * This represents the base class for particle system in Babylon.
  84155. * 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.
  84156. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84157. * @example https://doc.babylonjs.com/babylon101/particles
  84158. */
  84159. export class BaseParticleSystem {
  84160. /**
  84161. * Source color is added to the destination color without alpha affecting the result
  84162. */
  84163. static BLENDMODE_ONEONE: number;
  84164. /**
  84165. * Blend current color and particle color using particle’s alpha
  84166. */
  84167. static BLENDMODE_STANDARD: number;
  84168. /**
  84169. * Add current color and particle color multiplied by particle’s alpha
  84170. */
  84171. static BLENDMODE_ADD: number;
  84172. /**
  84173. * Multiply current color with particle color
  84174. */
  84175. static BLENDMODE_MULTIPLY: number;
  84176. /**
  84177. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84178. */
  84179. static BLENDMODE_MULTIPLYADD: number;
  84180. /**
  84181. * List of animations used by the particle system.
  84182. */
  84183. animations: Animation[];
  84184. /**
  84185. * The id of the Particle system.
  84186. */
  84187. id: string;
  84188. /**
  84189. * The friendly name of the Particle system.
  84190. */
  84191. name: string;
  84192. /**
  84193. * The rendering group used by the Particle system to chose when to render.
  84194. */
  84195. renderingGroupId: number;
  84196. /**
  84197. * The emitter represents the Mesh or position we are attaching the particle system to.
  84198. */
  84199. emitter: Nullable<AbstractMesh | Vector3>;
  84200. /**
  84201. * The maximum number of particles to emit per frame
  84202. */
  84203. emitRate: number;
  84204. /**
  84205. * If you want to launch only a few particles at once, that can be done, as well.
  84206. */
  84207. manualEmitCount: number;
  84208. /**
  84209. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84210. */
  84211. updateSpeed: number;
  84212. /**
  84213. * The amount of time the particle system is running (depends of the overall update speed).
  84214. */
  84215. targetStopDuration: number;
  84216. /**
  84217. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84218. */
  84219. disposeOnStop: boolean;
  84220. /**
  84221. * Minimum power of emitting particles.
  84222. */
  84223. minEmitPower: number;
  84224. /**
  84225. * Maximum power of emitting particles.
  84226. */
  84227. maxEmitPower: number;
  84228. /**
  84229. * Minimum life time of emitting particles.
  84230. */
  84231. minLifeTime: number;
  84232. /**
  84233. * Maximum life time of emitting particles.
  84234. */
  84235. maxLifeTime: number;
  84236. /**
  84237. * Minimum Size of emitting particles.
  84238. */
  84239. minSize: number;
  84240. /**
  84241. * Maximum Size of emitting particles.
  84242. */
  84243. maxSize: number;
  84244. /**
  84245. * Minimum scale of emitting particles on X axis.
  84246. */
  84247. minScaleX: number;
  84248. /**
  84249. * Maximum scale of emitting particles on X axis.
  84250. */
  84251. maxScaleX: number;
  84252. /**
  84253. * Minimum scale of emitting particles on Y axis.
  84254. */
  84255. minScaleY: number;
  84256. /**
  84257. * Maximum scale of emitting particles on Y axis.
  84258. */
  84259. maxScaleY: number;
  84260. /**
  84261. * Gets or sets the minimal initial rotation in radians.
  84262. */
  84263. minInitialRotation: number;
  84264. /**
  84265. * Gets or sets the maximal initial rotation in radians.
  84266. */
  84267. maxInitialRotation: number;
  84268. /**
  84269. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84270. */
  84271. minAngularSpeed: number;
  84272. /**
  84273. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84274. */
  84275. maxAngularSpeed: number;
  84276. /**
  84277. * The texture used to render each particle. (this can be a spritesheet)
  84278. */
  84279. particleTexture: Nullable<Texture>;
  84280. /**
  84281. * The layer mask we are rendering the particles through.
  84282. */
  84283. layerMask: number;
  84284. /**
  84285. * This can help using your own shader to render the particle system.
  84286. * The according effect will be created
  84287. */
  84288. customShader: any;
  84289. /**
  84290. * By default particle system starts as soon as they are created. This prevents the
  84291. * automatic start to happen and let you decide when to start emitting particles.
  84292. */
  84293. preventAutoStart: boolean;
  84294. private _noiseTexture;
  84295. /**
  84296. * Gets or sets a texture used to add random noise to particle positions
  84297. */
  84298. get noiseTexture(): Nullable<ProceduralTexture>;
  84299. set noiseTexture(value: Nullable<ProceduralTexture>);
  84300. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84301. noiseStrength: Vector3;
  84302. /**
  84303. * Callback triggered when the particle animation is ending.
  84304. */
  84305. onAnimationEnd: Nullable<() => void>;
  84306. /**
  84307. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84308. */
  84309. blendMode: number;
  84310. /**
  84311. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84312. * to override the particles.
  84313. */
  84314. forceDepthWrite: boolean;
  84315. /** 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 */
  84316. preWarmCycles: number;
  84317. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84318. preWarmStepOffset: number;
  84319. /**
  84320. * 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)
  84321. */
  84322. spriteCellChangeSpeed: number;
  84323. /**
  84324. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84325. */
  84326. startSpriteCellID: number;
  84327. /**
  84328. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84329. */
  84330. endSpriteCellID: number;
  84331. /**
  84332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84333. */
  84334. spriteCellWidth: number;
  84335. /**
  84336. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84337. */
  84338. spriteCellHeight: number;
  84339. /**
  84340. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84341. */
  84342. spriteRandomStartCell: boolean;
  84343. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84344. translationPivot: Vector2;
  84345. /** @hidden */
  84346. protected _isAnimationSheetEnabled: boolean;
  84347. /**
  84348. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84349. */
  84350. beginAnimationOnStart: boolean;
  84351. /**
  84352. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84353. */
  84354. beginAnimationFrom: number;
  84355. /**
  84356. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84357. */
  84358. beginAnimationTo: number;
  84359. /**
  84360. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84361. */
  84362. beginAnimationLoop: boolean;
  84363. /**
  84364. * Gets or sets a world offset applied to all particles
  84365. */
  84366. worldOffset: Vector3;
  84367. /**
  84368. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84369. */
  84370. get isAnimationSheetEnabled(): boolean;
  84371. set isAnimationSheetEnabled(value: boolean);
  84372. /**
  84373. * Get hosting scene
  84374. * @returns the scene
  84375. */
  84376. getScene(): Scene;
  84377. /**
  84378. * You can use gravity if you want to give an orientation to your particles.
  84379. */
  84380. gravity: Vector3;
  84381. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84382. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84383. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84384. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84385. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84386. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84387. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84388. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84389. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84390. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84391. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84392. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84393. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84394. /**
  84395. * Defines the delay in milliseconds before starting the system (0 by default)
  84396. */
  84397. startDelay: number;
  84398. /**
  84399. * Gets the current list of drag gradients.
  84400. * You must use addDragGradient and removeDragGradient to udpate this list
  84401. * @returns the list of drag gradients
  84402. */
  84403. getDragGradients(): Nullable<Array<FactorGradient>>;
  84404. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84405. limitVelocityDamping: number;
  84406. /**
  84407. * Gets the current list of limit velocity gradients.
  84408. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84409. * @returns the list of limit velocity gradients
  84410. */
  84411. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84412. /**
  84413. * Gets the current list of color gradients.
  84414. * You must use addColorGradient and removeColorGradient to udpate this list
  84415. * @returns the list of color gradients
  84416. */
  84417. getColorGradients(): Nullable<Array<ColorGradient>>;
  84418. /**
  84419. * Gets the current list of size gradients.
  84420. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84421. * @returns the list of size gradients
  84422. */
  84423. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84424. /**
  84425. * Gets the current list of color remap gradients.
  84426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84427. * @returns the list of color remap gradients
  84428. */
  84429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84430. /**
  84431. * Gets the current list of alpha remap gradients.
  84432. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84433. * @returns the list of alpha remap gradients
  84434. */
  84435. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84436. /**
  84437. * Gets the current list of life time gradients.
  84438. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84439. * @returns the list of life time gradients
  84440. */
  84441. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84442. /**
  84443. * Gets the current list of angular speed gradients.
  84444. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84445. * @returns the list of angular speed gradients
  84446. */
  84447. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84448. /**
  84449. * Gets the current list of velocity gradients.
  84450. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84451. * @returns the list of velocity gradients
  84452. */
  84453. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84454. /**
  84455. * Gets the current list of start size gradients.
  84456. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84457. * @returns the list of start size gradients
  84458. */
  84459. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84460. /**
  84461. * Gets the current list of emit rate gradients.
  84462. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84463. * @returns the list of emit rate gradients
  84464. */
  84465. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84466. /**
  84467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84468. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84469. */
  84470. get direction1(): Vector3;
  84471. set direction1(value: Vector3);
  84472. /**
  84473. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84474. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84475. */
  84476. get direction2(): Vector3;
  84477. set direction2(value: Vector3);
  84478. /**
  84479. * 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.
  84480. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84481. */
  84482. get minEmitBox(): Vector3;
  84483. set minEmitBox(value: Vector3);
  84484. /**
  84485. * 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.
  84486. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84487. */
  84488. get maxEmitBox(): Vector3;
  84489. set maxEmitBox(value: Vector3);
  84490. /**
  84491. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84492. */
  84493. color1: Color4;
  84494. /**
  84495. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84496. */
  84497. color2: Color4;
  84498. /**
  84499. * Color the particle will have at the end of its lifetime
  84500. */
  84501. colorDead: Color4;
  84502. /**
  84503. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84504. */
  84505. textureMask: Color4;
  84506. /**
  84507. * The particle emitter type defines the emitter used by the particle system.
  84508. * It can be for example box, sphere, or cone...
  84509. */
  84510. particleEmitterType: IParticleEmitterType;
  84511. /** @hidden */
  84512. _isSubEmitter: boolean;
  84513. /**
  84514. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84515. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84516. */
  84517. billboardMode: number;
  84518. protected _isBillboardBased: boolean;
  84519. /**
  84520. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84521. */
  84522. get isBillboardBased(): boolean;
  84523. set isBillboardBased(value: boolean);
  84524. /**
  84525. * The scene the particle system belongs to.
  84526. */
  84527. protected _scene: Scene;
  84528. /**
  84529. * Local cache of defines for image processing.
  84530. */
  84531. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84532. /**
  84533. * Default configuration related to image processing available in the standard Material.
  84534. */
  84535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84536. /**
  84537. * Gets the image processing configuration used either in this material.
  84538. */
  84539. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84540. /**
  84541. * Sets the Default image processing configuration used either in the this material.
  84542. *
  84543. * If sets to null, the scene one is in use.
  84544. */
  84545. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84546. /**
  84547. * Attaches a new image processing configuration to the Standard Material.
  84548. * @param configuration
  84549. */
  84550. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84551. /** @hidden */
  84552. protected _reset(): void;
  84553. /** @hidden */
  84554. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84555. /**
  84556. * Instantiates a particle system.
  84557. * 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.
  84558. * @param name The name of the particle system
  84559. */
  84560. constructor(name: string);
  84561. /**
  84562. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84565. * @returns the emitter
  84566. */
  84567. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84568. /**
  84569. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84570. * @param radius The radius of the hemisphere to emit from
  84571. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84572. * @returns the emitter
  84573. */
  84574. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84575. /**
  84576. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84577. * @param radius The radius of the sphere to emit from
  84578. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84579. * @returns the emitter
  84580. */
  84581. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84582. /**
  84583. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84584. * @param radius The radius of the sphere to emit from
  84585. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84586. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84587. * @returns the emitter
  84588. */
  84589. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84590. /**
  84591. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84592. * @param radius The radius of the emission cylinder
  84593. * @param height The height of the emission cylinder
  84594. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84595. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84596. * @returns the emitter
  84597. */
  84598. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84599. /**
  84600. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84601. * @param radius The radius of the cylinder to emit from
  84602. * @param height The height of the emission cylinder
  84603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84606. * @returns the emitter
  84607. */
  84608. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84609. /**
  84610. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84611. * @param radius The radius of the cone to emit from
  84612. * @param angle The base angle of the cone
  84613. * @returns the emitter
  84614. */
  84615. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84616. /**
  84617. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84620. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84621. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84622. * @returns the emitter
  84623. */
  84624. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84625. }
  84626. }
  84627. declare module BABYLON {
  84628. /**
  84629. * Type of sub emitter
  84630. */
  84631. export enum SubEmitterType {
  84632. /**
  84633. * Attached to the particle over it's lifetime
  84634. */
  84635. ATTACHED = 0,
  84636. /**
  84637. * Created when the particle dies
  84638. */
  84639. END = 1
  84640. }
  84641. /**
  84642. * Sub emitter class used to emit particles from an existing particle
  84643. */
  84644. export class SubEmitter {
  84645. /**
  84646. * the particle system to be used by the sub emitter
  84647. */
  84648. particleSystem: ParticleSystem;
  84649. /**
  84650. * Type of the submitter (Default: END)
  84651. */
  84652. type: SubEmitterType;
  84653. /**
  84654. * 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)
  84655. * Note: This only is supported when using an emitter of type Mesh
  84656. */
  84657. inheritDirection: boolean;
  84658. /**
  84659. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84660. */
  84661. inheritedVelocityAmount: number;
  84662. /**
  84663. * Creates a sub emitter
  84664. * @param particleSystem the particle system to be used by the sub emitter
  84665. */
  84666. constructor(
  84667. /**
  84668. * the particle system to be used by the sub emitter
  84669. */
  84670. particleSystem: ParticleSystem);
  84671. /**
  84672. * Clones the sub emitter
  84673. * @returns the cloned sub emitter
  84674. */
  84675. clone(): SubEmitter;
  84676. /**
  84677. * Serialize current object to a JSON object
  84678. * @returns the serialized object
  84679. */
  84680. serialize(): any;
  84681. /** @hidden */
  84682. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84683. /**
  84684. * Creates a new SubEmitter from a serialized JSON version
  84685. * @param serializationObject defines the JSON object to read from
  84686. * @param scene defines the hosting scene
  84687. * @param rootUrl defines the rootUrl for data loading
  84688. * @returns a new SubEmitter
  84689. */
  84690. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84691. /** Release associated resources */
  84692. dispose(): void;
  84693. }
  84694. }
  84695. declare module BABYLON {
  84696. /** @hidden */
  84697. export var imageProcessingDeclaration: {
  84698. name: string;
  84699. shader: string;
  84700. };
  84701. }
  84702. declare module BABYLON {
  84703. /** @hidden */
  84704. export var imageProcessingFunctions: {
  84705. name: string;
  84706. shader: string;
  84707. };
  84708. }
  84709. declare module BABYLON {
  84710. /** @hidden */
  84711. export var particlesPixelShader: {
  84712. name: string;
  84713. shader: string;
  84714. };
  84715. }
  84716. declare module BABYLON {
  84717. /** @hidden */
  84718. export var particlesVertexShader: {
  84719. name: string;
  84720. shader: string;
  84721. };
  84722. }
  84723. declare module BABYLON {
  84724. /**
  84725. * This represents a particle system in Babylon.
  84726. * 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.
  84727. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84728. * @example https://doc.babylonjs.com/babylon101/particles
  84729. */
  84730. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84731. /**
  84732. * Billboard mode will only apply to Y axis
  84733. */
  84734. static readonly BILLBOARDMODE_Y: number;
  84735. /**
  84736. * Billboard mode will apply to all axes
  84737. */
  84738. static readonly BILLBOARDMODE_ALL: number;
  84739. /**
  84740. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84741. */
  84742. static readonly BILLBOARDMODE_STRETCHED: number;
  84743. /**
  84744. * This function can be defined to provide custom update for active particles.
  84745. * This function will be called instead of regular update (age, position, color, etc.).
  84746. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84747. */
  84748. updateFunction: (particles: Particle[]) => void;
  84749. private _emitterWorldMatrix;
  84750. /**
  84751. * This function can be defined to specify initial direction for every new particle.
  84752. * It by default use the emitterType defined function
  84753. */
  84754. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84755. /**
  84756. * This function can be defined to specify initial position for every new particle.
  84757. * It by default use the emitterType defined function
  84758. */
  84759. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84760. /**
  84761. * @hidden
  84762. */
  84763. _inheritedVelocityOffset: Vector3;
  84764. /**
  84765. * An event triggered when the system is disposed
  84766. */
  84767. onDisposeObservable: Observable<ParticleSystem>;
  84768. private _onDisposeObserver;
  84769. /**
  84770. * Sets a callback that will be triggered when the system is disposed
  84771. */
  84772. set onDispose(callback: () => void);
  84773. private _particles;
  84774. private _epsilon;
  84775. private _capacity;
  84776. private _stockParticles;
  84777. private _newPartsExcess;
  84778. private _vertexData;
  84779. private _vertexBuffer;
  84780. private _vertexBuffers;
  84781. private _spriteBuffer;
  84782. private _indexBuffer;
  84783. private _effect;
  84784. private _customEffect;
  84785. private _cachedDefines;
  84786. private _scaledColorStep;
  84787. private _colorDiff;
  84788. private _scaledDirection;
  84789. private _scaledGravity;
  84790. private _currentRenderId;
  84791. private _alive;
  84792. private _useInstancing;
  84793. private _started;
  84794. private _stopped;
  84795. private _actualFrame;
  84796. private _scaledUpdateSpeed;
  84797. private _vertexBufferSize;
  84798. /** @hidden */
  84799. _currentEmitRateGradient: Nullable<FactorGradient>;
  84800. /** @hidden */
  84801. _currentEmitRate1: number;
  84802. /** @hidden */
  84803. _currentEmitRate2: number;
  84804. /** @hidden */
  84805. _currentStartSizeGradient: Nullable<FactorGradient>;
  84806. /** @hidden */
  84807. _currentStartSize1: number;
  84808. /** @hidden */
  84809. _currentStartSize2: number;
  84810. private readonly _rawTextureWidth;
  84811. private _rampGradientsTexture;
  84812. private _useRampGradients;
  84813. /** Gets or sets a boolean indicating that ramp gradients must be used
  84814. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84815. */
  84816. get useRampGradients(): boolean;
  84817. set useRampGradients(value: boolean);
  84818. /**
  84819. * 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.
  84820. * 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: [])
  84821. */
  84822. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84823. private _subEmitters;
  84824. /**
  84825. * @hidden
  84826. * If the particle systems emitter should be disposed when the particle system is disposed
  84827. */
  84828. _disposeEmitterOnDispose: boolean;
  84829. /**
  84830. * The current active Sub-systems, this property is used by the root particle system only.
  84831. */
  84832. activeSubSystems: Array<ParticleSystem>;
  84833. private _rootParticleSystem;
  84834. /**
  84835. * Gets the current list of active particles
  84836. */
  84837. get particles(): Particle[];
  84838. /**
  84839. * Returns the string "ParticleSystem"
  84840. * @returns a string containing the class name
  84841. */
  84842. getClassName(): string;
  84843. /**
  84844. * Instantiates a particle system.
  84845. * 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.
  84846. * @param name The name of the particle system
  84847. * @param capacity The max number of particles alive at the same time
  84848. * @param scene The scene the particle system belongs to
  84849. * @param customEffect a custom effect used to change the way particles are rendered by default
  84850. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84851. * @param epsilon Offset used to render the particles
  84852. */
  84853. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84854. private _addFactorGradient;
  84855. private _removeFactorGradient;
  84856. /**
  84857. * Adds a new life time gradient
  84858. * @param gradient defines the gradient to use (between 0 and 1)
  84859. * @param factor defines the life time factor to affect to the specified gradient
  84860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84861. * @returns the current particle system
  84862. */
  84863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84864. /**
  84865. * Remove a specific life time gradient
  84866. * @param gradient defines the gradient to remove
  84867. * @returns the current particle system
  84868. */
  84869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84870. /**
  84871. * Adds a new size gradient
  84872. * @param gradient defines the gradient to use (between 0 and 1)
  84873. * @param factor defines the size factor to affect to the specified gradient
  84874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84875. * @returns the current particle system
  84876. */
  84877. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84878. /**
  84879. * Remove a specific size gradient
  84880. * @param gradient defines the gradient to remove
  84881. * @returns the current particle system
  84882. */
  84883. removeSizeGradient(gradient: number): IParticleSystem;
  84884. /**
  84885. * Adds a new color remap gradient
  84886. * @param gradient defines the gradient to use (between 0 and 1)
  84887. * @param min defines the color remap minimal range
  84888. * @param max defines the color remap maximal range
  84889. * @returns the current particle system
  84890. */
  84891. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84892. /**
  84893. * Remove a specific color remap gradient
  84894. * @param gradient defines the gradient to remove
  84895. * @returns the current particle system
  84896. */
  84897. removeColorRemapGradient(gradient: number): IParticleSystem;
  84898. /**
  84899. * Adds a new alpha remap gradient
  84900. * @param gradient defines the gradient to use (between 0 and 1)
  84901. * @param min defines the alpha remap minimal range
  84902. * @param max defines the alpha remap maximal range
  84903. * @returns the current particle system
  84904. */
  84905. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84906. /**
  84907. * Remove a specific alpha remap gradient
  84908. * @param gradient defines the gradient to remove
  84909. * @returns the current particle system
  84910. */
  84911. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84912. /**
  84913. * Adds a new angular speed gradient
  84914. * @param gradient defines the gradient to use (between 0 and 1)
  84915. * @param factor defines the angular speed to affect to the specified gradient
  84916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84917. * @returns the current particle system
  84918. */
  84919. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84920. /**
  84921. * Remove a specific angular speed gradient
  84922. * @param gradient defines the gradient to remove
  84923. * @returns the current particle system
  84924. */
  84925. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84926. /**
  84927. * Adds a new velocity gradient
  84928. * @param gradient defines the gradient to use (between 0 and 1)
  84929. * @param factor defines the velocity to affect to the specified gradient
  84930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84931. * @returns the current particle system
  84932. */
  84933. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84934. /**
  84935. * Remove a specific velocity gradient
  84936. * @param gradient defines the gradient to remove
  84937. * @returns the current particle system
  84938. */
  84939. removeVelocityGradient(gradient: number): IParticleSystem;
  84940. /**
  84941. * Adds a new limit velocity gradient
  84942. * @param gradient defines the gradient to use (between 0 and 1)
  84943. * @param factor defines the limit velocity value to affect to the specified gradient
  84944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84945. * @returns the current particle system
  84946. */
  84947. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84948. /**
  84949. * Remove a specific limit velocity gradient
  84950. * @param gradient defines the gradient to remove
  84951. * @returns the current particle system
  84952. */
  84953. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84954. /**
  84955. * Adds a new drag gradient
  84956. * @param gradient defines the gradient to use (between 0 and 1)
  84957. * @param factor defines the drag value to affect to the specified gradient
  84958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84959. * @returns the current particle system
  84960. */
  84961. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84962. /**
  84963. * Remove a specific drag gradient
  84964. * @param gradient defines the gradient to remove
  84965. * @returns the current particle system
  84966. */
  84967. removeDragGradient(gradient: number): IParticleSystem;
  84968. /**
  84969. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84970. * @param gradient defines the gradient to use (between 0 and 1)
  84971. * @param factor defines the emit rate value to affect to the specified gradient
  84972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84973. * @returns the current particle system
  84974. */
  84975. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84976. /**
  84977. * Remove a specific emit rate gradient
  84978. * @param gradient defines the gradient to remove
  84979. * @returns the current particle system
  84980. */
  84981. removeEmitRateGradient(gradient: number): IParticleSystem;
  84982. /**
  84983. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84984. * @param gradient defines the gradient to use (between 0 and 1)
  84985. * @param factor defines the start size value to affect to the specified gradient
  84986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84987. * @returns the current particle system
  84988. */
  84989. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84990. /**
  84991. * Remove a specific start size gradient
  84992. * @param gradient defines the gradient to remove
  84993. * @returns the current particle system
  84994. */
  84995. removeStartSizeGradient(gradient: number): IParticleSystem;
  84996. private _createRampGradientTexture;
  84997. /**
  84998. * Gets the current list of ramp gradients.
  84999. * You must use addRampGradient and removeRampGradient to udpate this list
  85000. * @returns the list of ramp gradients
  85001. */
  85002. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85003. /**
  85004. * Adds a new ramp gradient used to remap particle colors
  85005. * @param gradient defines the gradient to use (between 0 and 1)
  85006. * @param color defines the color to affect to the specified gradient
  85007. * @returns the current particle system
  85008. */
  85009. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85010. /**
  85011. * Remove a specific ramp gradient
  85012. * @param gradient defines the gradient to remove
  85013. * @returns the current particle system
  85014. */
  85015. removeRampGradient(gradient: number): ParticleSystem;
  85016. /**
  85017. * Adds a new color gradient
  85018. * @param gradient defines the gradient to use (between 0 and 1)
  85019. * @param color1 defines the color to affect to the specified gradient
  85020. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85021. * @returns this particle system
  85022. */
  85023. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85024. /**
  85025. * Remove a specific color gradient
  85026. * @param gradient defines the gradient to remove
  85027. * @returns this particle system
  85028. */
  85029. removeColorGradient(gradient: number): IParticleSystem;
  85030. private _fetchR;
  85031. protected _reset(): void;
  85032. private _resetEffect;
  85033. private _createVertexBuffers;
  85034. private _createIndexBuffer;
  85035. /**
  85036. * Gets the maximum number of particles active at the same time.
  85037. * @returns The max number of active particles.
  85038. */
  85039. getCapacity(): number;
  85040. /**
  85041. * Gets whether there are still active particles in the system.
  85042. * @returns True if it is alive, otherwise false.
  85043. */
  85044. isAlive(): boolean;
  85045. /**
  85046. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85047. * @returns True if it has been started, otherwise false.
  85048. */
  85049. isStarted(): boolean;
  85050. private _prepareSubEmitterInternalArray;
  85051. /**
  85052. * Starts the particle system and begins to emit
  85053. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85054. */
  85055. start(delay?: number): void;
  85056. /**
  85057. * Stops the particle system.
  85058. * @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.
  85059. */
  85060. stop(stopSubEmitters?: boolean): void;
  85061. /**
  85062. * Remove all active particles
  85063. */
  85064. reset(): void;
  85065. /**
  85066. * @hidden (for internal use only)
  85067. */
  85068. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85069. /**
  85070. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85071. * Its lifetime will start back at 0.
  85072. */
  85073. recycleParticle: (particle: Particle) => void;
  85074. private _stopSubEmitters;
  85075. private _createParticle;
  85076. private _removeFromRoot;
  85077. private _emitFromParticle;
  85078. private _update;
  85079. /** @hidden */
  85080. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85081. /** @hidden */
  85082. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85083. /** @hidden */
  85084. private _getEffect;
  85085. /**
  85086. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85087. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85088. */
  85089. animate(preWarmOnly?: boolean): void;
  85090. private _appendParticleVertices;
  85091. /**
  85092. * Rebuilds the particle system.
  85093. */
  85094. rebuild(): void;
  85095. /**
  85096. * Is this system ready to be used/rendered
  85097. * @return true if the system is ready
  85098. */
  85099. isReady(): boolean;
  85100. private _render;
  85101. /**
  85102. * Renders the particle system in its current state.
  85103. * @returns the current number of particles
  85104. */
  85105. render(): number;
  85106. /**
  85107. * Disposes the particle system and free the associated resources
  85108. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85109. */
  85110. dispose(disposeTexture?: boolean): void;
  85111. /**
  85112. * Clones the particle system.
  85113. * @param name The name of the cloned object
  85114. * @param newEmitter The new emitter to use
  85115. * @returns the cloned particle system
  85116. */
  85117. clone(name: string, newEmitter: any): ParticleSystem;
  85118. /**
  85119. * Serializes the particle system to a JSON object.
  85120. * @returns the JSON object
  85121. */
  85122. serialize(): any;
  85123. /** @hidden */
  85124. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85125. /** @hidden */
  85126. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85127. /**
  85128. * Parses a JSON object to create a particle system.
  85129. * @param parsedParticleSystem The JSON object to parse
  85130. * @param scene The scene to create the particle system in
  85131. * @param rootUrl The root url to use to load external dependencies like texture
  85132. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85133. * @returns the Parsed particle system
  85134. */
  85135. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85136. }
  85137. }
  85138. declare module BABYLON {
  85139. /**
  85140. * A particle represents one of the element emitted by a particle system.
  85141. * This is mainly define by its coordinates, direction, velocity and age.
  85142. */
  85143. export class Particle {
  85144. /**
  85145. * The particle system the particle belongs to.
  85146. */
  85147. particleSystem: ParticleSystem;
  85148. private static _Count;
  85149. /**
  85150. * Unique ID of the particle
  85151. */
  85152. id: number;
  85153. /**
  85154. * The world position of the particle in the scene.
  85155. */
  85156. position: Vector3;
  85157. /**
  85158. * The world direction of the particle in the scene.
  85159. */
  85160. direction: Vector3;
  85161. /**
  85162. * The color of the particle.
  85163. */
  85164. color: Color4;
  85165. /**
  85166. * The color change of the particle per step.
  85167. */
  85168. colorStep: Color4;
  85169. /**
  85170. * Defines how long will the life of the particle be.
  85171. */
  85172. lifeTime: number;
  85173. /**
  85174. * The current age of the particle.
  85175. */
  85176. age: number;
  85177. /**
  85178. * The current size of the particle.
  85179. */
  85180. size: number;
  85181. /**
  85182. * The current scale of the particle.
  85183. */
  85184. scale: Vector2;
  85185. /**
  85186. * The current angle of the particle.
  85187. */
  85188. angle: number;
  85189. /**
  85190. * Defines how fast is the angle changing.
  85191. */
  85192. angularSpeed: number;
  85193. /**
  85194. * Defines the cell index used by the particle to be rendered from a sprite.
  85195. */
  85196. cellIndex: number;
  85197. /**
  85198. * The information required to support color remapping
  85199. */
  85200. remapData: Vector4;
  85201. /** @hidden */
  85202. _randomCellOffset?: number;
  85203. /** @hidden */
  85204. _initialDirection: Nullable<Vector3>;
  85205. /** @hidden */
  85206. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85207. /** @hidden */
  85208. _initialStartSpriteCellID: number;
  85209. /** @hidden */
  85210. _initialEndSpriteCellID: number;
  85211. /** @hidden */
  85212. _currentColorGradient: Nullable<ColorGradient>;
  85213. /** @hidden */
  85214. _currentColor1: Color4;
  85215. /** @hidden */
  85216. _currentColor2: Color4;
  85217. /** @hidden */
  85218. _currentSizeGradient: Nullable<FactorGradient>;
  85219. /** @hidden */
  85220. _currentSize1: number;
  85221. /** @hidden */
  85222. _currentSize2: number;
  85223. /** @hidden */
  85224. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85225. /** @hidden */
  85226. _currentAngularSpeed1: number;
  85227. /** @hidden */
  85228. _currentAngularSpeed2: number;
  85229. /** @hidden */
  85230. _currentVelocityGradient: Nullable<FactorGradient>;
  85231. /** @hidden */
  85232. _currentVelocity1: number;
  85233. /** @hidden */
  85234. _currentVelocity2: number;
  85235. /** @hidden */
  85236. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85237. /** @hidden */
  85238. _currentLimitVelocity1: number;
  85239. /** @hidden */
  85240. _currentLimitVelocity2: number;
  85241. /** @hidden */
  85242. _currentDragGradient: Nullable<FactorGradient>;
  85243. /** @hidden */
  85244. _currentDrag1: number;
  85245. /** @hidden */
  85246. _currentDrag2: number;
  85247. /** @hidden */
  85248. _randomNoiseCoordinates1: Vector3;
  85249. /** @hidden */
  85250. _randomNoiseCoordinates2: Vector3;
  85251. /**
  85252. * Creates a new instance Particle
  85253. * @param particleSystem the particle system the particle belongs to
  85254. */
  85255. constructor(
  85256. /**
  85257. * The particle system the particle belongs to.
  85258. */
  85259. particleSystem: ParticleSystem);
  85260. private updateCellInfoFromSystem;
  85261. /**
  85262. * Defines how the sprite cell index is updated for the particle
  85263. */
  85264. updateCellIndex(): void;
  85265. /** @hidden */
  85266. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85267. /** @hidden */
  85268. _inheritParticleInfoToSubEmitters(): void;
  85269. /** @hidden */
  85270. _reset(): void;
  85271. /**
  85272. * Copy the properties of particle to another one.
  85273. * @param other the particle to copy the information to.
  85274. */
  85275. copyTo(other: Particle): void;
  85276. }
  85277. }
  85278. declare module BABYLON {
  85279. /**
  85280. * Particle emitter represents a volume emitting particles.
  85281. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85282. */
  85283. export interface IParticleEmitterType {
  85284. /**
  85285. * Called by the particle System when the direction is computed for the created particle.
  85286. * @param worldMatrix is the world matrix of the particle system
  85287. * @param directionToUpdate is the direction vector to update with the result
  85288. * @param particle is the particle we are computed the direction for
  85289. */
  85290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85291. /**
  85292. * Called by the particle System when the position is computed for the created particle.
  85293. * @param worldMatrix is the world matrix of the particle system
  85294. * @param positionToUpdate is the position vector to update with the result
  85295. * @param particle is the particle we are computed the position for
  85296. */
  85297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85298. /**
  85299. * Clones the current emitter and returns a copy of it
  85300. * @returns the new emitter
  85301. */
  85302. clone(): IParticleEmitterType;
  85303. /**
  85304. * Called by the GPUParticleSystem to setup the update shader
  85305. * @param effect defines the update shader
  85306. */
  85307. applyToShader(effect: Effect): void;
  85308. /**
  85309. * Returns a string to use to update the GPU particles update shader
  85310. * @returns the effect defines string
  85311. */
  85312. getEffectDefines(): string;
  85313. /**
  85314. * Returns a string representing the class name
  85315. * @returns a string containing the class name
  85316. */
  85317. getClassName(): string;
  85318. /**
  85319. * Serializes the particle system to a JSON object.
  85320. * @returns the JSON object
  85321. */
  85322. serialize(): any;
  85323. /**
  85324. * Parse properties from a JSON object
  85325. * @param serializationObject defines the JSON object
  85326. * @param scene defines the hosting scene
  85327. */
  85328. parse(serializationObject: any, scene: Scene): void;
  85329. }
  85330. }
  85331. declare module BABYLON {
  85332. /**
  85333. * Particle emitter emitting particles from the inside of a box.
  85334. * It emits the particles randomly between 2 given directions.
  85335. */
  85336. export class BoxParticleEmitter implements IParticleEmitterType {
  85337. /**
  85338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85339. */
  85340. direction1: Vector3;
  85341. /**
  85342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85343. */
  85344. direction2: Vector3;
  85345. /**
  85346. * 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.
  85347. */
  85348. minEmitBox: Vector3;
  85349. /**
  85350. * 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.
  85351. */
  85352. maxEmitBox: Vector3;
  85353. /**
  85354. * Creates a new instance BoxParticleEmitter
  85355. */
  85356. constructor();
  85357. /**
  85358. * Called by the particle System when the direction is computed for the created particle.
  85359. * @param worldMatrix is the world matrix of the particle system
  85360. * @param directionToUpdate is the direction vector to update with the result
  85361. * @param particle is the particle we are computed the direction for
  85362. */
  85363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85364. /**
  85365. * Called by the particle System when the position is computed for the created particle.
  85366. * @param worldMatrix is the world matrix of the particle system
  85367. * @param positionToUpdate is the position vector to update with the result
  85368. * @param particle is the particle we are computed the position for
  85369. */
  85370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85371. /**
  85372. * Clones the current emitter and returns a copy of it
  85373. * @returns the new emitter
  85374. */
  85375. clone(): BoxParticleEmitter;
  85376. /**
  85377. * Called by the GPUParticleSystem to setup the update shader
  85378. * @param effect defines the update shader
  85379. */
  85380. applyToShader(effect: Effect): void;
  85381. /**
  85382. * Returns a string to use to update the GPU particles update shader
  85383. * @returns a string containng the defines string
  85384. */
  85385. getEffectDefines(): string;
  85386. /**
  85387. * Returns the string "BoxParticleEmitter"
  85388. * @returns a string containing the class name
  85389. */
  85390. getClassName(): string;
  85391. /**
  85392. * Serializes the particle system to a JSON object.
  85393. * @returns the JSON object
  85394. */
  85395. serialize(): any;
  85396. /**
  85397. * Parse properties from a JSON object
  85398. * @param serializationObject defines the JSON object
  85399. */
  85400. parse(serializationObject: any): void;
  85401. }
  85402. }
  85403. declare module BABYLON {
  85404. /**
  85405. * Particle emitter emitting particles from the inside of a cone.
  85406. * It emits the particles alongside the cone volume from the base to the particle.
  85407. * The emission direction might be randomized.
  85408. */
  85409. export class ConeParticleEmitter implements IParticleEmitterType {
  85410. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85411. directionRandomizer: number;
  85412. private _radius;
  85413. private _angle;
  85414. private _height;
  85415. /**
  85416. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85417. */
  85418. radiusRange: number;
  85419. /**
  85420. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85421. */
  85422. heightRange: number;
  85423. /**
  85424. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85425. */
  85426. emitFromSpawnPointOnly: boolean;
  85427. /**
  85428. * Gets or sets the radius of the emission cone
  85429. */
  85430. get radius(): number;
  85431. set radius(value: number);
  85432. /**
  85433. * Gets or sets the angle of the emission cone
  85434. */
  85435. get angle(): number;
  85436. set angle(value: number);
  85437. private _buildHeight;
  85438. /**
  85439. * Creates a new instance ConeParticleEmitter
  85440. * @param radius the radius of the emission cone (1 by default)
  85441. * @param angle the cone base angle (PI by default)
  85442. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85443. */
  85444. constructor(radius?: number, angle?: number,
  85445. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85446. directionRandomizer?: number);
  85447. /**
  85448. * Called by the particle System when the direction is computed for the created particle.
  85449. * @param worldMatrix is the world matrix of the particle system
  85450. * @param directionToUpdate is the direction vector to update with the result
  85451. * @param particle is the particle we are computed the direction for
  85452. */
  85453. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85454. /**
  85455. * Called by the particle System when the position is computed for the created particle.
  85456. * @param worldMatrix is the world matrix of the particle system
  85457. * @param positionToUpdate is the position vector to update with the result
  85458. * @param particle is the particle we are computed the position for
  85459. */
  85460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85461. /**
  85462. * Clones the current emitter and returns a copy of it
  85463. * @returns the new emitter
  85464. */
  85465. clone(): ConeParticleEmitter;
  85466. /**
  85467. * Called by the GPUParticleSystem to setup the update shader
  85468. * @param effect defines the update shader
  85469. */
  85470. applyToShader(effect: Effect): void;
  85471. /**
  85472. * Returns a string to use to update the GPU particles update shader
  85473. * @returns a string containng the defines string
  85474. */
  85475. getEffectDefines(): string;
  85476. /**
  85477. * Returns the string "ConeParticleEmitter"
  85478. * @returns a string containing the class name
  85479. */
  85480. getClassName(): string;
  85481. /**
  85482. * Serializes the particle system to a JSON object.
  85483. * @returns the JSON object
  85484. */
  85485. serialize(): any;
  85486. /**
  85487. * Parse properties from a JSON object
  85488. * @param serializationObject defines the JSON object
  85489. */
  85490. parse(serializationObject: any): void;
  85491. }
  85492. }
  85493. declare module BABYLON {
  85494. /**
  85495. * Particle emitter emitting particles from the inside of a cylinder.
  85496. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85497. */
  85498. export class CylinderParticleEmitter implements IParticleEmitterType {
  85499. /**
  85500. * The radius of the emission cylinder.
  85501. */
  85502. radius: number;
  85503. /**
  85504. * The height of the emission cylinder.
  85505. */
  85506. height: number;
  85507. /**
  85508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85509. */
  85510. radiusRange: number;
  85511. /**
  85512. * How much to randomize the particle direction [0-1].
  85513. */
  85514. directionRandomizer: number;
  85515. /**
  85516. * Creates a new instance CylinderParticleEmitter
  85517. * @param radius the radius of the emission cylinder (1 by default)
  85518. * @param height the height of the emission cylinder (1 by default)
  85519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85521. */
  85522. constructor(
  85523. /**
  85524. * The radius of the emission cylinder.
  85525. */
  85526. radius?: number,
  85527. /**
  85528. * The height of the emission cylinder.
  85529. */
  85530. height?: number,
  85531. /**
  85532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85533. */
  85534. radiusRange?: number,
  85535. /**
  85536. * How much to randomize the particle direction [0-1].
  85537. */
  85538. directionRandomizer?: number);
  85539. /**
  85540. * Called by the particle System when the direction is computed for the created particle.
  85541. * @param worldMatrix is the world matrix of the particle system
  85542. * @param directionToUpdate is the direction vector to update with the result
  85543. * @param particle is the particle we are computed the direction for
  85544. */
  85545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85546. /**
  85547. * Called by the particle System when the position is computed for the created particle.
  85548. * @param worldMatrix is the world matrix of the particle system
  85549. * @param positionToUpdate is the position vector to update with the result
  85550. * @param particle is the particle we are computed the position for
  85551. */
  85552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85553. /**
  85554. * Clones the current emitter and returns a copy of it
  85555. * @returns the new emitter
  85556. */
  85557. clone(): CylinderParticleEmitter;
  85558. /**
  85559. * Called by the GPUParticleSystem to setup the update shader
  85560. * @param effect defines the update shader
  85561. */
  85562. applyToShader(effect: Effect): void;
  85563. /**
  85564. * Returns a string to use to update the GPU particles update shader
  85565. * @returns a string containng the defines string
  85566. */
  85567. getEffectDefines(): string;
  85568. /**
  85569. * Returns the string "CylinderParticleEmitter"
  85570. * @returns a string containing the class name
  85571. */
  85572. getClassName(): string;
  85573. /**
  85574. * Serializes the particle system to a JSON object.
  85575. * @returns the JSON object
  85576. */
  85577. serialize(): any;
  85578. /**
  85579. * Parse properties from a JSON object
  85580. * @param serializationObject defines the JSON object
  85581. */
  85582. parse(serializationObject: any): void;
  85583. }
  85584. /**
  85585. * Particle emitter emitting particles from the inside of a cylinder.
  85586. * It emits the particles randomly between two vectors.
  85587. */
  85588. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85589. /**
  85590. * The min limit of the emission direction.
  85591. */
  85592. direction1: Vector3;
  85593. /**
  85594. * The max limit of the emission direction.
  85595. */
  85596. direction2: Vector3;
  85597. /**
  85598. * Creates a new instance CylinderDirectedParticleEmitter
  85599. * @param radius the radius of the emission cylinder (1 by default)
  85600. * @param height the height of the emission cylinder (1 by default)
  85601. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85602. * @param direction1 the min limit of the emission direction (up vector by default)
  85603. * @param direction2 the max limit of the emission direction (up vector by default)
  85604. */
  85605. constructor(radius?: number, height?: number, radiusRange?: number,
  85606. /**
  85607. * The min limit of the emission direction.
  85608. */
  85609. direction1?: Vector3,
  85610. /**
  85611. * The max limit of the emission direction.
  85612. */
  85613. direction2?: Vector3);
  85614. /**
  85615. * Called by the particle System when the direction is computed for the created particle.
  85616. * @param worldMatrix is the world matrix of the particle system
  85617. * @param directionToUpdate is the direction vector to update with the result
  85618. * @param particle is the particle we are computed the direction for
  85619. */
  85620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85621. /**
  85622. * Clones the current emitter and returns a copy of it
  85623. * @returns the new emitter
  85624. */
  85625. clone(): CylinderDirectedParticleEmitter;
  85626. /**
  85627. * Called by the GPUParticleSystem to setup the update shader
  85628. * @param effect defines the update shader
  85629. */
  85630. applyToShader(effect: Effect): void;
  85631. /**
  85632. * Returns a string to use to update the GPU particles update shader
  85633. * @returns a string containng the defines string
  85634. */
  85635. getEffectDefines(): string;
  85636. /**
  85637. * Returns the string "CylinderDirectedParticleEmitter"
  85638. * @returns a string containing the class name
  85639. */
  85640. getClassName(): string;
  85641. /**
  85642. * Serializes the particle system to a JSON object.
  85643. * @returns the JSON object
  85644. */
  85645. serialize(): any;
  85646. /**
  85647. * Parse properties from a JSON object
  85648. * @param serializationObject defines the JSON object
  85649. */
  85650. parse(serializationObject: any): void;
  85651. }
  85652. }
  85653. declare module BABYLON {
  85654. /**
  85655. * Particle emitter emitting particles from the inside of a hemisphere.
  85656. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85657. */
  85658. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85659. /**
  85660. * The radius of the emission hemisphere.
  85661. */
  85662. radius: number;
  85663. /**
  85664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85665. */
  85666. radiusRange: number;
  85667. /**
  85668. * How much to randomize the particle direction [0-1].
  85669. */
  85670. directionRandomizer: number;
  85671. /**
  85672. * Creates a new instance HemisphericParticleEmitter
  85673. * @param radius the radius of the emission hemisphere (1 by default)
  85674. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85676. */
  85677. constructor(
  85678. /**
  85679. * The radius of the emission hemisphere.
  85680. */
  85681. radius?: number,
  85682. /**
  85683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85684. */
  85685. radiusRange?: number,
  85686. /**
  85687. * How much to randomize the particle direction [0-1].
  85688. */
  85689. directionRandomizer?: number);
  85690. /**
  85691. * Called by the particle System when the direction is computed for the created particle.
  85692. * @param worldMatrix is the world matrix of the particle system
  85693. * @param directionToUpdate is the direction vector to update with the result
  85694. * @param particle is the particle we are computed the direction for
  85695. */
  85696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85697. /**
  85698. * Called by the particle System when the position is computed for the created particle.
  85699. * @param worldMatrix is the world matrix of the particle system
  85700. * @param positionToUpdate is the position vector to update with the result
  85701. * @param particle is the particle we are computed the position for
  85702. */
  85703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85704. /**
  85705. * Clones the current emitter and returns a copy of it
  85706. * @returns the new emitter
  85707. */
  85708. clone(): HemisphericParticleEmitter;
  85709. /**
  85710. * Called by the GPUParticleSystem to setup the update shader
  85711. * @param effect defines the update shader
  85712. */
  85713. applyToShader(effect: Effect): void;
  85714. /**
  85715. * Returns a string to use to update the GPU particles update shader
  85716. * @returns a string containng the defines string
  85717. */
  85718. getEffectDefines(): string;
  85719. /**
  85720. * Returns the string "HemisphericParticleEmitter"
  85721. * @returns a string containing the class name
  85722. */
  85723. getClassName(): string;
  85724. /**
  85725. * Serializes the particle system to a JSON object.
  85726. * @returns the JSON object
  85727. */
  85728. serialize(): any;
  85729. /**
  85730. * Parse properties from a JSON object
  85731. * @param serializationObject defines the JSON object
  85732. */
  85733. parse(serializationObject: any): void;
  85734. }
  85735. }
  85736. declare module BABYLON {
  85737. /**
  85738. * Particle emitter emitting particles from a point.
  85739. * It emits the particles randomly between 2 given directions.
  85740. */
  85741. export class PointParticleEmitter implements IParticleEmitterType {
  85742. /**
  85743. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85744. */
  85745. direction1: Vector3;
  85746. /**
  85747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85748. */
  85749. direction2: Vector3;
  85750. /**
  85751. * Creates a new instance PointParticleEmitter
  85752. */
  85753. constructor();
  85754. /**
  85755. * Called by the particle System when the direction is computed for the created particle.
  85756. * @param worldMatrix is the world matrix of the particle system
  85757. * @param directionToUpdate is the direction vector to update with the result
  85758. * @param particle is the particle we are computed the direction for
  85759. */
  85760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85761. /**
  85762. * Called by the particle System when the position is computed for the created particle.
  85763. * @param worldMatrix is the world matrix of the particle system
  85764. * @param positionToUpdate is the position vector to update with the result
  85765. * @param particle is the particle we are computed the position for
  85766. */
  85767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85768. /**
  85769. * Clones the current emitter and returns a copy of it
  85770. * @returns the new emitter
  85771. */
  85772. clone(): PointParticleEmitter;
  85773. /**
  85774. * Called by the GPUParticleSystem to setup the update shader
  85775. * @param effect defines the update shader
  85776. */
  85777. applyToShader(effect: Effect): void;
  85778. /**
  85779. * Returns a string to use to update the GPU particles update shader
  85780. * @returns a string containng the defines string
  85781. */
  85782. getEffectDefines(): string;
  85783. /**
  85784. * Returns the string "PointParticleEmitter"
  85785. * @returns a string containing the class name
  85786. */
  85787. getClassName(): string;
  85788. /**
  85789. * Serializes the particle system to a JSON object.
  85790. * @returns the JSON object
  85791. */
  85792. serialize(): any;
  85793. /**
  85794. * Parse properties from a JSON object
  85795. * @param serializationObject defines the JSON object
  85796. */
  85797. parse(serializationObject: any): void;
  85798. }
  85799. }
  85800. declare module BABYLON {
  85801. /**
  85802. * Particle emitter emitting particles from the inside of a sphere.
  85803. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85804. */
  85805. export class SphereParticleEmitter implements IParticleEmitterType {
  85806. /**
  85807. * The radius of the emission sphere.
  85808. */
  85809. radius: number;
  85810. /**
  85811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85812. */
  85813. radiusRange: number;
  85814. /**
  85815. * How much to randomize the particle direction [0-1].
  85816. */
  85817. directionRandomizer: number;
  85818. /**
  85819. * Creates a new instance SphereParticleEmitter
  85820. * @param radius the radius of the emission sphere (1 by default)
  85821. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85822. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85823. */
  85824. constructor(
  85825. /**
  85826. * The radius of the emission sphere.
  85827. */
  85828. radius?: number,
  85829. /**
  85830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85831. */
  85832. radiusRange?: number,
  85833. /**
  85834. * How much to randomize the particle direction [0-1].
  85835. */
  85836. directionRandomizer?: number);
  85837. /**
  85838. * Called by the particle System when the direction is computed for the created particle.
  85839. * @param worldMatrix is the world matrix of the particle system
  85840. * @param directionToUpdate is the direction vector to update with the result
  85841. * @param particle is the particle we are computed the direction for
  85842. */
  85843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85844. /**
  85845. * Called by the particle System when the position is computed for the created particle.
  85846. * @param worldMatrix is the world matrix of the particle system
  85847. * @param positionToUpdate is the position vector to update with the result
  85848. * @param particle is the particle we are computed the position for
  85849. */
  85850. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85851. /**
  85852. * Clones the current emitter and returns a copy of it
  85853. * @returns the new emitter
  85854. */
  85855. clone(): SphereParticleEmitter;
  85856. /**
  85857. * Called by the GPUParticleSystem to setup the update shader
  85858. * @param effect defines the update shader
  85859. */
  85860. applyToShader(effect: Effect): void;
  85861. /**
  85862. * Returns a string to use to update the GPU particles update shader
  85863. * @returns a string containng the defines string
  85864. */
  85865. getEffectDefines(): string;
  85866. /**
  85867. * Returns the string "SphereParticleEmitter"
  85868. * @returns a string containing the class name
  85869. */
  85870. getClassName(): string;
  85871. /**
  85872. * Serializes the particle system to a JSON object.
  85873. * @returns the JSON object
  85874. */
  85875. serialize(): any;
  85876. /**
  85877. * Parse properties from a JSON object
  85878. * @param serializationObject defines the JSON object
  85879. */
  85880. parse(serializationObject: any): void;
  85881. }
  85882. /**
  85883. * Particle emitter emitting particles from the inside of a sphere.
  85884. * It emits the particles randomly between two vectors.
  85885. */
  85886. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85887. /**
  85888. * The min limit of the emission direction.
  85889. */
  85890. direction1: Vector3;
  85891. /**
  85892. * The max limit of the emission direction.
  85893. */
  85894. direction2: Vector3;
  85895. /**
  85896. * Creates a new instance SphereDirectedParticleEmitter
  85897. * @param radius the radius of the emission sphere (1 by default)
  85898. * @param direction1 the min limit of the emission direction (up vector by default)
  85899. * @param direction2 the max limit of the emission direction (up vector by default)
  85900. */
  85901. constructor(radius?: number,
  85902. /**
  85903. * The min limit of the emission direction.
  85904. */
  85905. direction1?: Vector3,
  85906. /**
  85907. * The max limit of the emission direction.
  85908. */
  85909. direction2?: Vector3);
  85910. /**
  85911. * Called by the particle System when the direction is computed for the created particle.
  85912. * @param worldMatrix is the world matrix of the particle system
  85913. * @param directionToUpdate is the direction vector to update with the result
  85914. * @param particle is the particle we are computed the direction for
  85915. */
  85916. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85917. /**
  85918. * Clones the current emitter and returns a copy of it
  85919. * @returns the new emitter
  85920. */
  85921. clone(): SphereDirectedParticleEmitter;
  85922. /**
  85923. * Called by the GPUParticleSystem to setup the update shader
  85924. * @param effect defines the update shader
  85925. */
  85926. applyToShader(effect: Effect): void;
  85927. /**
  85928. * Returns a string to use to update the GPU particles update shader
  85929. * @returns a string containng the defines string
  85930. */
  85931. getEffectDefines(): string;
  85932. /**
  85933. * Returns the string "SphereDirectedParticleEmitter"
  85934. * @returns a string containing the class name
  85935. */
  85936. getClassName(): string;
  85937. /**
  85938. * Serializes the particle system to a JSON object.
  85939. * @returns the JSON object
  85940. */
  85941. serialize(): any;
  85942. /**
  85943. * Parse properties from a JSON object
  85944. * @param serializationObject defines the JSON object
  85945. */
  85946. parse(serializationObject: any): void;
  85947. }
  85948. }
  85949. declare module BABYLON {
  85950. /**
  85951. * Particle emitter emitting particles from a custom list of positions.
  85952. */
  85953. export class CustomParticleEmitter implements IParticleEmitterType {
  85954. /**
  85955. * Gets or sets the position generator that will create the inital position of each particle.
  85956. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85957. */
  85958. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  85959. /**
  85960. * Gets or sets the destination generator that will create the final destination of each particle.
  85961. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85962. */
  85963. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  85964. /**
  85965. * Creates a new instance CustomParticleEmitter
  85966. */
  85967. constructor();
  85968. /**
  85969. * Called by the particle System when the direction is computed for the created particle.
  85970. * @param worldMatrix is the world matrix of the particle system
  85971. * @param directionToUpdate is the direction vector to update with the result
  85972. * @param particle is the particle we are computed the direction for
  85973. */
  85974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85975. /**
  85976. * Called by the particle System when the position is computed for the created particle.
  85977. * @param worldMatrix is the world matrix of the particle system
  85978. * @param positionToUpdate is the position vector to update with the result
  85979. * @param particle is the particle we are computed the position for
  85980. */
  85981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85982. /**
  85983. * Clones the current emitter and returns a copy of it
  85984. * @returns the new emitter
  85985. */
  85986. clone(): CustomParticleEmitter;
  85987. /**
  85988. * Called by the GPUParticleSystem to setup the update shader
  85989. * @param effect defines the update shader
  85990. */
  85991. applyToShader(effect: Effect): void;
  85992. /**
  85993. * Returns a string to use to update the GPU particles update shader
  85994. * @returns a string containng the defines string
  85995. */
  85996. getEffectDefines(): string;
  85997. /**
  85998. * Returns the string "PointParticleEmitter"
  85999. * @returns a string containing the class name
  86000. */
  86001. getClassName(): string;
  86002. /**
  86003. * Serializes the particle system to a JSON object.
  86004. * @returns the JSON object
  86005. */
  86006. serialize(): any;
  86007. /**
  86008. * Parse properties from a JSON object
  86009. * @param serializationObject defines the JSON object
  86010. */
  86011. parse(serializationObject: any): void;
  86012. }
  86013. }
  86014. declare module BABYLON {
  86015. /**
  86016. * Particle emitter emitting particles from the inside of a box.
  86017. * It emits the particles randomly between 2 given directions.
  86018. */
  86019. export class MeshParticleEmitter implements IParticleEmitterType {
  86020. /** Defines the mesh to use as source */
  86021. mesh?: AbstractMesh | undefined;
  86022. private _indices;
  86023. private _positions;
  86024. private _normals;
  86025. private _storedNormal;
  86026. /**
  86027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86028. */
  86029. direction1: Vector3;
  86030. /**
  86031. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86032. */
  86033. direction2: Vector3;
  86034. /**
  86035. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86036. */
  86037. useMeshNormalsForDirection: boolean;
  86038. /**
  86039. * Creates a new instance MeshParticleEmitter
  86040. * @param mesh defines the mesh to use as source
  86041. */
  86042. constructor(
  86043. /** Defines the mesh to use as source */
  86044. mesh?: AbstractMesh | undefined);
  86045. /**
  86046. * Called by the particle System when the direction is computed for the created particle.
  86047. * @param worldMatrix is the world matrix of the particle system
  86048. * @param directionToUpdate is the direction vector to update with the result
  86049. * @param particle is the particle we are computed the direction for
  86050. */
  86051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86052. /**
  86053. * Called by the particle System when the position is computed for the created particle.
  86054. * @param worldMatrix is the world matrix of the particle system
  86055. * @param positionToUpdate is the position vector to update with the result
  86056. * @param particle is the particle we are computed the position for
  86057. */
  86058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86059. /**
  86060. * Clones the current emitter and returns a copy of it
  86061. * @returns the new emitter
  86062. */
  86063. clone(): MeshParticleEmitter;
  86064. /**
  86065. * Called by the GPUParticleSystem to setup the update shader
  86066. * @param effect defines the update shader
  86067. */
  86068. applyToShader(effect: Effect): void;
  86069. /**
  86070. * Returns a string to use to update the GPU particles update shader
  86071. * @returns a string containng the defines string
  86072. */
  86073. getEffectDefines(): string;
  86074. /**
  86075. * Returns the string "BoxParticleEmitter"
  86076. * @returns a string containing the class name
  86077. */
  86078. getClassName(): string;
  86079. /**
  86080. * Serializes the particle system to a JSON object.
  86081. * @returns the JSON object
  86082. */
  86083. serialize(): any;
  86084. /**
  86085. * Parse properties from a JSON object
  86086. * @param serializationObject defines the JSON object
  86087. * @param scene defines the hosting scene
  86088. */
  86089. parse(serializationObject: any, scene: Scene): void;
  86090. }
  86091. }
  86092. declare module BABYLON {
  86093. /**
  86094. * Interface representing a particle system in Babylon.js.
  86095. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86096. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86097. */
  86098. export interface IParticleSystem {
  86099. /**
  86100. * List of animations used by the particle system.
  86101. */
  86102. animations: Animation[];
  86103. /**
  86104. * The id of the Particle system.
  86105. */
  86106. id: string;
  86107. /**
  86108. * The name of the Particle system.
  86109. */
  86110. name: string;
  86111. /**
  86112. * The emitter represents the Mesh or position we are attaching the particle system to.
  86113. */
  86114. emitter: Nullable<AbstractMesh | Vector3>;
  86115. /**
  86116. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86117. */
  86118. isBillboardBased: boolean;
  86119. /**
  86120. * The rendering group used by the Particle system to chose when to render.
  86121. */
  86122. renderingGroupId: number;
  86123. /**
  86124. * The layer mask we are rendering the particles through.
  86125. */
  86126. layerMask: number;
  86127. /**
  86128. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86129. */
  86130. updateSpeed: number;
  86131. /**
  86132. * The amount of time the particle system is running (depends of the overall update speed).
  86133. */
  86134. targetStopDuration: number;
  86135. /**
  86136. * The texture used to render each particle. (this can be a spritesheet)
  86137. */
  86138. particleTexture: Nullable<Texture>;
  86139. /**
  86140. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86141. */
  86142. blendMode: number;
  86143. /**
  86144. * Minimum life time of emitting particles.
  86145. */
  86146. minLifeTime: number;
  86147. /**
  86148. * Maximum life time of emitting particles.
  86149. */
  86150. maxLifeTime: number;
  86151. /**
  86152. * Minimum Size of emitting particles.
  86153. */
  86154. minSize: number;
  86155. /**
  86156. * Maximum Size of emitting particles.
  86157. */
  86158. maxSize: number;
  86159. /**
  86160. * Minimum scale of emitting particles on X axis.
  86161. */
  86162. minScaleX: number;
  86163. /**
  86164. * Maximum scale of emitting particles on X axis.
  86165. */
  86166. maxScaleX: number;
  86167. /**
  86168. * Minimum scale of emitting particles on Y axis.
  86169. */
  86170. minScaleY: number;
  86171. /**
  86172. * Maximum scale of emitting particles on Y axis.
  86173. */
  86174. maxScaleY: number;
  86175. /**
  86176. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86177. */
  86178. color1: Color4;
  86179. /**
  86180. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86181. */
  86182. color2: Color4;
  86183. /**
  86184. * Color the particle will have at the end of its lifetime.
  86185. */
  86186. colorDead: Color4;
  86187. /**
  86188. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86189. */
  86190. emitRate: number;
  86191. /**
  86192. * You can use gravity if you want to give an orientation to your particles.
  86193. */
  86194. gravity: Vector3;
  86195. /**
  86196. * Minimum power of emitting particles.
  86197. */
  86198. minEmitPower: number;
  86199. /**
  86200. * Maximum power of emitting particles.
  86201. */
  86202. maxEmitPower: number;
  86203. /**
  86204. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86205. */
  86206. minAngularSpeed: number;
  86207. /**
  86208. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86209. */
  86210. maxAngularSpeed: number;
  86211. /**
  86212. * Gets or sets the minimal initial rotation in radians.
  86213. */
  86214. minInitialRotation: number;
  86215. /**
  86216. * Gets or sets the maximal initial rotation in radians.
  86217. */
  86218. maxInitialRotation: number;
  86219. /**
  86220. * The particle emitter type defines the emitter used by the particle system.
  86221. * It can be for example box, sphere, or cone...
  86222. */
  86223. particleEmitterType: Nullable<IParticleEmitterType>;
  86224. /**
  86225. * Defines the delay in milliseconds before starting the system (0 by default)
  86226. */
  86227. startDelay: number;
  86228. /**
  86229. * 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
  86230. */
  86231. preWarmCycles: number;
  86232. /**
  86233. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86234. */
  86235. preWarmStepOffset: number;
  86236. /**
  86237. * 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)
  86238. */
  86239. spriteCellChangeSpeed: number;
  86240. /**
  86241. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86242. */
  86243. startSpriteCellID: number;
  86244. /**
  86245. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86246. */
  86247. endSpriteCellID: number;
  86248. /**
  86249. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86250. */
  86251. spriteCellWidth: number;
  86252. /**
  86253. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86254. */
  86255. spriteCellHeight: number;
  86256. /**
  86257. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86258. */
  86259. spriteRandomStartCell: boolean;
  86260. /**
  86261. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86262. */
  86263. isAnimationSheetEnabled: boolean;
  86264. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86265. translationPivot: Vector2;
  86266. /**
  86267. * Gets or sets a texture used to add random noise to particle positions
  86268. */
  86269. noiseTexture: Nullable<BaseTexture>;
  86270. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86271. noiseStrength: Vector3;
  86272. /**
  86273. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86274. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86275. */
  86276. billboardMode: number;
  86277. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86278. limitVelocityDamping: number;
  86279. /**
  86280. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86281. */
  86282. beginAnimationOnStart: boolean;
  86283. /**
  86284. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86285. */
  86286. beginAnimationFrom: number;
  86287. /**
  86288. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86289. */
  86290. beginAnimationTo: number;
  86291. /**
  86292. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86293. */
  86294. beginAnimationLoop: boolean;
  86295. /**
  86296. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86297. */
  86298. disposeOnStop: boolean;
  86299. /**
  86300. * Gets the maximum number of particles active at the same time.
  86301. * @returns The max number of active particles.
  86302. */
  86303. getCapacity(): number;
  86304. /**
  86305. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86306. * @returns True if it has been started, otherwise false.
  86307. */
  86308. isStarted(): boolean;
  86309. /**
  86310. * Animates the particle system for this frame.
  86311. */
  86312. animate(): void;
  86313. /**
  86314. * Renders the particle system in its current state.
  86315. * @returns the current number of particles
  86316. */
  86317. render(): number;
  86318. /**
  86319. * Dispose the particle system and frees its associated resources.
  86320. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86321. */
  86322. dispose(disposeTexture?: boolean): void;
  86323. /**
  86324. * Clones the particle system.
  86325. * @param name The name of the cloned object
  86326. * @param newEmitter The new emitter to use
  86327. * @returns the cloned particle system
  86328. */
  86329. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86330. /**
  86331. * Serializes the particle system to a JSON object.
  86332. * @returns the JSON object
  86333. */
  86334. serialize(): any;
  86335. /**
  86336. * Rebuild the particle system
  86337. */
  86338. rebuild(): void;
  86339. /**
  86340. * Starts the particle system and begins to emit
  86341. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86342. */
  86343. start(delay?: number): void;
  86344. /**
  86345. * Stops the particle system.
  86346. */
  86347. stop(): void;
  86348. /**
  86349. * Remove all active particles
  86350. */
  86351. reset(): void;
  86352. /**
  86353. * Is this system ready to be used/rendered
  86354. * @return true if the system is ready
  86355. */
  86356. isReady(): boolean;
  86357. /**
  86358. * Adds a new color gradient
  86359. * @param gradient defines the gradient to use (between 0 and 1)
  86360. * @param color1 defines the color to affect to the specified gradient
  86361. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86362. * @returns the current particle system
  86363. */
  86364. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86365. /**
  86366. * Remove a specific color gradient
  86367. * @param gradient defines the gradient to remove
  86368. * @returns the current particle system
  86369. */
  86370. removeColorGradient(gradient: number): IParticleSystem;
  86371. /**
  86372. * Adds a new size gradient
  86373. * @param gradient defines the gradient to use (between 0 and 1)
  86374. * @param factor defines the size factor to affect to the specified gradient
  86375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86376. * @returns the current particle system
  86377. */
  86378. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86379. /**
  86380. * Remove a specific size gradient
  86381. * @param gradient defines the gradient to remove
  86382. * @returns the current particle system
  86383. */
  86384. removeSizeGradient(gradient: number): IParticleSystem;
  86385. /**
  86386. * Gets the current list of color gradients.
  86387. * You must use addColorGradient and removeColorGradient to udpate this list
  86388. * @returns the list of color gradients
  86389. */
  86390. getColorGradients(): Nullable<Array<ColorGradient>>;
  86391. /**
  86392. * Gets the current list of size gradients.
  86393. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86394. * @returns the list of size gradients
  86395. */
  86396. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86397. /**
  86398. * Gets the current list of angular speed gradients.
  86399. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86400. * @returns the list of angular speed gradients
  86401. */
  86402. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86403. /**
  86404. * Adds a new angular speed gradient
  86405. * @param gradient defines the gradient to use (between 0 and 1)
  86406. * @param factor defines the angular speed to affect to the specified gradient
  86407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86408. * @returns the current particle system
  86409. */
  86410. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86411. /**
  86412. * Remove a specific angular speed gradient
  86413. * @param gradient defines the gradient to remove
  86414. * @returns the current particle system
  86415. */
  86416. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86417. /**
  86418. * Gets the current list of velocity gradients.
  86419. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86420. * @returns the list of velocity gradients
  86421. */
  86422. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86423. /**
  86424. * Adds a new velocity gradient
  86425. * @param gradient defines the gradient to use (between 0 and 1)
  86426. * @param factor defines the velocity to affect to the specified gradient
  86427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86428. * @returns the current particle system
  86429. */
  86430. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86431. /**
  86432. * Remove a specific velocity gradient
  86433. * @param gradient defines the gradient to remove
  86434. * @returns the current particle system
  86435. */
  86436. removeVelocityGradient(gradient: number): IParticleSystem;
  86437. /**
  86438. * Gets the current list of limit velocity gradients.
  86439. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86440. * @returns the list of limit velocity gradients
  86441. */
  86442. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86443. /**
  86444. * Adds a new limit velocity gradient
  86445. * @param gradient defines the gradient to use (between 0 and 1)
  86446. * @param factor defines the limit velocity to affect to the specified gradient
  86447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86448. * @returns the current particle system
  86449. */
  86450. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86451. /**
  86452. * Remove a specific limit velocity gradient
  86453. * @param gradient defines the gradient to remove
  86454. * @returns the current particle system
  86455. */
  86456. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86457. /**
  86458. * Adds a new drag gradient
  86459. * @param gradient defines the gradient to use (between 0 and 1)
  86460. * @param factor defines the drag to affect to the specified gradient
  86461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86462. * @returns the current particle system
  86463. */
  86464. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86465. /**
  86466. * Remove a specific drag gradient
  86467. * @param gradient defines the gradient to remove
  86468. * @returns the current particle system
  86469. */
  86470. removeDragGradient(gradient: number): IParticleSystem;
  86471. /**
  86472. * Gets the current list of drag gradients.
  86473. * You must use addDragGradient and removeDragGradient to udpate this list
  86474. * @returns the list of drag gradients
  86475. */
  86476. getDragGradients(): Nullable<Array<FactorGradient>>;
  86477. /**
  86478. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86479. * @param gradient defines the gradient to use (between 0 and 1)
  86480. * @param factor defines the emit rate to affect to the specified gradient
  86481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86482. * @returns the current particle system
  86483. */
  86484. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86485. /**
  86486. * Remove a specific emit rate gradient
  86487. * @param gradient defines the gradient to remove
  86488. * @returns the current particle system
  86489. */
  86490. removeEmitRateGradient(gradient: number): IParticleSystem;
  86491. /**
  86492. * Gets the current list of emit rate gradients.
  86493. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86494. * @returns the list of emit rate gradients
  86495. */
  86496. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86497. /**
  86498. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86499. * @param gradient defines the gradient to use (between 0 and 1)
  86500. * @param factor defines the start size to affect to the specified gradient
  86501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86502. * @returns the current particle system
  86503. */
  86504. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86505. /**
  86506. * Remove a specific start size gradient
  86507. * @param gradient defines the gradient to remove
  86508. * @returns the current particle system
  86509. */
  86510. removeStartSizeGradient(gradient: number): IParticleSystem;
  86511. /**
  86512. * Gets the current list of start size gradients.
  86513. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86514. * @returns the list of start size gradients
  86515. */
  86516. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86517. /**
  86518. * Adds a new life time gradient
  86519. * @param gradient defines the gradient to use (between 0 and 1)
  86520. * @param factor defines the life time factor to affect to the specified gradient
  86521. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86522. * @returns the current particle system
  86523. */
  86524. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86525. /**
  86526. * Remove a specific life time gradient
  86527. * @param gradient defines the gradient to remove
  86528. * @returns the current particle system
  86529. */
  86530. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86531. /**
  86532. * Gets the current list of life time gradients.
  86533. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86534. * @returns the list of life time gradients
  86535. */
  86536. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86537. /**
  86538. * Gets the current list of color gradients.
  86539. * You must use addColorGradient and removeColorGradient to udpate this list
  86540. * @returns the list of color gradients
  86541. */
  86542. getColorGradients(): Nullable<Array<ColorGradient>>;
  86543. /**
  86544. * Adds a new ramp gradient used to remap particle colors
  86545. * @param gradient defines the gradient to use (between 0 and 1)
  86546. * @param color defines the color to affect to the specified gradient
  86547. * @returns the current particle system
  86548. */
  86549. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86550. /**
  86551. * Gets the current list of ramp gradients.
  86552. * You must use addRampGradient and removeRampGradient to udpate this list
  86553. * @returns the list of ramp gradients
  86554. */
  86555. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86556. /** Gets or sets a boolean indicating that ramp gradients must be used
  86557. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86558. */
  86559. useRampGradients: boolean;
  86560. /**
  86561. * Adds a new color remap gradient
  86562. * @param gradient defines the gradient to use (between 0 and 1)
  86563. * @param min defines the color remap minimal range
  86564. * @param max defines the color remap maximal range
  86565. * @returns the current particle system
  86566. */
  86567. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86568. /**
  86569. * Gets the current list of color remap gradients.
  86570. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86571. * @returns the list of color remap gradients
  86572. */
  86573. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86574. /**
  86575. * Adds a new alpha remap gradient
  86576. * @param gradient defines the gradient to use (between 0 and 1)
  86577. * @param min defines the alpha remap minimal range
  86578. * @param max defines the alpha remap maximal range
  86579. * @returns the current particle system
  86580. */
  86581. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86582. /**
  86583. * Gets the current list of alpha remap gradients.
  86584. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86585. * @returns the list of alpha remap gradients
  86586. */
  86587. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86588. /**
  86589. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86592. * @returns the emitter
  86593. */
  86594. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86595. /**
  86596. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86597. * @param radius The radius of the hemisphere to emit from
  86598. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86599. * @returns the emitter
  86600. */
  86601. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86602. /**
  86603. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86604. * @param radius The radius of the sphere to emit from
  86605. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86606. * @returns the emitter
  86607. */
  86608. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86609. /**
  86610. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86611. * @param radius The radius of the sphere to emit from
  86612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86614. * @returns the emitter
  86615. */
  86616. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86617. /**
  86618. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86619. * @param radius The radius of the emission cylinder
  86620. * @param height The height of the emission cylinder
  86621. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86622. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86623. * @returns the emitter
  86624. */
  86625. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86626. /**
  86627. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86628. * @param radius The radius of the cylinder to emit from
  86629. * @param height The height of the emission cylinder
  86630. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86631. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86632. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86633. * @returns the emitter
  86634. */
  86635. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86636. /**
  86637. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86638. * @param radius The radius of the cone to emit from
  86639. * @param angle The base angle of the cone
  86640. * @returns the emitter
  86641. */
  86642. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86643. /**
  86644. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86647. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86648. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86649. * @returns the emitter
  86650. */
  86651. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86652. /**
  86653. * Get hosting scene
  86654. * @returns the scene
  86655. */
  86656. getScene(): Scene;
  86657. }
  86658. }
  86659. declare module BABYLON {
  86660. /**
  86661. * 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.
  86662. * @see https://doc.babylonjs.com/how_to/transformnode
  86663. */
  86664. export class TransformNode extends Node {
  86665. /**
  86666. * Object will not rotate to face the camera
  86667. */
  86668. static BILLBOARDMODE_NONE: number;
  86669. /**
  86670. * Object will rotate to face the camera but only on the x axis
  86671. */
  86672. static BILLBOARDMODE_X: number;
  86673. /**
  86674. * Object will rotate to face the camera but only on the y axis
  86675. */
  86676. static BILLBOARDMODE_Y: number;
  86677. /**
  86678. * Object will rotate to face the camera but only on the z axis
  86679. */
  86680. static BILLBOARDMODE_Z: number;
  86681. /**
  86682. * Object will rotate to face the camera
  86683. */
  86684. static BILLBOARDMODE_ALL: number;
  86685. /**
  86686. * Object will rotate to face the camera's position instead of orientation
  86687. */
  86688. static BILLBOARDMODE_USE_POSITION: number;
  86689. private _forward;
  86690. private _forwardInverted;
  86691. private _up;
  86692. private _right;
  86693. private _rightInverted;
  86694. private _position;
  86695. private _rotation;
  86696. private _rotationQuaternion;
  86697. protected _scaling: Vector3;
  86698. protected _isDirty: boolean;
  86699. private _transformToBoneReferal;
  86700. private _isAbsoluteSynced;
  86701. private _billboardMode;
  86702. /**
  86703. * Gets or sets the billboard mode. Default is 0.
  86704. *
  86705. * | Value | Type | Description |
  86706. * | --- | --- | --- |
  86707. * | 0 | BILLBOARDMODE_NONE | |
  86708. * | 1 | BILLBOARDMODE_X | |
  86709. * | 2 | BILLBOARDMODE_Y | |
  86710. * | 4 | BILLBOARDMODE_Z | |
  86711. * | 7 | BILLBOARDMODE_ALL | |
  86712. *
  86713. */
  86714. get billboardMode(): number;
  86715. set billboardMode(value: number);
  86716. private _preserveParentRotationForBillboard;
  86717. /**
  86718. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86719. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86720. */
  86721. get preserveParentRotationForBillboard(): boolean;
  86722. set preserveParentRotationForBillboard(value: boolean);
  86723. /**
  86724. * 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
  86725. */
  86726. scalingDeterminant: number;
  86727. private _infiniteDistance;
  86728. /**
  86729. * Gets or sets the distance of the object to max, often used by skybox
  86730. */
  86731. get infiniteDistance(): boolean;
  86732. set infiniteDistance(value: boolean);
  86733. /**
  86734. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86735. * By default the system will update normals to compensate
  86736. */
  86737. ignoreNonUniformScaling: boolean;
  86738. /**
  86739. * 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
  86740. */
  86741. reIntegrateRotationIntoRotationQuaternion: boolean;
  86742. /** @hidden */
  86743. _poseMatrix: Nullable<Matrix>;
  86744. /** @hidden */
  86745. _localMatrix: Matrix;
  86746. private _usePivotMatrix;
  86747. private _absolutePosition;
  86748. private _absoluteScaling;
  86749. private _absoluteRotationQuaternion;
  86750. private _pivotMatrix;
  86751. private _pivotMatrixInverse;
  86752. protected _postMultiplyPivotMatrix: boolean;
  86753. protected _isWorldMatrixFrozen: boolean;
  86754. /** @hidden */
  86755. _indexInSceneTransformNodesArray: number;
  86756. /**
  86757. * An event triggered after the world matrix is updated
  86758. */
  86759. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86760. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86761. /**
  86762. * Gets a string identifying the name of the class
  86763. * @returns "TransformNode" string
  86764. */
  86765. getClassName(): string;
  86766. /**
  86767. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86768. */
  86769. get position(): Vector3;
  86770. set position(newPosition: Vector3);
  86771. /**
  86772. * 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)).
  86773. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86774. */
  86775. get rotation(): Vector3;
  86776. set rotation(newRotation: Vector3);
  86777. /**
  86778. * 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)).
  86779. */
  86780. get scaling(): Vector3;
  86781. set scaling(newScaling: Vector3);
  86782. /**
  86783. * 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).
  86784. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86785. */
  86786. get rotationQuaternion(): Nullable<Quaternion>;
  86787. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86788. /**
  86789. * The forward direction of that transform in world space.
  86790. */
  86791. get forward(): Vector3;
  86792. /**
  86793. * The up direction of that transform in world space.
  86794. */
  86795. get up(): Vector3;
  86796. /**
  86797. * The right direction of that transform in world space.
  86798. */
  86799. get right(): Vector3;
  86800. /**
  86801. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86802. * @param matrix the matrix to copy the pose from
  86803. * @returns this TransformNode.
  86804. */
  86805. updatePoseMatrix(matrix: Matrix): TransformNode;
  86806. /**
  86807. * Returns the mesh Pose matrix.
  86808. * @returns the pose matrix
  86809. */
  86810. getPoseMatrix(): Matrix;
  86811. /** @hidden */
  86812. _isSynchronized(): boolean;
  86813. /** @hidden */
  86814. _initCache(): void;
  86815. /**
  86816. * Flag the transform node as dirty (Forcing it to update everything)
  86817. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86818. * @returns this transform node
  86819. */
  86820. markAsDirty(property: string): TransformNode;
  86821. /**
  86822. * Returns the current mesh absolute position.
  86823. * Returns a Vector3.
  86824. */
  86825. get absolutePosition(): Vector3;
  86826. /**
  86827. * Returns the current mesh absolute scaling.
  86828. * Returns a Vector3.
  86829. */
  86830. get absoluteScaling(): Vector3;
  86831. /**
  86832. * Returns the current mesh absolute rotation.
  86833. * Returns a Quaternion.
  86834. */
  86835. get absoluteRotationQuaternion(): Quaternion;
  86836. /**
  86837. * Sets a new matrix to apply before all other transformation
  86838. * @param matrix defines the transform matrix
  86839. * @returns the current TransformNode
  86840. */
  86841. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86842. /**
  86843. * Sets a new pivot matrix to the current node
  86844. * @param matrix defines the new pivot matrix to use
  86845. * @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
  86846. * @returns the current TransformNode
  86847. */
  86848. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86849. /**
  86850. * Returns the mesh pivot matrix.
  86851. * Default : Identity.
  86852. * @returns the matrix
  86853. */
  86854. getPivotMatrix(): Matrix;
  86855. /**
  86856. * Instantiate (when possible) or clone that node with its hierarchy
  86857. * @param newParent defines the new parent to use for the instance (or clone)
  86858. * @param options defines options to configure how copy is done
  86859. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86860. * @returns an instance (or a clone) of the current node with its hiearchy
  86861. */
  86862. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86863. doNotInstantiate: boolean;
  86864. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86865. /**
  86866. * Prevents the World matrix to be computed any longer
  86867. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86868. * @returns the TransformNode.
  86869. */
  86870. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86871. /**
  86872. * Allows back the World matrix computation.
  86873. * @returns the TransformNode.
  86874. */
  86875. unfreezeWorldMatrix(): this;
  86876. /**
  86877. * True if the World matrix has been frozen.
  86878. */
  86879. get isWorldMatrixFrozen(): boolean;
  86880. /**
  86881. * Retuns the mesh absolute position in the World.
  86882. * @returns a Vector3.
  86883. */
  86884. getAbsolutePosition(): Vector3;
  86885. /**
  86886. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86887. * @param absolutePosition the absolute position to set
  86888. * @returns the TransformNode.
  86889. */
  86890. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86891. /**
  86892. * Sets the mesh position in its local space.
  86893. * @param vector3 the position to set in localspace
  86894. * @returns the TransformNode.
  86895. */
  86896. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86897. /**
  86898. * Returns the mesh position in the local space from the current World matrix values.
  86899. * @returns a new Vector3.
  86900. */
  86901. getPositionExpressedInLocalSpace(): Vector3;
  86902. /**
  86903. * Translates the mesh along the passed Vector3 in its local space.
  86904. * @param vector3 the distance to translate in localspace
  86905. * @returns the TransformNode.
  86906. */
  86907. locallyTranslate(vector3: Vector3): TransformNode;
  86908. private static _lookAtVectorCache;
  86909. /**
  86910. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86911. * @param targetPoint the position (must be in same space as current mesh) to look at
  86912. * @param yawCor optional yaw (y-axis) correction in radians
  86913. * @param pitchCor optional pitch (x-axis) correction in radians
  86914. * @param rollCor optional roll (z-axis) correction in radians
  86915. * @param space the choosen space of the target
  86916. * @returns the TransformNode.
  86917. */
  86918. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86919. /**
  86920. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86921. * This Vector3 is expressed in the World space.
  86922. * @param localAxis axis to rotate
  86923. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86924. */
  86925. getDirection(localAxis: Vector3): Vector3;
  86926. /**
  86927. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86928. * localAxis is expressed in the mesh local space.
  86929. * result is computed in the Wordl space from the mesh World matrix.
  86930. * @param localAxis axis to rotate
  86931. * @param result the resulting transformnode
  86932. * @returns this TransformNode.
  86933. */
  86934. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86935. /**
  86936. * Sets this transform node rotation to the given local axis.
  86937. * @param localAxis the axis in local space
  86938. * @param yawCor optional yaw (y-axis) correction in radians
  86939. * @param pitchCor optional pitch (x-axis) correction in radians
  86940. * @param rollCor optional roll (z-axis) correction in radians
  86941. * @returns this TransformNode
  86942. */
  86943. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86944. /**
  86945. * Sets a new pivot point to the current node
  86946. * @param point defines the new pivot point to use
  86947. * @param space defines if the point is in world or local space (local by default)
  86948. * @returns the current TransformNode
  86949. */
  86950. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86951. /**
  86952. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86953. * @returns the pivot point
  86954. */
  86955. getPivotPoint(): Vector3;
  86956. /**
  86957. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86958. * @param result the vector3 to store the result
  86959. * @returns this TransformNode.
  86960. */
  86961. getPivotPointToRef(result: Vector3): TransformNode;
  86962. /**
  86963. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86964. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86965. */
  86966. getAbsolutePivotPoint(): Vector3;
  86967. /**
  86968. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86969. * @param result vector3 to store the result
  86970. * @returns this TransformNode.
  86971. */
  86972. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86973. /**
  86974. * Defines the passed node as the parent of the current node.
  86975. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86976. * @see https://doc.babylonjs.com/how_to/parenting
  86977. * @param node the node ot set as the parent
  86978. * @returns this TransformNode.
  86979. */
  86980. setParent(node: Nullable<Node>): TransformNode;
  86981. private _nonUniformScaling;
  86982. /**
  86983. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86984. */
  86985. get nonUniformScaling(): boolean;
  86986. /** @hidden */
  86987. _updateNonUniformScalingState(value: boolean): boolean;
  86988. /**
  86989. * Attach the current TransformNode to another TransformNode associated with a bone
  86990. * @param bone Bone affecting the TransformNode
  86991. * @param affectedTransformNode TransformNode associated with the bone
  86992. * @returns this object
  86993. */
  86994. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  86995. /**
  86996. * Detach the transform node if its associated with a bone
  86997. * @returns this object
  86998. */
  86999. detachFromBone(): TransformNode;
  87000. private static _rotationAxisCache;
  87001. /**
  87002. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87003. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87004. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87005. * The passed axis is also normalized.
  87006. * @param axis the axis to rotate around
  87007. * @param amount the amount to rotate in radians
  87008. * @param space Space to rotate in (Default: local)
  87009. * @returns the TransformNode.
  87010. */
  87011. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87012. /**
  87013. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87014. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87015. * The passed axis is also normalized. .
  87016. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87017. * @param point the point to rotate around
  87018. * @param axis the axis to rotate around
  87019. * @param amount the amount to rotate in radians
  87020. * @returns the TransformNode
  87021. */
  87022. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87023. /**
  87024. * Translates the mesh along the axis vector for the passed distance in the given space.
  87025. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87026. * @param axis the axis to translate in
  87027. * @param distance the distance to translate
  87028. * @param space Space to rotate in (Default: local)
  87029. * @returns the TransformNode.
  87030. */
  87031. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87032. /**
  87033. * Adds a rotation step to the mesh current rotation.
  87034. * x, y, z are Euler angles expressed in radians.
  87035. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87036. * This means this rotation is made in the mesh local space only.
  87037. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87038. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87039. * ```javascript
  87040. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87041. * ```
  87042. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87043. * 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.
  87044. * @param x Rotation to add
  87045. * @param y Rotation to add
  87046. * @param z Rotation to add
  87047. * @returns the TransformNode.
  87048. */
  87049. addRotation(x: number, y: number, z: number): TransformNode;
  87050. /**
  87051. * @hidden
  87052. */
  87053. protected _getEffectiveParent(): Nullable<Node>;
  87054. /**
  87055. * Computes the world matrix of the node
  87056. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87057. * @returns the world matrix
  87058. */
  87059. computeWorldMatrix(force?: boolean): Matrix;
  87060. /**
  87061. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87062. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87063. */
  87064. resetLocalMatrix(independentOfChildren?: boolean): void;
  87065. protected _afterComputeWorldMatrix(): void;
  87066. /**
  87067. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87068. * @param func callback function to add
  87069. *
  87070. * @returns the TransformNode.
  87071. */
  87072. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87073. /**
  87074. * Removes a registered callback function.
  87075. * @param func callback function to remove
  87076. * @returns the TransformNode.
  87077. */
  87078. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87079. /**
  87080. * Gets the position of the current mesh in camera space
  87081. * @param camera defines the camera to use
  87082. * @returns a position
  87083. */
  87084. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87085. /**
  87086. * Returns the distance from the mesh to the active camera
  87087. * @param camera defines the camera to use
  87088. * @returns the distance
  87089. */
  87090. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87091. /**
  87092. * Clone the current transform node
  87093. * @param name Name of the new clone
  87094. * @param newParent New parent for the clone
  87095. * @param doNotCloneChildren Do not clone children hierarchy
  87096. * @returns the new transform node
  87097. */
  87098. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87099. /**
  87100. * Serializes the objects information.
  87101. * @param currentSerializationObject defines the object to serialize in
  87102. * @returns the serialized object
  87103. */
  87104. serialize(currentSerializationObject?: any): any;
  87105. /**
  87106. * Returns a new TransformNode object parsed from the source provided.
  87107. * @param parsedTransformNode is the source.
  87108. * @param scene the scne the object belongs to
  87109. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87110. * @returns a new TransformNode object parsed from the source provided.
  87111. */
  87112. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87113. /**
  87114. * Get all child-transformNodes of this node
  87115. * @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
  87116. * @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
  87117. * @returns an array of TransformNode
  87118. */
  87119. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87120. /**
  87121. * Releases resources associated with this transform node.
  87122. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87123. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87124. */
  87125. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87126. /**
  87127. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87128. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87129. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87130. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87131. * @returns the current mesh
  87132. */
  87133. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87134. private _syncAbsoluteScalingAndRotation;
  87135. }
  87136. }
  87137. declare module BABYLON {
  87138. /**
  87139. * Class used to override all child animations of a given target
  87140. */
  87141. export class AnimationPropertiesOverride {
  87142. /**
  87143. * Gets or sets a value indicating if animation blending must be used
  87144. */
  87145. enableBlending: boolean;
  87146. /**
  87147. * Gets or sets the blending speed to use when enableBlending is true
  87148. */
  87149. blendingSpeed: number;
  87150. /**
  87151. * Gets or sets the default loop mode to use
  87152. */
  87153. loopMode: number;
  87154. }
  87155. }
  87156. declare module BABYLON {
  87157. /**
  87158. * Class used to store bone information
  87159. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87160. */
  87161. export class Bone extends Node {
  87162. /**
  87163. * defines the bone name
  87164. */
  87165. name: string;
  87166. private static _tmpVecs;
  87167. private static _tmpQuat;
  87168. private static _tmpMats;
  87169. /**
  87170. * Gets the list of child bones
  87171. */
  87172. children: Bone[];
  87173. /** Gets the animations associated with this bone */
  87174. animations: Animation[];
  87175. /**
  87176. * Gets or sets bone length
  87177. */
  87178. length: number;
  87179. /**
  87180. * @hidden Internal only
  87181. * Set this value to map this bone to a different index in the transform matrices
  87182. * Set this value to -1 to exclude the bone from the transform matrices
  87183. */
  87184. _index: Nullable<number>;
  87185. private _skeleton;
  87186. private _localMatrix;
  87187. private _restPose;
  87188. private _baseMatrix;
  87189. private _absoluteTransform;
  87190. private _invertedAbsoluteTransform;
  87191. private _parent;
  87192. private _scalingDeterminant;
  87193. private _worldTransform;
  87194. private _localScaling;
  87195. private _localRotation;
  87196. private _localPosition;
  87197. private _needToDecompose;
  87198. private _needToCompose;
  87199. /** @hidden */
  87200. _linkedTransformNode: Nullable<TransformNode>;
  87201. /** @hidden */
  87202. _waitingTransformNodeId: Nullable<string>;
  87203. /** @hidden */
  87204. get _matrix(): Matrix;
  87205. /** @hidden */
  87206. set _matrix(value: Matrix);
  87207. /**
  87208. * Create a new bone
  87209. * @param name defines the bone name
  87210. * @param skeleton defines the parent skeleton
  87211. * @param parentBone defines the parent (can be null if the bone is the root)
  87212. * @param localMatrix defines the local matrix
  87213. * @param restPose defines the rest pose matrix
  87214. * @param baseMatrix defines the base matrix
  87215. * @param index defines index of the bone in the hiearchy
  87216. */
  87217. constructor(
  87218. /**
  87219. * defines the bone name
  87220. */
  87221. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87222. /**
  87223. * Gets the current object class name.
  87224. * @return the class name
  87225. */
  87226. getClassName(): string;
  87227. /**
  87228. * Gets the parent skeleton
  87229. * @returns a skeleton
  87230. */
  87231. getSkeleton(): Skeleton;
  87232. /**
  87233. * Gets parent bone
  87234. * @returns a bone or null if the bone is the root of the bone hierarchy
  87235. */
  87236. getParent(): Nullable<Bone>;
  87237. /**
  87238. * Returns an array containing the root bones
  87239. * @returns an array containing the root bones
  87240. */
  87241. getChildren(): Array<Bone>;
  87242. /**
  87243. * Gets the node index in matrix array generated for rendering
  87244. * @returns the node index
  87245. */
  87246. getIndex(): number;
  87247. /**
  87248. * Sets the parent bone
  87249. * @param parent defines the parent (can be null if the bone is the root)
  87250. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87251. */
  87252. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87253. /**
  87254. * Gets the local matrix
  87255. * @returns a matrix
  87256. */
  87257. getLocalMatrix(): Matrix;
  87258. /**
  87259. * Gets the base matrix (initial matrix which remains unchanged)
  87260. * @returns a matrix
  87261. */
  87262. getBaseMatrix(): Matrix;
  87263. /**
  87264. * Gets the rest pose matrix
  87265. * @returns a matrix
  87266. */
  87267. getRestPose(): Matrix;
  87268. /**
  87269. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87270. */
  87271. getWorldMatrix(): Matrix;
  87272. /**
  87273. * Sets the local matrix to rest pose matrix
  87274. */
  87275. returnToRest(): void;
  87276. /**
  87277. * Gets the inverse of the absolute transform matrix.
  87278. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87279. * @returns a matrix
  87280. */
  87281. getInvertedAbsoluteTransform(): Matrix;
  87282. /**
  87283. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87284. * @returns a matrix
  87285. */
  87286. getAbsoluteTransform(): Matrix;
  87287. /**
  87288. * Links with the given transform node.
  87289. * The local matrix of this bone is copied from the transform node every frame.
  87290. * @param transformNode defines the transform node to link to
  87291. */
  87292. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87293. /**
  87294. * Gets the node used to drive the bone's transformation
  87295. * @returns a transform node or null
  87296. */
  87297. getTransformNode(): Nullable<TransformNode>;
  87298. /** Gets or sets current position (in local space) */
  87299. get position(): Vector3;
  87300. set position(newPosition: Vector3);
  87301. /** Gets or sets current rotation (in local space) */
  87302. get rotation(): Vector3;
  87303. set rotation(newRotation: Vector3);
  87304. /** Gets or sets current rotation quaternion (in local space) */
  87305. get rotationQuaternion(): Quaternion;
  87306. set rotationQuaternion(newRotation: Quaternion);
  87307. /** Gets or sets current scaling (in local space) */
  87308. get scaling(): Vector3;
  87309. set scaling(newScaling: Vector3);
  87310. /**
  87311. * Gets the animation properties override
  87312. */
  87313. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87314. private _decompose;
  87315. private _compose;
  87316. /**
  87317. * Update the base and local matrices
  87318. * @param matrix defines the new base or local matrix
  87319. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87320. * @param updateLocalMatrix defines if the local matrix should be updated
  87321. */
  87322. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87323. /** @hidden */
  87324. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87325. /**
  87326. * Flag the bone as dirty (Forcing it to update everything)
  87327. */
  87328. markAsDirty(): void;
  87329. /** @hidden */
  87330. _markAsDirtyAndCompose(): void;
  87331. private _markAsDirtyAndDecompose;
  87332. /**
  87333. * Translate the bone in local or world space
  87334. * @param vec The amount to translate the bone
  87335. * @param space The space that the translation is in
  87336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87337. */
  87338. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87339. /**
  87340. * Set the postion of the bone in local or world space
  87341. * @param position The position to set the bone
  87342. * @param space The space that the position is in
  87343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87344. */
  87345. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87346. /**
  87347. * Set the absolute position of the bone (world space)
  87348. * @param position The position to set the bone
  87349. * @param mesh The mesh that this bone is attached to
  87350. */
  87351. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87352. /**
  87353. * Scale the bone on the x, y and z axes (in local space)
  87354. * @param x The amount to scale the bone on the x axis
  87355. * @param y The amount to scale the bone on the y axis
  87356. * @param z The amount to scale the bone on the z axis
  87357. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87358. */
  87359. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87360. /**
  87361. * Set the bone scaling in local space
  87362. * @param scale defines the scaling vector
  87363. */
  87364. setScale(scale: Vector3): void;
  87365. /**
  87366. * Gets the current scaling in local space
  87367. * @returns the current scaling vector
  87368. */
  87369. getScale(): Vector3;
  87370. /**
  87371. * Gets the current scaling in local space and stores it in a target vector
  87372. * @param result defines the target vector
  87373. */
  87374. getScaleToRef(result: Vector3): void;
  87375. /**
  87376. * Set the yaw, pitch, and roll of the bone in local or world space
  87377. * @param yaw The rotation of the bone on the y axis
  87378. * @param pitch The rotation of the bone on the x axis
  87379. * @param roll The rotation of the bone on the z axis
  87380. * @param space The space that the axes of rotation are in
  87381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87382. */
  87383. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87384. /**
  87385. * Add a rotation to the bone on an axis in local or world space
  87386. * @param axis The axis to rotate the bone on
  87387. * @param amount The amount to rotate the bone
  87388. * @param space The space that the axis is in
  87389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87390. */
  87391. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87392. /**
  87393. * Set the rotation of the bone to a particular axis angle in local or world space
  87394. * @param axis The axis to rotate the bone on
  87395. * @param angle The angle that the bone should be rotated to
  87396. * @param space The space that the axis is in
  87397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87398. */
  87399. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87400. /**
  87401. * Set the euler rotation of the bone in local of world space
  87402. * @param rotation The euler rotation that the bone should be set to
  87403. * @param space The space that the rotation is in
  87404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87405. */
  87406. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87407. /**
  87408. * Set the quaternion rotation of the bone in local of world space
  87409. * @param quat The quaternion rotation that the bone should be set to
  87410. * @param space The space that the rotation is in
  87411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87412. */
  87413. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87414. /**
  87415. * Set the rotation matrix of the bone in local of world space
  87416. * @param rotMat The rotation matrix that the bone should be set to
  87417. * @param space The space that the rotation is in
  87418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87419. */
  87420. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87421. private _rotateWithMatrix;
  87422. private _getNegativeRotationToRef;
  87423. /**
  87424. * Get the position of the bone in local or world space
  87425. * @param space The space that the returned position is in
  87426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87427. * @returns The position of the bone
  87428. */
  87429. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87430. /**
  87431. * Copy the position of the bone to a vector3 in local or world space
  87432. * @param space The space that the returned position is in
  87433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87434. * @param result The vector3 to copy the position to
  87435. */
  87436. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87437. /**
  87438. * Get the absolute position of the bone (world space)
  87439. * @param mesh The mesh that this bone is attached to
  87440. * @returns The absolute position of the bone
  87441. */
  87442. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87443. /**
  87444. * Copy the absolute position of the bone (world space) to the result param
  87445. * @param mesh The mesh that this bone is attached to
  87446. * @param result The vector3 to copy the absolute position to
  87447. */
  87448. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87449. /**
  87450. * Compute the absolute transforms of this bone and its children
  87451. */
  87452. computeAbsoluteTransforms(): void;
  87453. /**
  87454. * Get the world direction from an axis that is in the local space of the bone
  87455. * @param localAxis The local direction that is used to compute the world direction
  87456. * @param mesh The mesh that this bone is attached to
  87457. * @returns The world direction
  87458. */
  87459. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87460. /**
  87461. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87462. * @param localAxis The local direction that is used to compute the world direction
  87463. * @param mesh The mesh that this bone is attached to
  87464. * @param result The vector3 that the world direction will be copied to
  87465. */
  87466. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87467. /**
  87468. * Get the euler rotation of the bone in local or world space
  87469. * @param space The space that the rotation should be in
  87470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87471. * @returns The euler rotation
  87472. */
  87473. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87474. /**
  87475. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87476. * @param space The space that the rotation should be in
  87477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87478. * @param result The vector3 that the rotation should be copied to
  87479. */
  87480. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87481. /**
  87482. * Get the quaternion rotation of the bone in either local or world space
  87483. * @param space The space that the rotation should be in
  87484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87485. * @returns The quaternion rotation
  87486. */
  87487. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87488. /**
  87489. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87490. * @param space The space that the rotation should be in
  87491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87492. * @param result The quaternion that the rotation should be copied to
  87493. */
  87494. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87495. /**
  87496. * Get the rotation matrix of the bone in local or world space
  87497. * @param space The space that the rotation should be in
  87498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87499. * @returns The rotation matrix
  87500. */
  87501. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87502. /**
  87503. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87504. * @param space The space that the rotation should be in
  87505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87506. * @param result The quaternion that the rotation should be copied to
  87507. */
  87508. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87509. /**
  87510. * Get the world position of a point that is in the local space of the bone
  87511. * @param position The local position
  87512. * @param mesh The mesh that this bone is attached to
  87513. * @returns The world position
  87514. */
  87515. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87516. /**
  87517. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87518. * @param position The local position
  87519. * @param mesh The mesh that this bone is attached to
  87520. * @param result The vector3 that the world position should be copied to
  87521. */
  87522. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87523. /**
  87524. * Get the local position of a point that is in world space
  87525. * @param position The world position
  87526. * @param mesh The mesh that this bone is attached to
  87527. * @returns The local position
  87528. */
  87529. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87530. /**
  87531. * Get the local position of a point that is in world space and copy it to the result param
  87532. * @param position The world position
  87533. * @param mesh The mesh that this bone is attached to
  87534. * @param result The vector3 that the local position should be copied to
  87535. */
  87536. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87537. }
  87538. }
  87539. declare module BABYLON {
  87540. /**
  87541. * Defines a runtime animation
  87542. */
  87543. export class RuntimeAnimation {
  87544. private _events;
  87545. /**
  87546. * The current frame of the runtime animation
  87547. */
  87548. private _currentFrame;
  87549. /**
  87550. * The animation used by the runtime animation
  87551. */
  87552. private _animation;
  87553. /**
  87554. * The target of the runtime animation
  87555. */
  87556. private _target;
  87557. /**
  87558. * The initiating animatable
  87559. */
  87560. private _host;
  87561. /**
  87562. * The original value of the runtime animation
  87563. */
  87564. private _originalValue;
  87565. /**
  87566. * The original blend value of the runtime animation
  87567. */
  87568. private _originalBlendValue;
  87569. /**
  87570. * The offsets cache of the runtime animation
  87571. */
  87572. private _offsetsCache;
  87573. /**
  87574. * The high limits cache of the runtime animation
  87575. */
  87576. private _highLimitsCache;
  87577. /**
  87578. * Specifies if the runtime animation has been stopped
  87579. */
  87580. private _stopped;
  87581. /**
  87582. * The blending factor of the runtime animation
  87583. */
  87584. private _blendingFactor;
  87585. /**
  87586. * The BabylonJS scene
  87587. */
  87588. private _scene;
  87589. /**
  87590. * The current value of the runtime animation
  87591. */
  87592. private _currentValue;
  87593. /** @hidden */
  87594. _animationState: _IAnimationState;
  87595. /**
  87596. * The active target of the runtime animation
  87597. */
  87598. private _activeTargets;
  87599. private _currentActiveTarget;
  87600. private _directTarget;
  87601. /**
  87602. * The target path of the runtime animation
  87603. */
  87604. private _targetPath;
  87605. /**
  87606. * The weight of the runtime animation
  87607. */
  87608. private _weight;
  87609. /**
  87610. * The ratio offset of the runtime animation
  87611. */
  87612. private _ratioOffset;
  87613. /**
  87614. * The previous delay of the runtime animation
  87615. */
  87616. private _previousDelay;
  87617. /**
  87618. * The previous ratio of the runtime animation
  87619. */
  87620. private _previousRatio;
  87621. private _enableBlending;
  87622. private _keys;
  87623. private _minFrame;
  87624. private _maxFrame;
  87625. private _minValue;
  87626. private _maxValue;
  87627. private _targetIsArray;
  87628. /**
  87629. * Gets the current frame of the runtime animation
  87630. */
  87631. get currentFrame(): number;
  87632. /**
  87633. * Gets the weight of the runtime animation
  87634. */
  87635. get weight(): number;
  87636. /**
  87637. * Gets the current value of the runtime animation
  87638. */
  87639. get currentValue(): any;
  87640. /**
  87641. * Gets the target path of the runtime animation
  87642. */
  87643. get targetPath(): string;
  87644. /**
  87645. * Gets the actual target of the runtime animation
  87646. */
  87647. get target(): any;
  87648. /** @hidden */
  87649. _onLoop: () => void;
  87650. /**
  87651. * Create a new RuntimeAnimation object
  87652. * @param target defines the target of the animation
  87653. * @param animation defines the source animation object
  87654. * @param scene defines the hosting scene
  87655. * @param host defines the initiating Animatable
  87656. */
  87657. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87658. private _preparePath;
  87659. /**
  87660. * Gets the animation from the runtime animation
  87661. */
  87662. get animation(): Animation;
  87663. /**
  87664. * Resets the runtime animation to the beginning
  87665. * @param restoreOriginal defines whether to restore the target property to the original value
  87666. */
  87667. reset(restoreOriginal?: boolean): void;
  87668. /**
  87669. * Specifies if the runtime animation is stopped
  87670. * @returns Boolean specifying if the runtime animation is stopped
  87671. */
  87672. isStopped(): boolean;
  87673. /**
  87674. * Disposes of the runtime animation
  87675. */
  87676. dispose(): void;
  87677. /**
  87678. * Apply the interpolated value to the target
  87679. * @param currentValue defines the value computed by the animation
  87680. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87681. */
  87682. setValue(currentValue: any, weight: number): void;
  87683. private _getOriginalValues;
  87684. private _setValue;
  87685. /**
  87686. * Gets the loop pmode of the runtime animation
  87687. * @returns Loop Mode
  87688. */
  87689. private _getCorrectLoopMode;
  87690. /**
  87691. * Move the current animation to a given frame
  87692. * @param frame defines the frame to move to
  87693. */
  87694. goToFrame(frame: number): void;
  87695. /**
  87696. * @hidden Internal use only
  87697. */
  87698. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87699. /**
  87700. * Execute the current animation
  87701. * @param delay defines the delay to add to the current frame
  87702. * @param from defines the lower bound of the animation range
  87703. * @param to defines the upper bound of the animation range
  87704. * @param loop defines if the current animation must loop
  87705. * @param speedRatio defines the current speed ratio
  87706. * @param weight defines the weight of the animation (default is -1 so no weight)
  87707. * @param onLoop optional callback called when animation loops
  87708. * @returns a boolean indicating if the animation is running
  87709. */
  87710. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87711. }
  87712. }
  87713. declare module BABYLON {
  87714. /**
  87715. * Class used to store an actual running animation
  87716. */
  87717. export class Animatable {
  87718. /** defines the target object */
  87719. target: any;
  87720. /** defines the starting frame number (default is 0) */
  87721. fromFrame: number;
  87722. /** defines the ending frame number (default is 100) */
  87723. toFrame: number;
  87724. /** defines if the animation must loop (default is false) */
  87725. loopAnimation: boolean;
  87726. /** defines a callback to call when animation ends if it is not looping */
  87727. onAnimationEnd?: (() => void) | null | undefined;
  87728. /** defines a callback to call when animation loops */
  87729. onAnimationLoop?: (() => void) | null | undefined;
  87730. private _localDelayOffset;
  87731. private _pausedDelay;
  87732. private _runtimeAnimations;
  87733. private _paused;
  87734. private _scene;
  87735. private _speedRatio;
  87736. private _weight;
  87737. private _syncRoot;
  87738. /**
  87739. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87740. * This will only apply for non looping animation (default is true)
  87741. */
  87742. disposeOnEnd: boolean;
  87743. /**
  87744. * Gets a boolean indicating if the animation has started
  87745. */
  87746. animationStarted: boolean;
  87747. /**
  87748. * Observer raised when the animation ends
  87749. */
  87750. onAnimationEndObservable: Observable<Animatable>;
  87751. /**
  87752. * Observer raised when the animation loops
  87753. */
  87754. onAnimationLoopObservable: Observable<Animatable>;
  87755. /**
  87756. * Gets the root Animatable used to synchronize and normalize animations
  87757. */
  87758. get syncRoot(): Nullable<Animatable>;
  87759. /**
  87760. * Gets the current frame of the first RuntimeAnimation
  87761. * Used to synchronize Animatables
  87762. */
  87763. get masterFrame(): number;
  87764. /**
  87765. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87766. */
  87767. get weight(): number;
  87768. set weight(value: number);
  87769. /**
  87770. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87771. */
  87772. get speedRatio(): number;
  87773. set speedRatio(value: number);
  87774. /**
  87775. * Creates a new Animatable
  87776. * @param scene defines the hosting scene
  87777. * @param target defines the target object
  87778. * @param fromFrame defines the starting frame number (default is 0)
  87779. * @param toFrame defines the ending frame number (default is 100)
  87780. * @param loopAnimation defines if the animation must loop (default is false)
  87781. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87782. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87783. * @param animations defines a group of animation to add to the new Animatable
  87784. * @param onAnimationLoop defines a callback to call when animation loops
  87785. */
  87786. constructor(scene: Scene,
  87787. /** defines the target object */
  87788. target: any,
  87789. /** defines the starting frame number (default is 0) */
  87790. fromFrame?: number,
  87791. /** defines the ending frame number (default is 100) */
  87792. toFrame?: number,
  87793. /** defines if the animation must loop (default is false) */
  87794. loopAnimation?: boolean, speedRatio?: number,
  87795. /** defines a callback to call when animation ends if it is not looping */
  87796. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87797. /** defines a callback to call when animation loops */
  87798. onAnimationLoop?: (() => void) | null | undefined);
  87799. /**
  87800. * Synchronize and normalize current Animatable with a source Animatable
  87801. * This is useful when using animation weights and when animations are not of the same length
  87802. * @param root defines the root Animatable to synchronize with
  87803. * @returns the current Animatable
  87804. */
  87805. syncWith(root: Animatable): Animatable;
  87806. /**
  87807. * Gets the list of runtime animations
  87808. * @returns an array of RuntimeAnimation
  87809. */
  87810. getAnimations(): RuntimeAnimation[];
  87811. /**
  87812. * Adds more animations to the current animatable
  87813. * @param target defines the target of the animations
  87814. * @param animations defines the new animations to add
  87815. */
  87816. appendAnimations(target: any, animations: Animation[]): void;
  87817. /**
  87818. * Gets the source animation for a specific property
  87819. * @param property defines the propertyu to look for
  87820. * @returns null or the source animation for the given property
  87821. */
  87822. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87823. /**
  87824. * Gets the runtime animation for a specific property
  87825. * @param property defines the propertyu to look for
  87826. * @returns null or the runtime animation for the given property
  87827. */
  87828. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87829. /**
  87830. * Resets the animatable to its original state
  87831. */
  87832. reset(): void;
  87833. /**
  87834. * Allows the animatable to blend with current running animations
  87835. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87836. * @param blendingSpeed defines the blending speed to use
  87837. */
  87838. enableBlending(blendingSpeed: number): void;
  87839. /**
  87840. * Disable animation blending
  87841. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87842. */
  87843. disableBlending(): void;
  87844. /**
  87845. * Jump directly to a given frame
  87846. * @param frame defines the frame to jump to
  87847. */
  87848. goToFrame(frame: number): void;
  87849. /**
  87850. * Pause the animation
  87851. */
  87852. pause(): void;
  87853. /**
  87854. * Restart the animation
  87855. */
  87856. restart(): void;
  87857. private _raiseOnAnimationEnd;
  87858. /**
  87859. * Stop and delete the current animation
  87860. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87861. * @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)
  87862. */
  87863. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87864. /**
  87865. * Wait asynchronously for the animation to end
  87866. * @returns a promise which will be fullfilled when the animation ends
  87867. */
  87868. waitAsync(): Promise<Animatable>;
  87869. /** @hidden */
  87870. _animate(delay: number): boolean;
  87871. }
  87872. interface Scene {
  87873. /** @hidden */
  87874. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87875. /** @hidden */
  87876. _processLateAnimationBindingsForMatrices(holder: {
  87877. totalWeight: number;
  87878. animations: RuntimeAnimation[];
  87879. originalValue: Matrix;
  87880. }): any;
  87881. /** @hidden */
  87882. _processLateAnimationBindingsForQuaternions(holder: {
  87883. totalWeight: number;
  87884. animations: RuntimeAnimation[];
  87885. originalValue: Quaternion;
  87886. }, refQuaternion: Quaternion): Quaternion;
  87887. /** @hidden */
  87888. _processLateAnimationBindings(): void;
  87889. /**
  87890. * Will start the animation sequence of a given target
  87891. * @param target defines the target
  87892. * @param from defines from which frame should animation start
  87893. * @param to defines until which frame should animation run.
  87894. * @param weight defines the weight to apply to the animation (1.0 by default)
  87895. * @param loop defines if the animation loops
  87896. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87897. * @param onAnimationEnd defines the function to be executed when the animation ends
  87898. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87899. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87900. * @param onAnimationLoop defines the callback to call when an animation loops
  87901. * @returns the animatable object created for this animation
  87902. */
  87903. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87904. /**
  87905. * Will start the animation sequence of a given target
  87906. * @param target defines the target
  87907. * @param from defines from which frame should animation start
  87908. * @param to defines until which frame should animation run.
  87909. * @param loop defines if the animation loops
  87910. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87911. * @param onAnimationEnd defines the function to be executed when the animation ends
  87912. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87913. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87914. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87915. * @param onAnimationLoop defines the callback to call when an animation loops
  87916. * @returns the animatable object created for this animation
  87917. */
  87918. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87919. /**
  87920. * Will start the animation sequence of a given target and its hierarchy
  87921. * @param target defines the target
  87922. * @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.
  87923. * @param from defines from which frame should animation start
  87924. * @param to defines until which frame should animation run.
  87925. * @param loop defines if the animation loops
  87926. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87927. * @param onAnimationEnd defines the function to be executed when the animation ends
  87928. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87929. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87930. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87931. * @param onAnimationLoop defines the callback to call when an animation loops
  87932. * @returns the list of created animatables
  87933. */
  87934. 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[];
  87935. /**
  87936. * Begin a new animation on a given node
  87937. * @param target defines the target where the animation will take place
  87938. * @param animations defines the list of animations to start
  87939. * @param from defines the initial value
  87940. * @param to defines the final value
  87941. * @param loop defines if you want animation to loop (off by default)
  87942. * @param speedRatio defines the speed ratio to apply to all animations
  87943. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87944. * @param onAnimationLoop defines the callback to call when an animation loops
  87945. * @returns the list of created animatables
  87946. */
  87947. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  87948. /**
  87949. * Begin a new animation on a given node and its hierarchy
  87950. * @param target defines the root node where the animation will take place
  87951. * @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.
  87952. * @param animations defines the list of animations to start
  87953. * @param from defines the initial value
  87954. * @param to defines the final value
  87955. * @param loop defines if you want animation to loop (off by default)
  87956. * @param speedRatio defines the speed ratio to apply to all animations
  87957. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87958. * @param onAnimationLoop defines the callback to call when an animation loops
  87959. * @returns the list of animatables created for all nodes
  87960. */
  87961. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  87962. /**
  87963. * Gets the animatable associated with a specific target
  87964. * @param target defines the target of the animatable
  87965. * @returns the required animatable if found
  87966. */
  87967. getAnimatableByTarget(target: any): Nullable<Animatable>;
  87968. /**
  87969. * Gets all animatables associated with a given target
  87970. * @param target defines the target to look animatables for
  87971. * @returns an array of Animatables
  87972. */
  87973. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  87974. /**
  87975. * Stops and removes all animations that have been applied to the scene
  87976. */
  87977. stopAllAnimations(): void;
  87978. /**
  87979. * Gets the current delta time used by animation engine
  87980. */
  87981. deltaTime: number;
  87982. }
  87983. interface Bone {
  87984. /**
  87985. * Copy an animation range from another bone
  87986. * @param source defines the source bone
  87987. * @param rangeName defines the range name to copy
  87988. * @param frameOffset defines the frame offset
  87989. * @param rescaleAsRequired defines if rescaling must be applied if required
  87990. * @param skelDimensionsRatio defines the scaling ratio
  87991. * @returns true if operation was successful
  87992. */
  87993. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  87994. }
  87995. }
  87996. declare module BABYLON {
  87997. /**
  87998. * Class used to handle skinning animations
  87999. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88000. */
  88001. export class Skeleton implements IAnimatable {
  88002. /** defines the skeleton name */
  88003. name: string;
  88004. /** defines the skeleton Id */
  88005. id: string;
  88006. /**
  88007. * Defines the list of child bones
  88008. */
  88009. bones: Bone[];
  88010. /**
  88011. * Defines an estimate of the dimension of the skeleton at rest
  88012. */
  88013. dimensionsAtRest: Vector3;
  88014. /**
  88015. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88016. */
  88017. needInitialSkinMatrix: boolean;
  88018. /**
  88019. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88020. */
  88021. overrideMesh: Nullable<AbstractMesh>;
  88022. /**
  88023. * Gets the list of animations attached to this skeleton
  88024. */
  88025. animations: Array<Animation>;
  88026. private _scene;
  88027. private _isDirty;
  88028. private _transformMatrices;
  88029. private _transformMatrixTexture;
  88030. private _meshesWithPoseMatrix;
  88031. private _animatables;
  88032. private _identity;
  88033. private _synchronizedWithMesh;
  88034. private _ranges;
  88035. private _lastAbsoluteTransformsUpdateId;
  88036. private _canUseTextureForBones;
  88037. private _uniqueId;
  88038. /** @hidden */
  88039. _numBonesWithLinkedTransformNode: number;
  88040. /** @hidden */
  88041. _hasWaitingData: Nullable<boolean>;
  88042. /**
  88043. * Specifies if the skeleton should be serialized
  88044. */
  88045. doNotSerialize: boolean;
  88046. private _useTextureToStoreBoneMatrices;
  88047. /**
  88048. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88049. * Please note that this option is not available if the hardware does not support it
  88050. */
  88051. get useTextureToStoreBoneMatrices(): boolean;
  88052. set useTextureToStoreBoneMatrices(value: boolean);
  88053. private _animationPropertiesOverride;
  88054. /**
  88055. * Gets or sets the animation properties override
  88056. */
  88057. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88058. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88059. /**
  88060. * List of inspectable custom properties (used by the Inspector)
  88061. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88062. */
  88063. inspectableCustomProperties: IInspectable[];
  88064. /**
  88065. * An observable triggered before computing the skeleton's matrices
  88066. */
  88067. onBeforeComputeObservable: Observable<Skeleton>;
  88068. /**
  88069. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88070. */
  88071. get isUsingTextureForMatrices(): boolean;
  88072. /**
  88073. * Gets the unique ID of this skeleton
  88074. */
  88075. get uniqueId(): number;
  88076. /**
  88077. * Creates a new skeleton
  88078. * @param name defines the skeleton name
  88079. * @param id defines the skeleton Id
  88080. * @param scene defines the hosting scene
  88081. */
  88082. constructor(
  88083. /** defines the skeleton name */
  88084. name: string,
  88085. /** defines the skeleton Id */
  88086. id: string, scene: Scene);
  88087. /**
  88088. * Gets the current object class name.
  88089. * @return the class name
  88090. */
  88091. getClassName(): string;
  88092. /**
  88093. * Returns an array containing the root bones
  88094. * @returns an array containing the root bones
  88095. */
  88096. getChildren(): Array<Bone>;
  88097. /**
  88098. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88099. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88100. * @returns a Float32Array containing matrices data
  88101. */
  88102. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88103. /**
  88104. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88105. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88106. * @returns a raw texture containing the data
  88107. */
  88108. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88109. /**
  88110. * Gets the current hosting scene
  88111. * @returns a scene object
  88112. */
  88113. getScene(): Scene;
  88114. /**
  88115. * Gets a string representing the current skeleton data
  88116. * @param fullDetails defines a boolean indicating if we want a verbose version
  88117. * @returns a string representing the current skeleton data
  88118. */
  88119. toString(fullDetails?: boolean): string;
  88120. /**
  88121. * Get bone's index searching by name
  88122. * @param name defines bone's name to search for
  88123. * @return the indice of the bone. Returns -1 if not found
  88124. */
  88125. getBoneIndexByName(name: string): number;
  88126. /**
  88127. * Creater a new animation range
  88128. * @param name defines the name of the range
  88129. * @param from defines the start key
  88130. * @param to defines the end key
  88131. */
  88132. createAnimationRange(name: string, from: number, to: number): void;
  88133. /**
  88134. * Delete a specific animation range
  88135. * @param name defines the name of the range
  88136. * @param deleteFrames defines if frames must be removed as well
  88137. */
  88138. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88139. /**
  88140. * Gets a specific animation range
  88141. * @param name defines the name of the range to look for
  88142. * @returns the requested animation range or null if not found
  88143. */
  88144. getAnimationRange(name: string): Nullable<AnimationRange>;
  88145. /**
  88146. * Gets the list of all animation ranges defined on this skeleton
  88147. * @returns an array
  88148. */
  88149. getAnimationRanges(): Nullable<AnimationRange>[];
  88150. /**
  88151. * Copy animation range from a source skeleton.
  88152. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88153. * @param source defines the source skeleton
  88154. * @param name defines the name of the range to copy
  88155. * @param rescaleAsRequired defines if rescaling must be applied if required
  88156. * @returns true if operation was successful
  88157. */
  88158. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88159. /**
  88160. * Forces the skeleton to go to rest pose
  88161. */
  88162. returnToRest(): void;
  88163. private _getHighestAnimationFrame;
  88164. /**
  88165. * Begin a specific animation range
  88166. * @param name defines the name of the range to start
  88167. * @param loop defines if looping must be turned on (false by default)
  88168. * @param speedRatio defines the speed ratio to apply (1 by default)
  88169. * @param onAnimationEnd defines a callback which will be called when animation will end
  88170. * @returns a new animatable
  88171. */
  88172. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88173. /** @hidden */
  88174. _markAsDirty(): void;
  88175. /** @hidden */
  88176. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88177. /** @hidden */
  88178. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88179. private _computeTransformMatrices;
  88180. /**
  88181. * Build all resources required to render a skeleton
  88182. */
  88183. prepare(): void;
  88184. /**
  88185. * Gets the list of animatables currently running for this skeleton
  88186. * @returns an array of animatables
  88187. */
  88188. getAnimatables(): IAnimatable[];
  88189. /**
  88190. * Clone the current skeleton
  88191. * @param name defines the name of the new skeleton
  88192. * @param id defines the id of the new skeleton
  88193. * @returns the new skeleton
  88194. */
  88195. clone(name: string, id?: string): Skeleton;
  88196. /**
  88197. * Enable animation blending for this skeleton
  88198. * @param blendingSpeed defines the blending speed to apply
  88199. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88200. */
  88201. enableBlending(blendingSpeed?: number): void;
  88202. /**
  88203. * Releases all resources associated with the current skeleton
  88204. */
  88205. dispose(): void;
  88206. /**
  88207. * Serialize the skeleton in a JSON object
  88208. * @returns a JSON object
  88209. */
  88210. serialize(): any;
  88211. /**
  88212. * Creates a new skeleton from serialized data
  88213. * @param parsedSkeleton defines the serialized data
  88214. * @param scene defines the hosting scene
  88215. * @returns a new skeleton
  88216. */
  88217. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88218. /**
  88219. * Compute all node absolute transforms
  88220. * @param forceUpdate defines if computation must be done even if cache is up to date
  88221. */
  88222. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88223. /**
  88224. * Gets the root pose matrix
  88225. * @returns a matrix
  88226. */
  88227. getPoseMatrix(): Nullable<Matrix>;
  88228. /**
  88229. * Sorts bones per internal index
  88230. */
  88231. sortBones(): void;
  88232. private _sortBones;
  88233. }
  88234. }
  88235. declare module BABYLON {
  88236. /**
  88237. * Creates an instance based on a source mesh.
  88238. */
  88239. export class InstancedMesh extends AbstractMesh {
  88240. private _sourceMesh;
  88241. private _currentLOD;
  88242. /** @hidden */
  88243. _indexInSourceMeshInstanceArray: number;
  88244. constructor(name: string, source: Mesh);
  88245. /**
  88246. * Returns the string "InstancedMesh".
  88247. */
  88248. getClassName(): string;
  88249. /** Gets the list of lights affecting that mesh */
  88250. get lightSources(): Light[];
  88251. _resyncLightSources(): void;
  88252. _resyncLightSource(light: Light): void;
  88253. _removeLightSource(light: Light, dispose: boolean): void;
  88254. /**
  88255. * If the source mesh receives shadows
  88256. */
  88257. get receiveShadows(): boolean;
  88258. /**
  88259. * The material of the source mesh
  88260. */
  88261. get material(): Nullable<Material>;
  88262. /**
  88263. * Visibility of the source mesh
  88264. */
  88265. get visibility(): number;
  88266. /**
  88267. * Skeleton of the source mesh
  88268. */
  88269. get skeleton(): Nullable<Skeleton>;
  88270. /**
  88271. * Rendering ground id of the source mesh
  88272. */
  88273. get renderingGroupId(): number;
  88274. set renderingGroupId(value: number);
  88275. /**
  88276. * Returns the total number of vertices (integer).
  88277. */
  88278. getTotalVertices(): number;
  88279. /**
  88280. * Returns a positive integer : the total number of indices in this mesh geometry.
  88281. * @returns the numner of indices or zero if the mesh has no geometry.
  88282. */
  88283. getTotalIndices(): number;
  88284. /**
  88285. * The source mesh of the instance
  88286. */
  88287. get sourceMesh(): Mesh;
  88288. /**
  88289. * Is this node ready to be used/rendered
  88290. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88291. * @return {boolean} is it ready
  88292. */
  88293. isReady(completeCheck?: boolean): boolean;
  88294. /**
  88295. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88296. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88297. * @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.
  88298. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88299. */
  88300. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88301. /**
  88302. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88303. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88304. * The `data` are either a numeric array either a Float32Array.
  88305. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88306. * 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).
  88307. * Note that a new underlying VertexBuffer object is created each call.
  88308. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88309. *
  88310. * Possible `kind` values :
  88311. * - VertexBuffer.PositionKind
  88312. * - VertexBuffer.UVKind
  88313. * - VertexBuffer.UV2Kind
  88314. * - VertexBuffer.UV3Kind
  88315. * - VertexBuffer.UV4Kind
  88316. * - VertexBuffer.UV5Kind
  88317. * - VertexBuffer.UV6Kind
  88318. * - VertexBuffer.ColorKind
  88319. * - VertexBuffer.MatricesIndicesKind
  88320. * - VertexBuffer.MatricesIndicesExtraKind
  88321. * - VertexBuffer.MatricesWeightsKind
  88322. * - VertexBuffer.MatricesWeightsExtraKind
  88323. *
  88324. * Returns the Mesh.
  88325. */
  88326. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88327. /**
  88328. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88329. * If the mesh has no geometry, it is simply returned as it is.
  88330. * The `data` are either a numeric array either a Float32Array.
  88331. * No new underlying VertexBuffer object is created.
  88332. * 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.
  88333. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88334. *
  88335. * Possible `kind` values :
  88336. * - VertexBuffer.PositionKind
  88337. * - VertexBuffer.UVKind
  88338. * - VertexBuffer.UV2Kind
  88339. * - VertexBuffer.UV3Kind
  88340. * - VertexBuffer.UV4Kind
  88341. * - VertexBuffer.UV5Kind
  88342. * - VertexBuffer.UV6Kind
  88343. * - VertexBuffer.ColorKind
  88344. * - VertexBuffer.MatricesIndicesKind
  88345. * - VertexBuffer.MatricesIndicesExtraKind
  88346. * - VertexBuffer.MatricesWeightsKind
  88347. * - VertexBuffer.MatricesWeightsExtraKind
  88348. *
  88349. * Returns the Mesh.
  88350. */
  88351. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88352. /**
  88353. * Sets the mesh indices.
  88354. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88355. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88356. * This method creates a new index buffer each call.
  88357. * Returns the Mesh.
  88358. */
  88359. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88360. /**
  88361. * Boolean : True if the mesh owns the requested kind of data.
  88362. */
  88363. isVerticesDataPresent(kind: string): boolean;
  88364. /**
  88365. * Returns an array of indices (IndicesArray).
  88366. */
  88367. getIndices(): Nullable<IndicesArray>;
  88368. get _positions(): Nullable<Vector3[]>;
  88369. /**
  88370. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88371. * This means the mesh underlying bounding box and sphere are recomputed.
  88372. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88373. * @returns the current mesh
  88374. */
  88375. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88376. /** @hidden */
  88377. _preActivate(): InstancedMesh;
  88378. /** @hidden */
  88379. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88380. /** @hidden */
  88381. _postActivate(): void;
  88382. getWorldMatrix(): Matrix;
  88383. get isAnInstance(): boolean;
  88384. /**
  88385. * Returns the current associated LOD AbstractMesh.
  88386. */
  88387. getLOD(camera: Camera): AbstractMesh;
  88388. /** @hidden */
  88389. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88390. /** @hidden */
  88391. _syncSubMeshes(): InstancedMesh;
  88392. /** @hidden */
  88393. _generatePointsArray(): boolean;
  88394. /**
  88395. * Creates a new InstancedMesh from the current mesh.
  88396. * - name (string) : the cloned mesh name
  88397. * - newParent (optional Node) : the optional Node to parent the clone to.
  88398. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88399. *
  88400. * Returns the clone.
  88401. */
  88402. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88403. /**
  88404. * Disposes the InstancedMesh.
  88405. * Returns nothing.
  88406. */
  88407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88408. }
  88409. interface Mesh {
  88410. /**
  88411. * Register a custom buffer that will be instanced
  88412. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88413. * @param kind defines the buffer kind
  88414. * @param stride defines the stride in floats
  88415. */
  88416. registerInstancedBuffer(kind: string, stride: number): void;
  88417. /** @hidden */
  88418. _userInstancedBuffersStorage: {
  88419. data: {
  88420. [key: string]: Float32Array;
  88421. };
  88422. sizes: {
  88423. [key: string]: number;
  88424. };
  88425. vertexBuffers: {
  88426. [key: string]: Nullable<VertexBuffer>;
  88427. };
  88428. strides: {
  88429. [key: string]: number;
  88430. };
  88431. };
  88432. }
  88433. interface AbstractMesh {
  88434. /**
  88435. * Object used to store instanced buffers defined by user
  88436. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88437. */
  88438. instancedBuffers: {
  88439. [key: string]: any;
  88440. };
  88441. }
  88442. }
  88443. declare module BABYLON {
  88444. /**
  88445. * Defines the options associated with the creation of a shader material.
  88446. */
  88447. export interface IShaderMaterialOptions {
  88448. /**
  88449. * Does the material work in alpha blend mode
  88450. */
  88451. needAlphaBlending: boolean;
  88452. /**
  88453. * Does the material work in alpha test mode
  88454. */
  88455. needAlphaTesting: boolean;
  88456. /**
  88457. * The list of attribute names used in the shader
  88458. */
  88459. attributes: string[];
  88460. /**
  88461. * The list of unifrom names used in the shader
  88462. */
  88463. uniforms: string[];
  88464. /**
  88465. * The list of UBO names used in the shader
  88466. */
  88467. uniformBuffers: string[];
  88468. /**
  88469. * The list of sampler names used in the shader
  88470. */
  88471. samplers: string[];
  88472. /**
  88473. * The list of defines used in the shader
  88474. */
  88475. defines: string[];
  88476. }
  88477. /**
  88478. * 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.
  88479. *
  88480. * This returned material effects how the mesh will look based on the code in the shaders.
  88481. *
  88482. * @see http://doc.babylonjs.com/how_to/shader_material
  88483. */
  88484. export class ShaderMaterial extends Material {
  88485. private _shaderPath;
  88486. private _options;
  88487. private _textures;
  88488. private _textureArrays;
  88489. private _floats;
  88490. private _ints;
  88491. private _floatsArrays;
  88492. private _colors3;
  88493. private _colors3Arrays;
  88494. private _colors4;
  88495. private _colors4Arrays;
  88496. private _vectors2;
  88497. private _vectors3;
  88498. private _vectors4;
  88499. private _matrices;
  88500. private _matrixArrays;
  88501. private _matrices3x3;
  88502. private _matrices2x2;
  88503. private _vectors2Arrays;
  88504. private _vectors3Arrays;
  88505. private _vectors4Arrays;
  88506. private _cachedWorldViewMatrix;
  88507. private _cachedWorldViewProjectionMatrix;
  88508. private _renderId;
  88509. private _multiview;
  88510. /**
  88511. * Instantiate a new shader material.
  88512. * 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.
  88513. * This returned material effects how the mesh will look based on the code in the shaders.
  88514. * @see http://doc.babylonjs.com/how_to/shader_material
  88515. * @param name Define the name of the material in the scene
  88516. * @param scene Define the scene the material belongs to
  88517. * @param shaderPath Defines the route to the shader code in one of three ways:
  88518. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88519. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88520. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88521. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88522. * @param options Define the options used to create the shader
  88523. */
  88524. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88525. /**
  88526. * Gets the shader path used to define the shader code
  88527. * It can be modified to trigger a new compilation
  88528. */
  88529. get shaderPath(): any;
  88530. /**
  88531. * Sets the shader path used to define the shader code
  88532. * It can be modified to trigger a new compilation
  88533. */
  88534. set shaderPath(shaderPath: any);
  88535. /**
  88536. * Gets the options used to compile the shader.
  88537. * They can be modified to trigger a new compilation
  88538. */
  88539. get options(): IShaderMaterialOptions;
  88540. /**
  88541. * Gets the current class name of the material e.g. "ShaderMaterial"
  88542. * Mainly use in serialization.
  88543. * @returns the class name
  88544. */
  88545. getClassName(): string;
  88546. /**
  88547. * Specifies if the material will require alpha blending
  88548. * @returns a boolean specifying if alpha blending is needed
  88549. */
  88550. needAlphaBlending(): boolean;
  88551. /**
  88552. * Specifies if this material should be rendered in alpha test mode
  88553. * @returns a boolean specifying if an alpha test is needed.
  88554. */
  88555. needAlphaTesting(): boolean;
  88556. private _checkUniform;
  88557. /**
  88558. * Set a texture in the shader.
  88559. * @param name Define the name of the uniform samplers as defined in the shader
  88560. * @param texture Define the texture to bind to this sampler
  88561. * @return the material itself allowing "fluent" like uniform updates
  88562. */
  88563. setTexture(name: string, texture: Texture): ShaderMaterial;
  88564. /**
  88565. * Set a texture array in the shader.
  88566. * @param name Define the name of the uniform sampler array as defined in the shader
  88567. * @param textures Define the list of textures to bind to this sampler
  88568. * @return the material itself allowing "fluent" like uniform updates
  88569. */
  88570. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88571. /**
  88572. * Set a float in the shader.
  88573. * @param name Define the name of the uniform as defined in the shader
  88574. * @param value Define the value to give to the uniform
  88575. * @return the material itself allowing "fluent" like uniform updates
  88576. */
  88577. setFloat(name: string, value: number): ShaderMaterial;
  88578. /**
  88579. * Set a int in the shader.
  88580. * @param name Define the name of the uniform as defined in the shader
  88581. * @param value Define the value to give to the uniform
  88582. * @return the material itself allowing "fluent" like uniform updates
  88583. */
  88584. setInt(name: string, value: number): ShaderMaterial;
  88585. /**
  88586. * Set an array of floats in the shader.
  88587. * @param name Define the name of the uniform as defined in the shader
  88588. * @param value Define the value to give to the uniform
  88589. * @return the material itself allowing "fluent" like uniform updates
  88590. */
  88591. setFloats(name: string, value: number[]): ShaderMaterial;
  88592. /**
  88593. * Set a vec3 in the shader from a Color3.
  88594. * @param name Define the name of the uniform as defined in the shader
  88595. * @param value Define the value to give to the uniform
  88596. * @return the material itself allowing "fluent" like uniform updates
  88597. */
  88598. setColor3(name: string, value: Color3): ShaderMaterial;
  88599. /**
  88600. * Set a vec3 array in the shader from a Color3 array.
  88601. * @param name Define the name of the uniform as defined in the shader
  88602. * @param value Define the value to give to the uniform
  88603. * @return the material itself allowing "fluent" like uniform updates
  88604. */
  88605. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88606. /**
  88607. * Set a vec4 in the shader from a Color4.
  88608. * @param name Define the name of the uniform as defined in the shader
  88609. * @param value Define the value to give to the uniform
  88610. * @return the material itself allowing "fluent" like uniform updates
  88611. */
  88612. setColor4(name: string, value: Color4): ShaderMaterial;
  88613. /**
  88614. * Set a vec4 array in the shader from a Color4 array.
  88615. * @param name Define the name of the uniform as defined in the shader
  88616. * @param value Define the value to give to the uniform
  88617. * @return the material itself allowing "fluent" like uniform updates
  88618. */
  88619. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88620. /**
  88621. * Set a vec2 in the shader from a Vector2.
  88622. * @param name Define the name of the uniform as defined in the shader
  88623. * @param value Define the value to give to the uniform
  88624. * @return the material itself allowing "fluent" like uniform updates
  88625. */
  88626. setVector2(name: string, value: Vector2): ShaderMaterial;
  88627. /**
  88628. * Set a vec3 in the shader from a Vector3.
  88629. * @param name Define the name of the uniform as defined in the shader
  88630. * @param value Define the value to give to the uniform
  88631. * @return the material itself allowing "fluent" like uniform updates
  88632. */
  88633. setVector3(name: string, value: Vector3): ShaderMaterial;
  88634. /**
  88635. * Set a vec4 in the shader from a Vector4.
  88636. * @param name Define the name of the uniform as defined in the shader
  88637. * @param value Define the value to give to the uniform
  88638. * @return the material itself allowing "fluent" like uniform updates
  88639. */
  88640. setVector4(name: string, value: Vector4): ShaderMaterial;
  88641. /**
  88642. * Set a mat4 in the shader from a Matrix.
  88643. * @param name Define the name of the uniform as defined in the shader
  88644. * @param value Define the value to give to the uniform
  88645. * @return the material itself allowing "fluent" like uniform updates
  88646. */
  88647. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88648. /**
  88649. * Set a float32Array in the shader from a matrix array.
  88650. * @param name Define the name of the uniform as defined in the shader
  88651. * @param value Define the value to give to the uniform
  88652. * @return the material itself allowing "fluent" like uniform updates
  88653. */
  88654. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88655. /**
  88656. * Set a mat3 in the shader from a Float32Array.
  88657. * @param name Define the name of the uniform as defined in the shader
  88658. * @param value Define the value to give to the uniform
  88659. * @return the material itself allowing "fluent" like uniform updates
  88660. */
  88661. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88662. /**
  88663. * Set a mat2 in the shader from a Float32Array.
  88664. * @param name Define the name of the uniform as defined in the shader
  88665. * @param value Define the value to give to the uniform
  88666. * @return the material itself allowing "fluent" like uniform updates
  88667. */
  88668. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88669. /**
  88670. * Set a vec2 array in the shader from a number array.
  88671. * @param name Define the name of the uniform as defined in the shader
  88672. * @param value Define the value to give to the uniform
  88673. * @return the material itself allowing "fluent" like uniform updates
  88674. */
  88675. setArray2(name: string, value: number[]): ShaderMaterial;
  88676. /**
  88677. * Set a vec3 array in the shader from a number array.
  88678. * @param name Define the name of the uniform as defined in the shader
  88679. * @param value Define the value to give to the uniform
  88680. * @return the material itself allowing "fluent" like uniform updates
  88681. */
  88682. setArray3(name: string, value: number[]): ShaderMaterial;
  88683. /**
  88684. * Set a vec4 array in the shader from a number array.
  88685. * @param name Define the name of the uniform as defined in the shader
  88686. * @param value Define the value to give to the uniform
  88687. * @return the material itself allowing "fluent" like uniform updates
  88688. */
  88689. setArray4(name: string, value: number[]): ShaderMaterial;
  88690. private _checkCache;
  88691. /**
  88692. * Specifies that the submesh is ready to be used
  88693. * @param mesh defines the mesh to check
  88694. * @param subMesh defines which submesh to check
  88695. * @param useInstances specifies that instances should be used
  88696. * @returns a boolean indicating that the submesh is ready or not
  88697. */
  88698. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88699. /**
  88700. * Checks if the material is ready to render the requested mesh
  88701. * @param mesh Define the mesh to render
  88702. * @param useInstances Define whether or not the material is used with instances
  88703. * @returns true if ready, otherwise false
  88704. */
  88705. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88706. /**
  88707. * Binds the world matrix to the material
  88708. * @param world defines the world transformation matrix
  88709. */
  88710. bindOnlyWorldMatrix(world: Matrix): void;
  88711. /**
  88712. * Binds the material to the mesh
  88713. * @param world defines the world transformation matrix
  88714. * @param mesh defines the mesh to bind the material to
  88715. */
  88716. bind(world: Matrix, mesh?: Mesh): void;
  88717. /**
  88718. * Gets the active textures from the material
  88719. * @returns an array of textures
  88720. */
  88721. getActiveTextures(): BaseTexture[];
  88722. /**
  88723. * Specifies if the material uses a texture
  88724. * @param texture defines the texture to check against the material
  88725. * @returns a boolean specifying if the material uses the texture
  88726. */
  88727. hasTexture(texture: BaseTexture): boolean;
  88728. /**
  88729. * Makes a duplicate of the material, and gives it a new name
  88730. * @param name defines the new name for the duplicated material
  88731. * @returns the cloned material
  88732. */
  88733. clone(name: string): ShaderMaterial;
  88734. /**
  88735. * Disposes the material
  88736. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88737. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88738. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88739. */
  88740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88741. /**
  88742. * Serializes this material in a JSON representation
  88743. * @returns the serialized material object
  88744. */
  88745. serialize(): any;
  88746. /**
  88747. * Creates a shader material from parsed shader material data
  88748. * @param source defines the JSON represnetation of the material
  88749. * @param scene defines the hosting scene
  88750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88751. * @returns a new material
  88752. */
  88753. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88754. }
  88755. }
  88756. declare module BABYLON {
  88757. /** @hidden */
  88758. export var colorPixelShader: {
  88759. name: string;
  88760. shader: string;
  88761. };
  88762. }
  88763. declare module BABYLON {
  88764. /** @hidden */
  88765. export var colorVertexShader: {
  88766. name: string;
  88767. shader: string;
  88768. };
  88769. }
  88770. declare module BABYLON {
  88771. /**
  88772. * Line mesh
  88773. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88774. */
  88775. export class LinesMesh extends Mesh {
  88776. /**
  88777. * If vertex color should be applied to the mesh
  88778. */
  88779. readonly useVertexColor?: boolean | undefined;
  88780. /**
  88781. * If vertex alpha should be applied to the mesh
  88782. */
  88783. readonly useVertexAlpha?: boolean | undefined;
  88784. /**
  88785. * Color of the line (Default: White)
  88786. */
  88787. color: Color3;
  88788. /**
  88789. * Alpha of the line (Default: 1)
  88790. */
  88791. alpha: number;
  88792. /**
  88793. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88794. * This margin is expressed in world space coordinates, so its value may vary.
  88795. * Default value is 0.1
  88796. */
  88797. intersectionThreshold: number;
  88798. private _colorShader;
  88799. private color4;
  88800. /**
  88801. * Creates a new LinesMesh
  88802. * @param name defines the name
  88803. * @param scene defines the hosting scene
  88804. * @param parent defines the parent mesh if any
  88805. * @param source defines the optional source LinesMesh used to clone data from
  88806. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88807. * When false, achieved by calling a clone(), also passing False.
  88808. * This will make creation of children, recursive.
  88809. * @param useVertexColor defines if this LinesMesh supports vertex color
  88810. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88811. */
  88812. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88813. /**
  88814. * If vertex color should be applied to the mesh
  88815. */
  88816. useVertexColor?: boolean | undefined,
  88817. /**
  88818. * If vertex alpha should be applied to the mesh
  88819. */
  88820. useVertexAlpha?: boolean | undefined);
  88821. private _addClipPlaneDefine;
  88822. private _removeClipPlaneDefine;
  88823. isReady(): boolean;
  88824. /**
  88825. * Returns the string "LineMesh"
  88826. */
  88827. getClassName(): string;
  88828. /**
  88829. * @hidden
  88830. */
  88831. get material(): Material;
  88832. /**
  88833. * @hidden
  88834. */
  88835. set material(value: Material);
  88836. /**
  88837. * @hidden
  88838. */
  88839. get checkCollisions(): boolean;
  88840. /** @hidden */
  88841. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88842. /** @hidden */
  88843. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88844. /**
  88845. * Disposes of the line mesh
  88846. * @param doNotRecurse If children should be disposed
  88847. */
  88848. dispose(doNotRecurse?: boolean): void;
  88849. /**
  88850. * Returns a new LineMesh object cloned from the current one.
  88851. */
  88852. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88853. /**
  88854. * Creates a new InstancedLinesMesh object from the mesh model.
  88855. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88856. * @param name defines the name of the new instance
  88857. * @returns a new InstancedLinesMesh
  88858. */
  88859. createInstance(name: string): InstancedLinesMesh;
  88860. }
  88861. /**
  88862. * Creates an instance based on a source LinesMesh
  88863. */
  88864. export class InstancedLinesMesh extends InstancedMesh {
  88865. /**
  88866. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88867. * This margin is expressed in world space coordinates, so its value may vary.
  88868. * Initilized with the intersectionThreshold value of the source LinesMesh
  88869. */
  88870. intersectionThreshold: number;
  88871. constructor(name: string, source: LinesMesh);
  88872. /**
  88873. * Returns the string "InstancedLinesMesh".
  88874. */
  88875. getClassName(): string;
  88876. }
  88877. }
  88878. declare module BABYLON {
  88879. /** @hidden */
  88880. export var linePixelShader: {
  88881. name: string;
  88882. shader: string;
  88883. };
  88884. }
  88885. declare module BABYLON {
  88886. /** @hidden */
  88887. export var lineVertexShader: {
  88888. name: string;
  88889. shader: string;
  88890. };
  88891. }
  88892. declare module BABYLON {
  88893. interface AbstractMesh {
  88894. /**
  88895. * Gets the edgesRenderer associated with the mesh
  88896. */
  88897. edgesRenderer: Nullable<EdgesRenderer>;
  88898. }
  88899. interface LinesMesh {
  88900. /**
  88901. * Enables the edge rendering mode on the mesh.
  88902. * This mode makes the mesh edges visible
  88903. * @param epsilon defines the maximal distance between two angles to detect a face
  88904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88905. * @returns the currentAbstractMesh
  88906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88907. */
  88908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88909. }
  88910. interface InstancedLinesMesh {
  88911. /**
  88912. * Enables the edge rendering mode on the mesh.
  88913. * This mode makes the mesh edges visible
  88914. * @param epsilon defines the maximal distance between two angles to detect a face
  88915. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88916. * @returns the current InstancedLinesMesh
  88917. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88918. */
  88919. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88920. }
  88921. /**
  88922. * Defines the minimum contract an Edges renderer should follow.
  88923. */
  88924. export interface IEdgesRenderer extends IDisposable {
  88925. /**
  88926. * Gets or sets a boolean indicating if the edgesRenderer is active
  88927. */
  88928. isEnabled: boolean;
  88929. /**
  88930. * Renders the edges of the attached mesh,
  88931. */
  88932. render(): void;
  88933. /**
  88934. * Checks wether or not the edges renderer is ready to render.
  88935. * @return true if ready, otherwise false.
  88936. */
  88937. isReady(): boolean;
  88938. }
  88939. /**
  88940. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88941. */
  88942. export class EdgesRenderer implements IEdgesRenderer {
  88943. /**
  88944. * Define the size of the edges with an orthographic camera
  88945. */
  88946. edgesWidthScalerForOrthographic: number;
  88947. /**
  88948. * Define the size of the edges with a perspective camera
  88949. */
  88950. edgesWidthScalerForPerspective: number;
  88951. protected _source: AbstractMesh;
  88952. protected _linesPositions: number[];
  88953. protected _linesNormals: number[];
  88954. protected _linesIndices: number[];
  88955. protected _epsilon: number;
  88956. protected _indicesCount: number;
  88957. protected _lineShader: ShaderMaterial;
  88958. protected _ib: DataBuffer;
  88959. protected _buffers: {
  88960. [key: string]: Nullable<VertexBuffer>;
  88961. };
  88962. protected _checkVerticesInsteadOfIndices: boolean;
  88963. private _meshRebuildObserver;
  88964. private _meshDisposeObserver;
  88965. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88966. isEnabled: boolean;
  88967. /**
  88968. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88969. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88970. * @param source Mesh used to create edges
  88971. * @param epsilon sum of angles in adjacency to check for edge
  88972. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88973. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88974. */
  88975. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88976. protected _prepareRessources(): void;
  88977. /** @hidden */
  88978. _rebuild(): void;
  88979. /**
  88980. * Releases the required resources for the edges renderer
  88981. */
  88982. dispose(): void;
  88983. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88984. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88985. /**
  88986. * Checks if the pair of p0 and p1 is en edge
  88987. * @param faceIndex
  88988. * @param edge
  88989. * @param faceNormals
  88990. * @param p0
  88991. * @param p1
  88992. * @private
  88993. */
  88994. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88995. /**
  88996. * push line into the position, normal and index buffer
  88997. * @protected
  88998. */
  88999. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89000. /**
  89001. * Generates lines edges from adjacencjes
  89002. * @private
  89003. */
  89004. _generateEdgesLines(): void;
  89005. /**
  89006. * Checks wether or not the edges renderer is ready to render.
  89007. * @return true if ready, otherwise false.
  89008. */
  89009. isReady(): boolean;
  89010. /**
  89011. * Renders the edges of the attached mesh,
  89012. */
  89013. render(): void;
  89014. }
  89015. /**
  89016. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89017. */
  89018. export class LineEdgesRenderer extends EdgesRenderer {
  89019. /**
  89020. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89021. * @param source LineMesh used to generate edges
  89022. * @param epsilon not important (specified angle for edge detection)
  89023. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89024. */
  89025. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89026. /**
  89027. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89028. */
  89029. _generateEdgesLines(): void;
  89030. }
  89031. }
  89032. declare module BABYLON {
  89033. /**
  89034. * This represents the object necessary to create a rendering group.
  89035. * This is exclusively used and created by the rendering manager.
  89036. * To modify the behavior, you use the available helpers in your scene or meshes.
  89037. * @hidden
  89038. */
  89039. export class RenderingGroup {
  89040. index: number;
  89041. private static _zeroVector;
  89042. private _scene;
  89043. private _opaqueSubMeshes;
  89044. private _transparentSubMeshes;
  89045. private _alphaTestSubMeshes;
  89046. private _depthOnlySubMeshes;
  89047. private _particleSystems;
  89048. private _spriteManagers;
  89049. private _opaqueSortCompareFn;
  89050. private _alphaTestSortCompareFn;
  89051. private _transparentSortCompareFn;
  89052. private _renderOpaque;
  89053. private _renderAlphaTest;
  89054. private _renderTransparent;
  89055. /** @hidden */
  89056. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89057. onBeforeTransparentRendering: () => void;
  89058. /**
  89059. * Set the opaque sort comparison function.
  89060. * If null the sub meshes will be render in the order they were created
  89061. */
  89062. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89063. /**
  89064. * Set the alpha test sort comparison function.
  89065. * If null the sub meshes will be render in the order they were created
  89066. */
  89067. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89068. /**
  89069. * Set the transparent sort comparison function.
  89070. * If null the sub meshes will be render in the order they were created
  89071. */
  89072. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89073. /**
  89074. * Creates a new rendering group.
  89075. * @param index The rendering group index
  89076. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89077. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89078. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89079. */
  89080. 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>);
  89081. /**
  89082. * Render all the sub meshes contained in the group.
  89083. * @param customRenderFunction Used to override the default render behaviour of the group.
  89084. * @returns true if rendered some submeshes.
  89085. */
  89086. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89087. /**
  89088. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89089. * @param subMeshes The submeshes to render
  89090. */
  89091. private renderOpaqueSorted;
  89092. /**
  89093. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89094. * @param subMeshes The submeshes to render
  89095. */
  89096. private renderAlphaTestSorted;
  89097. /**
  89098. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89099. * @param subMeshes The submeshes to render
  89100. */
  89101. private renderTransparentSorted;
  89102. /**
  89103. * Renders the submeshes in a specified order.
  89104. * @param subMeshes The submeshes to sort before render
  89105. * @param sortCompareFn The comparison function use to sort
  89106. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89107. * @param transparent Specifies to activate blending if true
  89108. */
  89109. private static renderSorted;
  89110. /**
  89111. * Renders the submeshes in the order they were dispatched (no sort applied).
  89112. * @param subMeshes The submeshes to render
  89113. */
  89114. private static renderUnsorted;
  89115. /**
  89116. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89117. * are rendered back to front if in the same alpha index.
  89118. *
  89119. * @param a The first submesh
  89120. * @param b The second submesh
  89121. * @returns The result of the comparison
  89122. */
  89123. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89124. /**
  89125. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89126. * are rendered back to front.
  89127. *
  89128. * @param a The first submesh
  89129. * @param b The second submesh
  89130. * @returns The result of the comparison
  89131. */
  89132. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89133. /**
  89134. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89135. * are rendered front to back (prevent overdraw).
  89136. *
  89137. * @param a The first submesh
  89138. * @param b The second submesh
  89139. * @returns The result of the comparison
  89140. */
  89141. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89142. /**
  89143. * Resets the different lists of submeshes to prepare a new frame.
  89144. */
  89145. prepare(): void;
  89146. dispose(): void;
  89147. /**
  89148. * Inserts the submesh in its correct queue depending on its material.
  89149. * @param subMesh The submesh to dispatch
  89150. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89151. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89152. */
  89153. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89154. dispatchSprites(spriteManager: ISpriteManager): void;
  89155. dispatchParticles(particleSystem: IParticleSystem): void;
  89156. private _renderParticles;
  89157. private _renderSprites;
  89158. }
  89159. }
  89160. declare module BABYLON {
  89161. /**
  89162. * Interface describing the different options available in the rendering manager
  89163. * regarding Auto Clear between groups.
  89164. */
  89165. export interface IRenderingManagerAutoClearSetup {
  89166. /**
  89167. * Defines whether or not autoclear is enable.
  89168. */
  89169. autoClear: boolean;
  89170. /**
  89171. * Defines whether or not to autoclear the depth buffer.
  89172. */
  89173. depth: boolean;
  89174. /**
  89175. * Defines whether or not to autoclear the stencil buffer.
  89176. */
  89177. stencil: boolean;
  89178. }
  89179. /**
  89180. * This class is used by the onRenderingGroupObservable
  89181. */
  89182. export class RenderingGroupInfo {
  89183. /**
  89184. * The Scene that being rendered
  89185. */
  89186. scene: Scene;
  89187. /**
  89188. * The camera currently used for the rendering pass
  89189. */
  89190. camera: Nullable<Camera>;
  89191. /**
  89192. * The ID of the renderingGroup being processed
  89193. */
  89194. renderingGroupId: number;
  89195. }
  89196. /**
  89197. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89198. * It is enable to manage the different groups as well as the different necessary sort functions.
  89199. * This should not be used directly aside of the few static configurations
  89200. */
  89201. export class RenderingManager {
  89202. /**
  89203. * The max id used for rendering groups (not included)
  89204. */
  89205. static MAX_RENDERINGGROUPS: number;
  89206. /**
  89207. * The min id used for rendering groups (included)
  89208. */
  89209. static MIN_RENDERINGGROUPS: number;
  89210. /**
  89211. * Used to globally prevent autoclearing scenes.
  89212. */
  89213. static AUTOCLEAR: boolean;
  89214. /**
  89215. * @hidden
  89216. */
  89217. _useSceneAutoClearSetup: boolean;
  89218. private _scene;
  89219. private _renderingGroups;
  89220. private _depthStencilBufferAlreadyCleaned;
  89221. private _autoClearDepthStencil;
  89222. private _customOpaqueSortCompareFn;
  89223. private _customAlphaTestSortCompareFn;
  89224. private _customTransparentSortCompareFn;
  89225. private _renderingGroupInfo;
  89226. /**
  89227. * Instantiates a new rendering group for a particular scene
  89228. * @param scene Defines the scene the groups belongs to
  89229. */
  89230. constructor(scene: Scene);
  89231. private _clearDepthStencilBuffer;
  89232. /**
  89233. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89234. * @hidden
  89235. */
  89236. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89237. /**
  89238. * Resets the different information of the group to prepare a new frame
  89239. * @hidden
  89240. */
  89241. reset(): void;
  89242. /**
  89243. * Dispose and release the group and its associated resources.
  89244. * @hidden
  89245. */
  89246. dispose(): void;
  89247. /**
  89248. * Clear the info related to rendering groups preventing retention points during dispose.
  89249. */
  89250. freeRenderingGroups(): void;
  89251. private _prepareRenderingGroup;
  89252. /**
  89253. * Add a sprite manager to the rendering manager in order to render it this frame.
  89254. * @param spriteManager Define the sprite manager to render
  89255. */
  89256. dispatchSprites(spriteManager: ISpriteManager): void;
  89257. /**
  89258. * Add a particle system to the rendering manager in order to render it this frame.
  89259. * @param particleSystem Define the particle system to render
  89260. */
  89261. dispatchParticles(particleSystem: IParticleSystem): void;
  89262. /**
  89263. * Add a submesh to the manager in order to render it this frame
  89264. * @param subMesh The submesh to dispatch
  89265. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89266. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89267. */
  89268. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89269. /**
  89270. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89271. * This allowed control for front to back rendering or reversly depending of the special needs.
  89272. *
  89273. * @param renderingGroupId The rendering group id corresponding to its index
  89274. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89275. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89276. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89277. */
  89278. 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;
  89279. /**
  89280. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89281. *
  89282. * @param renderingGroupId The rendering group id corresponding to its index
  89283. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89284. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89285. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89286. */
  89287. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89288. /**
  89289. * Gets the current auto clear configuration for one rendering group of the rendering
  89290. * manager.
  89291. * @param index the rendering group index to get the information for
  89292. * @returns The auto clear setup for the requested rendering group
  89293. */
  89294. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89295. }
  89296. }
  89297. declare module BABYLON {
  89298. /**
  89299. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89300. */
  89301. export interface ICustomShaderOptions {
  89302. /**
  89303. * Gets or sets the custom shader name to use
  89304. */
  89305. shaderName: string;
  89306. /**
  89307. * The list of attribute names used in the shader
  89308. */
  89309. attributes?: string[];
  89310. /**
  89311. * The list of unifrom names used in the shader
  89312. */
  89313. uniforms?: string[];
  89314. /**
  89315. * The list of sampler names used in the shader
  89316. */
  89317. samplers?: string[];
  89318. /**
  89319. * The list of defines used in the shader
  89320. */
  89321. defines?: string[];
  89322. }
  89323. /**
  89324. * Interface to implement to create a shadow generator compatible with BJS.
  89325. */
  89326. export interface IShadowGenerator {
  89327. /**
  89328. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89329. * @returns The render target texture if present otherwise, null
  89330. */
  89331. getShadowMap(): Nullable<RenderTargetTexture>;
  89332. /**
  89333. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89334. * @param subMesh The submesh we want to render in the shadow map
  89335. * @param useInstances Defines wether will draw in the map using instances
  89336. * @returns true if ready otherwise, false
  89337. */
  89338. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89339. /**
  89340. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89341. * @param defines Defines of the material we want to update
  89342. * @param lightIndex Index of the light in the enabled light list of the material
  89343. */
  89344. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89345. /**
  89346. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89347. * defined in the generator but impacting the effect).
  89348. * It implies the unifroms available on the materials are the standard BJS ones.
  89349. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89350. * @param effect The effect we are binfing the information for
  89351. */
  89352. bindShadowLight(lightIndex: string, effect: Effect): void;
  89353. /**
  89354. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89355. * (eq to shadow prjection matrix * light transform matrix)
  89356. * @returns The transform matrix used to create the shadow map
  89357. */
  89358. getTransformMatrix(): Matrix;
  89359. /**
  89360. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89361. * Cube and 2D textures for instance.
  89362. */
  89363. recreateShadowMap(): void;
  89364. /**
  89365. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89366. * @param onCompiled Callback triggered at the and of the effects compilation
  89367. * @param options Sets of optional options forcing the compilation with different modes
  89368. */
  89369. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89370. useInstances: boolean;
  89371. }>): void;
  89372. /**
  89373. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89374. * @param options Sets of optional options forcing the compilation with different modes
  89375. * @returns A promise that resolves when the compilation completes
  89376. */
  89377. forceCompilationAsync(options?: Partial<{
  89378. useInstances: boolean;
  89379. }>): Promise<void>;
  89380. /**
  89381. * Serializes the shadow generator setup to a json object.
  89382. * @returns The serialized JSON object
  89383. */
  89384. serialize(): any;
  89385. /**
  89386. * Disposes the Shadow map and related Textures and effects.
  89387. */
  89388. dispose(): void;
  89389. }
  89390. /**
  89391. * Default implementation IShadowGenerator.
  89392. * This is the main object responsible of generating shadows in the framework.
  89393. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89394. */
  89395. export class ShadowGenerator implements IShadowGenerator {
  89396. /**
  89397. * Name of the shadow generator class
  89398. */
  89399. static CLASSNAME: string;
  89400. /**
  89401. * Shadow generator mode None: no filtering applied.
  89402. */
  89403. static readonly FILTER_NONE: number;
  89404. /**
  89405. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89407. */
  89408. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89409. /**
  89410. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89411. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89412. */
  89413. static readonly FILTER_POISSONSAMPLING: number;
  89414. /**
  89415. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89416. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89417. */
  89418. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89419. /**
  89420. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89421. * edge artifacts on steep falloff.
  89422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89423. */
  89424. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89425. /**
  89426. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89427. * edge artifacts on steep falloff.
  89428. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89429. */
  89430. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89431. /**
  89432. * Shadow generator mode PCF: Percentage Closer Filtering
  89433. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89434. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89435. */
  89436. static readonly FILTER_PCF: number;
  89437. /**
  89438. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89439. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89440. * Contact Hardening
  89441. */
  89442. static readonly FILTER_PCSS: number;
  89443. /**
  89444. * Reserved for PCF and PCSS
  89445. * Highest Quality.
  89446. *
  89447. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89448. *
  89449. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89450. */
  89451. static readonly QUALITY_HIGH: number;
  89452. /**
  89453. * Reserved for PCF and PCSS
  89454. * Good tradeoff for quality/perf cross devices
  89455. *
  89456. * Execute PCF on a 3*3 kernel.
  89457. *
  89458. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89459. */
  89460. static readonly QUALITY_MEDIUM: number;
  89461. /**
  89462. * Reserved for PCF and PCSS
  89463. * The lowest quality but the fastest.
  89464. *
  89465. * Execute PCF on a 1*1 kernel.
  89466. *
  89467. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89468. */
  89469. static readonly QUALITY_LOW: number;
  89470. /** Gets or sets the custom shader name to use */
  89471. customShaderOptions: ICustomShaderOptions;
  89472. /**
  89473. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89474. */
  89475. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89476. /**
  89477. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89478. */
  89479. onAfterShadowMapRenderObservable: Observable<Effect>;
  89480. /**
  89481. * Observable triggered before a mesh is rendered in the shadow map.
  89482. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89483. */
  89484. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89485. /**
  89486. * Observable triggered after a mesh is rendered in the shadow map.
  89487. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89488. */
  89489. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89490. protected _bias: number;
  89491. /**
  89492. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89493. */
  89494. get bias(): number;
  89495. /**
  89496. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89497. */
  89498. set bias(bias: number);
  89499. protected _normalBias: number;
  89500. /**
  89501. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89502. */
  89503. get normalBias(): number;
  89504. /**
  89505. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89506. */
  89507. set normalBias(normalBias: number);
  89508. protected _blurBoxOffset: number;
  89509. /**
  89510. * Gets the blur box offset: offset applied during the blur pass.
  89511. * Only useful if useKernelBlur = false
  89512. */
  89513. get blurBoxOffset(): number;
  89514. /**
  89515. * Sets the blur box offset: offset applied during the blur pass.
  89516. * Only useful if useKernelBlur = false
  89517. */
  89518. set blurBoxOffset(value: number);
  89519. protected _blurScale: number;
  89520. /**
  89521. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89522. * 2 means half of the size.
  89523. */
  89524. get blurScale(): number;
  89525. /**
  89526. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89527. * 2 means half of the size.
  89528. */
  89529. set blurScale(value: number);
  89530. protected _blurKernel: number;
  89531. /**
  89532. * Gets the blur kernel: kernel size of the blur pass.
  89533. * Only useful if useKernelBlur = true
  89534. */
  89535. get blurKernel(): number;
  89536. /**
  89537. * Sets the blur kernel: kernel size of the blur pass.
  89538. * Only useful if useKernelBlur = true
  89539. */
  89540. set blurKernel(value: number);
  89541. protected _useKernelBlur: boolean;
  89542. /**
  89543. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89544. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89545. */
  89546. get useKernelBlur(): boolean;
  89547. /**
  89548. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89549. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89550. */
  89551. set useKernelBlur(value: boolean);
  89552. protected _depthScale: number;
  89553. /**
  89554. * Gets the depth scale used in ESM mode.
  89555. */
  89556. get depthScale(): number;
  89557. /**
  89558. * Sets the depth scale used in ESM mode.
  89559. * This can override the scale stored on the light.
  89560. */
  89561. set depthScale(value: number);
  89562. protected _validateFilter(filter: number): number;
  89563. protected _filter: number;
  89564. /**
  89565. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89566. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89567. */
  89568. get filter(): number;
  89569. /**
  89570. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89571. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89572. */
  89573. set filter(value: number);
  89574. /**
  89575. * Gets if the current filter is set to Poisson Sampling.
  89576. */
  89577. get usePoissonSampling(): boolean;
  89578. /**
  89579. * Sets the current filter to Poisson Sampling.
  89580. */
  89581. set usePoissonSampling(value: boolean);
  89582. /**
  89583. * Gets if the current filter is set to ESM.
  89584. */
  89585. get useExponentialShadowMap(): boolean;
  89586. /**
  89587. * Sets the current filter is to ESM.
  89588. */
  89589. set useExponentialShadowMap(value: boolean);
  89590. /**
  89591. * Gets if the current filter is set to filtered ESM.
  89592. */
  89593. get useBlurExponentialShadowMap(): boolean;
  89594. /**
  89595. * Gets if the current filter is set to filtered ESM.
  89596. */
  89597. set useBlurExponentialShadowMap(value: boolean);
  89598. /**
  89599. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89600. * exponential to prevent steep falloff artifacts).
  89601. */
  89602. get useCloseExponentialShadowMap(): boolean;
  89603. /**
  89604. * Sets the current filter to "close ESM" (using the inverse of the
  89605. * exponential to prevent steep falloff artifacts).
  89606. */
  89607. set useCloseExponentialShadowMap(value: boolean);
  89608. /**
  89609. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89610. * exponential to prevent steep falloff artifacts).
  89611. */
  89612. get useBlurCloseExponentialShadowMap(): boolean;
  89613. /**
  89614. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89615. * exponential to prevent steep falloff artifacts).
  89616. */
  89617. set useBlurCloseExponentialShadowMap(value: boolean);
  89618. /**
  89619. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89620. */
  89621. get usePercentageCloserFiltering(): boolean;
  89622. /**
  89623. * Sets the current filter to "PCF" (percentage closer filtering).
  89624. */
  89625. set usePercentageCloserFiltering(value: boolean);
  89626. protected _filteringQuality: number;
  89627. /**
  89628. * Gets the PCF or PCSS Quality.
  89629. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89630. */
  89631. get filteringQuality(): number;
  89632. /**
  89633. * Sets the PCF or PCSS Quality.
  89634. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89635. */
  89636. set filteringQuality(filteringQuality: number);
  89637. /**
  89638. * Gets if the current filter is set to "PCSS" (contact hardening).
  89639. */
  89640. get useContactHardeningShadow(): boolean;
  89641. /**
  89642. * Sets the current filter to "PCSS" (contact hardening).
  89643. */
  89644. set useContactHardeningShadow(value: boolean);
  89645. protected _contactHardeningLightSizeUVRatio: number;
  89646. /**
  89647. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89648. * Using a ratio helps keeping shape stability independently of the map size.
  89649. *
  89650. * It does not account for the light projection as it was having too much
  89651. * instability during the light setup or during light position changes.
  89652. *
  89653. * Only valid if useContactHardeningShadow is true.
  89654. */
  89655. get contactHardeningLightSizeUVRatio(): number;
  89656. /**
  89657. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89658. * Using a ratio helps keeping shape stability independently of the map size.
  89659. *
  89660. * It does not account for the light projection as it was having too much
  89661. * instability during the light setup or during light position changes.
  89662. *
  89663. * Only valid if useContactHardeningShadow is true.
  89664. */
  89665. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89666. protected _darkness: number;
  89667. /** Gets or sets the actual darkness of a shadow */
  89668. get darkness(): number;
  89669. set darkness(value: number);
  89670. /**
  89671. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89672. * 0 means strongest and 1 would means no shadow.
  89673. * @returns the darkness.
  89674. */
  89675. getDarkness(): number;
  89676. /**
  89677. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89678. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89679. * @returns the shadow generator allowing fluent coding.
  89680. */
  89681. setDarkness(darkness: number): ShadowGenerator;
  89682. protected _transparencyShadow: boolean;
  89683. /** Gets or sets the ability to have transparent shadow */
  89684. get transparencyShadow(): boolean;
  89685. set transparencyShadow(value: boolean);
  89686. /**
  89687. * Sets the ability to have transparent shadow (boolean).
  89688. * @param transparent True if transparent else False
  89689. * @returns the shadow generator allowing fluent coding
  89690. */
  89691. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89692. protected _shadowMap: Nullable<RenderTargetTexture>;
  89693. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89694. /**
  89695. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89696. * @returns The render target texture if present otherwise, null
  89697. */
  89698. getShadowMap(): Nullable<RenderTargetTexture>;
  89699. /**
  89700. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89701. * @returns The render target texture if the shadow map is present otherwise, null
  89702. */
  89703. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89704. /**
  89705. * Gets the class name of that object
  89706. * @returns "ShadowGenerator"
  89707. */
  89708. getClassName(): string;
  89709. /**
  89710. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89711. * @param mesh Mesh to add
  89712. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89713. * @returns the Shadow Generator itself
  89714. */
  89715. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89716. /**
  89717. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89718. * @param mesh Mesh to remove
  89719. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89720. * @returns the Shadow Generator itself
  89721. */
  89722. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89723. /**
  89724. * Controls the extent to which the shadows fade out at the edge of the frustum
  89725. */
  89726. frustumEdgeFalloff: number;
  89727. protected _light: IShadowLight;
  89728. /**
  89729. * Returns the associated light object.
  89730. * @returns the light generating the shadow
  89731. */
  89732. getLight(): IShadowLight;
  89733. /**
  89734. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89735. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89736. * It might on the other hand introduce peter panning.
  89737. */
  89738. forceBackFacesOnly: boolean;
  89739. protected _scene: Scene;
  89740. protected _lightDirection: Vector3;
  89741. protected _effect: Effect;
  89742. protected _viewMatrix: Matrix;
  89743. protected _projectionMatrix: Matrix;
  89744. protected _transformMatrix: Matrix;
  89745. protected _cachedPosition: Vector3;
  89746. protected _cachedDirection: Vector3;
  89747. protected _cachedDefines: string;
  89748. protected _currentRenderID: number;
  89749. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89750. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89751. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89752. protected _blurPostProcesses: PostProcess[];
  89753. protected _mapSize: number;
  89754. protected _currentFaceIndex: number;
  89755. protected _currentFaceIndexCache: number;
  89756. protected _textureType: number;
  89757. protected _defaultTextureMatrix: Matrix;
  89758. protected _storedUniqueId: Nullable<number>;
  89759. /** @hidden */
  89760. static _SceneComponentInitialization: (scene: Scene) => void;
  89761. /**
  89762. * Creates a ShadowGenerator object.
  89763. * A ShadowGenerator is the required tool to use the shadows.
  89764. * Each light casting shadows needs to use its own ShadowGenerator.
  89765. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89766. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89767. * @param light The light object generating the shadows.
  89768. * @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.
  89769. */
  89770. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89771. protected _initializeGenerator(): void;
  89772. protected _createTargetRenderTexture(): void;
  89773. protected _initializeShadowMap(): void;
  89774. protected _initializeBlurRTTAndPostProcesses(): void;
  89775. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89776. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89777. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89778. protected _applyFilterValues(): void;
  89779. /**
  89780. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89781. * @param onCompiled Callback triggered at the and of the effects compilation
  89782. * @param options Sets of optional options forcing the compilation with different modes
  89783. */
  89784. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89785. useInstances: boolean;
  89786. }>): void;
  89787. /**
  89788. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89789. * @param options Sets of optional options forcing the compilation with different modes
  89790. * @returns A promise that resolves when the compilation completes
  89791. */
  89792. forceCompilationAsync(options?: Partial<{
  89793. useInstances: boolean;
  89794. }>): Promise<void>;
  89795. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89796. /**
  89797. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89798. * @param subMesh The submesh we want to render in the shadow map
  89799. * @param useInstances Defines wether will draw in the map using instances
  89800. * @returns true if ready otherwise, false
  89801. */
  89802. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89803. /**
  89804. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89805. * @param defines Defines of the material we want to update
  89806. * @param lightIndex Index of the light in the enabled light list of the material
  89807. */
  89808. prepareDefines(defines: any, lightIndex: number): void;
  89809. /**
  89810. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89811. * defined in the generator but impacting the effect).
  89812. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89813. * @param effect The effect we are binfing the information for
  89814. */
  89815. bindShadowLight(lightIndex: string, effect: Effect): void;
  89816. /**
  89817. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89818. * (eq to shadow prjection matrix * light transform matrix)
  89819. * @returns The transform matrix used to create the shadow map
  89820. */
  89821. getTransformMatrix(): Matrix;
  89822. /**
  89823. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89824. * Cube and 2D textures for instance.
  89825. */
  89826. recreateShadowMap(): void;
  89827. protected _disposeBlurPostProcesses(): void;
  89828. protected _disposeRTTandPostProcesses(): void;
  89829. /**
  89830. * Disposes the ShadowGenerator.
  89831. * Returns nothing.
  89832. */
  89833. dispose(): void;
  89834. /**
  89835. * Serializes the shadow generator setup to a json object.
  89836. * @returns The serialized JSON object
  89837. */
  89838. serialize(): any;
  89839. /**
  89840. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89841. * @param parsedShadowGenerator The JSON object to parse
  89842. * @param scene The scene to create the shadow map for
  89843. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89844. * @returns The parsed shadow generator
  89845. */
  89846. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89847. }
  89848. }
  89849. declare module BABYLON {
  89850. /**
  89851. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89852. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89853. * 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.
  89854. */
  89855. export abstract class Light extends Node {
  89856. /**
  89857. * Falloff Default: light is falling off following the material specification:
  89858. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89859. */
  89860. static readonly FALLOFF_DEFAULT: number;
  89861. /**
  89862. * Falloff Physical: light is falling off following the inverse squared distance law.
  89863. */
  89864. static readonly FALLOFF_PHYSICAL: number;
  89865. /**
  89866. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89867. * to enhance interoperability with other engines.
  89868. */
  89869. static readonly FALLOFF_GLTF: number;
  89870. /**
  89871. * Falloff Standard: light is falling off like in the standard material
  89872. * to enhance interoperability with other materials.
  89873. */
  89874. static readonly FALLOFF_STANDARD: number;
  89875. /**
  89876. * If every light affecting the material is in this lightmapMode,
  89877. * material.lightmapTexture adds or multiplies
  89878. * (depends on material.useLightmapAsShadowmap)
  89879. * after every other light calculations.
  89880. */
  89881. static readonly LIGHTMAP_DEFAULT: number;
  89882. /**
  89883. * material.lightmapTexture as only diffuse lighting from this light
  89884. * adds only specular lighting from this light
  89885. * adds dynamic shadows
  89886. */
  89887. static readonly LIGHTMAP_SPECULAR: number;
  89888. /**
  89889. * material.lightmapTexture as only lighting
  89890. * no light calculation from this light
  89891. * only adds dynamic shadows from this light
  89892. */
  89893. static readonly LIGHTMAP_SHADOWSONLY: number;
  89894. /**
  89895. * Each light type uses the default quantity according to its type:
  89896. * point/spot lights use luminous intensity
  89897. * directional lights use illuminance
  89898. */
  89899. static readonly INTENSITYMODE_AUTOMATIC: number;
  89900. /**
  89901. * lumen (lm)
  89902. */
  89903. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89904. /**
  89905. * candela (lm/sr)
  89906. */
  89907. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89908. /**
  89909. * lux (lm/m^2)
  89910. */
  89911. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89912. /**
  89913. * nit (cd/m^2)
  89914. */
  89915. static readonly INTENSITYMODE_LUMINANCE: number;
  89916. /**
  89917. * Light type const id of the point light.
  89918. */
  89919. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89920. /**
  89921. * Light type const id of the directional light.
  89922. */
  89923. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89924. /**
  89925. * Light type const id of the spot light.
  89926. */
  89927. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89928. /**
  89929. * Light type const id of the hemispheric light.
  89930. */
  89931. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89932. /**
  89933. * Diffuse gives the basic color to an object.
  89934. */
  89935. diffuse: Color3;
  89936. /**
  89937. * Specular produces a highlight color on an object.
  89938. * Note: This is note affecting PBR materials.
  89939. */
  89940. specular: Color3;
  89941. /**
  89942. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89943. * falling off base on range or angle.
  89944. * This can be set to any values in Light.FALLOFF_x.
  89945. *
  89946. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89947. * other types of materials.
  89948. */
  89949. falloffType: number;
  89950. /**
  89951. * Strength of the light.
  89952. * Note: By default it is define in the framework own unit.
  89953. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89954. */
  89955. intensity: number;
  89956. private _range;
  89957. protected _inverseSquaredRange: number;
  89958. /**
  89959. * Defines how far from the source the light is impacting in scene units.
  89960. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89961. */
  89962. get range(): number;
  89963. /**
  89964. * Defines how far from the source the light is impacting in scene units.
  89965. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89966. */
  89967. set range(value: number);
  89968. /**
  89969. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89970. * of light.
  89971. */
  89972. private _photometricScale;
  89973. private _intensityMode;
  89974. /**
  89975. * Gets the photometric scale used to interpret the intensity.
  89976. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89977. */
  89978. get intensityMode(): number;
  89979. /**
  89980. * Sets the photometric scale used to interpret the intensity.
  89981. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89982. */
  89983. set intensityMode(value: number);
  89984. private _radius;
  89985. /**
  89986. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89987. */
  89988. get radius(): number;
  89989. /**
  89990. * sets the light radius used by PBR Materials to simulate soft area lights.
  89991. */
  89992. set radius(value: number);
  89993. private _renderPriority;
  89994. /**
  89995. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89996. * exceeding the number allowed of the materials.
  89997. */
  89998. renderPriority: number;
  89999. private _shadowEnabled;
  90000. /**
  90001. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90002. * the current shadow generator.
  90003. */
  90004. get shadowEnabled(): boolean;
  90005. /**
  90006. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90007. * the current shadow generator.
  90008. */
  90009. set shadowEnabled(value: boolean);
  90010. private _includedOnlyMeshes;
  90011. /**
  90012. * Gets the only meshes impacted by this light.
  90013. */
  90014. get includedOnlyMeshes(): AbstractMesh[];
  90015. /**
  90016. * Sets the only meshes impacted by this light.
  90017. */
  90018. set includedOnlyMeshes(value: AbstractMesh[]);
  90019. private _excludedMeshes;
  90020. /**
  90021. * Gets the meshes not impacted by this light.
  90022. */
  90023. get excludedMeshes(): AbstractMesh[];
  90024. /**
  90025. * Sets the meshes not impacted by this light.
  90026. */
  90027. set excludedMeshes(value: AbstractMesh[]);
  90028. private _excludeWithLayerMask;
  90029. /**
  90030. * Gets the layer id use to find what meshes are not impacted by the light.
  90031. * Inactive if 0
  90032. */
  90033. get excludeWithLayerMask(): number;
  90034. /**
  90035. * Sets the layer id use to find what meshes are not impacted by the light.
  90036. * Inactive if 0
  90037. */
  90038. set excludeWithLayerMask(value: number);
  90039. private _includeOnlyWithLayerMask;
  90040. /**
  90041. * Gets the layer id use to find what meshes are impacted by the light.
  90042. * Inactive if 0
  90043. */
  90044. get includeOnlyWithLayerMask(): number;
  90045. /**
  90046. * Sets the layer id use to find what meshes are impacted by the light.
  90047. * Inactive if 0
  90048. */
  90049. set includeOnlyWithLayerMask(value: number);
  90050. private _lightmapMode;
  90051. /**
  90052. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90053. */
  90054. get lightmapMode(): number;
  90055. /**
  90056. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90057. */
  90058. set lightmapMode(value: number);
  90059. /**
  90060. * Shadow generator associted to the light.
  90061. * @hidden Internal use only.
  90062. */
  90063. _shadowGenerator: Nullable<IShadowGenerator>;
  90064. /**
  90065. * @hidden Internal use only.
  90066. */
  90067. _excludedMeshesIds: string[];
  90068. /**
  90069. * @hidden Internal use only.
  90070. */
  90071. _includedOnlyMeshesIds: string[];
  90072. /**
  90073. * The current light unifom buffer.
  90074. * @hidden Internal use only.
  90075. */
  90076. _uniformBuffer: UniformBuffer;
  90077. /** @hidden */
  90078. _renderId: number;
  90079. /**
  90080. * Creates a Light object in the scene.
  90081. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90082. * @param name The firendly name of the light
  90083. * @param scene The scene the light belongs too
  90084. */
  90085. constructor(name: string, scene: Scene);
  90086. protected abstract _buildUniformLayout(): void;
  90087. /**
  90088. * Sets the passed Effect "effect" with the Light information.
  90089. * @param effect The effect to update
  90090. * @param lightIndex The index of the light in the effect to update
  90091. * @returns The light
  90092. */
  90093. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90094. /**
  90095. * Sets the passed Effect "effect" with the Light textures.
  90096. * @param effect The effect to update
  90097. * @param lightIndex The index of the light in the effect to update
  90098. * @returns The light
  90099. */
  90100. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90101. /**
  90102. * Binds the lights information from the scene to the effect for the given mesh.
  90103. * @param lightIndex Light index
  90104. * @param scene The scene where the light belongs to
  90105. * @param effect The effect we are binding the data to
  90106. * @param useSpecular Defines if specular is supported
  90107. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90108. */
  90109. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90110. /**
  90111. * Sets the passed Effect "effect" with the Light information.
  90112. * @param effect The effect to update
  90113. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90114. * @returns The light
  90115. */
  90116. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90117. /**
  90118. * Returns the string "Light".
  90119. * @returns the class name
  90120. */
  90121. getClassName(): string;
  90122. /** @hidden */
  90123. readonly _isLight: boolean;
  90124. /**
  90125. * Converts the light information to a readable string for debug purpose.
  90126. * @param fullDetails Supports for multiple levels of logging within scene loading
  90127. * @returns the human readable light info
  90128. */
  90129. toString(fullDetails?: boolean): string;
  90130. /** @hidden */
  90131. protected _syncParentEnabledState(): void;
  90132. /**
  90133. * Set the enabled state of this node.
  90134. * @param value - the new enabled state
  90135. */
  90136. setEnabled(value: boolean): void;
  90137. /**
  90138. * Returns the Light associated shadow generator if any.
  90139. * @return the associated shadow generator.
  90140. */
  90141. getShadowGenerator(): Nullable<IShadowGenerator>;
  90142. /**
  90143. * Returns a Vector3, the absolute light position in the World.
  90144. * @returns the world space position of the light
  90145. */
  90146. getAbsolutePosition(): Vector3;
  90147. /**
  90148. * Specifies if the light will affect the passed mesh.
  90149. * @param mesh The mesh to test against the light
  90150. * @return true the mesh is affected otherwise, false.
  90151. */
  90152. canAffectMesh(mesh: AbstractMesh): boolean;
  90153. /**
  90154. * Sort function to order lights for rendering.
  90155. * @param a First Light object to compare to second.
  90156. * @param b Second Light object to compare first.
  90157. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90158. */
  90159. static CompareLightsPriority(a: Light, b: Light): number;
  90160. /**
  90161. * Releases resources associated with this node.
  90162. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90163. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90164. */
  90165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90166. /**
  90167. * Returns the light type ID (integer).
  90168. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90169. */
  90170. getTypeID(): number;
  90171. /**
  90172. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90173. * @returns the scaled intensity in intensity mode unit
  90174. */
  90175. getScaledIntensity(): number;
  90176. /**
  90177. * Returns a new Light object, named "name", from the current one.
  90178. * @param name The name of the cloned light
  90179. * @returns the new created light
  90180. */
  90181. clone(name: string): Nullable<Light>;
  90182. /**
  90183. * Serializes the current light into a Serialization object.
  90184. * @returns the serialized object.
  90185. */
  90186. serialize(): any;
  90187. /**
  90188. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90189. * This new light is named "name" and added to the passed scene.
  90190. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90191. * @param name The friendly name of the light
  90192. * @param scene The scene the new light will belong to
  90193. * @returns the constructor function
  90194. */
  90195. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90196. /**
  90197. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90198. * @param parsedLight The JSON representation of the light
  90199. * @param scene The scene to create the parsed light in
  90200. * @returns the created light after parsing
  90201. */
  90202. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90203. private _hookArrayForExcluded;
  90204. private _hookArrayForIncludedOnly;
  90205. private _resyncMeshes;
  90206. /**
  90207. * Forces the meshes to update their light related information in their rendering used effects
  90208. * @hidden Internal Use Only
  90209. */
  90210. _markMeshesAsLightDirty(): void;
  90211. /**
  90212. * Recomputes the cached photometric scale if needed.
  90213. */
  90214. private _computePhotometricScale;
  90215. /**
  90216. * Returns the Photometric Scale according to the light type and intensity mode.
  90217. */
  90218. private _getPhotometricScale;
  90219. /**
  90220. * Reorder the light in the scene according to their defined priority.
  90221. * @hidden Internal Use Only
  90222. */
  90223. _reorderLightsInScene(): void;
  90224. /**
  90225. * Prepares the list of defines specific to the light type.
  90226. * @param defines the list of defines
  90227. * @param lightIndex defines the index of the light for the effect
  90228. */
  90229. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90230. }
  90231. }
  90232. declare module BABYLON {
  90233. /**
  90234. * Interface used to define Action
  90235. */
  90236. export interface IAction {
  90237. /**
  90238. * Trigger for the action
  90239. */
  90240. trigger: number;
  90241. /** Options of the trigger */
  90242. triggerOptions: any;
  90243. /**
  90244. * Gets the trigger parameters
  90245. * @returns the trigger parameters
  90246. */
  90247. getTriggerParameter(): any;
  90248. /**
  90249. * Internal only - executes current action event
  90250. * @hidden
  90251. */
  90252. _executeCurrent(evt?: ActionEvent): void;
  90253. /**
  90254. * Serialize placeholder for child classes
  90255. * @param parent of child
  90256. * @returns the serialized object
  90257. */
  90258. serialize(parent: any): any;
  90259. /**
  90260. * Internal only
  90261. * @hidden
  90262. */
  90263. _prepare(): void;
  90264. /**
  90265. * Internal only - manager for action
  90266. * @hidden
  90267. */
  90268. _actionManager: AbstractActionManager;
  90269. /**
  90270. * Adds action to chain of actions, may be a DoNothingAction
  90271. * @param action defines the next action to execute
  90272. * @returns The action passed in
  90273. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90274. */
  90275. then(action: IAction): IAction;
  90276. }
  90277. /**
  90278. * The action to be carried out following a trigger
  90279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90280. */
  90281. export class Action implements IAction {
  90282. /** the trigger, with or without parameters, for the action */
  90283. triggerOptions: any;
  90284. /**
  90285. * Trigger for the action
  90286. */
  90287. trigger: number;
  90288. /**
  90289. * Internal only - manager for action
  90290. * @hidden
  90291. */
  90292. _actionManager: ActionManager;
  90293. private _nextActiveAction;
  90294. private _child;
  90295. private _condition?;
  90296. private _triggerParameter;
  90297. /**
  90298. * An event triggered prior to action being executed.
  90299. */
  90300. onBeforeExecuteObservable: Observable<Action>;
  90301. /**
  90302. * Creates a new Action
  90303. * @param triggerOptions the trigger, with or without parameters, for the action
  90304. * @param condition an optional determinant of action
  90305. */
  90306. constructor(
  90307. /** the trigger, with or without parameters, for the action */
  90308. triggerOptions: any, condition?: Condition);
  90309. /**
  90310. * Internal only
  90311. * @hidden
  90312. */
  90313. _prepare(): void;
  90314. /**
  90315. * Gets the trigger parameters
  90316. * @returns the trigger parameters
  90317. */
  90318. getTriggerParameter(): any;
  90319. /**
  90320. * Internal only - executes current action event
  90321. * @hidden
  90322. */
  90323. _executeCurrent(evt?: ActionEvent): void;
  90324. /**
  90325. * Execute placeholder for child classes
  90326. * @param evt optional action event
  90327. */
  90328. execute(evt?: ActionEvent): void;
  90329. /**
  90330. * Skips to next active action
  90331. */
  90332. skipToNextActiveAction(): void;
  90333. /**
  90334. * Adds action to chain of actions, may be a DoNothingAction
  90335. * @param action defines the next action to execute
  90336. * @returns The action passed in
  90337. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90338. */
  90339. then(action: Action): Action;
  90340. /**
  90341. * Internal only
  90342. * @hidden
  90343. */
  90344. _getProperty(propertyPath: string): string;
  90345. /**
  90346. * Internal only
  90347. * @hidden
  90348. */
  90349. _getEffectiveTarget(target: any, propertyPath: string): any;
  90350. /**
  90351. * Serialize placeholder for child classes
  90352. * @param parent of child
  90353. * @returns the serialized object
  90354. */
  90355. serialize(parent: any): any;
  90356. /**
  90357. * Internal only called by serialize
  90358. * @hidden
  90359. */
  90360. protected _serialize(serializedAction: any, parent?: any): any;
  90361. /**
  90362. * Internal only
  90363. * @hidden
  90364. */
  90365. static _SerializeValueAsString: (value: any) => string;
  90366. /**
  90367. * Internal only
  90368. * @hidden
  90369. */
  90370. static _GetTargetProperty: (target: Node | Scene) => {
  90371. name: string;
  90372. targetType: string;
  90373. value: string;
  90374. };
  90375. }
  90376. }
  90377. declare module BABYLON {
  90378. /**
  90379. * A Condition applied to an Action
  90380. */
  90381. export class Condition {
  90382. /**
  90383. * Internal only - manager for action
  90384. * @hidden
  90385. */
  90386. _actionManager: ActionManager;
  90387. /**
  90388. * Internal only
  90389. * @hidden
  90390. */
  90391. _evaluationId: number;
  90392. /**
  90393. * Internal only
  90394. * @hidden
  90395. */
  90396. _currentResult: boolean;
  90397. /**
  90398. * Creates a new Condition
  90399. * @param actionManager the manager of the action the condition is applied to
  90400. */
  90401. constructor(actionManager: ActionManager);
  90402. /**
  90403. * Check if the current condition is valid
  90404. * @returns a boolean
  90405. */
  90406. isValid(): boolean;
  90407. /**
  90408. * Internal only
  90409. * @hidden
  90410. */
  90411. _getProperty(propertyPath: string): string;
  90412. /**
  90413. * Internal only
  90414. * @hidden
  90415. */
  90416. _getEffectiveTarget(target: any, propertyPath: string): any;
  90417. /**
  90418. * Serialize placeholder for child classes
  90419. * @returns the serialized object
  90420. */
  90421. serialize(): any;
  90422. /**
  90423. * Internal only
  90424. * @hidden
  90425. */
  90426. protected _serialize(serializedCondition: any): any;
  90427. }
  90428. /**
  90429. * Defines specific conditional operators as extensions of Condition
  90430. */
  90431. export class ValueCondition extends Condition {
  90432. /** path to specify the property of the target the conditional operator uses */
  90433. propertyPath: string;
  90434. /** the value compared by the conditional operator against the current value of the property */
  90435. value: any;
  90436. /** the conditional operator, default ValueCondition.IsEqual */
  90437. operator: number;
  90438. /**
  90439. * Internal only
  90440. * @hidden
  90441. */
  90442. private static _IsEqual;
  90443. /**
  90444. * Internal only
  90445. * @hidden
  90446. */
  90447. private static _IsDifferent;
  90448. /**
  90449. * Internal only
  90450. * @hidden
  90451. */
  90452. private static _IsGreater;
  90453. /**
  90454. * Internal only
  90455. * @hidden
  90456. */
  90457. private static _IsLesser;
  90458. /**
  90459. * returns the number for IsEqual
  90460. */
  90461. static get IsEqual(): number;
  90462. /**
  90463. * Returns the number for IsDifferent
  90464. */
  90465. static get IsDifferent(): number;
  90466. /**
  90467. * Returns the number for IsGreater
  90468. */
  90469. static get IsGreater(): number;
  90470. /**
  90471. * Returns the number for IsLesser
  90472. */
  90473. static get IsLesser(): number;
  90474. /**
  90475. * Internal only The action manager for the condition
  90476. * @hidden
  90477. */
  90478. _actionManager: ActionManager;
  90479. /**
  90480. * Internal only
  90481. * @hidden
  90482. */
  90483. private _target;
  90484. /**
  90485. * Internal only
  90486. * @hidden
  90487. */
  90488. private _effectiveTarget;
  90489. /**
  90490. * Internal only
  90491. * @hidden
  90492. */
  90493. private _property;
  90494. /**
  90495. * Creates a new ValueCondition
  90496. * @param actionManager manager for the action the condition applies to
  90497. * @param target for the action
  90498. * @param propertyPath path to specify the property of the target the conditional operator uses
  90499. * @param value the value compared by the conditional operator against the current value of the property
  90500. * @param operator the conditional operator, default ValueCondition.IsEqual
  90501. */
  90502. constructor(actionManager: ActionManager, target: any,
  90503. /** path to specify the property of the target the conditional operator uses */
  90504. propertyPath: string,
  90505. /** the value compared by the conditional operator against the current value of the property */
  90506. value: any,
  90507. /** the conditional operator, default ValueCondition.IsEqual */
  90508. operator?: number);
  90509. /**
  90510. * Compares the given value with the property value for the specified conditional operator
  90511. * @returns the result of the comparison
  90512. */
  90513. isValid(): boolean;
  90514. /**
  90515. * Serialize the ValueCondition into a JSON compatible object
  90516. * @returns serialization object
  90517. */
  90518. serialize(): any;
  90519. /**
  90520. * Gets the name of the conditional operator for the ValueCondition
  90521. * @param operator the conditional operator
  90522. * @returns the name
  90523. */
  90524. static GetOperatorName(operator: number): string;
  90525. }
  90526. /**
  90527. * Defines a predicate condition as an extension of Condition
  90528. */
  90529. export class PredicateCondition extends Condition {
  90530. /** defines the predicate function used to validate the condition */
  90531. predicate: () => boolean;
  90532. /**
  90533. * Internal only - manager for action
  90534. * @hidden
  90535. */
  90536. _actionManager: ActionManager;
  90537. /**
  90538. * Creates a new PredicateCondition
  90539. * @param actionManager manager for the action the condition applies to
  90540. * @param predicate defines the predicate function used to validate the condition
  90541. */
  90542. constructor(actionManager: ActionManager,
  90543. /** defines the predicate function used to validate the condition */
  90544. predicate: () => boolean);
  90545. /**
  90546. * @returns the validity of the predicate condition
  90547. */
  90548. isValid(): boolean;
  90549. }
  90550. /**
  90551. * Defines a state condition as an extension of Condition
  90552. */
  90553. export class StateCondition extends Condition {
  90554. /** Value to compare with target state */
  90555. value: string;
  90556. /**
  90557. * Internal only - manager for action
  90558. * @hidden
  90559. */
  90560. _actionManager: ActionManager;
  90561. /**
  90562. * Internal only
  90563. * @hidden
  90564. */
  90565. private _target;
  90566. /**
  90567. * Creates a new StateCondition
  90568. * @param actionManager manager for the action the condition applies to
  90569. * @param target of the condition
  90570. * @param value to compare with target state
  90571. */
  90572. constructor(actionManager: ActionManager, target: any,
  90573. /** Value to compare with target state */
  90574. value: string);
  90575. /**
  90576. * Gets a boolean indicating if the current condition is met
  90577. * @returns the validity of the state
  90578. */
  90579. isValid(): boolean;
  90580. /**
  90581. * Serialize the StateCondition into a JSON compatible object
  90582. * @returns serialization object
  90583. */
  90584. serialize(): any;
  90585. }
  90586. }
  90587. declare module BABYLON {
  90588. /**
  90589. * This defines an action responsible to toggle a boolean once triggered.
  90590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90591. */
  90592. export class SwitchBooleanAction extends Action {
  90593. /**
  90594. * The path to the boolean property in the target object
  90595. */
  90596. propertyPath: string;
  90597. private _target;
  90598. private _effectiveTarget;
  90599. private _property;
  90600. /**
  90601. * Instantiate the action
  90602. * @param triggerOptions defines the trigger options
  90603. * @param target defines the object containing the boolean
  90604. * @param propertyPath defines the path to the boolean property in the target object
  90605. * @param condition defines the trigger related conditions
  90606. */
  90607. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90608. /** @hidden */
  90609. _prepare(): void;
  90610. /**
  90611. * Execute the action toggle the boolean value.
  90612. */
  90613. execute(): void;
  90614. /**
  90615. * Serializes the actions and its related information.
  90616. * @param parent defines the object to serialize in
  90617. * @returns the serialized object
  90618. */
  90619. serialize(parent: any): any;
  90620. }
  90621. /**
  90622. * This defines an action responsible to set a the state field of the target
  90623. * to a desired value once triggered.
  90624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90625. */
  90626. export class SetStateAction extends Action {
  90627. /**
  90628. * The value to store in the state field.
  90629. */
  90630. value: string;
  90631. private _target;
  90632. /**
  90633. * Instantiate the action
  90634. * @param triggerOptions defines the trigger options
  90635. * @param target defines the object containing the state property
  90636. * @param value defines the value to store in the state field
  90637. * @param condition defines the trigger related conditions
  90638. */
  90639. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90640. /**
  90641. * Execute the action and store the value on the target state property.
  90642. */
  90643. execute(): void;
  90644. /**
  90645. * Serializes the actions and its related information.
  90646. * @param parent defines the object to serialize in
  90647. * @returns the serialized object
  90648. */
  90649. serialize(parent: any): any;
  90650. }
  90651. /**
  90652. * This defines an action responsible to set a property of the target
  90653. * to a desired value once triggered.
  90654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90655. */
  90656. export class SetValueAction extends Action {
  90657. /**
  90658. * The path of the property to set in the target.
  90659. */
  90660. propertyPath: string;
  90661. /**
  90662. * The value to set in the property
  90663. */
  90664. value: any;
  90665. private _target;
  90666. private _effectiveTarget;
  90667. private _property;
  90668. /**
  90669. * Instantiate the action
  90670. * @param triggerOptions defines the trigger options
  90671. * @param target defines the object containing the property
  90672. * @param propertyPath defines the path of the property to set in the target
  90673. * @param value defines the value to set in the property
  90674. * @param condition defines the trigger related conditions
  90675. */
  90676. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90677. /** @hidden */
  90678. _prepare(): void;
  90679. /**
  90680. * Execute the action and set the targetted property to the desired value.
  90681. */
  90682. execute(): void;
  90683. /**
  90684. * Serializes the actions and its related information.
  90685. * @param parent defines the object to serialize in
  90686. * @returns the serialized object
  90687. */
  90688. serialize(parent: any): any;
  90689. }
  90690. /**
  90691. * This defines an action responsible to increment the target value
  90692. * to a desired value once triggered.
  90693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90694. */
  90695. export class IncrementValueAction extends Action {
  90696. /**
  90697. * The path of the property to increment in the target.
  90698. */
  90699. propertyPath: string;
  90700. /**
  90701. * The value we should increment the property by.
  90702. */
  90703. value: any;
  90704. private _target;
  90705. private _effectiveTarget;
  90706. private _property;
  90707. /**
  90708. * Instantiate the action
  90709. * @param triggerOptions defines the trigger options
  90710. * @param target defines the object containing the property
  90711. * @param propertyPath defines the path of the property to increment in the target
  90712. * @param value defines the value value we should increment the property by
  90713. * @param condition defines the trigger related conditions
  90714. */
  90715. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90716. /** @hidden */
  90717. _prepare(): void;
  90718. /**
  90719. * Execute the action and increment the target of the value amount.
  90720. */
  90721. execute(): void;
  90722. /**
  90723. * Serializes the actions and its related information.
  90724. * @param parent defines the object to serialize in
  90725. * @returns the serialized object
  90726. */
  90727. serialize(parent: any): any;
  90728. }
  90729. /**
  90730. * This defines an action responsible to start an animation once triggered.
  90731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90732. */
  90733. export class PlayAnimationAction extends Action {
  90734. /**
  90735. * Where the animation should start (animation frame)
  90736. */
  90737. from: number;
  90738. /**
  90739. * Where the animation should stop (animation frame)
  90740. */
  90741. to: number;
  90742. /**
  90743. * Define if the animation should loop or stop after the first play.
  90744. */
  90745. loop?: boolean;
  90746. private _target;
  90747. /**
  90748. * Instantiate the action
  90749. * @param triggerOptions defines the trigger options
  90750. * @param target defines the target animation or animation name
  90751. * @param from defines from where the animation should start (animation frame)
  90752. * @param end defines where the animation should stop (animation frame)
  90753. * @param loop defines if the animation should loop or stop after the first play
  90754. * @param condition defines the trigger related conditions
  90755. */
  90756. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90757. /** @hidden */
  90758. _prepare(): void;
  90759. /**
  90760. * Execute the action and play the animation.
  90761. */
  90762. execute(): void;
  90763. /**
  90764. * Serializes the actions and its related information.
  90765. * @param parent defines the object to serialize in
  90766. * @returns the serialized object
  90767. */
  90768. serialize(parent: any): any;
  90769. }
  90770. /**
  90771. * This defines an action responsible to stop an animation once triggered.
  90772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90773. */
  90774. export class StopAnimationAction extends Action {
  90775. private _target;
  90776. /**
  90777. * Instantiate the action
  90778. * @param triggerOptions defines the trigger options
  90779. * @param target defines the target animation or animation name
  90780. * @param condition defines the trigger related conditions
  90781. */
  90782. constructor(triggerOptions: any, target: any, condition?: Condition);
  90783. /** @hidden */
  90784. _prepare(): void;
  90785. /**
  90786. * Execute the action and stop the animation.
  90787. */
  90788. execute(): void;
  90789. /**
  90790. * Serializes the actions and its related information.
  90791. * @param parent defines the object to serialize in
  90792. * @returns the serialized object
  90793. */
  90794. serialize(parent: any): any;
  90795. }
  90796. /**
  90797. * This defines an action responsible that does nothing once triggered.
  90798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90799. */
  90800. export class DoNothingAction extends Action {
  90801. /**
  90802. * Instantiate the action
  90803. * @param triggerOptions defines the trigger options
  90804. * @param condition defines the trigger related conditions
  90805. */
  90806. constructor(triggerOptions?: any, condition?: Condition);
  90807. /**
  90808. * Execute the action and do nothing.
  90809. */
  90810. execute(): void;
  90811. /**
  90812. * Serializes the actions and its related information.
  90813. * @param parent defines the object to serialize in
  90814. * @returns the serialized object
  90815. */
  90816. serialize(parent: any): any;
  90817. }
  90818. /**
  90819. * This defines an action responsible to trigger several actions once triggered.
  90820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90821. */
  90822. export class CombineAction extends Action {
  90823. /**
  90824. * The list of aggregated animations to run.
  90825. */
  90826. children: Action[];
  90827. /**
  90828. * Instantiate the action
  90829. * @param triggerOptions defines the trigger options
  90830. * @param children defines the list of aggregated animations to run
  90831. * @param condition defines the trigger related conditions
  90832. */
  90833. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90834. /** @hidden */
  90835. _prepare(): void;
  90836. /**
  90837. * Execute the action and executes all the aggregated actions.
  90838. */
  90839. execute(evt: ActionEvent): 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 run code (external event) once triggered.
  90849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90850. */
  90851. export class ExecuteCodeAction extends Action {
  90852. /**
  90853. * The callback function to run.
  90854. */
  90855. func: (evt: ActionEvent) => void;
  90856. /**
  90857. * Instantiate the action
  90858. * @param triggerOptions defines the trigger options
  90859. * @param func defines the callback function to run
  90860. * @param condition defines the trigger related conditions
  90861. */
  90862. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90863. /**
  90864. * Execute the action and run the attached code.
  90865. */
  90866. execute(evt: ActionEvent): void;
  90867. }
  90868. /**
  90869. * This defines an action responsible to set the parent property of the target once triggered.
  90870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90871. */
  90872. export class SetParentAction extends Action {
  90873. private _parent;
  90874. private _target;
  90875. /**
  90876. * Instantiate the action
  90877. * @param triggerOptions defines the trigger options
  90878. * @param target defines the target containing the parent property
  90879. * @param parent defines from where the animation should start (animation frame)
  90880. * @param condition defines the trigger related conditions
  90881. */
  90882. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90883. /** @hidden */
  90884. _prepare(): void;
  90885. /**
  90886. * Execute the action and set the parent property.
  90887. */
  90888. execute(): void;
  90889. /**
  90890. * Serializes the actions and its related information.
  90891. * @param parent defines the object to serialize in
  90892. * @returns the serialized object
  90893. */
  90894. serialize(parent: any): any;
  90895. }
  90896. }
  90897. declare module BABYLON {
  90898. /**
  90899. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90900. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90902. */
  90903. export class ActionManager extends AbstractActionManager {
  90904. /**
  90905. * Nothing
  90906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90907. */
  90908. static readonly NothingTrigger: number;
  90909. /**
  90910. * On pick
  90911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90912. */
  90913. static readonly OnPickTrigger: number;
  90914. /**
  90915. * On left pick
  90916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90917. */
  90918. static readonly OnLeftPickTrigger: number;
  90919. /**
  90920. * On right pick
  90921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90922. */
  90923. static readonly OnRightPickTrigger: number;
  90924. /**
  90925. * On center pick
  90926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90927. */
  90928. static readonly OnCenterPickTrigger: number;
  90929. /**
  90930. * On pick down
  90931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90932. */
  90933. static readonly OnPickDownTrigger: number;
  90934. /**
  90935. * On double pick
  90936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90937. */
  90938. static readonly OnDoublePickTrigger: number;
  90939. /**
  90940. * On pick up
  90941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90942. */
  90943. static readonly OnPickUpTrigger: number;
  90944. /**
  90945. * On pick out.
  90946. * This trigger will only be raised if you also declared a OnPickDown
  90947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90948. */
  90949. static readonly OnPickOutTrigger: number;
  90950. /**
  90951. * On long press
  90952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90953. */
  90954. static readonly OnLongPressTrigger: number;
  90955. /**
  90956. * On pointer over
  90957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90958. */
  90959. static readonly OnPointerOverTrigger: number;
  90960. /**
  90961. * On pointer out
  90962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90963. */
  90964. static readonly OnPointerOutTrigger: number;
  90965. /**
  90966. * On every frame
  90967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90968. */
  90969. static readonly OnEveryFrameTrigger: number;
  90970. /**
  90971. * On intersection enter
  90972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90973. */
  90974. static readonly OnIntersectionEnterTrigger: number;
  90975. /**
  90976. * On intersection exit
  90977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90978. */
  90979. static readonly OnIntersectionExitTrigger: number;
  90980. /**
  90981. * On key down
  90982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90983. */
  90984. static readonly OnKeyDownTrigger: number;
  90985. /**
  90986. * On key up
  90987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90988. */
  90989. static readonly OnKeyUpTrigger: number;
  90990. private _scene;
  90991. /**
  90992. * Creates a new action manager
  90993. * @param scene defines the hosting scene
  90994. */
  90995. constructor(scene: Scene);
  90996. /**
  90997. * Releases all associated resources
  90998. */
  90999. dispose(): void;
  91000. /**
  91001. * Gets hosting scene
  91002. * @returns the hosting scene
  91003. */
  91004. getScene(): Scene;
  91005. /**
  91006. * Does this action manager handles actions of any of the given triggers
  91007. * @param triggers defines the triggers to be tested
  91008. * @return a boolean indicating whether one (or more) of the triggers is handled
  91009. */
  91010. hasSpecificTriggers(triggers: number[]): boolean;
  91011. /**
  91012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91013. * speed.
  91014. * @param triggerA defines the trigger to be tested
  91015. * @param triggerB defines the trigger to be tested
  91016. * @return a boolean indicating whether one (or more) of the triggers is handled
  91017. */
  91018. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91019. /**
  91020. * Does this action manager handles actions of a given trigger
  91021. * @param trigger defines the trigger to be tested
  91022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91023. * @return whether the trigger is handled
  91024. */
  91025. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91026. /**
  91027. * Does this action manager has pointer triggers
  91028. */
  91029. get hasPointerTriggers(): boolean;
  91030. /**
  91031. * Does this action manager has pick triggers
  91032. */
  91033. get hasPickTriggers(): boolean;
  91034. /**
  91035. * Registers an action to this action manager
  91036. * @param action defines the action to be registered
  91037. * @return the action amended (prepared) after registration
  91038. */
  91039. registerAction(action: IAction): Nullable<IAction>;
  91040. /**
  91041. * Unregisters an action to this action manager
  91042. * @param action defines the action to be unregistered
  91043. * @return a boolean indicating whether the action has been unregistered
  91044. */
  91045. unregisterAction(action: IAction): Boolean;
  91046. /**
  91047. * Process a specific trigger
  91048. * @param trigger defines the trigger to process
  91049. * @param evt defines the event details to be processed
  91050. */
  91051. processTrigger(trigger: number, evt?: IActionEvent): void;
  91052. /** @hidden */
  91053. _getEffectiveTarget(target: any, propertyPath: string): any;
  91054. /** @hidden */
  91055. _getProperty(propertyPath: string): string;
  91056. /**
  91057. * Serialize this manager to a JSON object
  91058. * @param name defines the property name to store this manager
  91059. * @returns a JSON representation of this manager
  91060. */
  91061. serialize(name: string): any;
  91062. /**
  91063. * Creates a new ActionManager from a JSON data
  91064. * @param parsedActions defines the JSON data to read from
  91065. * @param object defines the hosting mesh
  91066. * @param scene defines the hosting scene
  91067. */
  91068. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91069. /**
  91070. * Get a trigger name by index
  91071. * @param trigger defines the trigger index
  91072. * @returns a trigger name
  91073. */
  91074. static GetTriggerName(trigger: number): string;
  91075. }
  91076. }
  91077. declare module BABYLON {
  91078. /**
  91079. * Class used to represent a sprite
  91080. * @see http://doc.babylonjs.com/babylon101/sprites
  91081. */
  91082. export class Sprite {
  91083. /** defines the name */
  91084. name: string;
  91085. /** Gets or sets the current world position */
  91086. position: Vector3;
  91087. /** Gets or sets the main color */
  91088. color: Color4;
  91089. /** Gets or sets the width */
  91090. width: number;
  91091. /** Gets or sets the height */
  91092. height: number;
  91093. /** Gets or sets rotation angle */
  91094. angle: number;
  91095. /** Gets or sets the cell index in the sprite sheet */
  91096. cellIndex: number;
  91097. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91098. cellRef: string;
  91099. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91100. invertU: number;
  91101. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91102. invertV: number;
  91103. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91104. disposeWhenFinishedAnimating: boolean;
  91105. /** Gets the list of attached animations */
  91106. animations: Animation[];
  91107. /** Gets or sets a boolean indicating if the sprite can be picked */
  91108. isPickable: boolean;
  91109. /**
  91110. * Gets or sets the associated action manager
  91111. */
  91112. actionManager: Nullable<ActionManager>;
  91113. private _animationStarted;
  91114. private _loopAnimation;
  91115. private _fromIndex;
  91116. private _toIndex;
  91117. private _delay;
  91118. private _direction;
  91119. private _manager;
  91120. private _time;
  91121. private _onAnimationEnd;
  91122. /**
  91123. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91124. */
  91125. isVisible: boolean;
  91126. /**
  91127. * Gets or sets the sprite size
  91128. */
  91129. get size(): number;
  91130. set size(value: number);
  91131. /**
  91132. * Creates a new Sprite
  91133. * @param name defines the name
  91134. * @param manager defines the manager
  91135. */
  91136. constructor(
  91137. /** defines the name */
  91138. name: string, manager: ISpriteManager);
  91139. /**
  91140. * Starts an animation
  91141. * @param from defines the initial key
  91142. * @param to defines the end key
  91143. * @param loop defines if the animation must loop
  91144. * @param delay defines the start delay (in ms)
  91145. * @param onAnimationEnd defines a callback to call when animation ends
  91146. */
  91147. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91148. /** Stops current animation (if any) */
  91149. stopAnimation(): void;
  91150. /** @hidden */
  91151. _animate(deltaTime: number): void;
  91152. /** Release associated resources */
  91153. dispose(): void;
  91154. }
  91155. }
  91156. declare module BABYLON {
  91157. /**
  91158. * Information about the result of picking within a scene
  91159. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91160. */
  91161. export class PickingInfo {
  91162. /** @hidden */
  91163. _pickingUnavailable: boolean;
  91164. /**
  91165. * If the pick collided with an object
  91166. */
  91167. hit: boolean;
  91168. /**
  91169. * Distance away where the pick collided
  91170. */
  91171. distance: number;
  91172. /**
  91173. * The location of pick collision
  91174. */
  91175. pickedPoint: Nullable<Vector3>;
  91176. /**
  91177. * The mesh corresponding the the pick collision
  91178. */
  91179. pickedMesh: Nullable<AbstractMesh>;
  91180. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91181. bu: number;
  91182. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91183. bv: number;
  91184. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91185. faceId: number;
  91186. /** Id of the the submesh that was picked */
  91187. subMeshId: number;
  91188. /** If a sprite was picked, this will be the sprite the pick collided with */
  91189. pickedSprite: Nullable<Sprite>;
  91190. /**
  91191. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91192. */
  91193. originMesh: Nullable<AbstractMesh>;
  91194. /**
  91195. * The ray that was used to perform the picking.
  91196. */
  91197. ray: Nullable<Ray>;
  91198. /**
  91199. * Gets the normal correspodning to the face the pick collided with
  91200. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91201. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91202. * @returns The normal correspodning to the face the pick collided with
  91203. */
  91204. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91205. /**
  91206. * Gets the texture coordinates of where the pick occured
  91207. * @returns the vector containing the coordnates of the texture
  91208. */
  91209. getTextureCoordinates(): Nullable<Vector2>;
  91210. }
  91211. }
  91212. declare module BABYLON {
  91213. /**
  91214. * Gather the list of pointer event types as constants.
  91215. */
  91216. export class PointerEventTypes {
  91217. /**
  91218. * 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.
  91219. */
  91220. static readonly POINTERDOWN: number;
  91221. /**
  91222. * The pointerup event is fired when a pointer is no longer active.
  91223. */
  91224. static readonly POINTERUP: number;
  91225. /**
  91226. * The pointermove event is fired when a pointer changes coordinates.
  91227. */
  91228. static readonly POINTERMOVE: number;
  91229. /**
  91230. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91231. */
  91232. static readonly POINTERWHEEL: number;
  91233. /**
  91234. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91235. */
  91236. static readonly POINTERPICK: number;
  91237. /**
  91238. * The pointertap event is fired when a the object has been touched and released without drag.
  91239. */
  91240. static readonly POINTERTAP: number;
  91241. /**
  91242. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91243. */
  91244. static readonly POINTERDOUBLETAP: number;
  91245. }
  91246. /**
  91247. * Base class of pointer info types.
  91248. */
  91249. export class PointerInfoBase {
  91250. /**
  91251. * Defines the type of event (PointerEventTypes)
  91252. */
  91253. type: number;
  91254. /**
  91255. * Defines the related dom event
  91256. */
  91257. event: PointerEvent | MouseWheelEvent;
  91258. /**
  91259. * Instantiates the base class of pointers info.
  91260. * @param type Defines the type of event (PointerEventTypes)
  91261. * @param event Defines the related dom event
  91262. */
  91263. constructor(
  91264. /**
  91265. * Defines the type of event (PointerEventTypes)
  91266. */
  91267. type: number,
  91268. /**
  91269. * Defines the related dom event
  91270. */
  91271. event: PointerEvent | MouseWheelEvent);
  91272. }
  91273. /**
  91274. * This class is used to store pointer related info for the onPrePointerObservable event.
  91275. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91276. */
  91277. export class PointerInfoPre extends PointerInfoBase {
  91278. /**
  91279. * Ray from a pointer if availible (eg. 6dof controller)
  91280. */
  91281. ray: Nullable<Ray>;
  91282. /**
  91283. * Defines the local position of the pointer on the canvas.
  91284. */
  91285. localPosition: Vector2;
  91286. /**
  91287. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91288. */
  91289. skipOnPointerObservable: boolean;
  91290. /**
  91291. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91292. * @param type Defines the type of event (PointerEventTypes)
  91293. * @param event Defines the related dom event
  91294. * @param localX Defines the local x coordinates of the pointer when the event occured
  91295. * @param localY Defines the local y coordinates of the pointer when the event occured
  91296. */
  91297. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91298. }
  91299. /**
  91300. * This type contains all the data related to a pointer event in Babylon.js.
  91301. * 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.
  91302. */
  91303. export class PointerInfo extends PointerInfoBase {
  91304. /**
  91305. * Defines the picking info associated to the info (if any)\
  91306. */
  91307. pickInfo: Nullable<PickingInfo>;
  91308. /**
  91309. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91310. * @param type Defines the type of event (PointerEventTypes)
  91311. * @param event Defines the related dom event
  91312. * @param pickInfo Defines the picking info associated to the info (if any)\
  91313. */
  91314. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91315. /**
  91316. * Defines the picking info associated to the info (if any)\
  91317. */
  91318. pickInfo: Nullable<PickingInfo>);
  91319. }
  91320. /**
  91321. * Data relating to a touch event on the screen.
  91322. */
  91323. export interface PointerTouch {
  91324. /**
  91325. * X coordinate of touch.
  91326. */
  91327. x: number;
  91328. /**
  91329. * Y coordinate of touch.
  91330. */
  91331. y: number;
  91332. /**
  91333. * Id of touch. Unique for each finger.
  91334. */
  91335. pointerId: number;
  91336. /**
  91337. * Event type passed from DOM.
  91338. */
  91339. type: any;
  91340. }
  91341. }
  91342. declare module BABYLON {
  91343. /**
  91344. * Manage the mouse inputs to control the movement of a free camera.
  91345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91346. */
  91347. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91348. /**
  91349. * Define if touch is enabled in the mouse input
  91350. */
  91351. touchEnabled: boolean;
  91352. /**
  91353. * Defines the camera the input is attached to.
  91354. */
  91355. camera: FreeCamera;
  91356. /**
  91357. * Defines the buttons associated with the input to handle camera move.
  91358. */
  91359. buttons: number[];
  91360. /**
  91361. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91362. */
  91363. angularSensibility: number;
  91364. private _pointerInput;
  91365. private _onMouseMove;
  91366. private _observer;
  91367. private previousPosition;
  91368. /**
  91369. * Observable for when a pointer move event occurs containing the move offset
  91370. */
  91371. onPointerMovedObservable: Observable<{
  91372. offsetX: number;
  91373. offsetY: number;
  91374. }>;
  91375. /**
  91376. * @hidden
  91377. * If the camera should be rotated automatically based on pointer movement
  91378. */
  91379. _allowCameraRotation: boolean;
  91380. /**
  91381. * Manage the mouse inputs to control the movement of a free camera.
  91382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91383. * @param touchEnabled Defines if touch is enabled or not
  91384. */
  91385. constructor(
  91386. /**
  91387. * Define if touch is enabled in the mouse input
  91388. */
  91389. touchEnabled?: boolean);
  91390. /**
  91391. * Attach the input controls to a specific dom element to get the input from.
  91392. * @param element Defines the element the controls should be listened from
  91393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91394. */
  91395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91396. /**
  91397. * Called on JS contextmenu event.
  91398. * Override this method to provide functionality.
  91399. */
  91400. protected onContextMenu(evt: PointerEvent): void;
  91401. /**
  91402. * Detach the current controls from the specified dom element.
  91403. * @param element Defines the element to stop listening the inputs from
  91404. */
  91405. detachControl(element: Nullable<HTMLElement>): void;
  91406. /**
  91407. * Gets the class name of the current intput.
  91408. * @returns the class name
  91409. */
  91410. getClassName(): string;
  91411. /**
  91412. * Get the friendly name associated with the input class.
  91413. * @returns the input friendly name
  91414. */
  91415. getSimpleName(): string;
  91416. }
  91417. }
  91418. declare module BABYLON {
  91419. /**
  91420. * Manage the touch inputs to control the movement of a free camera.
  91421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91422. */
  91423. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91424. /**
  91425. * Defines the camera the input is attached to.
  91426. */
  91427. camera: FreeCamera;
  91428. /**
  91429. * Defines the touch sensibility for rotation.
  91430. * The higher the faster.
  91431. */
  91432. touchAngularSensibility: number;
  91433. /**
  91434. * Defines the touch sensibility for move.
  91435. * The higher the faster.
  91436. */
  91437. touchMoveSensibility: number;
  91438. private _offsetX;
  91439. private _offsetY;
  91440. private _pointerPressed;
  91441. private _pointerInput;
  91442. private _observer;
  91443. private _onLostFocus;
  91444. /**
  91445. * Attach the input controls to a specific dom element to get the input from.
  91446. * @param element Defines the element the controls should be listened from
  91447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91448. */
  91449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91450. /**
  91451. * Detach the current controls from the specified dom element.
  91452. * @param element Defines the element to stop listening the inputs from
  91453. */
  91454. detachControl(element: Nullable<HTMLElement>): void;
  91455. /**
  91456. * Update the current camera state depending on the inputs that have been used this frame.
  91457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91458. */
  91459. checkInputs(): void;
  91460. /**
  91461. * Gets the class name of the current intput.
  91462. * @returns the class name
  91463. */
  91464. getClassName(): string;
  91465. /**
  91466. * Get the friendly name associated with the input class.
  91467. * @returns the input friendly name
  91468. */
  91469. getSimpleName(): string;
  91470. }
  91471. }
  91472. declare module BABYLON {
  91473. /**
  91474. * Default Inputs manager for the FreeCamera.
  91475. * It groups all the default supported inputs for ease of use.
  91476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91477. */
  91478. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91479. /**
  91480. * @hidden
  91481. */
  91482. _mouseInput: Nullable<FreeCameraMouseInput>;
  91483. /**
  91484. * Instantiates a new FreeCameraInputsManager.
  91485. * @param camera Defines the camera the inputs belong to
  91486. */
  91487. constructor(camera: FreeCamera);
  91488. /**
  91489. * Add keyboard input support to the input manager.
  91490. * @returns the current input manager
  91491. */
  91492. addKeyboard(): FreeCameraInputsManager;
  91493. /**
  91494. * Add mouse input support to the input manager.
  91495. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91496. * @returns the current input manager
  91497. */
  91498. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91499. /**
  91500. * Removes the mouse input support from the manager
  91501. * @returns the current input manager
  91502. */
  91503. removeMouse(): FreeCameraInputsManager;
  91504. /**
  91505. * Add touch input support to the input manager.
  91506. * @returns the current input manager
  91507. */
  91508. addTouch(): FreeCameraInputsManager;
  91509. /**
  91510. * Remove all attached input methods from a camera
  91511. */
  91512. clear(): void;
  91513. }
  91514. }
  91515. declare module BABYLON {
  91516. /**
  91517. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91518. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91519. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91520. */
  91521. export class FreeCamera extends TargetCamera {
  91522. /**
  91523. * Define the collision ellipsoid of the camera.
  91524. * This is helpful to simulate a camera body like the player body around the camera
  91525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91526. */
  91527. ellipsoid: Vector3;
  91528. /**
  91529. * Define an offset for the position of the ellipsoid around the camera.
  91530. * This can be helpful to determine the center of the body near the gravity center of the body
  91531. * instead of its head.
  91532. */
  91533. ellipsoidOffset: Vector3;
  91534. /**
  91535. * Enable or disable collisions of the camera with the rest of the scene objects.
  91536. */
  91537. checkCollisions: boolean;
  91538. /**
  91539. * Enable or disable gravity on the camera.
  91540. */
  91541. applyGravity: boolean;
  91542. /**
  91543. * Define the input manager associated to the camera.
  91544. */
  91545. inputs: FreeCameraInputsManager;
  91546. /**
  91547. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91548. * Higher values reduce sensitivity.
  91549. */
  91550. get angularSensibility(): number;
  91551. /**
  91552. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91553. * Higher values reduce sensitivity.
  91554. */
  91555. set angularSensibility(value: number);
  91556. /**
  91557. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91558. */
  91559. get keysUp(): number[];
  91560. set keysUp(value: number[]);
  91561. /**
  91562. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91563. */
  91564. get keysDown(): number[];
  91565. set keysDown(value: number[]);
  91566. /**
  91567. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91568. */
  91569. get keysLeft(): number[];
  91570. set keysLeft(value: number[]);
  91571. /**
  91572. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91573. */
  91574. get keysRight(): number[];
  91575. set keysRight(value: number[]);
  91576. /**
  91577. * Event raised when the camera collide with a mesh in the scene.
  91578. */
  91579. onCollide: (collidedMesh: AbstractMesh) => void;
  91580. private _collider;
  91581. private _needMoveForGravity;
  91582. private _oldPosition;
  91583. private _diffPosition;
  91584. private _newPosition;
  91585. /** @hidden */
  91586. _localDirection: Vector3;
  91587. /** @hidden */
  91588. _transformedDirection: Vector3;
  91589. /**
  91590. * Instantiates a Free Camera.
  91591. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91592. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91594. * @param name Define the name of the camera in the scene
  91595. * @param position Define the start position of the camera in the scene
  91596. * @param scene Define the scene the camera belongs to
  91597. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91598. */
  91599. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91600. /**
  91601. * Attached controls to the current camera.
  91602. * @param element Defines the element the controls should be listened from
  91603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91604. */
  91605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91606. /**
  91607. * Detach the current controls from the camera.
  91608. * The camera will stop reacting to inputs.
  91609. * @param element Defines the element to stop listening the inputs from
  91610. */
  91611. detachControl(element: HTMLElement): void;
  91612. private _collisionMask;
  91613. /**
  91614. * Define a collision mask to limit the list of object the camera can collide with
  91615. */
  91616. get collisionMask(): number;
  91617. set collisionMask(mask: number);
  91618. /** @hidden */
  91619. _collideWithWorld(displacement: Vector3): void;
  91620. private _onCollisionPositionChange;
  91621. /** @hidden */
  91622. _checkInputs(): void;
  91623. /** @hidden */
  91624. _decideIfNeedsToMove(): boolean;
  91625. /** @hidden */
  91626. _updatePosition(): void;
  91627. /**
  91628. * Destroy the camera and release the current resources hold by it.
  91629. */
  91630. dispose(): void;
  91631. /**
  91632. * Gets the current object class name.
  91633. * @return the class name
  91634. */
  91635. getClassName(): string;
  91636. }
  91637. }
  91638. declare module BABYLON {
  91639. /**
  91640. * Represents a gamepad control stick position
  91641. */
  91642. export class StickValues {
  91643. /**
  91644. * The x component of the control stick
  91645. */
  91646. x: number;
  91647. /**
  91648. * The y component of the control stick
  91649. */
  91650. y: number;
  91651. /**
  91652. * Initializes the gamepad x and y control stick values
  91653. * @param x The x component of the gamepad control stick value
  91654. * @param y The y component of the gamepad control stick value
  91655. */
  91656. constructor(
  91657. /**
  91658. * The x component of the control stick
  91659. */
  91660. x: number,
  91661. /**
  91662. * The y component of the control stick
  91663. */
  91664. y: number);
  91665. }
  91666. /**
  91667. * An interface which manages callbacks for gamepad button changes
  91668. */
  91669. export interface GamepadButtonChanges {
  91670. /**
  91671. * Called when a gamepad has been changed
  91672. */
  91673. changed: boolean;
  91674. /**
  91675. * Called when a gamepad press event has been triggered
  91676. */
  91677. pressChanged: boolean;
  91678. /**
  91679. * Called when a touch event has been triggered
  91680. */
  91681. touchChanged: boolean;
  91682. /**
  91683. * Called when a value has changed
  91684. */
  91685. valueChanged: boolean;
  91686. }
  91687. /**
  91688. * Represents a gamepad
  91689. */
  91690. export class Gamepad {
  91691. /**
  91692. * The id of the gamepad
  91693. */
  91694. id: string;
  91695. /**
  91696. * The index of the gamepad
  91697. */
  91698. index: number;
  91699. /**
  91700. * The browser gamepad
  91701. */
  91702. browserGamepad: any;
  91703. /**
  91704. * Specifies what type of gamepad this represents
  91705. */
  91706. type: number;
  91707. private _leftStick;
  91708. private _rightStick;
  91709. /** @hidden */
  91710. _isConnected: boolean;
  91711. private _leftStickAxisX;
  91712. private _leftStickAxisY;
  91713. private _rightStickAxisX;
  91714. private _rightStickAxisY;
  91715. /**
  91716. * Triggered when the left control stick has been changed
  91717. */
  91718. private _onleftstickchanged;
  91719. /**
  91720. * Triggered when the right control stick has been changed
  91721. */
  91722. private _onrightstickchanged;
  91723. /**
  91724. * Represents a gamepad controller
  91725. */
  91726. static GAMEPAD: number;
  91727. /**
  91728. * Represents a generic controller
  91729. */
  91730. static GENERIC: number;
  91731. /**
  91732. * Represents an XBox controller
  91733. */
  91734. static XBOX: number;
  91735. /**
  91736. * Represents a pose-enabled controller
  91737. */
  91738. static POSE_ENABLED: number;
  91739. /**
  91740. * Represents an Dual Shock controller
  91741. */
  91742. static DUALSHOCK: number;
  91743. /**
  91744. * Specifies whether the left control stick should be Y-inverted
  91745. */
  91746. protected _invertLeftStickY: boolean;
  91747. /**
  91748. * Specifies if the gamepad has been connected
  91749. */
  91750. get isConnected(): boolean;
  91751. /**
  91752. * Initializes the gamepad
  91753. * @param id The id of the gamepad
  91754. * @param index The index of the gamepad
  91755. * @param browserGamepad The browser gamepad
  91756. * @param leftStickX The x component of the left joystick
  91757. * @param leftStickY The y component of the left joystick
  91758. * @param rightStickX The x component of the right joystick
  91759. * @param rightStickY The y component of the right joystick
  91760. */
  91761. constructor(
  91762. /**
  91763. * The id of the gamepad
  91764. */
  91765. id: string,
  91766. /**
  91767. * The index of the gamepad
  91768. */
  91769. index: number,
  91770. /**
  91771. * The browser gamepad
  91772. */
  91773. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91774. /**
  91775. * Callback triggered when the left joystick has changed
  91776. * @param callback
  91777. */
  91778. onleftstickchanged(callback: (values: StickValues) => void): void;
  91779. /**
  91780. * Callback triggered when the right joystick has changed
  91781. * @param callback
  91782. */
  91783. onrightstickchanged(callback: (values: StickValues) => void): void;
  91784. /**
  91785. * Gets the left joystick
  91786. */
  91787. get leftStick(): StickValues;
  91788. /**
  91789. * Sets the left joystick values
  91790. */
  91791. set leftStick(newValues: StickValues);
  91792. /**
  91793. * Gets the right joystick
  91794. */
  91795. get rightStick(): StickValues;
  91796. /**
  91797. * Sets the right joystick value
  91798. */
  91799. set rightStick(newValues: StickValues);
  91800. /**
  91801. * Updates the gamepad joystick positions
  91802. */
  91803. update(): void;
  91804. /**
  91805. * Disposes the gamepad
  91806. */
  91807. dispose(): void;
  91808. }
  91809. /**
  91810. * Represents a generic gamepad
  91811. */
  91812. export class GenericPad extends Gamepad {
  91813. private _buttons;
  91814. private _onbuttondown;
  91815. private _onbuttonup;
  91816. /**
  91817. * Observable triggered when a button has been pressed
  91818. */
  91819. onButtonDownObservable: Observable<number>;
  91820. /**
  91821. * Observable triggered when a button has been released
  91822. */
  91823. onButtonUpObservable: Observable<number>;
  91824. /**
  91825. * Callback triggered when a button has been pressed
  91826. * @param callback Called when a button has been pressed
  91827. */
  91828. onbuttondown(callback: (buttonPressed: number) => void): void;
  91829. /**
  91830. * Callback triggered when a button has been released
  91831. * @param callback Called when a button has been released
  91832. */
  91833. onbuttonup(callback: (buttonReleased: number) => void): void;
  91834. /**
  91835. * Initializes the generic gamepad
  91836. * @param id The id of the generic gamepad
  91837. * @param index The index of the generic gamepad
  91838. * @param browserGamepad The browser gamepad
  91839. */
  91840. constructor(id: string, index: number, browserGamepad: any);
  91841. private _setButtonValue;
  91842. /**
  91843. * Updates the generic gamepad
  91844. */
  91845. update(): void;
  91846. /**
  91847. * Disposes the generic gamepad
  91848. */
  91849. dispose(): void;
  91850. }
  91851. }
  91852. declare module BABYLON {
  91853. /**
  91854. * Defines the types of pose enabled controllers that are supported
  91855. */
  91856. export enum PoseEnabledControllerType {
  91857. /**
  91858. * HTC Vive
  91859. */
  91860. VIVE = 0,
  91861. /**
  91862. * Oculus Rift
  91863. */
  91864. OCULUS = 1,
  91865. /**
  91866. * Windows mixed reality
  91867. */
  91868. WINDOWS = 2,
  91869. /**
  91870. * Samsung gear VR
  91871. */
  91872. GEAR_VR = 3,
  91873. /**
  91874. * Google Daydream
  91875. */
  91876. DAYDREAM = 4,
  91877. /**
  91878. * Generic
  91879. */
  91880. GENERIC = 5
  91881. }
  91882. /**
  91883. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91884. */
  91885. export interface MutableGamepadButton {
  91886. /**
  91887. * Value of the button/trigger
  91888. */
  91889. value: number;
  91890. /**
  91891. * If the button/trigger is currently touched
  91892. */
  91893. touched: boolean;
  91894. /**
  91895. * If the button/trigger is currently pressed
  91896. */
  91897. pressed: boolean;
  91898. }
  91899. /**
  91900. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91901. * @hidden
  91902. */
  91903. export interface ExtendedGamepadButton extends GamepadButton {
  91904. /**
  91905. * If the button/trigger is currently pressed
  91906. */
  91907. readonly pressed: boolean;
  91908. /**
  91909. * If the button/trigger is currently touched
  91910. */
  91911. readonly touched: boolean;
  91912. /**
  91913. * Value of the button/trigger
  91914. */
  91915. readonly value: number;
  91916. }
  91917. /** @hidden */
  91918. export interface _GamePadFactory {
  91919. /**
  91920. * Returns whether or not the current gamepad can be created for this type of controller.
  91921. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91922. * @returns true if it can be created, otherwise false
  91923. */
  91924. canCreate(gamepadInfo: any): boolean;
  91925. /**
  91926. * Creates a new instance of the Gamepad.
  91927. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91928. * @returns the new gamepad instance
  91929. */
  91930. create(gamepadInfo: any): Gamepad;
  91931. }
  91932. /**
  91933. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91934. */
  91935. export class PoseEnabledControllerHelper {
  91936. /** @hidden */
  91937. static _ControllerFactories: _GamePadFactory[];
  91938. /** @hidden */
  91939. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  91940. /**
  91941. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91942. * @param vrGamepad the gamepad to initialized
  91943. * @returns a vr controller of the type the gamepad identified as
  91944. */
  91945. static InitiateController(vrGamepad: any): Gamepad;
  91946. }
  91947. /**
  91948. * Defines the PoseEnabledController object that contains state of a vr capable controller
  91949. */
  91950. export class PoseEnabledController extends Gamepad implements PoseControlled {
  91951. /**
  91952. * If the controller is used in a webXR session
  91953. */
  91954. isXR: boolean;
  91955. private _deviceRoomPosition;
  91956. private _deviceRoomRotationQuaternion;
  91957. /**
  91958. * The device position in babylon space
  91959. */
  91960. devicePosition: Vector3;
  91961. /**
  91962. * The device rotation in babylon space
  91963. */
  91964. deviceRotationQuaternion: Quaternion;
  91965. /**
  91966. * The scale factor of the device in babylon space
  91967. */
  91968. deviceScaleFactor: number;
  91969. /**
  91970. * (Likely devicePosition should be used instead) The device position in its room space
  91971. */
  91972. position: Vector3;
  91973. /**
  91974. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  91975. */
  91976. rotationQuaternion: Quaternion;
  91977. /**
  91978. * The type of controller (Eg. Windows mixed reality)
  91979. */
  91980. controllerType: PoseEnabledControllerType;
  91981. protected _calculatedPosition: Vector3;
  91982. private _calculatedRotation;
  91983. /**
  91984. * The raw pose from the device
  91985. */
  91986. rawPose: DevicePose;
  91987. private _trackPosition;
  91988. private _maxRotationDistFromHeadset;
  91989. private _draggedRoomRotation;
  91990. /**
  91991. * @hidden
  91992. */
  91993. _disableTrackPosition(fixedPosition: Vector3): void;
  91994. /**
  91995. * Internal, the mesh attached to the controller
  91996. * @hidden
  91997. */
  91998. _mesh: Nullable<AbstractMesh>;
  91999. private _poseControlledCamera;
  92000. private _leftHandSystemQuaternion;
  92001. /**
  92002. * Internal, matrix used to convert room space to babylon space
  92003. * @hidden
  92004. */
  92005. _deviceToWorld: Matrix;
  92006. /**
  92007. * Node to be used when casting a ray from the controller
  92008. * @hidden
  92009. */
  92010. _pointingPoseNode: Nullable<TransformNode>;
  92011. /**
  92012. * Name of the child mesh that can be used to cast a ray from the controller
  92013. */
  92014. static readonly POINTING_POSE: string;
  92015. /**
  92016. * Creates a new PoseEnabledController from a gamepad
  92017. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92018. */
  92019. constructor(browserGamepad: any);
  92020. private _workingMatrix;
  92021. /**
  92022. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92023. */
  92024. update(): void;
  92025. /**
  92026. * Updates only the pose device and mesh without doing any button event checking
  92027. */
  92028. protected _updatePoseAndMesh(): void;
  92029. /**
  92030. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92031. * @param poseData raw pose fromthe device
  92032. */
  92033. updateFromDevice(poseData: DevicePose): void;
  92034. /**
  92035. * @hidden
  92036. */
  92037. _meshAttachedObservable: Observable<AbstractMesh>;
  92038. /**
  92039. * Attaches a mesh to the controller
  92040. * @param mesh the mesh to be attached
  92041. */
  92042. attachToMesh(mesh: AbstractMesh): void;
  92043. /**
  92044. * Attaches the controllers mesh to a camera
  92045. * @param camera the camera the mesh should be attached to
  92046. */
  92047. attachToPoseControlledCamera(camera: TargetCamera): void;
  92048. /**
  92049. * Disposes of the controller
  92050. */
  92051. dispose(): void;
  92052. /**
  92053. * The mesh that is attached to the controller
  92054. */
  92055. get mesh(): Nullable<AbstractMesh>;
  92056. /**
  92057. * Gets the ray of the controller in the direction the controller is pointing
  92058. * @param length the length the resulting ray should be
  92059. * @returns a ray in the direction the controller is pointing
  92060. */
  92061. getForwardRay(length?: number): Ray;
  92062. }
  92063. }
  92064. declare module BABYLON {
  92065. /**
  92066. * Defines the WebVRController object that represents controllers tracked in 3D space
  92067. */
  92068. export abstract class WebVRController extends PoseEnabledController {
  92069. /**
  92070. * Internal, the default controller model for the controller
  92071. */
  92072. protected _defaultModel: Nullable<AbstractMesh>;
  92073. /**
  92074. * Fired when the trigger state has changed
  92075. */
  92076. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92077. /**
  92078. * Fired when the main button state has changed
  92079. */
  92080. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92081. /**
  92082. * Fired when the secondary button state has changed
  92083. */
  92084. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92085. /**
  92086. * Fired when the pad state has changed
  92087. */
  92088. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92089. /**
  92090. * Fired when controllers stick values have changed
  92091. */
  92092. onPadValuesChangedObservable: Observable<StickValues>;
  92093. /**
  92094. * Array of button availible on the controller
  92095. */
  92096. protected _buttons: Array<MutableGamepadButton>;
  92097. private _onButtonStateChange;
  92098. /**
  92099. * Fired when a controller button's state has changed
  92100. * @param callback the callback containing the button that was modified
  92101. */
  92102. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92103. /**
  92104. * X and Y axis corresponding to the controllers joystick
  92105. */
  92106. pad: StickValues;
  92107. /**
  92108. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92109. */
  92110. hand: string;
  92111. /**
  92112. * The default controller model for the controller
  92113. */
  92114. get defaultModel(): Nullable<AbstractMesh>;
  92115. /**
  92116. * Creates a new WebVRController from a gamepad
  92117. * @param vrGamepad the gamepad that the WebVRController should be created from
  92118. */
  92119. constructor(vrGamepad: any);
  92120. /**
  92121. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92122. */
  92123. update(): void;
  92124. /**
  92125. * Function to be called when a button is modified
  92126. */
  92127. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92128. /**
  92129. * Loads a mesh and attaches it to the controller
  92130. * @param scene the scene the mesh should be added to
  92131. * @param meshLoaded callback for when the mesh has been loaded
  92132. */
  92133. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92134. private _setButtonValue;
  92135. private _changes;
  92136. private _checkChanges;
  92137. /**
  92138. * Disposes of th webVRCOntroller
  92139. */
  92140. dispose(): void;
  92141. }
  92142. }
  92143. declare module BABYLON {
  92144. /**
  92145. * The HemisphericLight simulates the ambient environment light,
  92146. * so the passed direction is the light reflection direction, not the incoming direction.
  92147. */
  92148. export class HemisphericLight extends Light {
  92149. /**
  92150. * The groundColor is the light in the opposite direction to the one specified during creation.
  92151. * 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.
  92152. */
  92153. groundColor: Color3;
  92154. /**
  92155. * The light reflection direction, not the incoming direction.
  92156. */
  92157. direction: Vector3;
  92158. /**
  92159. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92160. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92161. * The HemisphericLight can't cast shadows.
  92162. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92163. * @param name The friendly name of the light
  92164. * @param direction The direction of the light reflection
  92165. * @param scene The scene the light belongs to
  92166. */
  92167. constructor(name: string, direction: Vector3, scene: Scene);
  92168. protected _buildUniformLayout(): void;
  92169. /**
  92170. * Returns the string "HemisphericLight".
  92171. * @return The class name
  92172. */
  92173. getClassName(): string;
  92174. /**
  92175. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92176. * Returns the updated direction.
  92177. * @param target The target the direction should point to
  92178. * @return The computed direction
  92179. */
  92180. setDirectionToTarget(target: Vector3): Vector3;
  92181. /**
  92182. * Returns the shadow generator associated to the light.
  92183. * @returns Always null for hemispheric lights because it does not support shadows.
  92184. */
  92185. getShadowGenerator(): Nullable<IShadowGenerator>;
  92186. /**
  92187. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92188. * @param effect The effect to update
  92189. * @param lightIndex The index of the light in the effect to update
  92190. * @returns The hemispheric light
  92191. */
  92192. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92193. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92194. /**
  92195. * Computes the world matrix of the node
  92196. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92197. * @param useWasUpdatedFlag defines a reserved property
  92198. * @returns the world matrix
  92199. */
  92200. computeWorldMatrix(): Matrix;
  92201. /**
  92202. * Returns the integer 3.
  92203. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92204. */
  92205. getTypeID(): number;
  92206. /**
  92207. * Prepares the list of defines specific to the light type.
  92208. * @param defines the list of defines
  92209. * @param lightIndex defines the index of the light for the effect
  92210. */
  92211. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92212. }
  92213. }
  92214. declare module BABYLON {
  92215. /** @hidden */
  92216. export var vrMultiviewToSingleviewPixelShader: {
  92217. name: string;
  92218. shader: string;
  92219. };
  92220. }
  92221. declare module BABYLON {
  92222. /**
  92223. * Renders to multiple views with a single draw call
  92224. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92225. */
  92226. export class MultiviewRenderTarget extends RenderTargetTexture {
  92227. /**
  92228. * Creates a multiview render target
  92229. * @param scene scene used with the render target
  92230. * @param size the size of the render target (used for each view)
  92231. */
  92232. constructor(scene: Scene, size?: number | {
  92233. width: number;
  92234. height: number;
  92235. } | {
  92236. ratio: number;
  92237. });
  92238. /**
  92239. * @hidden
  92240. * @param faceIndex the face index, if its a cube texture
  92241. */
  92242. _bindFrameBuffer(faceIndex?: number): void;
  92243. /**
  92244. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92245. * @returns the view count
  92246. */
  92247. getViewCount(): number;
  92248. }
  92249. }
  92250. declare module BABYLON {
  92251. /**
  92252. * Represents a camera frustum
  92253. */
  92254. export class Frustum {
  92255. /**
  92256. * Gets the planes representing the frustum
  92257. * @param transform matrix to be applied to the returned planes
  92258. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92259. */
  92260. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92261. /**
  92262. * Gets the near frustum plane transformed by the transform matrix
  92263. * @param transform transformation matrix to be applied to the resulting frustum plane
  92264. * @param frustumPlane the resuling frustum plane
  92265. */
  92266. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92267. /**
  92268. * Gets the far frustum plane transformed by the transform matrix
  92269. * @param transform transformation matrix to be applied to the resulting frustum plane
  92270. * @param frustumPlane the resuling frustum plane
  92271. */
  92272. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92273. /**
  92274. * Gets the left frustum plane transformed by the transform matrix
  92275. * @param transform transformation matrix to be applied to the resulting frustum plane
  92276. * @param frustumPlane the resuling frustum plane
  92277. */
  92278. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92279. /**
  92280. * Gets the right frustum plane transformed by the transform matrix
  92281. * @param transform transformation matrix to be applied to the resulting frustum plane
  92282. * @param frustumPlane the resuling frustum plane
  92283. */
  92284. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92285. /**
  92286. * Gets the top frustum plane transformed by the transform matrix
  92287. * @param transform transformation matrix to be applied to the resulting frustum plane
  92288. * @param frustumPlane the resuling frustum plane
  92289. */
  92290. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92291. /**
  92292. * Gets the bottom frustum plane transformed by the transform matrix
  92293. * @param transform transformation matrix to be applied to the resulting frustum plane
  92294. * @param frustumPlane the resuling frustum plane
  92295. */
  92296. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92297. /**
  92298. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92299. * @param transform transformation matrix to be applied to the resulting frustum planes
  92300. * @param frustumPlanes the resuling frustum planes
  92301. */
  92302. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92303. }
  92304. }
  92305. declare module BABYLON {
  92306. interface Engine {
  92307. /**
  92308. * Creates a new multiview render target
  92309. * @param width defines the width of the texture
  92310. * @param height defines the height of the texture
  92311. * @returns the created multiview texture
  92312. */
  92313. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92314. /**
  92315. * Binds a multiview framebuffer to be drawn to
  92316. * @param multiviewTexture texture to bind
  92317. */
  92318. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92319. }
  92320. interface Camera {
  92321. /**
  92322. * @hidden
  92323. * 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)
  92324. */
  92325. _useMultiviewToSingleView: boolean;
  92326. /**
  92327. * @hidden
  92328. * 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)
  92329. */
  92330. _multiviewTexture: Nullable<RenderTargetTexture>;
  92331. /**
  92332. * @hidden
  92333. * ensures the multiview texture of the camera exists and has the specified width/height
  92334. * @param width height to set on the multiview texture
  92335. * @param height width to set on the multiview texture
  92336. */
  92337. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92338. }
  92339. interface Scene {
  92340. /** @hidden */
  92341. _transformMatrixR: Matrix;
  92342. /** @hidden */
  92343. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92344. /** @hidden */
  92345. _createMultiviewUbo(): void;
  92346. /** @hidden */
  92347. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92348. /** @hidden */
  92349. _renderMultiviewToSingleView(camera: Camera): void;
  92350. }
  92351. }
  92352. declare module BABYLON {
  92353. /**
  92354. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92355. * This will not be used for webXR as it supports displaying texture arrays directly
  92356. */
  92357. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92358. /**
  92359. * Initializes a VRMultiviewToSingleview
  92360. * @param name name of the post process
  92361. * @param camera camera to be applied to
  92362. * @param scaleFactor scaling factor to the size of the output texture
  92363. */
  92364. constructor(name: string, camera: Camera, scaleFactor: number);
  92365. }
  92366. }
  92367. declare module BABYLON {
  92368. /**
  92369. * Interface used to define additional presentation attributes
  92370. */
  92371. export interface IVRPresentationAttributes {
  92372. /**
  92373. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92374. */
  92375. highRefreshRate: boolean;
  92376. /**
  92377. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92378. */
  92379. foveationLevel: number;
  92380. }
  92381. interface Engine {
  92382. /** @hidden */
  92383. _vrDisplay: any;
  92384. /** @hidden */
  92385. _vrSupported: boolean;
  92386. /** @hidden */
  92387. _oldSize: Size;
  92388. /** @hidden */
  92389. _oldHardwareScaleFactor: number;
  92390. /** @hidden */
  92391. _vrExclusivePointerMode: boolean;
  92392. /** @hidden */
  92393. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92394. /** @hidden */
  92395. _onVRDisplayPointerRestricted: () => void;
  92396. /** @hidden */
  92397. _onVRDisplayPointerUnrestricted: () => void;
  92398. /** @hidden */
  92399. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92400. /** @hidden */
  92401. _onVrDisplayDisconnect: Nullable<() => void>;
  92402. /** @hidden */
  92403. _onVrDisplayPresentChange: Nullable<() => void>;
  92404. /**
  92405. * Observable signaled when VR display mode changes
  92406. */
  92407. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92408. /**
  92409. * Observable signaled when VR request present is complete
  92410. */
  92411. onVRRequestPresentComplete: Observable<boolean>;
  92412. /**
  92413. * Observable signaled when VR request present starts
  92414. */
  92415. onVRRequestPresentStart: Observable<Engine>;
  92416. /**
  92417. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92418. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92419. */
  92420. isInVRExclusivePointerMode: boolean;
  92421. /**
  92422. * Gets a boolean indicating if a webVR device was detected
  92423. * @returns true if a webVR device was detected
  92424. */
  92425. isVRDevicePresent(): boolean;
  92426. /**
  92427. * Gets the current webVR device
  92428. * @returns the current webVR device (or null)
  92429. */
  92430. getVRDevice(): any;
  92431. /**
  92432. * Initializes a webVR display and starts listening to display change events
  92433. * The onVRDisplayChangedObservable will be notified upon these changes
  92434. * @returns A promise containing a VRDisplay and if vr is supported
  92435. */
  92436. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92437. /** @hidden */
  92438. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92439. /**
  92440. * Gets or sets the presentation attributes used to configure VR rendering
  92441. */
  92442. vrPresentationAttributes?: IVRPresentationAttributes;
  92443. /**
  92444. * Call this function to switch to webVR mode
  92445. * Will do nothing if webVR is not supported or if there is no webVR device
  92446. * @param options the webvr options provided to the camera. mainly used for multiview
  92447. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92448. */
  92449. enableVR(options: WebVROptions): void;
  92450. /** @hidden */
  92451. _onVRFullScreenTriggered(): void;
  92452. }
  92453. }
  92454. declare module BABYLON {
  92455. /**
  92456. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92457. * IMPORTANT!! The data is right-hand data.
  92458. * @export
  92459. * @interface DevicePose
  92460. */
  92461. export interface DevicePose {
  92462. /**
  92463. * The position of the device, values in array are [x,y,z].
  92464. */
  92465. readonly position: Nullable<Float32Array>;
  92466. /**
  92467. * The linearVelocity of the device, values in array are [x,y,z].
  92468. */
  92469. readonly linearVelocity: Nullable<Float32Array>;
  92470. /**
  92471. * The linearAcceleration of the device, values in array are [x,y,z].
  92472. */
  92473. readonly linearAcceleration: Nullable<Float32Array>;
  92474. /**
  92475. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92476. */
  92477. readonly orientation: Nullable<Float32Array>;
  92478. /**
  92479. * The angularVelocity of the device, values in array are [x,y,z].
  92480. */
  92481. readonly angularVelocity: Nullable<Float32Array>;
  92482. /**
  92483. * The angularAcceleration of the device, values in array are [x,y,z].
  92484. */
  92485. readonly angularAcceleration: Nullable<Float32Array>;
  92486. }
  92487. /**
  92488. * Interface representing a pose controlled object in Babylon.
  92489. * A pose controlled object has both regular pose values as well as pose values
  92490. * from an external device such as a VR head mounted display
  92491. */
  92492. export interface PoseControlled {
  92493. /**
  92494. * The position of the object in babylon space.
  92495. */
  92496. position: Vector3;
  92497. /**
  92498. * The rotation quaternion of the object in babylon space.
  92499. */
  92500. rotationQuaternion: Quaternion;
  92501. /**
  92502. * The position of the device in babylon space.
  92503. */
  92504. devicePosition?: Vector3;
  92505. /**
  92506. * The rotation quaternion of the device in babylon space.
  92507. */
  92508. deviceRotationQuaternion: Quaternion;
  92509. /**
  92510. * The raw pose coming from the device.
  92511. */
  92512. rawPose: Nullable<DevicePose>;
  92513. /**
  92514. * The scale of the device to be used when translating from device space to babylon space.
  92515. */
  92516. deviceScaleFactor: number;
  92517. /**
  92518. * Updates the poseControlled values based on the input device pose.
  92519. * @param poseData the pose data to update the object with
  92520. */
  92521. updateFromDevice(poseData: DevicePose): void;
  92522. }
  92523. /**
  92524. * Set of options to customize the webVRCamera
  92525. */
  92526. export interface WebVROptions {
  92527. /**
  92528. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92529. */
  92530. trackPosition?: boolean;
  92531. /**
  92532. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92533. */
  92534. positionScale?: number;
  92535. /**
  92536. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92537. */
  92538. displayName?: string;
  92539. /**
  92540. * Should the native controller meshes be initialized. (default: true)
  92541. */
  92542. controllerMeshes?: boolean;
  92543. /**
  92544. * Creating a default HemiLight only on controllers. (default: true)
  92545. */
  92546. defaultLightingOnControllers?: boolean;
  92547. /**
  92548. * If you don't want to use the default VR button of the helper. (default: false)
  92549. */
  92550. useCustomVRButton?: boolean;
  92551. /**
  92552. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92553. */
  92554. customVRButton?: HTMLButtonElement;
  92555. /**
  92556. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92557. */
  92558. rayLength?: number;
  92559. /**
  92560. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92561. */
  92562. defaultHeight?: number;
  92563. /**
  92564. * If multiview should be used if availible (default: false)
  92565. */
  92566. useMultiview?: boolean;
  92567. }
  92568. /**
  92569. * This represents a WebVR camera.
  92570. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92571. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92572. */
  92573. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92574. private webVROptions;
  92575. /**
  92576. * @hidden
  92577. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92578. */
  92579. _vrDevice: any;
  92580. /**
  92581. * The rawPose of the vrDevice.
  92582. */
  92583. rawPose: Nullable<DevicePose>;
  92584. private _onVREnabled;
  92585. private _specsVersion;
  92586. private _attached;
  92587. private _frameData;
  92588. protected _descendants: Array<Node>;
  92589. private _deviceRoomPosition;
  92590. /** @hidden */
  92591. _deviceRoomRotationQuaternion: Quaternion;
  92592. private _standingMatrix;
  92593. /**
  92594. * Represents device position in babylon space.
  92595. */
  92596. devicePosition: Vector3;
  92597. /**
  92598. * Represents device rotation in babylon space.
  92599. */
  92600. deviceRotationQuaternion: Quaternion;
  92601. /**
  92602. * The scale of the device to be used when translating from device space to babylon space.
  92603. */
  92604. deviceScaleFactor: number;
  92605. private _deviceToWorld;
  92606. private _worldToDevice;
  92607. /**
  92608. * References to the webVR controllers for the vrDevice.
  92609. */
  92610. controllers: Array<WebVRController>;
  92611. /**
  92612. * Emits an event when a controller is attached.
  92613. */
  92614. onControllersAttachedObservable: Observable<WebVRController[]>;
  92615. /**
  92616. * Emits an event when a controller's mesh has been loaded;
  92617. */
  92618. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92619. /**
  92620. * Emits an event when the HMD's pose has been updated.
  92621. */
  92622. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92623. private _poseSet;
  92624. /**
  92625. * If the rig cameras be used as parent instead of this camera.
  92626. */
  92627. rigParenting: boolean;
  92628. private _lightOnControllers;
  92629. private _defaultHeight?;
  92630. /**
  92631. * Instantiates a WebVRFreeCamera.
  92632. * @param name The name of the WebVRFreeCamera
  92633. * @param position The starting anchor position for the camera
  92634. * @param scene The scene the camera belongs to
  92635. * @param webVROptions a set of customizable options for the webVRCamera
  92636. */
  92637. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92638. /**
  92639. * Gets the device distance from the ground in meters.
  92640. * @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.
  92641. */
  92642. deviceDistanceToRoomGround(): number;
  92643. /**
  92644. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92645. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92646. */
  92647. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92648. /**
  92649. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92650. * @returns A promise with a boolean set to if the standing matrix is supported.
  92651. */
  92652. useStandingMatrixAsync(): Promise<boolean>;
  92653. /**
  92654. * Disposes the camera
  92655. */
  92656. dispose(): void;
  92657. /**
  92658. * Gets a vrController by name.
  92659. * @param name The name of the controller to retreive
  92660. * @returns the controller matching the name specified or null if not found
  92661. */
  92662. getControllerByName(name: string): Nullable<WebVRController>;
  92663. private _leftController;
  92664. /**
  92665. * The controller corresponding to the users left hand.
  92666. */
  92667. get leftController(): Nullable<WebVRController>;
  92668. private _rightController;
  92669. /**
  92670. * The controller corresponding to the users right hand.
  92671. */
  92672. get rightController(): Nullable<WebVRController>;
  92673. /**
  92674. * Casts a ray forward from the vrCamera's gaze.
  92675. * @param length Length of the ray (default: 100)
  92676. * @returns the ray corresponding to the gaze
  92677. */
  92678. getForwardRay(length?: number): Ray;
  92679. /**
  92680. * @hidden
  92681. * Updates the camera based on device's frame data
  92682. */
  92683. _checkInputs(): void;
  92684. /**
  92685. * Updates the poseControlled values based on the input device pose.
  92686. * @param poseData Pose coming from the device
  92687. */
  92688. updateFromDevice(poseData: DevicePose): void;
  92689. private _htmlElementAttached;
  92690. private _detachIfAttached;
  92691. /**
  92692. * WebVR's attach control will start broadcasting frames to the device.
  92693. * Note that in certain browsers (chrome for example) this function must be called
  92694. * within a user-interaction callback. Example:
  92695. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92696. *
  92697. * @param element html element to attach the vrDevice to
  92698. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92699. */
  92700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92701. /**
  92702. * Detaches the camera from the html element and disables VR
  92703. *
  92704. * @param element html element to detach from
  92705. */
  92706. detachControl(element: HTMLElement): void;
  92707. /**
  92708. * @returns the name of this class
  92709. */
  92710. getClassName(): string;
  92711. /**
  92712. * Calls resetPose on the vrDisplay
  92713. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92714. */
  92715. resetToCurrentRotation(): void;
  92716. /**
  92717. * @hidden
  92718. * Updates the rig cameras (left and right eye)
  92719. */
  92720. _updateRigCameras(): void;
  92721. private _workingVector;
  92722. private _oneVector;
  92723. private _workingMatrix;
  92724. private updateCacheCalled;
  92725. private _correctPositionIfNotTrackPosition;
  92726. /**
  92727. * @hidden
  92728. * Updates the cached values of the camera
  92729. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92730. */
  92731. _updateCache(ignoreParentClass?: boolean): void;
  92732. /**
  92733. * @hidden
  92734. * Get current device position in babylon world
  92735. */
  92736. _computeDevicePosition(): void;
  92737. /**
  92738. * Updates the current device position and rotation in the babylon world
  92739. */
  92740. update(): void;
  92741. /**
  92742. * @hidden
  92743. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92744. * @returns an identity matrix
  92745. */
  92746. _getViewMatrix(): Matrix;
  92747. private _tmpMatrix;
  92748. /**
  92749. * This function is called by the two RIG cameras.
  92750. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92751. * @hidden
  92752. */
  92753. _getWebVRViewMatrix(): Matrix;
  92754. /** @hidden */
  92755. _getWebVRProjectionMatrix(): Matrix;
  92756. private _onGamepadConnectedObserver;
  92757. private _onGamepadDisconnectedObserver;
  92758. private _updateCacheWhenTrackingDisabledObserver;
  92759. /**
  92760. * Initializes the controllers and their meshes
  92761. */
  92762. initControllers(): void;
  92763. }
  92764. }
  92765. declare module BABYLON {
  92766. /**
  92767. * Size options for a post process
  92768. */
  92769. export type PostProcessOptions = {
  92770. width: number;
  92771. height: number;
  92772. };
  92773. /**
  92774. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92775. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92776. */
  92777. export class PostProcess {
  92778. /** Name of the PostProcess. */
  92779. name: string;
  92780. /**
  92781. * Gets or sets the unique id of the post process
  92782. */
  92783. uniqueId: number;
  92784. /**
  92785. * Width of the texture to apply the post process on
  92786. */
  92787. width: number;
  92788. /**
  92789. * Height of the texture to apply the post process on
  92790. */
  92791. height: number;
  92792. /**
  92793. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92794. * @hidden
  92795. */
  92796. _outputTexture: Nullable<InternalTexture>;
  92797. /**
  92798. * Sampling mode used by the shader
  92799. * See https://doc.babylonjs.com/classes/3.1/texture
  92800. */
  92801. renderTargetSamplingMode: number;
  92802. /**
  92803. * Clear color to use when screen clearing
  92804. */
  92805. clearColor: Color4;
  92806. /**
  92807. * If the buffer needs to be cleared before applying the post process. (default: true)
  92808. * Should be set to false if shader will overwrite all previous pixels.
  92809. */
  92810. autoClear: boolean;
  92811. /**
  92812. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92813. */
  92814. alphaMode: number;
  92815. /**
  92816. * Sets the setAlphaBlendConstants of the babylon engine
  92817. */
  92818. alphaConstants: Color4;
  92819. /**
  92820. * Animations to be used for the post processing
  92821. */
  92822. animations: Animation[];
  92823. /**
  92824. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92825. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92826. */
  92827. enablePixelPerfectMode: boolean;
  92828. /**
  92829. * Force the postprocess to be applied without taking in account viewport
  92830. */
  92831. forceFullscreenViewport: boolean;
  92832. /**
  92833. * List of inspectable custom properties (used by the Inspector)
  92834. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92835. */
  92836. inspectableCustomProperties: IInspectable[];
  92837. /**
  92838. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92839. *
  92840. * | Value | Type | Description |
  92841. * | ----- | ----------------------------------- | ----------- |
  92842. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92843. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92844. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92845. *
  92846. */
  92847. scaleMode: number;
  92848. /**
  92849. * Force textures to be a power of two (default: false)
  92850. */
  92851. alwaysForcePOT: boolean;
  92852. private _samples;
  92853. /**
  92854. * Number of sample textures (default: 1)
  92855. */
  92856. get samples(): number;
  92857. set samples(n: number);
  92858. /**
  92859. * Modify the scale of the post process to be the same as the viewport (default: false)
  92860. */
  92861. adaptScaleToCurrentViewport: boolean;
  92862. private _camera;
  92863. private _scene;
  92864. private _engine;
  92865. private _options;
  92866. private _reusable;
  92867. private _textureType;
  92868. private _textureFormat;
  92869. /**
  92870. * Smart array of input and output textures for the post process.
  92871. * @hidden
  92872. */
  92873. _textures: SmartArray<InternalTexture>;
  92874. /**
  92875. * The index in _textures that corresponds to the output texture.
  92876. * @hidden
  92877. */
  92878. _currentRenderTextureInd: number;
  92879. private _effect;
  92880. private _samplers;
  92881. private _fragmentUrl;
  92882. private _vertexUrl;
  92883. private _parameters;
  92884. private _scaleRatio;
  92885. protected _indexParameters: any;
  92886. private _shareOutputWithPostProcess;
  92887. private _texelSize;
  92888. private _forcedOutputTexture;
  92889. /**
  92890. * Returns the fragment url or shader name used in the post process.
  92891. * @returns the fragment url or name in the shader store.
  92892. */
  92893. getEffectName(): string;
  92894. /**
  92895. * An event triggered when the postprocess is activated.
  92896. */
  92897. onActivateObservable: Observable<Camera>;
  92898. private _onActivateObserver;
  92899. /**
  92900. * A function that is added to the onActivateObservable
  92901. */
  92902. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92903. /**
  92904. * An event triggered when the postprocess changes its size.
  92905. */
  92906. onSizeChangedObservable: Observable<PostProcess>;
  92907. private _onSizeChangedObserver;
  92908. /**
  92909. * A function that is added to the onSizeChangedObservable
  92910. */
  92911. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92912. /**
  92913. * An event triggered when the postprocess applies its effect.
  92914. */
  92915. onApplyObservable: Observable<Effect>;
  92916. private _onApplyObserver;
  92917. /**
  92918. * A function that is added to the onApplyObservable
  92919. */
  92920. set onApply(callback: (effect: Effect) => void);
  92921. /**
  92922. * An event triggered before rendering the postprocess
  92923. */
  92924. onBeforeRenderObservable: Observable<Effect>;
  92925. private _onBeforeRenderObserver;
  92926. /**
  92927. * A function that is added to the onBeforeRenderObservable
  92928. */
  92929. set onBeforeRender(callback: (effect: Effect) => void);
  92930. /**
  92931. * An event triggered after rendering the postprocess
  92932. */
  92933. onAfterRenderObservable: Observable<Effect>;
  92934. private _onAfterRenderObserver;
  92935. /**
  92936. * A function that is added to the onAfterRenderObservable
  92937. */
  92938. set onAfterRender(callback: (efect: Effect) => void);
  92939. /**
  92940. * 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
  92941. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  92942. */
  92943. get inputTexture(): InternalTexture;
  92944. set inputTexture(value: InternalTexture);
  92945. /**
  92946. * Gets the camera which post process is applied to.
  92947. * @returns The camera the post process is applied to.
  92948. */
  92949. getCamera(): Camera;
  92950. /**
  92951. * Gets the texel size of the postprocess.
  92952. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  92953. */
  92954. get texelSize(): Vector2;
  92955. /**
  92956. * Creates a new instance PostProcess
  92957. * @param name The name of the PostProcess.
  92958. * @param fragmentUrl The url of the fragment shader to be used.
  92959. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  92960. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  92961. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  92962. * @param camera The camera to apply the render pass to.
  92963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92964. * @param engine The engine which the post process will be applied. (default: current engine)
  92965. * @param reusable If the post process can be reused on the same frame. (default: false)
  92966. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  92967. * @param textureType Type of textures used when performing the post process. (default: 0)
  92968. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  92969. * @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
  92970. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  92971. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  92972. */
  92973. constructor(
  92974. /** Name of the PostProcess. */
  92975. 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);
  92976. /**
  92977. * Gets a string idenfifying the name of the class
  92978. * @returns "PostProcess" string
  92979. */
  92980. getClassName(): string;
  92981. /**
  92982. * Gets the engine which this post process belongs to.
  92983. * @returns The engine the post process was enabled with.
  92984. */
  92985. getEngine(): Engine;
  92986. /**
  92987. * The effect that is created when initializing the post process.
  92988. * @returns The created effect corresponding the the postprocess.
  92989. */
  92990. getEffect(): Effect;
  92991. /**
  92992. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  92993. * @param postProcess The post process to share the output with.
  92994. * @returns This post process.
  92995. */
  92996. shareOutputWith(postProcess: PostProcess): PostProcess;
  92997. /**
  92998. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  92999. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93000. */
  93001. useOwnOutput(): void;
  93002. /**
  93003. * Updates the effect with the current post process compile time values and recompiles the shader.
  93004. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93005. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93006. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93007. * @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
  93008. * @param onCompiled Called when the shader has been compiled.
  93009. * @param onError Called if there is an error when compiling a shader.
  93010. */
  93011. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93012. /**
  93013. * The post process is reusable if it can be used multiple times within one frame.
  93014. * @returns If the post process is reusable
  93015. */
  93016. isReusable(): boolean;
  93017. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93018. markTextureDirty(): void;
  93019. /**
  93020. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93021. * 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.
  93022. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93023. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93024. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93025. * @returns The target texture that was bound to be written to.
  93026. */
  93027. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93028. /**
  93029. * If the post process is supported.
  93030. */
  93031. get isSupported(): boolean;
  93032. /**
  93033. * The aspect ratio of the output texture.
  93034. */
  93035. get aspectRatio(): number;
  93036. /**
  93037. * Get a value indicating if the post-process is ready to be used
  93038. * @returns true if the post-process is ready (shader is compiled)
  93039. */
  93040. isReady(): boolean;
  93041. /**
  93042. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93043. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93044. */
  93045. apply(): Nullable<Effect>;
  93046. private _disposeTextures;
  93047. /**
  93048. * Disposes the post process.
  93049. * @param camera The camera to dispose the post process on.
  93050. */
  93051. dispose(camera?: Camera): void;
  93052. }
  93053. }
  93054. declare module BABYLON {
  93055. /** @hidden */
  93056. export var kernelBlurVaryingDeclaration: {
  93057. name: string;
  93058. shader: string;
  93059. };
  93060. }
  93061. declare module BABYLON {
  93062. /** @hidden */
  93063. export var kernelBlurFragment: {
  93064. name: string;
  93065. shader: string;
  93066. };
  93067. }
  93068. declare module BABYLON {
  93069. /** @hidden */
  93070. export var kernelBlurFragment2: {
  93071. name: string;
  93072. shader: string;
  93073. };
  93074. }
  93075. declare module BABYLON {
  93076. /** @hidden */
  93077. export var kernelBlurPixelShader: {
  93078. name: string;
  93079. shader: string;
  93080. };
  93081. }
  93082. declare module BABYLON {
  93083. /** @hidden */
  93084. export var kernelBlurVertex: {
  93085. name: string;
  93086. shader: string;
  93087. };
  93088. }
  93089. declare module BABYLON {
  93090. /** @hidden */
  93091. export var kernelBlurVertexShader: {
  93092. name: string;
  93093. shader: string;
  93094. };
  93095. }
  93096. declare module BABYLON {
  93097. /**
  93098. * The Blur Post Process which blurs an image based on a kernel and direction.
  93099. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93100. */
  93101. export class BlurPostProcess extends PostProcess {
  93102. /** The direction in which to blur the image. */
  93103. direction: Vector2;
  93104. private blockCompilation;
  93105. protected _kernel: number;
  93106. protected _idealKernel: number;
  93107. protected _packedFloat: boolean;
  93108. private _staticDefines;
  93109. /**
  93110. * Sets the length in pixels of the blur sample region
  93111. */
  93112. set kernel(v: number);
  93113. /**
  93114. * Gets the length in pixels of the blur sample region
  93115. */
  93116. get kernel(): number;
  93117. /**
  93118. * Sets wether or not the blur needs to unpack/repack floats
  93119. */
  93120. set packedFloat(v: boolean);
  93121. /**
  93122. * Gets wether or not the blur is unpacking/repacking floats
  93123. */
  93124. get packedFloat(): boolean;
  93125. /**
  93126. * Creates a new instance BlurPostProcess
  93127. * @param name The name of the effect.
  93128. * @param direction The direction in which to blur the image.
  93129. * @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.
  93130. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93131. * @param camera The camera to apply the render pass to.
  93132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93133. * @param engine The engine which the post process will be applied. (default: current engine)
  93134. * @param reusable If the post process can be reused on the same frame. (default: false)
  93135. * @param textureType Type of textures used when performing the post process. (default: 0)
  93136. * @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)
  93137. */
  93138. constructor(name: string,
  93139. /** The direction in which to blur the image. */
  93140. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93141. /**
  93142. * Updates the effect with the current post process compile time values and recompiles the shader.
  93143. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93144. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93145. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93146. * @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
  93147. * @param onCompiled Called when the shader has been compiled.
  93148. * @param onError Called if there is an error when compiling a shader.
  93149. */
  93150. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93151. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93152. /**
  93153. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93154. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93155. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93156. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93157. * The gaps between physical kernels are compensated for in the weighting of the samples
  93158. * @param idealKernel Ideal blur kernel.
  93159. * @return Nearest best kernel.
  93160. */
  93161. protected _nearestBestKernel(idealKernel: number): number;
  93162. /**
  93163. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93164. * @param x The point on the Gaussian distribution to sample.
  93165. * @return the value of the Gaussian function at x.
  93166. */
  93167. protected _gaussianWeight(x: number): number;
  93168. /**
  93169. * Generates a string that can be used as a floating point number in GLSL.
  93170. * @param x Value to print.
  93171. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93172. * @return GLSL float string.
  93173. */
  93174. protected _glslFloat(x: number, decimalFigures?: number): string;
  93175. }
  93176. }
  93177. declare module BABYLON {
  93178. /**
  93179. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93180. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93181. * You can then easily use it as a reflectionTexture on a flat surface.
  93182. * In case the surface is not a plane, please consider relying on reflection probes.
  93183. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93184. */
  93185. export class MirrorTexture extends RenderTargetTexture {
  93186. private scene;
  93187. /**
  93188. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93189. * 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.
  93190. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93191. */
  93192. mirrorPlane: Plane;
  93193. /**
  93194. * Define the blur ratio used to blur the reflection if needed.
  93195. */
  93196. set blurRatio(value: number);
  93197. get blurRatio(): number;
  93198. /**
  93199. * Define the adaptive blur kernel used to blur the reflection if needed.
  93200. * This will autocompute the closest best match for the `blurKernel`
  93201. */
  93202. set adaptiveBlurKernel(value: number);
  93203. /**
  93204. * Define the blur kernel used to blur the reflection if needed.
  93205. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93206. */
  93207. set blurKernel(value: number);
  93208. /**
  93209. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93210. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93211. */
  93212. set blurKernelX(value: number);
  93213. get blurKernelX(): number;
  93214. /**
  93215. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93216. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93217. */
  93218. set blurKernelY(value: number);
  93219. get blurKernelY(): number;
  93220. private _autoComputeBlurKernel;
  93221. protected _onRatioRescale(): void;
  93222. private _updateGammaSpace;
  93223. private _imageProcessingConfigChangeObserver;
  93224. private _transformMatrix;
  93225. private _mirrorMatrix;
  93226. private _savedViewMatrix;
  93227. private _blurX;
  93228. private _blurY;
  93229. private _adaptiveBlurKernel;
  93230. private _blurKernelX;
  93231. private _blurKernelY;
  93232. private _blurRatio;
  93233. /**
  93234. * Instantiates a Mirror Texture.
  93235. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93236. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93237. * You can then easily use it as a reflectionTexture on a flat surface.
  93238. * In case the surface is not a plane, please consider relying on reflection probes.
  93239. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93240. * @param name
  93241. * @param size
  93242. * @param scene
  93243. * @param generateMipMaps
  93244. * @param type
  93245. * @param samplingMode
  93246. * @param generateDepthBuffer
  93247. */
  93248. constructor(name: string, size: number | {
  93249. width: number;
  93250. height: number;
  93251. } | {
  93252. ratio: number;
  93253. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93254. private _preparePostProcesses;
  93255. /**
  93256. * Clone the mirror texture.
  93257. * @returns the cloned texture
  93258. */
  93259. clone(): MirrorTexture;
  93260. /**
  93261. * Serialize the texture to a JSON representation you could use in Parse later on
  93262. * @returns the serialized JSON representation
  93263. */
  93264. serialize(): any;
  93265. /**
  93266. * Dispose the texture and release its associated resources.
  93267. */
  93268. dispose(): void;
  93269. }
  93270. }
  93271. declare module BABYLON {
  93272. /**
  93273. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93274. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93275. */
  93276. export class Texture extends BaseTexture {
  93277. /**
  93278. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93279. */
  93280. static SerializeBuffers: boolean;
  93281. /** @hidden */
  93282. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93283. /** @hidden */
  93284. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93285. /** @hidden */
  93286. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93287. /** nearest is mag = nearest and min = nearest and mip = linear */
  93288. static readonly NEAREST_SAMPLINGMODE: number;
  93289. /** nearest is mag = nearest and min = nearest and mip = linear */
  93290. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93291. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93292. static readonly BILINEAR_SAMPLINGMODE: number;
  93293. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93294. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93295. /** Trilinear is mag = linear and min = linear and mip = linear */
  93296. static readonly TRILINEAR_SAMPLINGMODE: number;
  93297. /** Trilinear is mag = linear and min = linear and mip = linear */
  93298. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93299. /** mag = nearest and min = nearest and mip = nearest */
  93300. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93301. /** mag = nearest and min = linear and mip = nearest */
  93302. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93303. /** mag = nearest and min = linear and mip = linear */
  93304. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93305. /** mag = nearest and min = linear and mip = none */
  93306. static readonly NEAREST_LINEAR: number;
  93307. /** mag = nearest and min = nearest and mip = none */
  93308. static readonly NEAREST_NEAREST: number;
  93309. /** mag = linear and min = nearest and mip = nearest */
  93310. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93311. /** mag = linear and min = nearest and mip = linear */
  93312. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93313. /** mag = linear and min = linear and mip = none */
  93314. static readonly LINEAR_LINEAR: number;
  93315. /** mag = linear and min = nearest and mip = none */
  93316. static readonly LINEAR_NEAREST: number;
  93317. /** Explicit coordinates mode */
  93318. static readonly EXPLICIT_MODE: number;
  93319. /** Spherical coordinates mode */
  93320. static readonly SPHERICAL_MODE: number;
  93321. /** Planar coordinates mode */
  93322. static readonly PLANAR_MODE: number;
  93323. /** Cubic coordinates mode */
  93324. static readonly CUBIC_MODE: number;
  93325. /** Projection coordinates mode */
  93326. static readonly PROJECTION_MODE: number;
  93327. /** Inverse Cubic coordinates mode */
  93328. static readonly SKYBOX_MODE: number;
  93329. /** Inverse Cubic coordinates mode */
  93330. static readonly INVCUBIC_MODE: number;
  93331. /** Equirectangular coordinates mode */
  93332. static readonly EQUIRECTANGULAR_MODE: number;
  93333. /** Equirectangular Fixed coordinates mode */
  93334. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93335. /** Equirectangular Fixed Mirrored coordinates mode */
  93336. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93337. /** Texture is not repeating outside of 0..1 UVs */
  93338. static readonly CLAMP_ADDRESSMODE: number;
  93339. /** Texture is repeating outside of 0..1 UVs */
  93340. static readonly WRAP_ADDRESSMODE: number;
  93341. /** Texture is repeating and mirrored */
  93342. static readonly MIRROR_ADDRESSMODE: number;
  93343. /**
  93344. * 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
  93345. */
  93346. static UseSerializedUrlIfAny: boolean;
  93347. /**
  93348. * Define the url of the texture.
  93349. */
  93350. url: Nullable<string>;
  93351. /**
  93352. * Define an offset on the texture to offset the u coordinates of the UVs
  93353. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93354. */
  93355. uOffset: number;
  93356. /**
  93357. * Define an offset on the texture to offset the v coordinates of the UVs
  93358. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93359. */
  93360. vOffset: number;
  93361. /**
  93362. * Define an offset on the texture to scale the u coordinates of the UVs
  93363. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93364. */
  93365. uScale: number;
  93366. /**
  93367. * Define an offset on the texture to scale the v coordinates of the UVs
  93368. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93369. */
  93370. vScale: number;
  93371. /**
  93372. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93373. * @see http://doc.babylonjs.com/how_to/more_materials
  93374. */
  93375. uAng: number;
  93376. /**
  93377. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93378. * @see http://doc.babylonjs.com/how_to/more_materials
  93379. */
  93380. vAng: number;
  93381. /**
  93382. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93383. * @see http://doc.babylonjs.com/how_to/more_materials
  93384. */
  93385. wAng: number;
  93386. /**
  93387. * Defines the center of rotation (U)
  93388. */
  93389. uRotationCenter: number;
  93390. /**
  93391. * Defines the center of rotation (V)
  93392. */
  93393. vRotationCenter: number;
  93394. /**
  93395. * Defines the center of rotation (W)
  93396. */
  93397. wRotationCenter: number;
  93398. /**
  93399. * Are mip maps generated for this texture or not.
  93400. */
  93401. get noMipmap(): boolean;
  93402. /**
  93403. * List of inspectable custom properties (used by the Inspector)
  93404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93405. */
  93406. inspectableCustomProperties: Nullable<IInspectable[]>;
  93407. private _noMipmap;
  93408. /** @hidden */
  93409. _invertY: boolean;
  93410. private _rowGenerationMatrix;
  93411. private _cachedTextureMatrix;
  93412. private _projectionModeMatrix;
  93413. private _t0;
  93414. private _t1;
  93415. private _t2;
  93416. private _cachedUOffset;
  93417. private _cachedVOffset;
  93418. private _cachedUScale;
  93419. private _cachedVScale;
  93420. private _cachedUAng;
  93421. private _cachedVAng;
  93422. private _cachedWAng;
  93423. private _cachedProjectionMatrixId;
  93424. private _cachedCoordinatesMode;
  93425. /** @hidden */
  93426. protected _initialSamplingMode: number;
  93427. /** @hidden */
  93428. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93429. private _deleteBuffer;
  93430. protected _format: Nullable<number>;
  93431. private _delayedOnLoad;
  93432. private _delayedOnError;
  93433. private _mimeType?;
  93434. /**
  93435. * Observable triggered once the texture has been loaded.
  93436. */
  93437. onLoadObservable: Observable<Texture>;
  93438. protected _isBlocking: boolean;
  93439. /**
  93440. * Is the texture preventing material to render while loading.
  93441. * If false, a default texture will be used instead of the loading one during the preparation step.
  93442. */
  93443. set isBlocking(value: boolean);
  93444. get isBlocking(): boolean;
  93445. /**
  93446. * Get the current sampling mode associated with the texture.
  93447. */
  93448. get samplingMode(): number;
  93449. /**
  93450. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93451. */
  93452. get invertY(): boolean;
  93453. /**
  93454. * Instantiates a new texture.
  93455. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93456. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93457. * @param url defines the url of the picture to load as a texture
  93458. * @param scene defines the scene or engine the texture will belong to
  93459. * @param noMipmap defines if the texture will require mip maps or not
  93460. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93461. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93462. * @param onLoad defines a callback triggered when the texture has been loaded
  93463. * @param onError defines a callback triggered when an error occurred during the loading session
  93464. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93465. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93466. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93467. * @param mimeType defines an optional mime type information
  93468. */
  93469. 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);
  93470. /**
  93471. * Update the url (and optional buffer) of this texture if url was null during construction.
  93472. * @param url the url of the texture
  93473. * @param buffer the buffer of the texture (defaults to null)
  93474. * @param onLoad callback called when the texture is loaded (defaults to null)
  93475. */
  93476. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93477. /**
  93478. * Finish the loading sequence of a texture flagged as delayed load.
  93479. * @hidden
  93480. */
  93481. delayLoad(): void;
  93482. private _prepareRowForTextureGeneration;
  93483. /**
  93484. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93485. * @returns the transform matrix of the texture.
  93486. */
  93487. getTextureMatrix(uBase?: number): Matrix;
  93488. /**
  93489. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93490. * @returns The reflection texture transform
  93491. */
  93492. getReflectionTextureMatrix(): Matrix;
  93493. /**
  93494. * Clones the texture.
  93495. * @returns the cloned texture
  93496. */
  93497. clone(): Texture;
  93498. /**
  93499. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93500. * @returns The JSON representation of the texture
  93501. */
  93502. serialize(): any;
  93503. /**
  93504. * Get the current class name of the texture useful for serialization or dynamic coding.
  93505. * @returns "Texture"
  93506. */
  93507. getClassName(): string;
  93508. /**
  93509. * Dispose the texture and release its associated resources.
  93510. */
  93511. dispose(): void;
  93512. /**
  93513. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93514. * @param parsedTexture Define the JSON representation of the texture
  93515. * @param scene Define the scene the parsed texture should be instantiated in
  93516. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93517. * @returns The parsed texture if successful
  93518. */
  93519. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93520. /**
  93521. * Creates a texture from its base 64 representation.
  93522. * @param data Define the base64 payload without the data: prefix
  93523. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93524. * @param scene Define the scene the texture should belong to
  93525. * @param noMipmap Forces the texture to not create mip map information if true
  93526. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93527. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93528. * @param onLoad define a callback triggered when the texture has been loaded
  93529. * @param onError define a callback triggered when an error occurred during the loading session
  93530. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93531. * @returns the created texture
  93532. */
  93533. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93534. /**
  93535. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93536. * @param data Define the base64 payload without the data: prefix
  93537. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93538. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93539. * @param scene Define the scene the texture should belong to
  93540. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93541. * @param noMipmap Forces the texture to not create mip map information if true
  93542. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93543. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93544. * @param onLoad define a callback triggered when the texture has been loaded
  93545. * @param onError define a callback triggered when an error occurred during the loading session
  93546. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93547. * @returns the created texture
  93548. */
  93549. 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;
  93550. }
  93551. }
  93552. declare module BABYLON {
  93553. /**
  93554. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93555. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93556. */
  93557. export class PostProcessManager {
  93558. private _scene;
  93559. private _indexBuffer;
  93560. private _vertexBuffers;
  93561. /**
  93562. * Creates a new instance PostProcess
  93563. * @param scene The scene that the post process is associated with.
  93564. */
  93565. constructor(scene: Scene);
  93566. private _prepareBuffers;
  93567. private _buildIndexBuffer;
  93568. /**
  93569. * Rebuilds the vertex buffers of the manager.
  93570. * @hidden
  93571. */
  93572. _rebuild(): void;
  93573. /**
  93574. * Prepares a frame to be run through a post process.
  93575. * @param sourceTexture The input texture to the post procesess. (default: null)
  93576. * @param postProcesses An array of post processes to be run. (default: null)
  93577. * @returns True if the post processes were able to be run.
  93578. * @hidden
  93579. */
  93580. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93581. /**
  93582. * Manually render a set of post processes to a texture.
  93583. * @param postProcesses An array of post processes to be run.
  93584. * @param targetTexture The target texture to render to.
  93585. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93586. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93587. * @param lodLevel defines which lod of the texture to render to
  93588. */
  93589. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93590. /**
  93591. * Finalize the result of the output of the postprocesses.
  93592. * @param doNotPresent If true the result will not be displayed to the screen.
  93593. * @param targetTexture The target texture to render to.
  93594. * @param faceIndex The index of the face to bind the target texture to.
  93595. * @param postProcesses The array of post processes to render.
  93596. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93597. * @hidden
  93598. */
  93599. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93600. /**
  93601. * Disposes of the post process manager.
  93602. */
  93603. dispose(): void;
  93604. }
  93605. }
  93606. declare module BABYLON {
  93607. /**
  93608. * This Helps creating a texture that will be created from a camera in your scene.
  93609. * It is basically a dynamic texture that could be used to create special effects for instance.
  93610. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93611. */
  93612. export class RenderTargetTexture extends Texture {
  93613. isCube: boolean;
  93614. /**
  93615. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93616. */
  93617. static readonly REFRESHRATE_RENDER_ONCE: number;
  93618. /**
  93619. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93620. */
  93621. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93622. /**
  93623. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93624. * the central point of your effect and can save a lot of performances.
  93625. */
  93626. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93627. /**
  93628. * Use this predicate to dynamically define the list of mesh you want to render.
  93629. * If set, the renderList property will be overwritten.
  93630. */
  93631. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93632. private _renderList;
  93633. /**
  93634. * Use this list to define the list of mesh you want to render.
  93635. */
  93636. get renderList(): Nullable<Array<AbstractMesh>>;
  93637. set renderList(value: Nullable<Array<AbstractMesh>>);
  93638. /**
  93639. * Use this function to overload the renderList array at rendering time.
  93640. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93641. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93642. * the cube (if the RTT is a cube, else layerOrFace=0).
  93643. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93644. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93645. * hold dummy elements!
  93646. */
  93647. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93648. private _hookArray;
  93649. /**
  93650. * Define if particles should be rendered in your texture.
  93651. */
  93652. renderParticles: boolean;
  93653. /**
  93654. * Define if sprites should be rendered in your texture.
  93655. */
  93656. renderSprites: boolean;
  93657. /**
  93658. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93659. */
  93660. coordinatesMode: number;
  93661. /**
  93662. * Define the camera used to render the texture.
  93663. */
  93664. activeCamera: Nullable<Camera>;
  93665. /**
  93666. * Override the render function of the texture with your own one.
  93667. */
  93668. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93669. /**
  93670. * Define if camera post processes should be use while rendering the texture.
  93671. */
  93672. useCameraPostProcesses: boolean;
  93673. /**
  93674. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93675. */
  93676. ignoreCameraViewport: boolean;
  93677. private _postProcessManager;
  93678. private _postProcesses;
  93679. private _resizeObserver;
  93680. /**
  93681. * An event triggered when the texture is unbind.
  93682. */
  93683. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93684. /**
  93685. * An event triggered when the texture is unbind.
  93686. */
  93687. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93688. private _onAfterUnbindObserver;
  93689. /**
  93690. * Set a after unbind callback in the texture.
  93691. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93692. */
  93693. set onAfterUnbind(callback: () => void);
  93694. /**
  93695. * An event triggered before rendering the texture
  93696. */
  93697. onBeforeRenderObservable: Observable<number>;
  93698. private _onBeforeRenderObserver;
  93699. /**
  93700. * Set a before render callback in the texture.
  93701. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93702. */
  93703. set onBeforeRender(callback: (faceIndex: number) => void);
  93704. /**
  93705. * An event triggered after rendering the texture
  93706. */
  93707. onAfterRenderObservable: Observable<number>;
  93708. private _onAfterRenderObserver;
  93709. /**
  93710. * Set a after render callback in the texture.
  93711. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93712. */
  93713. set onAfterRender(callback: (faceIndex: number) => void);
  93714. /**
  93715. * An event triggered after the texture clear
  93716. */
  93717. onClearObservable: Observable<Engine>;
  93718. private _onClearObserver;
  93719. /**
  93720. * Set a clear callback in the texture.
  93721. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93722. */
  93723. set onClear(callback: (Engine: Engine) => void);
  93724. /**
  93725. * An event triggered when the texture is resized.
  93726. */
  93727. onResizeObservable: Observable<RenderTargetTexture>;
  93728. /**
  93729. * Define the clear color of the Render Target if it should be different from the scene.
  93730. */
  93731. clearColor: Color4;
  93732. protected _size: number | {
  93733. width: number;
  93734. height: number;
  93735. layers?: number;
  93736. };
  93737. protected _initialSizeParameter: number | {
  93738. width: number;
  93739. height: number;
  93740. } | {
  93741. ratio: number;
  93742. };
  93743. protected _sizeRatio: Nullable<number>;
  93744. /** @hidden */
  93745. _generateMipMaps: boolean;
  93746. protected _renderingManager: RenderingManager;
  93747. /** @hidden */
  93748. _waitingRenderList: string[];
  93749. protected _doNotChangeAspectRatio: boolean;
  93750. protected _currentRefreshId: number;
  93751. protected _refreshRate: number;
  93752. protected _textureMatrix: Matrix;
  93753. protected _samples: number;
  93754. protected _renderTargetOptions: RenderTargetCreationOptions;
  93755. /**
  93756. * Gets render target creation options that were used.
  93757. */
  93758. get renderTargetOptions(): RenderTargetCreationOptions;
  93759. protected _engine: Engine;
  93760. protected _onRatioRescale(): void;
  93761. /**
  93762. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93763. * It must define where the camera used to render the texture is set
  93764. */
  93765. boundingBoxPosition: Vector3;
  93766. private _boundingBoxSize;
  93767. /**
  93768. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93769. * When defined, the cubemap will switch to local mode
  93770. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93771. * @example https://www.babylonjs-playground.com/#RNASML
  93772. */
  93773. set boundingBoxSize(value: Vector3);
  93774. get boundingBoxSize(): Vector3;
  93775. /**
  93776. * In case the RTT has been created with a depth texture, get the associated
  93777. * depth texture.
  93778. * Otherwise, return null.
  93779. */
  93780. get depthStencilTexture(): Nullable<InternalTexture>;
  93781. /**
  93782. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93783. * or used a shadow, depth texture...
  93784. * @param name The friendly name of the texture
  93785. * @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)
  93786. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93787. * @param generateMipMaps True if mip maps need to be generated after render.
  93788. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93789. * @param type The type of the buffer in the RTT (int, half float, float...)
  93790. * @param isCube True if a cube texture needs to be created
  93791. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93792. * @param generateDepthBuffer True to generate a depth buffer
  93793. * @param generateStencilBuffer True to generate a stencil buffer
  93794. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93795. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93796. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93797. */
  93798. constructor(name: string, size: number | {
  93799. width: number;
  93800. height: number;
  93801. layers?: number;
  93802. } | {
  93803. ratio: number;
  93804. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93805. /**
  93806. * Creates a depth stencil texture.
  93807. * This is only available in WebGL 2 or with the depth texture extension available.
  93808. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93809. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93810. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93811. */
  93812. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93813. private _processSizeParameter;
  93814. /**
  93815. * Define the number of samples to use in case of MSAA.
  93816. * It defaults to one meaning no MSAA has been enabled.
  93817. */
  93818. get samples(): number;
  93819. set samples(value: number);
  93820. /**
  93821. * Resets the refresh counter of the texture and start bak from scratch.
  93822. * Could be useful to regenerate the texture if it is setup to render only once.
  93823. */
  93824. resetRefreshCounter(): void;
  93825. /**
  93826. * Define the refresh rate of the texture or the rendering frequency.
  93827. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93828. */
  93829. get refreshRate(): number;
  93830. set refreshRate(value: number);
  93831. /**
  93832. * Adds a post process to the render target rendering passes.
  93833. * @param postProcess define the post process to add
  93834. */
  93835. addPostProcess(postProcess: PostProcess): void;
  93836. /**
  93837. * Clear all the post processes attached to the render target
  93838. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93839. */
  93840. clearPostProcesses(dispose?: boolean): void;
  93841. /**
  93842. * Remove one of the post process from the list of attached post processes to the texture
  93843. * @param postProcess define the post process to remove from the list
  93844. */
  93845. removePostProcess(postProcess: PostProcess): void;
  93846. /** @hidden */
  93847. _shouldRender(): boolean;
  93848. /**
  93849. * Gets the actual render size of the texture.
  93850. * @returns the width of the render size
  93851. */
  93852. getRenderSize(): number;
  93853. /**
  93854. * Gets the actual render width of the texture.
  93855. * @returns the width of the render size
  93856. */
  93857. getRenderWidth(): number;
  93858. /**
  93859. * Gets the actual render height of the texture.
  93860. * @returns the height of the render size
  93861. */
  93862. getRenderHeight(): number;
  93863. /**
  93864. * Gets the actual number of layers of the texture.
  93865. * @returns the number of layers
  93866. */
  93867. getRenderLayers(): number;
  93868. /**
  93869. * Get if the texture can be rescaled or not.
  93870. */
  93871. get canRescale(): boolean;
  93872. /**
  93873. * Resize the texture using a ratio.
  93874. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93875. */
  93876. scale(ratio: number): void;
  93877. /**
  93878. * Get the texture reflection matrix used to rotate/transform the reflection.
  93879. * @returns the reflection matrix
  93880. */
  93881. getReflectionTextureMatrix(): Matrix;
  93882. /**
  93883. * Resize the texture to a new desired size.
  93884. * Be carrefull as it will recreate all the data in the new texture.
  93885. * @param size Define the new size. It can be:
  93886. * - a number for squared texture,
  93887. * - an object containing { width: number, height: number }
  93888. * - or an object containing a ratio { ratio: number }
  93889. */
  93890. resize(size: number | {
  93891. width: number;
  93892. height: number;
  93893. } | {
  93894. ratio: number;
  93895. }): void;
  93896. private _defaultRenderListPrepared;
  93897. /**
  93898. * Renders all the objects from the render list into the texture.
  93899. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93900. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93901. */
  93902. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93903. private _bestReflectionRenderTargetDimension;
  93904. private _prepareRenderingManager;
  93905. /**
  93906. * @hidden
  93907. * @param faceIndex face index to bind to if this is a cubetexture
  93908. * @param layer defines the index of the texture to bind in the array
  93909. */
  93910. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93911. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93912. private renderToTarget;
  93913. /**
  93914. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93915. * This allowed control for front to back rendering or reversly depending of the special needs.
  93916. *
  93917. * @param renderingGroupId The rendering group id corresponding to its index
  93918. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93919. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93920. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93921. */
  93922. 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;
  93923. /**
  93924. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93925. *
  93926. * @param renderingGroupId The rendering group id corresponding to its index
  93927. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93928. */
  93929. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93930. /**
  93931. * Clones the texture.
  93932. * @returns the cloned texture
  93933. */
  93934. clone(): RenderTargetTexture;
  93935. /**
  93936. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93937. * @returns The JSON representation of the texture
  93938. */
  93939. serialize(): any;
  93940. /**
  93941. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93942. */
  93943. disposeFramebufferObjects(): void;
  93944. /**
  93945. * Dispose the texture and release its associated resources.
  93946. */
  93947. dispose(): void;
  93948. /** @hidden */
  93949. _rebuild(): void;
  93950. /**
  93951. * Clear the info related to rendering groups preventing retention point in material dispose.
  93952. */
  93953. freeRenderingGroups(): void;
  93954. /**
  93955. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93956. * @returns the view count
  93957. */
  93958. getViewCount(): number;
  93959. }
  93960. }
  93961. declare module BABYLON {
  93962. /**
  93963. * Options for compiling materials.
  93964. */
  93965. export interface IMaterialCompilationOptions {
  93966. /**
  93967. * Defines whether clip planes are enabled.
  93968. */
  93969. clipPlane: boolean;
  93970. /**
  93971. * Defines whether instances are enabled.
  93972. */
  93973. useInstances: boolean;
  93974. }
  93975. /**
  93976. * Base class for the main features of a material in Babylon.js
  93977. */
  93978. export class Material implements IAnimatable {
  93979. /**
  93980. * Returns the triangle fill mode
  93981. */
  93982. static readonly TriangleFillMode: number;
  93983. /**
  93984. * Returns the wireframe mode
  93985. */
  93986. static readonly WireFrameFillMode: number;
  93987. /**
  93988. * Returns the point fill mode
  93989. */
  93990. static readonly PointFillMode: number;
  93991. /**
  93992. * Returns the point list draw mode
  93993. */
  93994. static readonly PointListDrawMode: number;
  93995. /**
  93996. * Returns the line list draw mode
  93997. */
  93998. static readonly LineListDrawMode: number;
  93999. /**
  94000. * Returns the line loop draw mode
  94001. */
  94002. static readonly LineLoopDrawMode: number;
  94003. /**
  94004. * Returns the line strip draw mode
  94005. */
  94006. static readonly LineStripDrawMode: number;
  94007. /**
  94008. * Returns the triangle strip draw mode
  94009. */
  94010. static readonly TriangleStripDrawMode: number;
  94011. /**
  94012. * Returns the triangle fan draw mode
  94013. */
  94014. static readonly TriangleFanDrawMode: number;
  94015. /**
  94016. * Stores the clock-wise side orientation
  94017. */
  94018. static readonly ClockWiseSideOrientation: number;
  94019. /**
  94020. * Stores the counter clock-wise side orientation
  94021. */
  94022. static readonly CounterClockWiseSideOrientation: number;
  94023. /**
  94024. * The dirty texture flag value
  94025. */
  94026. static readonly TextureDirtyFlag: number;
  94027. /**
  94028. * The dirty light flag value
  94029. */
  94030. static readonly LightDirtyFlag: number;
  94031. /**
  94032. * The dirty fresnel flag value
  94033. */
  94034. static readonly FresnelDirtyFlag: number;
  94035. /**
  94036. * The dirty attribute flag value
  94037. */
  94038. static readonly AttributesDirtyFlag: number;
  94039. /**
  94040. * The dirty misc flag value
  94041. */
  94042. static readonly MiscDirtyFlag: number;
  94043. /**
  94044. * The all dirty flag value
  94045. */
  94046. static readonly AllDirtyFlag: number;
  94047. /**
  94048. * The ID of the material
  94049. */
  94050. id: string;
  94051. /**
  94052. * Gets or sets the unique id of the material
  94053. */
  94054. uniqueId: number;
  94055. /**
  94056. * The name of the material
  94057. */
  94058. name: string;
  94059. /**
  94060. * Gets or sets user defined metadata
  94061. */
  94062. metadata: any;
  94063. /**
  94064. * For internal use only. Please do not use.
  94065. */
  94066. reservedDataStore: any;
  94067. /**
  94068. * Specifies if the ready state should be checked on each call
  94069. */
  94070. checkReadyOnEveryCall: boolean;
  94071. /**
  94072. * Specifies if the ready state should be checked once
  94073. */
  94074. checkReadyOnlyOnce: boolean;
  94075. /**
  94076. * The state of the material
  94077. */
  94078. state: string;
  94079. /**
  94080. * The alpha value of the material
  94081. */
  94082. protected _alpha: number;
  94083. /**
  94084. * List of inspectable custom properties (used by the Inspector)
  94085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94086. */
  94087. inspectableCustomProperties: IInspectable[];
  94088. /**
  94089. * Sets the alpha value of the material
  94090. */
  94091. set alpha(value: number);
  94092. /**
  94093. * Gets the alpha value of the material
  94094. */
  94095. get alpha(): number;
  94096. /**
  94097. * Specifies if back face culling is enabled
  94098. */
  94099. protected _backFaceCulling: boolean;
  94100. /**
  94101. * Sets the back-face culling state
  94102. */
  94103. set backFaceCulling(value: boolean);
  94104. /**
  94105. * Gets the back-face culling state
  94106. */
  94107. get backFaceCulling(): boolean;
  94108. /**
  94109. * Stores the value for side orientation
  94110. */
  94111. sideOrientation: number;
  94112. /**
  94113. * Callback triggered when the material is compiled
  94114. */
  94115. onCompiled: Nullable<(effect: Effect) => void>;
  94116. /**
  94117. * Callback triggered when an error occurs
  94118. */
  94119. onError: Nullable<(effect: Effect, errors: string) => void>;
  94120. /**
  94121. * Callback triggered to get the render target textures
  94122. */
  94123. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94124. /**
  94125. * Gets a boolean indicating that current material needs to register RTT
  94126. */
  94127. get hasRenderTargetTextures(): boolean;
  94128. /**
  94129. * Specifies if the material should be serialized
  94130. */
  94131. doNotSerialize: boolean;
  94132. /**
  94133. * @hidden
  94134. */
  94135. _storeEffectOnSubMeshes: boolean;
  94136. /**
  94137. * Stores the animations for the material
  94138. */
  94139. animations: Nullable<Array<Animation>>;
  94140. /**
  94141. * An event triggered when the material is disposed
  94142. */
  94143. onDisposeObservable: Observable<Material>;
  94144. /**
  94145. * An observer which watches for dispose events
  94146. */
  94147. private _onDisposeObserver;
  94148. private _onUnBindObservable;
  94149. /**
  94150. * Called during a dispose event
  94151. */
  94152. set onDispose(callback: () => void);
  94153. private _onBindObservable;
  94154. /**
  94155. * An event triggered when the material is bound
  94156. */
  94157. get onBindObservable(): Observable<AbstractMesh>;
  94158. /**
  94159. * An observer which watches for bind events
  94160. */
  94161. private _onBindObserver;
  94162. /**
  94163. * Called during a bind event
  94164. */
  94165. set onBind(callback: (Mesh: AbstractMesh) => void);
  94166. /**
  94167. * An event triggered when the material is unbound
  94168. */
  94169. get onUnBindObservable(): Observable<Material>;
  94170. /**
  94171. * Stores the value of the alpha mode
  94172. */
  94173. private _alphaMode;
  94174. /**
  94175. * Sets the value of the alpha mode.
  94176. *
  94177. * | Value | Type | Description |
  94178. * | --- | --- | --- |
  94179. * | 0 | ALPHA_DISABLE | |
  94180. * | 1 | ALPHA_ADD | |
  94181. * | 2 | ALPHA_COMBINE | |
  94182. * | 3 | ALPHA_SUBTRACT | |
  94183. * | 4 | ALPHA_MULTIPLY | |
  94184. * | 5 | ALPHA_MAXIMIZED | |
  94185. * | 6 | ALPHA_ONEONE | |
  94186. * | 7 | ALPHA_PREMULTIPLIED | |
  94187. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94188. * | 9 | ALPHA_INTERPOLATE | |
  94189. * | 10 | ALPHA_SCREENMODE | |
  94190. *
  94191. */
  94192. set alphaMode(value: number);
  94193. /**
  94194. * Gets the value of the alpha mode
  94195. */
  94196. get alphaMode(): number;
  94197. /**
  94198. * Stores the state of the need depth pre-pass value
  94199. */
  94200. private _needDepthPrePass;
  94201. /**
  94202. * Sets the need depth pre-pass value
  94203. */
  94204. set needDepthPrePass(value: boolean);
  94205. /**
  94206. * Gets the depth pre-pass value
  94207. */
  94208. get needDepthPrePass(): boolean;
  94209. /**
  94210. * Specifies if depth writing should be disabled
  94211. */
  94212. disableDepthWrite: boolean;
  94213. /**
  94214. * Specifies if depth writing should be forced
  94215. */
  94216. forceDepthWrite: boolean;
  94217. /**
  94218. * Specifies the depth function that should be used. 0 means the default engine function
  94219. */
  94220. depthFunction: number;
  94221. /**
  94222. * Specifies if there should be a separate pass for culling
  94223. */
  94224. separateCullingPass: boolean;
  94225. /**
  94226. * Stores the state specifing if fog should be enabled
  94227. */
  94228. private _fogEnabled;
  94229. /**
  94230. * Sets the state for enabling fog
  94231. */
  94232. set fogEnabled(value: boolean);
  94233. /**
  94234. * Gets the value of the fog enabled state
  94235. */
  94236. get fogEnabled(): boolean;
  94237. /**
  94238. * Stores the size of points
  94239. */
  94240. pointSize: number;
  94241. /**
  94242. * Stores the z offset value
  94243. */
  94244. zOffset: number;
  94245. /**
  94246. * Gets a value specifying if wireframe mode is enabled
  94247. */
  94248. get wireframe(): boolean;
  94249. /**
  94250. * Sets the state of wireframe mode
  94251. */
  94252. set wireframe(value: boolean);
  94253. /**
  94254. * Gets the value specifying if point clouds are enabled
  94255. */
  94256. get pointsCloud(): boolean;
  94257. /**
  94258. * Sets the state of point cloud mode
  94259. */
  94260. set pointsCloud(value: boolean);
  94261. /**
  94262. * Gets the material fill mode
  94263. */
  94264. get fillMode(): number;
  94265. /**
  94266. * Sets the material fill mode
  94267. */
  94268. set fillMode(value: number);
  94269. /**
  94270. * @hidden
  94271. * Stores the effects for the material
  94272. */
  94273. _effect: Nullable<Effect>;
  94274. /**
  94275. * Specifies if uniform buffers should be used
  94276. */
  94277. private _useUBO;
  94278. /**
  94279. * Stores a reference to the scene
  94280. */
  94281. private _scene;
  94282. /**
  94283. * Stores the fill mode state
  94284. */
  94285. private _fillMode;
  94286. /**
  94287. * Specifies if the depth write state should be cached
  94288. */
  94289. private _cachedDepthWriteState;
  94290. /**
  94291. * Specifies if the depth function state should be cached
  94292. */
  94293. private _cachedDepthFunctionState;
  94294. /**
  94295. * Stores the uniform buffer
  94296. */
  94297. protected _uniformBuffer: UniformBuffer;
  94298. /** @hidden */
  94299. _indexInSceneMaterialArray: number;
  94300. /** @hidden */
  94301. meshMap: Nullable<{
  94302. [id: string]: AbstractMesh | undefined;
  94303. }>;
  94304. /**
  94305. * Creates a material instance
  94306. * @param name defines the name of the material
  94307. * @param scene defines the scene to reference
  94308. * @param doNotAdd specifies if the material should be added to the scene
  94309. */
  94310. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94311. /**
  94312. * Returns a string representation of the current material
  94313. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94314. * @returns a string with material information
  94315. */
  94316. toString(fullDetails?: boolean): string;
  94317. /**
  94318. * Gets the class name of the material
  94319. * @returns a string with the class name of the material
  94320. */
  94321. getClassName(): string;
  94322. /**
  94323. * Specifies if updates for the material been locked
  94324. */
  94325. get isFrozen(): boolean;
  94326. /**
  94327. * Locks updates for the material
  94328. */
  94329. freeze(): void;
  94330. /**
  94331. * Unlocks updates for the material
  94332. */
  94333. unfreeze(): void;
  94334. /**
  94335. * Specifies if the material is ready to be used
  94336. * @param mesh defines the mesh to check
  94337. * @param useInstances specifies if instances should be used
  94338. * @returns a boolean indicating if the material is ready to be used
  94339. */
  94340. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94341. /**
  94342. * Specifies that the submesh is ready to be used
  94343. * @param mesh defines the mesh to check
  94344. * @param subMesh defines which submesh to check
  94345. * @param useInstances specifies that instances should be used
  94346. * @returns a boolean indicating that the submesh is ready or not
  94347. */
  94348. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94349. /**
  94350. * Returns the material effect
  94351. * @returns the effect associated with the material
  94352. */
  94353. getEffect(): Nullable<Effect>;
  94354. /**
  94355. * Returns the current scene
  94356. * @returns a Scene
  94357. */
  94358. getScene(): Scene;
  94359. /**
  94360. * Specifies if the material will require alpha blending
  94361. * @returns a boolean specifying if alpha blending is needed
  94362. */
  94363. needAlphaBlending(): boolean;
  94364. /**
  94365. * Specifies if the mesh will require alpha blending
  94366. * @param mesh defines the mesh to check
  94367. * @returns a boolean specifying if alpha blending is needed for the mesh
  94368. */
  94369. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94370. /**
  94371. * Specifies if this material should be rendered in alpha test mode
  94372. * @returns a boolean specifying if an alpha test is needed.
  94373. */
  94374. needAlphaTesting(): boolean;
  94375. /**
  94376. * Gets the texture used for the alpha test
  94377. * @returns the texture to use for alpha testing
  94378. */
  94379. getAlphaTestTexture(): Nullable<BaseTexture>;
  94380. /**
  94381. * Marks the material to indicate that it needs to be re-calculated
  94382. */
  94383. markDirty(): void;
  94384. /** @hidden */
  94385. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94386. /**
  94387. * Binds the material to the mesh
  94388. * @param world defines the world transformation matrix
  94389. * @param mesh defines the mesh to bind the material to
  94390. */
  94391. bind(world: Matrix, mesh?: Mesh): void;
  94392. /**
  94393. * Binds the submesh to the material
  94394. * @param world defines the world transformation matrix
  94395. * @param mesh defines the mesh containing the submesh
  94396. * @param subMesh defines the submesh to bind the material to
  94397. */
  94398. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94399. /**
  94400. * Binds the world matrix to the material
  94401. * @param world defines the world transformation matrix
  94402. */
  94403. bindOnlyWorldMatrix(world: Matrix): void;
  94404. /**
  94405. * Binds the scene's uniform buffer to the effect.
  94406. * @param effect defines the effect to bind to the scene uniform buffer
  94407. * @param sceneUbo defines the uniform buffer storing scene data
  94408. */
  94409. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94410. /**
  94411. * Binds the view matrix to the effect
  94412. * @param effect defines the effect to bind the view matrix to
  94413. */
  94414. bindView(effect: Effect): void;
  94415. /**
  94416. * Binds the view projection matrix to the effect
  94417. * @param effect defines the effect to bind the view projection matrix to
  94418. */
  94419. bindViewProjection(effect: Effect): void;
  94420. /**
  94421. * Specifies if material alpha testing should be turned on for the mesh
  94422. * @param mesh defines the mesh to check
  94423. */
  94424. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94425. /**
  94426. * Processes to execute after binding the material to a mesh
  94427. * @param mesh defines the rendered mesh
  94428. */
  94429. protected _afterBind(mesh?: Mesh): void;
  94430. /**
  94431. * Unbinds the material from the mesh
  94432. */
  94433. unbind(): void;
  94434. /**
  94435. * Gets the active textures from the material
  94436. * @returns an array of textures
  94437. */
  94438. getActiveTextures(): BaseTexture[];
  94439. /**
  94440. * Specifies if the material uses a texture
  94441. * @param texture defines the texture to check against the material
  94442. * @returns a boolean specifying if the material uses the texture
  94443. */
  94444. hasTexture(texture: BaseTexture): boolean;
  94445. /**
  94446. * Makes a duplicate of the material, and gives it a new name
  94447. * @param name defines the new name for the duplicated material
  94448. * @returns the cloned material
  94449. */
  94450. clone(name: string): Nullable<Material>;
  94451. /**
  94452. * Gets the meshes bound to the material
  94453. * @returns an array of meshes bound to the material
  94454. */
  94455. getBindedMeshes(): AbstractMesh[];
  94456. /**
  94457. * Force shader compilation
  94458. * @param mesh defines the mesh associated with this material
  94459. * @param onCompiled defines a function to execute once the material is compiled
  94460. * @param options defines the options to configure the compilation
  94461. * @param onError defines a function to execute if the material fails compiling
  94462. */
  94463. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94464. /**
  94465. * Force shader compilation
  94466. * @param mesh defines the mesh that will use this material
  94467. * @param options defines additional options for compiling the shaders
  94468. * @returns a promise that resolves when the compilation completes
  94469. */
  94470. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94471. private static readonly _AllDirtyCallBack;
  94472. private static readonly _ImageProcessingDirtyCallBack;
  94473. private static readonly _TextureDirtyCallBack;
  94474. private static readonly _FresnelDirtyCallBack;
  94475. private static readonly _MiscDirtyCallBack;
  94476. private static readonly _LightsDirtyCallBack;
  94477. private static readonly _AttributeDirtyCallBack;
  94478. private static _FresnelAndMiscDirtyCallBack;
  94479. private static _TextureAndMiscDirtyCallBack;
  94480. private static readonly _DirtyCallbackArray;
  94481. private static readonly _RunDirtyCallBacks;
  94482. /**
  94483. * Marks a define in the material to indicate that it needs to be re-computed
  94484. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94485. */
  94486. markAsDirty(flag: number): void;
  94487. /**
  94488. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94489. * @param func defines a function which checks material defines against the submeshes
  94490. */
  94491. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94492. /**
  94493. * Indicates that we need to re-calculated for all submeshes
  94494. */
  94495. protected _markAllSubMeshesAsAllDirty(): void;
  94496. /**
  94497. * Indicates that image processing needs to be re-calculated for all submeshes
  94498. */
  94499. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94500. /**
  94501. * Indicates that textures need to be re-calculated for all submeshes
  94502. */
  94503. protected _markAllSubMeshesAsTexturesDirty(): void;
  94504. /**
  94505. * Indicates that fresnel needs to be re-calculated for all submeshes
  94506. */
  94507. protected _markAllSubMeshesAsFresnelDirty(): void;
  94508. /**
  94509. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94510. */
  94511. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94512. /**
  94513. * Indicates that lights need to be re-calculated for all submeshes
  94514. */
  94515. protected _markAllSubMeshesAsLightsDirty(): void;
  94516. /**
  94517. * Indicates that attributes need to be re-calculated for all submeshes
  94518. */
  94519. protected _markAllSubMeshesAsAttributesDirty(): void;
  94520. /**
  94521. * Indicates that misc needs to be re-calculated for all submeshes
  94522. */
  94523. protected _markAllSubMeshesAsMiscDirty(): void;
  94524. /**
  94525. * Indicates that textures and misc need to be re-calculated for all submeshes
  94526. */
  94527. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94528. /**
  94529. * Disposes the material
  94530. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94531. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94532. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94533. */
  94534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94535. /** @hidden */
  94536. private releaseVertexArrayObject;
  94537. /**
  94538. * Serializes this material
  94539. * @returns the serialized material object
  94540. */
  94541. serialize(): any;
  94542. /**
  94543. * Creates a material from parsed material data
  94544. * @param parsedMaterial defines parsed material data
  94545. * @param scene defines the hosting scene
  94546. * @param rootUrl defines the root URL to use to load textures
  94547. * @returns a new material
  94548. */
  94549. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94550. }
  94551. }
  94552. declare module BABYLON {
  94553. /**
  94554. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94555. * separate meshes. This can be use to improve performances.
  94556. * @see http://doc.babylonjs.com/how_to/multi_materials
  94557. */
  94558. export class MultiMaterial extends Material {
  94559. private _subMaterials;
  94560. /**
  94561. * Gets or Sets the list of Materials used within the multi material.
  94562. * They need to be ordered according to the submeshes order in the associated mesh
  94563. */
  94564. get subMaterials(): Nullable<Material>[];
  94565. set subMaterials(value: Nullable<Material>[]);
  94566. /**
  94567. * Function used to align with Node.getChildren()
  94568. * @returns the list of Materials used within the multi material
  94569. */
  94570. getChildren(): Nullable<Material>[];
  94571. /**
  94572. * Instantiates a new Multi Material
  94573. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94574. * separate meshes. This can be use to improve performances.
  94575. * @see http://doc.babylonjs.com/how_to/multi_materials
  94576. * @param name Define the name in the scene
  94577. * @param scene Define the scene the material belongs to
  94578. */
  94579. constructor(name: string, scene: Scene);
  94580. private _hookArray;
  94581. /**
  94582. * Get one of the submaterial by its index in the submaterials array
  94583. * @param index The index to look the sub material at
  94584. * @returns The Material if the index has been defined
  94585. */
  94586. getSubMaterial(index: number): Nullable<Material>;
  94587. /**
  94588. * Get the list of active textures for the whole sub materials list.
  94589. * @returns All the textures that will be used during the rendering
  94590. */
  94591. getActiveTextures(): BaseTexture[];
  94592. /**
  94593. * Gets the current class name of the material e.g. "MultiMaterial"
  94594. * Mainly use in serialization.
  94595. * @returns the class name
  94596. */
  94597. getClassName(): string;
  94598. /**
  94599. * Checks if the material is ready to render the requested sub mesh
  94600. * @param mesh Define the mesh the submesh belongs to
  94601. * @param subMesh Define the sub mesh to look readyness for
  94602. * @param useInstances Define whether or not the material is used with instances
  94603. * @returns true if ready, otherwise false
  94604. */
  94605. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94606. /**
  94607. * Clones the current material and its related sub materials
  94608. * @param name Define the name of the newly cloned material
  94609. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94610. * @returns the cloned material
  94611. */
  94612. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94613. /**
  94614. * Serializes the materials into a JSON representation.
  94615. * @returns the JSON representation
  94616. */
  94617. serialize(): any;
  94618. /**
  94619. * Dispose the material and release its associated resources
  94620. * @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)
  94621. * @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)
  94622. * @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)
  94623. */
  94624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94625. /**
  94626. * Creates a MultiMaterial from parsed MultiMaterial data.
  94627. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94628. * @param scene defines the hosting scene
  94629. * @returns a new MultiMaterial
  94630. */
  94631. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94632. }
  94633. }
  94634. declare module BABYLON {
  94635. /**
  94636. * Base class for submeshes
  94637. */
  94638. export class BaseSubMesh {
  94639. /** @hidden */
  94640. _materialDefines: Nullable<MaterialDefines>;
  94641. /** @hidden */
  94642. _materialEffect: Nullable<Effect>;
  94643. /**
  94644. * Gets material defines used by the effect associated to the sub mesh
  94645. */
  94646. get materialDefines(): Nullable<MaterialDefines>;
  94647. /**
  94648. * Sets material defines used by the effect associated to the sub mesh
  94649. */
  94650. set materialDefines(defines: Nullable<MaterialDefines>);
  94651. /**
  94652. * Gets associated effect
  94653. */
  94654. get effect(): Nullable<Effect>;
  94655. /**
  94656. * Sets associated effect (effect used to render this submesh)
  94657. * @param effect defines the effect to associate with
  94658. * @param defines defines the set of defines used to compile this effect
  94659. */
  94660. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94661. }
  94662. /**
  94663. * Defines a subdivision inside a mesh
  94664. */
  94665. export class SubMesh extends BaseSubMesh implements ICullable {
  94666. /** the material index to use */
  94667. materialIndex: number;
  94668. /** vertex index start */
  94669. verticesStart: number;
  94670. /** vertices count */
  94671. verticesCount: number;
  94672. /** index start */
  94673. indexStart: number;
  94674. /** indices count */
  94675. indexCount: number;
  94676. /** @hidden */
  94677. _linesIndexCount: number;
  94678. private _mesh;
  94679. private _renderingMesh;
  94680. private _boundingInfo;
  94681. private _linesIndexBuffer;
  94682. /** @hidden */
  94683. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94684. /** @hidden */
  94685. _trianglePlanes: Plane[];
  94686. /** @hidden */
  94687. _lastColliderTransformMatrix: Nullable<Matrix>;
  94688. /** @hidden */
  94689. _renderId: number;
  94690. /** @hidden */
  94691. _alphaIndex: number;
  94692. /** @hidden */
  94693. _distanceToCamera: number;
  94694. /** @hidden */
  94695. _id: number;
  94696. private _currentMaterial;
  94697. /**
  94698. * Add a new submesh to a mesh
  94699. * @param materialIndex defines the material index to use
  94700. * @param verticesStart defines vertex index start
  94701. * @param verticesCount defines vertices count
  94702. * @param indexStart defines index start
  94703. * @param indexCount defines indices count
  94704. * @param mesh defines the parent mesh
  94705. * @param renderingMesh defines an optional rendering mesh
  94706. * @param createBoundingBox defines if bounding box should be created for this submesh
  94707. * @returns the new submesh
  94708. */
  94709. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94710. /**
  94711. * Creates a new submesh
  94712. * @param materialIndex defines the material index to use
  94713. * @param verticesStart defines vertex index start
  94714. * @param verticesCount defines vertices count
  94715. * @param indexStart defines index start
  94716. * @param indexCount defines indices count
  94717. * @param mesh defines the parent mesh
  94718. * @param renderingMesh defines an optional rendering mesh
  94719. * @param createBoundingBox defines if bounding box should be created for this submesh
  94720. */
  94721. constructor(
  94722. /** the material index to use */
  94723. materialIndex: number,
  94724. /** vertex index start */
  94725. verticesStart: number,
  94726. /** vertices count */
  94727. verticesCount: number,
  94728. /** index start */
  94729. indexStart: number,
  94730. /** indices count */
  94731. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94732. /**
  94733. * Returns true if this submesh covers the entire parent mesh
  94734. * @ignorenaming
  94735. */
  94736. get IsGlobal(): boolean;
  94737. /**
  94738. * Returns the submesh BoudingInfo object
  94739. * @returns current bounding info (or mesh's one if the submesh is global)
  94740. */
  94741. getBoundingInfo(): BoundingInfo;
  94742. /**
  94743. * Sets the submesh BoundingInfo
  94744. * @param boundingInfo defines the new bounding info to use
  94745. * @returns the SubMesh
  94746. */
  94747. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94748. /**
  94749. * Returns the mesh of the current submesh
  94750. * @return the parent mesh
  94751. */
  94752. getMesh(): AbstractMesh;
  94753. /**
  94754. * Returns the rendering mesh of the submesh
  94755. * @returns the rendering mesh (could be different from parent mesh)
  94756. */
  94757. getRenderingMesh(): Mesh;
  94758. /**
  94759. * Returns the submesh material
  94760. * @returns null or the current material
  94761. */
  94762. getMaterial(): Nullable<Material>;
  94763. /**
  94764. * Sets a new updated BoundingInfo object to the submesh
  94765. * @param data defines an optional position array to use to determine the bounding info
  94766. * @returns the SubMesh
  94767. */
  94768. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94769. /** @hidden */
  94770. _checkCollision(collider: Collider): boolean;
  94771. /**
  94772. * Updates the submesh BoundingInfo
  94773. * @param world defines the world matrix to use to update the bounding info
  94774. * @returns the submesh
  94775. */
  94776. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94777. /**
  94778. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94779. * @param frustumPlanes defines the frustum planes
  94780. * @returns true if the submesh is intersecting with the frustum
  94781. */
  94782. isInFrustum(frustumPlanes: Plane[]): boolean;
  94783. /**
  94784. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94785. * @param frustumPlanes defines the frustum planes
  94786. * @returns true if the submesh is inside the frustum
  94787. */
  94788. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94789. /**
  94790. * Renders the submesh
  94791. * @param enableAlphaMode defines if alpha needs to be used
  94792. * @returns the submesh
  94793. */
  94794. render(enableAlphaMode: boolean): SubMesh;
  94795. /**
  94796. * @hidden
  94797. */
  94798. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94799. /**
  94800. * Checks if the submesh intersects with a ray
  94801. * @param ray defines the ray to test
  94802. * @returns true is the passed ray intersects the submesh bounding box
  94803. */
  94804. canIntersects(ray: Ray): boolean;
  94805. /**
  94806. * Intersects current submesh with a ray
  94807. * @param ray defines the ray to test
  94808. * @param positions defines mesh's positions array
  94809. * @param indices defines mesh's indices array
  94810. * @param fastCheck defines if only bounding info should be used
  94811. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94812. * @returns intersection info or null if no intersection
  94813. */
  94814. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94815. /** @hidden */
  94816. private _intersectLines;
  94817. /** @hidden */
  94818. private _intersectUnIndexedLines;
  94819. /** @hidden */
  94820. private _intersectTriangles;
  94821. /** @hidden */
  94822. private _intersectUnIndexedTriangles;
  94823. /** @hidden */
  94824. _rebuild(): void;
  94825. /**
  94826. * Creates a new submesh from the passed mesh
  94827. * @param newMesh defines the new hosting mesh
  94828. * @param newRenderingMesh defines an optional rendering mesh
  94829. * @returns the new submesh
  94830. */
  94831. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94832. /**
  94833. * Release associated resources
  94834. */
  94835. dispose(): void;
  94836. /**
  94837. * Gets the class name
  94838. * @returns the string "SubMesh".
  94839. */
  94840. getClassName(): string;
  94841. /**
  94842. * Creates a new submesh from indices data
  94843. * @param materialIndex the index of the main mesh material
  94844. * @param startIndex the index where to start the copy in the mesh indices array
  94845. * @param indexCount the number of indices to copy then from the startIndex
  94846. * @param mesh the main mesh to create the submesh from
  94847. * @param renderingMesh the optional rendering mesh
  94848. * @returns a new submesh
  94849. */
  94850. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94851. }
  94852. }
  94853. declare module BABYLON {
  94854. /**
  94855. * Class used to represent data loading progression
  94856. */
  94857. export class SceneLoaderFlags {
  94858. private static _ForceFullSceneLoadingForIncremental;
  94859. private static _ShowLoadingScreen;
  94860. private static _CleanBoneMatrixWeights;
  94861. private static _loggingLevel;
  94862. /**
  94863. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94864. */
  94865. static get ForceFullSceneLoadingForIncremental(): boolean;
  94866. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94867. /**
  94868. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94869. */
  94870. static get ShowLoadingScreen(): boolean;
  94871. static set ShowLoadingScreen(value: boolean);
  94872. /**
  94873. * Defines the current logging level (while loading the scene)
  94874. * @ignorenaming
  94875. */
  94876. static get loggingLevel(): number;
  94877. static set loggingLevel(value: number);
  94878. /**
  94879. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94880. */
  94881. static get CleanBoneMatrixWeights(): boolean;
  94882. static set CleanBoneMatrixWeights(value: boolean);
  94883. }
  94884. }
  94885. declare module BABYLON {
  94886. /**
  94887. * Class used to store geometry data (vertex buffers + index buffer)
  94888. */
  94889. export class Geometry implements IGetSetVerticesData {
  94890. /**
  94891. * Gets or sets the ID of the geometry
  94892. */
  94893. id: string;
  94894. /**
  94895. * Gets or sets the unique ID of the geometry
  94896. */
  94897. uniqueId: number;
  94898. /**
  94899. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94900. */
  94901. delayLoadState: number;
  94902. /**
  94903. * Gets the file containing the data to load when running in delay load state
  94904. */
  94905. delayLoadingFile: Nullable<string>;
  94906. /**
  94907. * Callback called when the geometry is updated
  94908. */
  94909. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94910. private _scene;
  94911. private _engine;
  94912. private _meshes;
  94913. private _totalVertices;
  94914. /** @hidden */
  94915. _indices: IndicesArray;
  94916. /** @hidden */
  94917. _vertexBuffers: {
  94918. [key: string]: VertexBuffer;
  94919. };
  94920. private _isDisposed;
  94921. private _extend;
  94922. private _boundingBias;
  94923. /** @hidden */
  94924. _delayInfo: Array<string>;
  94925. private _indexBuffer;
  94926. private _indexBufferIsUpdatable;
  94927. /** @hidden */
  94928. _boundingInfo: Nullable<BoundingInfo>;
  94929. /** @hidden */
  94930. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94931. /** @hidden */
  94932. _softwareSkinningFrameId: number;
  94933. private _vertexArrayObjects;
  94934. private _updatable;
  94935. /** @hidden */
  94936. _positions: Nullable<Vector3[]>;
  94937. /**
  94938. * 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
  94939. */
  94940. get boundingBias(): Vector2;
  94941. /**
  94942. * 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
  94943. */
  94944. set boundingBias(value: Vector2);
  94945. /**
  94946. * Static function used to attach a new empty geometry to a mesh
  94947. * @param mesh defines the mesh to attach the geometry to
  94948. * @returns the new Geometry
  94949. */
  94950. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94951. /**
  94952. * Creates a new geometry
  94953. * @param id defines the unique ID
  94954. * @param scene defines the hosting scene
  94955. * @param vertexData defines the VertexData used to get geometry data
  94956. * @param updatable defines if geometry must be updatable (false by default)
  94957. * @param mesh defines the mesh that will be associated with the geometry
  94958. */
  94959. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94960. /**
  94961. * Gets the current extend of the geometry
  94962. */
  94963. get extend(): {
  94964. minimum: Vector3;
  94965. maximum: Vector3;
  94966. };
  94967. /**
  94968. * Gets the hosting scene
  94969. * @returns the hosting Scene
  94970. */
  94971. getScene(): Scene;
  94972. /**
  94973. * Gets the hosting engine
  94974. * @returns the hosting Engine
  94975. */
  94976. getEngine(): Engine;
  94977. /**
  94978. * Defines if the geometry is ready to use
  94979. * @returns true if the geometry is ready to be used
  94980. */
  94981. isReady(): boolean;
  94982. /**
  94983. * Gets a value indicating that the geometry should not be serialized
  94984. */
  94985. get doNotSerialize(): boolean;
  94986. /** @hidden */
  94987. _rebuild(): void;
  94988. /**
  94989. * Affects all geometry data in one call
  94990. * @param vertexData defines the geometry data
  94991. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94992. */
  94993. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94994. /**
  94995. * Set specific vertex data
  94996. * @param kind defines the data kind (Position, normal, etc...)
  94997. * @param data defines the vertex data to use
  94998. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94999. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95000. */
  95001. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95002. /**
  95003. * Removes a specific vertex data
  95004. * @param kind defines the data kind (Position, normal, etc...)
  95005. */
  95006. removeVerticesData(kind: string): void;
  95007. /**
  95008. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95009. * @param buffer defines the vertex buffer to use
  95010. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95011. */
  95012. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95013. /**
  95014. * Update a specific vertex buffer
  95015. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95016. * It will do nothing if the buffer is not updatable
  95017. * @param kind defines the data kind (Position, normal, etc...)
  95018. * @param data defines the data to use
  95019. * @param offset defines the offset in the target buffer where to store the data
  95020. * @param useBytes set to true if the offset is in bytes
  95021. */
  95022. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95023. /**
  95024. * Update a specific vertex buffer
  95025. * This function will create a new buffer if the current one is not updatable
  95026. * @param kind defines the data kind (Position, normal, etc...)
  95027. * @param data defines the data to use
  95028. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95029. */
  95030. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95031. private _updateBoundingInfo;
  95032. /** @hidden */
  95033. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95034. /**
  95035. * Gets total number of vertices
  95036. * @returns the total number of vertices
  95037. */
  95038. getTotalVertices(): number;
  95039. /**
  95040. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95041. * @param kind defines the data kind (Position, normal, etc...)
  95042. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95043. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95044. * @returns a float array containing vertex data
  95045. */
  95046. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95047. /**
  95048. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95049. * @param kind defines the data kind (Position, normal, etc...)
  95050. * @returns true if the vertex buffer with the specified kind is updatable
  95051. */
  95052. isVertexBufferUpdatable(kind: string): boolean;
  95053. /**
  95054. * Gets a specific vertex buffer
  95055. * @param kind defines the data kind (Position, normal, etc...)
  95056. * @returns a VertexBuffer
  95057. */
  95058. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95059. /**
  95060. * Returns all vertex buffers
  95061. * @return an object holding all vertex buffers indexed by kind
  95062. */
  95063. getVertexBuffers(): Nullable<{
  95064. [key: string]: VertexBuffer;
  95065. }>;
  95066. /**
  95067. * Gets a boolean indicating if specific vertex buffer is present
  95068. * @param kind defines the data kind (Position, normal, etc...)
  95069. * @returns true if data is present
  95070. */
  95071. isVerticesDataPresent(kind: string): boolean;
  95072. /**
  95073. * Gets a list of all attached data kinds (Position, normal, etc...)
  95074. * @returns a list of string containing all kinds
  95075. */
  95076. getVerticesDataKinds(): string[];
  95077. /**
  95078. * Update index buffer
  95079. * @param indices defines the indices to store in the index buffer
  95080. * @param offset defines the offset in the target buffer where to store the data
  95081. * @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)
  95082. */
  95083. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95084. /**
  95085. * Creates a new index buffer
  95086. * @param indices defines the indices to store in the index buffer
  95087. * @param totalVertices defines the total number of vertices (could be null)
  95088. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95089. */
  95090. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95091. /**
  95092. * Return the total number of indices
  95093. * @returns the total number of indices
  95094. */
  95095. getTotalIndices(): number;
  95096. /**
  95097. * Gets the index buffer array
  95098. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95099. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95100. * @returns the index buffer array
  95101. */
  95102. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95103. /**
  95104. * Gets the index buffer
  95105. * @return the index buffer
  95106. */
  95107. getIndexBuffer(): Nullable<DataBuffer>;
  95108. /** @hidden */
  95109. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95110. /**
  95111. * Release the associated resources for a specific mesh
  95112. * @param mesh defines the source mesh
  95113. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95114. */
  95115. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95116. /**
  95117. * Apply current geometry to a given mesh
  95118. * @param mesh defines the mesh to apply geometry to
  95119. */
  95120. applyToMesh(mesh: Mesh): void;
  95121. private _updateExtend;
  95122. private _applyToMesh;
  95123. private notifyUpdate;
  95124. /**
  95125. * Load the geometry if it was flagged as delay loaded
  95126. * @param scene defines the hosting scene
  95127. * @param onLoaded defines a callback called when the geometry is loaded
  95128. */
  95129. load(scene: Scene, onLoaded?: () => void): void;
  95130. private _queueLoad;
  95131. /**
  95132. * Invert the geometry to move from a right handed system to a left handed one.
  95133. */
  95134. toLeftHanded(): void;
  95135. /** @hidden */
  95136. _resetPointsArrayCache(): void;
  95137. /** @hidden */
  95138. _generatePointsArray(): boolean;
  95139. /**
  95140. * Gets a value indicating if the geometry is disposed
  95141. * @returns true if the geometry was disposed
  95142. */
  95143. isDisposed(): boolean;
  95144. private _disposeVertexArrayObjects;
  95145. /**
  95146. * Free all associated resources
  95147. */
  95148. dispose(): void;
  95149. /**
  95150. * Clone the current geometry into a new geometry
  95151. * @param id defines the unique ID of the new geometry
  95152. * @returns a new geometry object
  95153. */
  95154. copy(id: string): Geometry;
  95155. /**
  95156. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95157. * @return a JSON representation of the current geometry data (without the vertices data)
  95158. */
  95159. serialize(): any;
  95160. private toNumberArray;
  95161. /**
  95162. * Serialize all vertices data into a JSON oject
  95163. * @returns a JSON representation of the current geometry data
  95164. */
  95165. serializeVerticeData(): any;
  95166. /**
  95167. * Extracts a clone of a mesh geometry
  95168. * @param mesh defines the source mesh
  95169. * @param id defines the unique ID of the new geometry object
  95170. * @returns the new geometry object
  95171. */
  95172. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95173. /**
  95174. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95175. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95176. * Be aware Math.random() could cause collisions, but:
  95177. * "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"
  95178. * @returns a string containing a new GUID
  95179. */
  95180. static RandomId(): string;
  95181. /** @hidden */
  95182. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95183. private static _CleanMatricesWeights;
  95184. /**
  95185. * Create a new geometry from persisted data (Using .babylon file format)
  95186. * @param parsedVertexData defines the persisted data
  95187. * @param scene defines the hosting scene
  95188. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95189. * @returns the new geometry object
  95190. */
  95191. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95192. }
  95193. }
  95194. declare module BABYLON {
  95195. /**
  95196. * Define an interface for all classes that will get and set the data on vertices
  95197. */
  95198. export interface IGetSetVerticesData {
  95199. /**
  95200. * Gets a boolean indicating if specific vertex data is present
  95201. * @param kind defines the vertex data kind to use
  95202. * @returns true is data kind is present
  95203. */
  95204. isVerticesDataPresent(kind: string): boolean;
  95205. /**
  95206. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95207. * @param kind defines the data kind (Position, normal, etc...)
  95208. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95209. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95210. * @returns a float array containing vertex data
  95211. */
  95212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95213. /**
  95214. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95215. * @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.
  95216. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95217. * @returns the indices array or an empty array if the mesh has no geometry
  95218. */
  95219. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95220. /**
  95221. * Set specific vertex data
  95222. * @param kind defines the data kind (Position, normal, etc...)
  95223. * @param data defines the vertex data to use
  95224. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95225. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95226. */
  95227. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95228. /**
  95229. * Update a specific associated vertex buffer
  95230. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95231. * - VertexBuffer.PositionKind
  95232. * - VertexBuffer.UVKind
  95233. * - VertexBuffer.UV2Kind
  95234. * - VertexBuffer.UV3Kind
  95235. * - VertexBuffer.UV4Kind
  95236. * - VertexBuffer.UV5Kind
  95237. * - VertexBuffer.UV6Kind
  95238. * - VertexBuffer.ColorKind
  95239. * - VertexBuffer.MatricesIndicesKind
  95240. * - VertexBuffer.MatricesIndicesExtraKind
  95241. * - VertexBuffer.MatricesWeightsKind
  95242. * - VertexBuffer.MatricesWeightsExtraKind
  95243. * @param data defines the data source
  95244. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95245. * @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)
  95246. */
  95247. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95248. /**
  95249. * Creates a new index buffer
  95250. * @param indices defines the indices to store in the index buffer
  95251. * @param totalVertices defines the total number of vertices (could be null)
  95252. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95253. */
  95254. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95255. }
  95256. /**
  95257. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95258. */
  95259. export class VertexData {
  95260. /**
  95261. * Mesh side orientation : usually the external or front surface
  95262. */
  95263. static readonly FRONTSIDE: number;
  95264. /**
  95265. * Mesh side orientation : usually the internal or back surface
  95266. */
  95267. static readonly BACKSIDE: number;
  95268. /**
  95269. * Mesh side orientation : both internal and external or front and back surfaces
  95270. */
  95271. static readonly DOUBLESIDE: number;
  95272. /**
  95273. * Mesh side orientation : by default, `FRONTSIDE`
  95274. */
  95275. static readonly DEFAULTSIDE: number;
  95276. /**
  95277. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95278. */
  95279. positions: Nullable<FloatArray>;
  95280. /**
  95281. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95282. */
  95283. normals: Nullable<FloatArray>;
  95284. /**
  95285. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95286. */
  95287. tangents: Nullable<FloatArray>;
  95288. /**
  95289. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95290. */
  95291. uvs: Nullable<FloatArray>;
  95292. /**
  95293. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95294. */
  95295. uvs2: Nullable<FloatArray>;
  95296. /**
  95297. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95298. */
  95299. uvs3: Nullable<FloatArray>;
  95300. /**
  95301. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95302. */
  95303. uvs4: Nullable<FloatArray>;
  95304. /**
  95305. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95306. */
  95307. uvs5: Nullable<FloatArray>;
  95308. /**
  95309. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95310. */
  95311. uvs6: Nullable<FloatArray>;
  95312. /**
  95313. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95314. */
  95315. colors: Nullable<FloatArray>;
  95316. /**
  95317. * 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).
  95318. */
  95319. matricesIndices: Nullable<FloatArray>;
  95320. /**
  95321. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95322. */
  95323. matricesWeights: Nullable<FloatArray>;
  95324. /**
  95325. * An array extending the number of possible indices
  95326. */
  95327. matricesIndicesExtra: Nullable<FloatArray>;
  95328. /**
  95329. * An array extending the number of possible weights when the number of indices is extended
  95330. */
  95331. matricesWeightsExtra: Nullable<FloatArray>;
  95332. /**
  95333. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95334. */
  95335. indices: Nullable<IndicesArray>;
  95336. /**
  95337. * Uses the passed data array to set the set the values for the specified kind of data
  95338. * @param data a linear array of floating numbers
  95339. * @param kind the type of data that is being set, eg positions, colors etc
  95340. */
  95341. set(data: FloatArray, kind: string): void;
  95342. /**
  95343. * Associates the vertexData to the passed Mesh.
  95344. * Sets it as updatable or not (default `false`)
  95345. * @param mesh the mesh the vertexData is applied to
  95346. * @param updatable when used and having the value true allows new data to update the vertexData
  95347. * @returns the VertexData
  95348. */
  95349. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95350. /**
  95351. * Associates the vertexData to the passed Geometry.
  95352. * Sets it as updatable or not (default `false`)
  95353. * @param geometry the geometry the vertexData is applied to
  95354. * @param updatable when used and having the value true allows new data to update the vertexData
  95355. * @returns VertexData
  95356. */
  95357. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95358. /**
  95359. * Updates the associated mesh
  95360. * @param mesh the mesh to be updated
  95361. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95362. * @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
  95363. * @returns VertexData
  95364. */
  95365. updateMesh(mesh: Mesh): VertexData;
  95366. /**
  95367. * Updates the associated geometry
  95368. * @param geometry the geometry to be updated
  95369. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95370. * @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
  95371. * @returns VertexData.
  95372. */
  95373. updateGeometry(geometry: Geometry): VertexData;
  95374. private _applyTo;
  95375. private _update;
  95376. /**
  95377. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95378. * @param matrix the transforming matrix
  95379. * @returns the VertexData
  95380. */
  95381. transform(matrix: Matrix): VertexData;
  95382. /**
  95383. * Merges the passed VertexData into the current one
  95384. * @param other the VertexData to be merged into the current one
  95385. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95386. * @returns the modified VertexData
  95387. */
  95388. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95389. private _mergeElement;
  95390. private _validate;
  95391. /**
  95392. * Serializes the VertexData
  95393. * @returns a serialized object
  95394. */
  95395. serialize(): any;
  95396. /**
  95397. * Extracts the vertexData from a mesh
  95398. * @param mesh the mesh from which to extract the VertexData
  95399. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95400. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95401. * @returns the object VertexData associated to the passed mesh
  95402. */
  95403. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95404. /**
  95405. * Extracts the vertexData from the geometry
  95406. * @param geometry the geometry from which to extract the VertexData
  95407. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95408. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95409. * @returns the object VertexData associated to the passed mesh
  95410. */
  95411. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95412. private static _ExtractFrom;
  95413. /**
  95414. * Creates the VertexData for a Ribbon
  95415. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95416. * * pathArray array of paths, each of which an array of successive Vector3
  95417. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95418. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95419. * * 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
  95420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95421. * * 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)
  95422. * * 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)
  95423. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95424. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95425. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95426. * @returns the VertexData of the ribbon
  95427. */
  95428. static CreateRibbon(options: {
  95429. pathArray: Vector3[][];
  95430. closeArray?: boolean;
  95431. closePath?: boolean;
  95432. offset?: number;
  95433. sideOrientation?: number;
  95434. frontUVs?: Vector4;
  95435. backUVs?: Vector4;
  95436. invertUV?: boolean;
  95437. uvs?: Vector2[];
  95438. colors?: Color4[];
  95439. }): VertexData;
  95440. /**
  95441. * Creates the VertexData for a box
  95442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95443. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95444. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95445. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95446. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95447. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95448. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95450. * * 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)
  95451. * * 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)
  95452. * @returns the VertexData of the box
  95453. */
  95454. static CreateBox(options: {
  95455. size?: number;
  95456. width?: number;
  95457. height?: number;
  95458. depth?: number;
  95459. faceUV?: Vector4[];
  95460. faceColors?: Color4[];
  95461. sideOrientation?: number;
  95462. frontUVs?: Vector4;
  95463. backUVs?: Vector4;
  95464. }): VertexData;
  95465. /**
  95466. * Creates the VertexData for a tiled box
  95467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95468. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95469. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95470. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95472. * @returns the VertexData of the box
  95473. */
  95474. static CreateTiledBox(options: {
  95475. pattern?: number;
  95476. width?: number;
  95477. height?: number;
  95478. depth?: number;
  95479. tileSize?: number;
  95480. tileWidth?: number;
  95481. tileHeight?: number;
  95482. alignHorizontal?: number;
  95483. alignVertical?: number;
  95484. faceUV?: Vector4[];
  95485. faceColors?: Color4[];
  95486. sideOrientation?: number;
  95487. }): VertexData;
  95488. /**
  95489. * Creates the VertexData for a tiled plane
  95490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95491. * * pattern a limited pattern arrangement depending on the number
  95492. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95493. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95494. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95496. * * 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)
  95497. * * 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)
  95498. * @returns the VertexData of the tiled plane
  95499. */
  95500. static CreateTiledPlane(options: {
  95501. pattern?: number;
  95502. tileSize?: number;
  95503. tileWidth?: number;
  95504. tileHeight?: number;
  95505. size?: number;
  95506. width?: number;
  95507. height?: number;
  95508. alignHorizontal?: number;
  95509. alignVertical?: number;
  95510. sideOrientation?: number;
  95511. frontUVs?: Vector4;
  95512. backUVs?: Vector4;
  95513. }): VertexData;
  95514. /**
  95515. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95517. * * segments sets the number of horizontal strips optional, default 32
  95518. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95519. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95520. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95521. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95522. * * 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
  95523. * * 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
  95524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95525. * * 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)
  95526. * * 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)
  95527. * @returns the VertexData of the ellipsoid
  95528. */
  95529. static CreateSphere(options: {
  95530. segments?: number;
  95531. diameter?: number;
  95532. diameterX?: number;
  95533. diameterY?: number;
  95534. diameterZ?: number;
  95535. arc?: number;
  95536. slice?: number;
  95537. sideOrientation?: number;
  95538. frontUVs?: Vector4;
  95539. backUVs?: Vector4;
  95540. }): VertexData;
  95541. /**
  95542. * Creates the VertexData for a cylinder, cone or prism
  95543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95544. * * height sets the height (y direction) of the cylinder, optional, default 2
  95545. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95546. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95547. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95548. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95549. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95550. * * 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
  95551. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95552. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95553. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95554. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95556. * * 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)
  95557. * * 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)
  95558. * @returns the VertexData of the cylinder, cone or prism
  95559. */
  95560. static CreateCylinder(options: {
  95561. height?: number;
  95562. diameterTop?: number;
  95563. diameterBottom?: number;
  95564. diameter?: number;
  95565. tessellation?: number;
  95566. subdivisions?: number;
  95567. arc?: number;
  95568. faceColors?: Color4[];
  95569. faceUV?: Vector4[];
  95570. hasRings?: boolean;
  95571. enclose?: boolean;
  95572. sideOrientation?: number;
  95573. frontUVs?: Vector4;
  95574. backUVs?: Vector4;
  95575. }): VertexData;
  95576. /**
  95577. * Creates the VertexData for a torus
  95578. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95579. * * diameter the diameter of the torus, optional default 1
  95580. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95581. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95583. * * 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)
  95584. * * 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)
  95585. * @returns the VertexData of the torus
  95586. */
  95587. static CreateTorus(options: {
  95588. diameter?: number;
  95589. thickness?: number;
  95590. tessellation?: number;
  95591. sideOrientation?: number;
  95592. frontUVs?: Vector4;
  95593. backUVs?: Vector4;
  95594. }): VertexData;
  95595. /**
  95596. * Creates the VertexData of the LineSystem
  95597. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95598. * - lines an array of lines, each line being an array of successive Vector3
  95599. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95600. * @returns the VertexData of the LineSystem
  95601. */
  95602. static CreateLineSystem(options: {
  95603. lines: Vector3[][];
  95604. colors?: Nullable<Color4[][]>;
  95605. }): VertexData;
  95606. /**
  95607. * Create the VertexData for a DashedLines
  95608. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95609. * - points an array successive Vector3
  95610. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95611. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95612. * - dashNb the intended total number of dashes, optional, default 200
  95613. * @returns the VertexData for the DashedLines
  95614. */
  95615. static CreateDashedLines(options: {
  95616. points: Vector3[];
  95617. dashSize?: number;
  95618. gapSize?: number;
  95619. dashNb?: number;
  95620. }): VertexData;
  95621. /**
  95622. * Creates the VertexData for a Ground
  95623. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95624. * - width the width (x direction) of the ground, optional, default 1
  95625. * - height the height (z direction) of the ground, optional, default 1
  95626. * - subdivisions the number of subdivisions per side, optional, default 1
  95627. * @returns the VertexData of the Ground
  95628. */
  95629. static CreateGround(options: {
  95630. width?: number;
  95631. height?: number;
  95632. subdivisions?: number;
  95633. subdivisionsX?: number;
  95634. subdivisionsY?: number;
  95635. }): VertexData;
  95636. /**
  95637. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95638. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95639. * * xmin the ground minimum X coordinate, optional, default -1
  95640. * * zmin the ground minimum Z coordinate, optional, default -1
  95641. * * xmax the ground maximum X coordinate, optional, default 1
  95642. * * zmax the ground maximum Z coordinate, optional, default 1
  95643. * * 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}
  95644. * * 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}
  95645. * @returns the VertexData of the TiledGround
  95646. */
  95647. static CreateTiledGround(options: {
  95648. xmin: number;
  95649. zmin: number;
  95650. xmax: number;
  95651. zmax: number;
  95652. subdivisions?: {
  95653. w: number;
  95654. h: number;
  95655. };
  95656. precision?: {
  95657. w: number;
  95658. h: number;
  95659. };
  95660. }): VertexData;
  95661. /**
  95662. * Creates the VertexData of the Ground designed from a heightmap
  95663. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95664. * * width the width (x direction) of the ground
  95665. * * height the height (z direction) of the ground
  95666. * * subdivisions the number of subdivisions per side
  95667. * * minHeight the minimum altitude on the ground, optional, default 0
  95668. * * maxHeight the maximum altitude on the ground, optional default 1
  95669. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95670. * * buffer the array holding the image color data
  95671. * * bufferWidth the width of image
  95672. * * bufferHeight the height of image
  95673. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95674. * @returns the VertexData of the Ground designed from a heightmap
  95675. */
  95676. static CreateGroundFromHeightMap(options: {
  95677. width: number;
  95678. height: number;
  95679. subdivisions: number;
  95680. minHeight: number;
  95681. maxHeight: number;
  95682. colorFilter: Color3;
  95683. buffer: Uint8Array;
  95684. bufferWidth: number;
  95685. bufferHeight: number;
  95686. alphaFilter: number;
  95687. }): VertexData;
  95688. /**
  95689. * Creates the VertexData for a Plane
  95690. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95691. * * size sets the width and height of the plane to the value of size, optional default 1
  95692. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95693. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95695. * * 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)
  95696. * * 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)
  95697. * @returns the VertexData of the box
  95698. */
  95699. static CreatePlane(options: {
  95700. size?: number;
  95701. width?: number;
  95702. height?: number;
  95703. sideOrientation?: number;
  95704. frontUVs?: Vector4;
  95705. backUVs?: Vector4;
  95706. }): VertexData;
  95707. /**
  95708. * Creates the VertexData of the Disc or regular Polygon
  95709. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95710. * * radius the radius of the disc, optional default 0.5
  95711. * * tessellation the number of polygon sides, optional, default 64
  95712. * * 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
  95713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95714. * * 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)
  95715. * * 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)
  95716. * @returns the VertexData of the box
  95717. */
  95718. static CreateDisc(options: {
  95719. radius?: number;
  95720. tessellation?: number;
  95721. arc?: number;
  95722. sideOrientation?: number;
  95723. frontUVs?: Vector4;
  95724. backUVs?: Vector4;
  95725. }): VertexData;
  95726. /**
  95727. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95728. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95729. * @param polygon a mesh built from polygonTriangulation.build()
  95730. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95731. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95732. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95733. * @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)
  95734. * @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)
  95735. * @returns the VertexData of the Polygon
  95736. */
  95737. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95738. /**
  95739. * Creates the VertexData of the IcoSphere
  95740. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95741. * * radius the radius of the IcoSphere, optional default 1
  95742. * * radiusX allows stretching in the x direction, optional, default radius
  95743. * * radiusY allows stretching in the y direction, optional, default radius
  95744. * * radiusZ allows stretching in the z direction, optional, default radius
  95745. * * flat when true creates a flat shaded mesh, optional, default true
  95746. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95748. * * 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)
  95749. * * 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)
  95750. * @returns the VertexData of the IcoSphere
  95751. */
  95752. static CreateIcoSphere(options: {
  95753. radius?: number;
  95754. radiusX?: number;
  95755. radiusY?: number;
  95756. radiusZ?: number;
  95757. flat?: boolean;
  95758. subdivisions?: number;
  95759. sideOrientation?: number;
  95760. frontUVs?: Vector4;
  95761. backUVs?: Vector4;
  95762. }): VertexData;
  95763. /**
  95764. * Creates the VertexData for a Polyhedron
  95765. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95766. * * type provided types are:
  95767. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95768. * * 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)
  95769. * * size the size of the IcoSphere, optional default 1
  95770. * * sizeX allows stretching in the x direction, optional, default size
  95771. * * sizeY allows stretching in the y direction, optional, default size
  95772. * * sizeZ allows stretching in the z direction, optional, default size
  95773. * * 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
  95774. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95775. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95776. * * flat when true creates a flat shaded mesh, optional, default true
  95777. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95779. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  95780. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  95781. * @returns the VertexData of the Polyhedron
  95782. */
  95783. static CreatePolyhedron(options: {
  95784. type?: number;
  95785. size?: number;
  95786. sizeX?: number;
  95787. sizeY?: number;
  95788. sizeZ?: number;
  95789. custom?: any;
  95790. faceUV?: Vector4[];
  95791. faceColors?: Color4[];
  95792. flat?: boolean;
  95793. sideOrientation?: number;
  95794. frontUVs?: Vector4;
  95795. backUVs?: Vector4;
  95796. }): VertexData;
  95797. /**
  95798. * Creates the VertexData for a TorusKnot
  95799. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95800. * * radius the radius of the torus knot, optional, default 2
  95801. * * tube the thickness of the tube, optional, default 0.5
  95802. * * radialSegments the number of sides on each tube segments, optional, default 32
  95803. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95804. * * p the number of windings around the z axis, optional, default 2
  95805. * * q the number of windings around the x axis, optional, default 3
  95806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95807. * * 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)
  95808. * * 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)
  95809. * @returns the VertexData of the Torus Knot
  95810. */
  95811. static CreateTorusKnot(options: {
  95812. radius?: number;
  95813. tube?: number;
  95814. radialSegments?: number;
  95815. tubularSegments?: number;
  95816. p?: number;
  95817. q?: number;
  95818. sideOrientation?: number;
  95819. frontUVs?: Vector4;
  95820. backUVs?: Vector4;
  95821. }): VertexData;
  95822. /**
  95823. * Compute normals for given positions and indices
  95824. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95825. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95826. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95827. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95828. * * facetNormals : optional array of facet normals (vector3)
  95829. * * facetPositions : optional array of facet positions (vector3)
  95830. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95831. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95832. * * bInfo : optional bounding info, required for facetPartitioning computation
  95833. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95834. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95835. * * useRightHandedSystem: optional boolean to for right handed system computation
  95836. * * depthSort : optional boolean to enable the facet depth sort computation
  95837. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95838. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95839. */
  95840. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95841. facetNormals?: any;
  95842. facetPositions?: any;
  95843. facetPartitioning?: any;
  95844. ratio?: number;
  95845. bInfo?: any;
  95846. bbSize?: Vector3;
  95847. subDiv?: any;
  95848. useRightHandedSystem?: boolean;
  95849. depthSort?: boolean;
  95850. distanceTo?: Vector3;
  95851. depthSortedFacets?: any;
  95852. }): void;
  95853. /** @hidden */
  95854. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95855. /**
  95856. * Applies VertexData created from the imported parameters to the geometry
  95857. * @param parsedVertexData the parsed data from an imported file
  95858. * @param geometry the geometry to apply the VertexData to
  95859. */
  95860. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95861. }
  95862. }
  95863. declare module BABYLON {
  95864. /**
  95865. * Defines a target to use with MorphTargetManager
  95866. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95867. */
  95868. export class MorphTarget implements IAnimatable {
  95869. /** defines the name of the target */
  95870. name: string;
  95871. /**
  95872. * Gets or sets the list of animations
  95873. */
  95874. animations: Animation[];
  95875. private _scene;
  95876. private _positions;
  95877. private _normals;
  95878. private _tangents;
  95879. private _uvs;
  95880. private _influence;
  95881. private _uniqueId;
  95882. /**
  95883. * Observable raised when the influence changes
  95884. */
  95885. onInfluenceChanged: Observable<boolean>;
  95886. /** @hidden */
  95887. _onDataLayoutChanged: Observable<void>;
  95888. /**
  95889. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95890. */
  95891. get influence(): number;
  95892. set influence(influence: number);
  95893. /**
  95894. * Gets or sets the id of the morph Target
  95895. */
  95896. id: string;
  95897. private _animationPropertiesOverride;
  95898. /**
  95899. * Gets or sets the animation properties override
  95900. */
  95901. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95902. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95903. /**
  95904. * Creates a new MorphTarget
  95905. * @param name defines the name of the target
  95906. * @param influence defines the influence to use
  95907. * @param scene defines the scene the morphtarget belongs to
  95908. */
  95909. constructor(
  95910. /** defines the name of the target */
  95911. name: string, influence?: number, scene?: Nullable<Scene>);
  95912. /**
  95913. * Gets the unique ID of this manager
  95914. */
  95915. get uniqueId(): number;
  95916. /**
  95917. * Gets a boolean defining if the target contains position data
  95918. */
  95919. get hasPositions(): boolean;
  95920. /**
  95921. * Gets a boolean defining if the target contains normal data
  95922. */
  95923. get hasNormals(): boolean;
  95924. /**
  95925. * Gets a boolean defining if the target contains tangent data
  95926. */
  95927. get hasTangents(): boolean;
  95928. /**
  95929. * Gets a boolean defining if the target contains texture coordinates data
  95930. */
  95931. get hasUVs(): boolean;
  95932. /**
  95933. * Affects position data to this target
  95934. * @param data defines the position data to use
  95935. */
  95936. setPositions(data: Nullable<FloatArray>): void;
  95937. /**
  95938. * Gets the position data stored in this target
  95939. * @returns a FloatArray containing the position data (or null if not present)
  95940. */
  95941. getPositions(): Nullable<FloatArray>;
  95942. /**
  95943. * Affects normal data to this target
  95944. * @param data defines the normal data to use
  95945. */
  95946. setNormals(data: Nullable<FloatArray>): void;
  95947. /**
  95948. * Gets the normal data stored in this target
  95949. * @returns a FloatArray containing the normal data (or null if not present)
  95950. */
  95951. getNormals(): Nullable<FloatArray>;
  95952. /**
  95953. * Affects tangent data to this target
  95954. * @param data defines the tangent data to use
  95955. */
  95956. setTangents(data: Nullable<FloatArray>): void;
  95957. /**
  95958. * Gets the tangent data stored in this target
  95959. * @returns a FloatArray containing the tangent data (or null if not present)
  95960. */
  95961. getTangents(): Nullable<FloatArray>;
  95962. /**
  95963. * Affects texture coordinates data to this target
  95964. * @param data defines the texture coordinates data to use
  95965. */
  95966. setUVs(data: Nullable<FloatArray>): void;
  95967. /**
  95968. * Gets the texture coordinates data stored in this target
  95969. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95970. */
  95971. getUVs(): Nullable<FloatArray>;
  95972. /**
  95973. * Clone the current target
  95974. * @returns a new MorphTarget
  95975. */
  95976. clone(): MorphTarget;
  95977. /**
  95978. * Serializes the current target into a Serialization object
  95979. * @returns the serialized object
  95980. */
  95981. serialize(): any;
  95982. /**
  95983. * Returns the string "MorphTarget"
  95984. * @returns "MorphTarget"
  95985. */
  95986. getClassName(): string;
  95987. /**
  95988. * Creates a new target from serialized data
  95989. * @param serializationObject defines the serialized data to use
  95990. * @returns a new MorphTarget
  95991. */
  95992. static Parse(serializationObject: any): MorphTarget;
  95993. /**
  95994. * Creates a MorphTarget from mesh data
  95995. * @param mesh defines the source mesh
  95996. * @param name defines the name to use for the new target
  95997. * @param influence defines the influence to attach to the target
  95998. * @returns a new MorphTarget
  95999. */
  96000. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96001. }
  96002. }
  96003. declare module BABYLON {
  96004. /**
  96005. * This class is used to deform meshes using morphing between different targets
  96006. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96007. */
  96008. export class MorphTargetManager {
  96009. private _targets;
  96010. private _targetInfluenceChangedObservers;
  96011. private _targetDataLayoutChangedObservers;
  96012. private _activeTargets;
  96013. private _scene;
  96014. private _influences;
  96015. private _supportsNormals;
  96016. private _supportsTangents;
  96017. private _supportsUVs;
  96018. private _vertexCount;
  96019. private _uniqueId;
  96020. private _tempInfluences;
  96021. /**
  96022. * Gets or sets a boolean indicating if normals must be morphed
  96023. */
  96024. enableNormalMorphing: boolean;
  96025. /**
  96026. * Gets or sets a boolean indicating if tangents must be morphed
  96027. */
  96028. enableTangentMorphing: boolean;
  96029. /**
  96030. * Gets or sets a boolean indicating if UV must be morphed
  96031. */
  96032. enableUVMorphing: boolean;
  96033. /**
  96034. * Creates a new MorphTargetManager
  96035. * @param scene defines the current scene
  96036. */
  96037. constructor(scene?: Nullable<Scene>);
  96038. /**
  96039. * Gets the unique ID of this manager
  96040. */
  96041. get uniqueId(): number;
  96042. /**
  96043. * Gets the number of vertices handled by this manager
  96044. */
  96045. get vertexCount(): number;
  96046. /**
  96047. * Gets a boolean indicating if this manager supports morphing of normals
  96048. */
  96049. get supportsNormals(): boolean;
  96050. /**
  96051. * Gets a boolean indicating if this manager supports morphing of tangents
  96052. */
  96053. get supportsTangents(): boolean;
  96054. /**
  96055. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96056. */
  96057. get supportsUVs(): boolean;
  96058. /**
  96059. * Gets the number of targets stored in this manager
  96060. */
  96061. get numTargets(): number;
  96062. /**
  96063. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96064. */
  96065. get numInfluencers(): number;
  96066. /**
  96067. * Gets the list of influences (one per target)
  96068. */
  96069. get influences(): Float32Array;
  96070. /**
  96071. * Gets the active target at specified index. An active target is a target with an influence > 0
  96072. * @param index defines the index to check
  96073. * @returns the requested target
  96074. */
  96075. getActiveTarget(index: number): MorphTarget;
  96076. /**
  96077. * Gets the target at specified index
  96078. * @param index defines the index to check
  96079. * @returns the requested target
  96080. */
  96081. getTarget(index: number): MorphTarget;
  96082. /**
  96083. * Add a new target to this manager
  96084. * @param target defines the target to add
  96085. */
  96086. addTarget(target: MorphTarget): void;
  96087. /**
  96088. * Removes a target from the manager
  96089. * @param target defines the target to remove
  96090. */
  96091. removeTarget(target: MorphTarget): void;
  96092. /**
  96093. * Clone the current manager
  96094. * @returns a new MorphTargetManager
  96095. */
  96096. clone(): MorphTargetManager;
  96097. /**
  96098. * Serializes the current manager into a Serialization object
  96099. * @returns the serialized object
  96100. */
  96101. serialize(): any;
  96102. private _syncActiveTargets;
  96103. /**
  96104. * Syncrhonize the targets with all the meshes using this morph target manager
  96105. */
  96106. synchronize(): void;
  96107. /**
  96108. * Creates a new MorphTargetManager from serialized data
  96109. * @param serializationObject defines the serialized data
  96110. * @param scene defines the hosting scene
  96111. * @returns the new MorphTargetManager
  96112. */
  96113. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96114. }
  96115. }
  96116. declare module BABYLON {
  96117. /**
  96118. * Class used to represent a specific level of detail of a mesh
  96119. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96120. */
  96121. export class MeshLODLevel {
  96122. /** Defines the distance where this level should start being displayed */
  96123. distance: number;
  96124. /** Defines the mesh to use to render this level */
  96125. mesh: Nullable<Mesh>;
  96126. /**
  96127. * Creates a new LOD level
  96128. * @param distance defines the distance where this level should star being displayed
  96129. * @param mesh defines the mesh to use to render this level
  96130. */
  96131. constructor(
  96132. /** Defines the distance where this level should start being displayed */
  96133. distance: number,
  96134. /** Defines the mesh to use to render this level */
  96135. mesh: Nullable<Mesh>);
  96136. }
  96137. }
  96138. declare module BABYLON {
  96139. /**
  96140. * Mesh representing the gorund
  96141. */
  96142. export class GroundMesh extends Mesh {
  96143. /** If octree should be generated */
  96144. generateOctree: boolean;
  96145. private _heightQuads;
  96146. /** @hidden */
  96147. _subdivisionsX: number;
  96148. /** @hidden */
  96149. _subdivisionsY: number;
  96150. /** @hidden */
  96151. _width: number;
  96152. /** @hidden */
  96153. _height: number;
  96154. /** @hidden */
  96155. _minX: number;
  96156. /** @hidden */
  96157. _maxX: number;
  96158. /** @hidden */
  96159. _minZ: number;
  96160. /** @hidden */
  96161. _maxZ: number;
  96162. constructor(name: string, scene: Scene);
  96163. /**
  96164. * "GroundMesh"
  96165. * @returns "GroundMesh"
  96166. */
  96167. getClassName(): string;
  96168. /**
  96169. * The minimum of x and y subdivisions
  96170. */
  96171. get subdivisions(): number;
  96172. /**
  96173. * X subdivisions
  96174. */
  96175. get subdivisionsX(): number;
  96176. /**
  96177. * Y subdivisions
  96178. */
  96179. get subdivisionsY(): number;
  96180. /**
  96181. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96182. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96183. * @param chunksCount the number of subdivisions for x and y
  96184. * @param octreeBlocksSize (Default: 32)
  96185. */
  96186. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96187. /**
  96188. * Returns a height (y) value in the Worl system :
  96189. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96190. * @param x x coordinate
  96191. * @param z z coordinate
  96192. * @returns the ground y position if (x, z) are outside the ground surface.
  96193. */
  96194. getHeightAtCoordinates(x: number, z: number): number;
  96195. /**
  96196. * Returns a normalized vector (Vector3) orthogonal to the ground
  96197. * at the ground coordinates (x, z) expressed in the World system.
  96198. * @param x x coordinate
  96199. * @param z z coordinate
  96200. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96201. */
  96202. getNormalAtCoordinates(x: number, z: number): Vector3;
  96203. /**
  96204. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96205. * at the ground coordinates (x, z) expressed in the World system.
  96206. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96207. * @param x x coordinate
  96208. * @param z z coordinate
  96209. * @param ref vector to store the result
  96210. * @returns the GroundMesh.
  96211. */
  96212. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96213. /**
  96214. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96215. * if the ground has been updated.
  96216. * This can be used in the render loop.
  96217. * @returns the GroundMesh.
  96218. */
  96219. updateCoordinateHeights(): GroundMesh;
  96220. private _getFacetAt;
  96221. private _initHeightQuads;
  96222. private _computeHeightQuads;
  96223. /**
  96224. * Serializes this ground mesh
  96225. * @param serializationObject object to write serialization to
  96226. */
  96227. serialize(serializationObject: any): void;
  96228. /**
  96229. * Parses a serialized ground mesh
  96230. * @param parsedMesh the serialized mesh
  96231. * @param scene the scene to create the ground mesh in
  96232. * @returns the created ground mesh
  96233. */
  96234. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96235. }
  96236. }
  96237. declare module BABYLON {
  96238. /**
  96239. * Interface for Physics-Joint data
  96240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96241. */
  96242. export interface PhysicsJointData {
  96243. /**
  96244. * The main pivot of the joint
  96245. */
  96246. mainPivot?: Vector3;
  96247. /**
  96248. * The connected pivot of the joint
  96249. */
  96250. connectedPivot?: Vector3;
  96251. /**
  96252. * The main axis of the joint
  96253. */
  96254. mainAxis?: Vector3;
  96255. /**
  96256. * The connected axis of the joint
  96257. */
  96258. connectedAxis?: Vector3;
  96259. /**
  96260. * The collision of the joint
  96261. */
  96262. collision?: boolean;
  96263. /**
  96264. * Native Oimo/Cannon/Energy data
  96265. */
  96266. nativeParams?: any;
  96267. }
  96268. /**
  96269. * This is a holder class for the physics joint created by the physics plugin
  96270. * It holds a set of functions to control the underlying joint
  96271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96272. */
  96273. export class PhysicsJoint {
  96274. /**
  96275. * The type of the physics joint
  96276. */
  96277. type: number;
  96278. /**
  96279. * The data for the physics joint
  96280. */
  96281. jointData: PhysicsJointData;
  96282. private _physicsJoint;
  96283. protected _physicsPlugin: IPhysicsEnginePlugin;
  96284. /**
  96285. * Initializes the physics joint
  96286. * @param type The type of the physics joint
  96287. * @param jointData The data for the physics joint
  96288. */
  96289. constructor(
  96290. /**
  96291. * The type of the physics joint
  96292. */
  96293. type: number,
  96294. /**
  96295. * The data for the physics joint
  96296. */
  96297. jointData: PhysicsJointData);
  96298. /**
  96299. * Gets the physics joint
  96300. */
  96301. get physicsJoint(): any;
  96302. /**
  96303. * Sets the physics joint
  96304. */
  96305. set physicsJoint(newJoint: any);
  96306. /**
  96307. * Sets the physics plugin
  96308. */
  96309. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96310. /**
  96311. * Execute a function that is physics-plugin specific.
  96312. * @param {Function} func the function that will be executed.
  96313. * It accepts two parameters: the physics world and the physics joint
  96314. */
  96315. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96316. /**
  96317. * Distance-Joint type
  96318. */
  96319. static DistanceJoint: number;
  96320. /**
  96321. * Hinge-Joint type
  96322. */
  96323. static HingeJoint: number;
  96324. /**
  96325. * Ball-and-Socket joint type
  96326. */
  96327. static BallAndSocketJoint: number;
  96328. /**
  96329. * Wheel-Joint type
  96330. */
  96331. static WheelJoint: number;
  96332. /**
  96333. * Slider-Joint type
  96334. */
  96335. static SliderJoint: number;
  96336. /**
  96337. * Prismatic-Joint type
  96338. */
  96339. static PrismaticJoint: number;
  96340. /**
  96341. * Universal-Joint type
  96342. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96343. */
  96344. static UniversalJoint: number;
  96345. /**
  96346. * Hinge-Joint 2 type
  96347. */
  96348. static Hinge2Joint: number;
  96349. /**
  96350. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96351. */
  96352. static PointToPointJoint: number;
  96353. /**
  96354. * Spring-Joint type
  96355. */
  96356. static SpringJoint: number;
  96357. /**
  96358. * Lock-Joint type
  96359. */
  96360. static LockJoint: number;
  96361. }
  96362. /**
  96363. * A class representing a physics distance joint
  96364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96365. */
  96366. export class DistanceJoint extends PhysicsJoint {
  96367. /**
  96368. *
  96369. * @param jointData The data for the Distance-Joint
  96370. */
  96371. constructor(jointData: DistanceJointData);
  96372. /**
  96373. * Update the predefined distance.
  96374. * @param maxDistance The maximum preferred distance
  96375. * @param minDistance The minimum preferred distance
  96376. */
  96377. updateDistance(maxDistance: number, minDistance?: number): void;
  96378. }
  96379. /**
  96380. * Represents a Motor-Enabled Joint
  96381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96382. */
  96383. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96384. /**
  96385. * Initializes the Motor-Enabled Joint
  96386. * @param type The type of the joint
  96387. * @param jointData The physica joint data for the joint
  96388. */
  96389. constructor(type: number, jointData: PhysicsJointData);
  96390. /**
  96391. * Set the motor values.
  96392. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96393. * @param force the force to apply
  96394. * @param maxForce max force for this motor.
  96395. */
  96396. setMotor(force?: number, maxForce?: number): void;
  96397. /**
  96398. * Set the motor's limits.
  96399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96400. * @param upperLimit The upper limit of the motor
  96401. * @param lowerLimit The lower limit of the motor
  96402. */
  96403. setLimit(upperLimit: number, lowerLimit?: number): void;
  96404. }
  96405. /**
  96406. * This class represents a single physics Hinge-Joint
  96407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96408. */
  96409. export class HingeJoint extends MotorEnabledJoint {
  96410. /**
  96411. * Initializes the Hinge-Joint
  96412. * @param jointData The joint data for the Hinge-Joint
  96413. */
  96414. constructor(jointData: PhysicsJointData);
  96415. /**
  96416. * Set the motor values.
  96417. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96418. * @param {number} force the force to apply
  96419. * @param {number} maxForce max force for this motor.
  96420. */
  96421. setMotor(force?: number, maxForce?: number): void;
  96422. /**
  96423. * Set the motor's limits.
  96424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96425. * @param upperLimit The upper limit of the motor
  96426. * @param lowerLimit The lower limit of the motor
  96427. */
  96428. setLimit(upperLimit: number, lowerLimit?: number): void;
  96429. }
  96430. /**
  96431. * This class represents a dual hinge physics joint (same as wheel joint)
  96432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96433. */
  96434. export class Hinge2Joint extends MotorEnabledJoint {
  96435. /**
  96436. * Initializes the Hinge2-Joint
  96437. * @param jointData The joint data for the Hinge2-Joint
  96438. */
  96439. constructor(jointData: PhysicsJointData);
  96440. /**
  96441. * Set the motor values.
  96442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96443. * @param {number} targetSpeed the speed the motor is to reach
  96444. * @param {number} maxForce max force for this motor.
  96445. * @param {motorIndex} the motor's index, 0 or 1.
  96446. */
  96447. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96448. /**
  96449. * Set the motor limits.
  96450. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96451. * @param {number} upperLimit the upper limit
  96452. * @param {number} lowerLimit lower limit
  96453. * @param {motorIndex} the motor's index, 0 or 1.
  96454. */
  96455. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96456. }
  96457. /**
  96458. * Interface for a motor enabled joint
  96459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96460. */
  96461. export interface IMotorEnabledJoint {
  96462. /**
  96463. * Physics joint
  96464. */
  96465. physicsJoint: any;
  96466. /**
  96467. * Sets the motor of the motor-enabled joint
  96468. * @param force The force of the motor
  96469. * @param maxForce The maximum force of the motor
  96470. * @param motorIndex The index of the motor
  96471. */
  96472. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96473. /**
  96474. * Sets the limit of the motor
  96475. * @param upperLimit The upper limit of the motor
  96476. * @param lowerLimit The lower limit of the motor
  96477. * @param motorIndex The index of the motor
  96478. */
  96479. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96480. }
  96481. /**
  96482. * Joint data for a Distance-Joint
  96483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96484. */
  96485. export interface DistanceJointData extends PhysicsJointData {
  96486. /**
  96487. * Max distance the 2 joint objects can be apart
  96488. */
  96489. maxDistance: number;
  96490. }
  96491. /**
  96492. * Joint data from a spring joint
  96493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96494. */
  96495. export interface SpringJointData extends PhysicsJointData {
  96496. /**
  96497. * Length of the spring
  96498. */
  96499. length: number;
  96500. /**
  96501. * Stiffness of the spring
  96502. */
  96503. stiffness: number;
  96504. /**
  96505. * Damping of the spring
  96506. */
  96507. damping: number;
  96508. /** this callback will be called when applying the force to the impostors. */
  96509. forceApplicationCallback: () => void;
  96510. }
  96511. }
  96512. declare module BABYLON {
  96513. /**
  96514. * Holds the data for the raycast result
  96515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96516. */
  96517. export class PhysicsRaycastResult {
  96518. private _hasHit;
  96519. private _hitDistance;
  96520. private _hitNormalWorld;
  96521. private _hitPointWorld;
  96522. private _rayFromWorld;
  96523. private _rayToWorld;
  96524. /**
  96525. * Gets if there was a hit
  96526. */
  96527. get hasHit(): boolean;
  96528. /**
  96529. * Gets the distance from the hit
  96530. */
  96531. get hitDistance(): number;
  96532. /**
  96533. * Gets the hit normal/direction in the world
  96534. */
  96535. get hitNormalWorld(): Vector3;
  96536. /**
  96537. * Gets the hit point in the world
  96538. */
  96539. get hitPointWorld(): Vector3;
  96540. /**
  96541. * Gets the ray "start point" of the ray in the world
  96542. */
  96543. get rayFromWorld(): Vector3;
  96544. /**
  96545. * Gets the ray "end point" of the ray in the world
  96546. */
  96547. get rayToWorld(): Vector3;
  96548. /**
  96549. * Sets the hit data (normal & point in world space)
  96550. * @param hitNormalWorld defines the normal in world space
  96551. * @param hitPointWorld defines the point in world space
  96552. */
  96553. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96554. /**
  96555. * Sets the distance from the start point to the hit point
  96556. * @param distance
  96557. */
  96558. setHitDistance(distance: number): void;
  96559. /**
  96560. * Calculates the distance manually
  96561. */
  96562. calculateHitDistance(): void;
  96563. /**
  96564. * Resets all the values to default
  96565. * @param from The from point on world space
  96566. * @param to The to point on world space
  96567. */
  96568. reset(from?: Vector3, to?: Vector3): void;
  96569. }
  96570. /**
  96571. * Interface for the size containing width and height
  96572. */
  96573. interface IXYZ {
  96574. /**
  96575. * X
  96576. */
  96577. x: number;
  96578. /**
  96579. * Y
  96580. */
  96581. y: number;
  96582. /**
  96583. * Z
  96584. */
  96585. z: number;
  96586. }
  96587. }
  96588. declare module BABYLON {
  96589. /**
  96590. * Interface used to describe a physics joint
  96591. */
  96592. export interface PhysicsImpostorJoint {
  96593. /** Defines the main impostor to which the joint is linked */
  96594. mainImpostor: PhysicsImpostor;
  96595. /** Defines the impostor that is connected to the main impostor using this joint */
  96596. connectedImpostor: PhysicsImpostor;
  96597. /** Defines the joint itself */
  96598. joint: PhysicsJoint;
  96599. }
  96600. /** @hidden */
  96601. export interface IPhysicsEnginePlugin {
  96602. world: any;
  96603. name: string;
  96604. setGravity(gravity: Vector3): void;
  96605. setTimeStep(timeStep: number): void;
  96606. getTimeStep(): number;
  96607. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96608. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96609. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96610. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96611. removePhysicsBody(impostor: PhysicsImpostor): void;
  96612. generateJoint(joint: PhysicsImpostorJoint): void;
  96613. removeJoint(joint: PhysicsImpostorJoint): void;
  96614. isSupported(): boolean;
  96615. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96616. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96617. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96618. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96619. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96620. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96621. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96622. getBodyMass(impostor: PhysicsImpostor): number;
  96623. getBodyFriction(impostor: PhysicsImpostor): number;
  96624. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96625. getBodyRestitution(impostor: PhysicsImpostor): number;
  96626. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96627. getBodyPressure?(impostor: PhysicsImpostor): number;
  96628. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96629. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96630. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96631. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96632. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96633. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96634. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96635. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96636. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96637. sleepBody(impostor: PhysicsImpostor): void;
  96638. wakeUpBody(impostor: PhysicsImpostor): void;
  96639. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96641. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96642. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96643. getRadius(impostor: PhysicsImpostor): number;
  96644. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96645. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96646. dispose(): void;
  96647. }
  96648. /**
  96649. * Interface used to define a physics engine
  96650. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96651. */
  96652. export interface IPhysicsEngine {
  96653. /**
  96654. * Gets the gravity vector used by the simulation
  96655. */
  96656. gravity: Vector3;
  96657. /**
  96658. * Sets the gravity vector used by the simulation
  96659. * @param gravity defines the gravity vector to use
  96660. */
  96661. setGravity(gravity: Vector3): void;
  96662. /**
  96663. * Set the time step of the physics engine.
  96664. * Default is 1/60.
  96665. * To slow it down, enter 1/600 for example.
  96666. * To speed it up, 1/30
  96667. * @param newTimeStep the new timestep to apply to this world.
  96668. */
  96669. setTimeStep(newTimeStep: number): void;
  96670. /**
  96671. * Get the time step of the physics engine.
  96672. * @returns the current time step
  96673. */
  96674. getTimeStep(): number;
  96675. /**
  96676. * Set the sub time step of the physics engine.
  96677. * Default is 0 meaning there is no sub steps
  96678. * To increase physics resolution precision, set a small value (like 1 ms)
  96679. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96680. */
  96681. setSubTimeStep(subTimeStep: number): void;
  96682. /**
  96683. * Get the sub time step of the physics engine.
  96684. * @returns the current sub time step
  96685. */
  96686. getSubTimeStep(): number;
  96687. /**
  96688. * Release all resources
  96689. */
  96690. dispose(): void;
  96691. /**
  96692. * Gets the name of the current physics plugin
  96693. * @returns the name of the plugin
  96694. */
  96695. getPhysicsPluginName(): string;
  96696. /**
  96697. * Adding a new impostor for the impostor tracking.
  96698. * This will be done by the impostor itself.
  96699. * @param impostor the impostor to add
  96700. */
  96701. addImpostor(impostor: PhysicsImpostor): void;
  96702. /**
  96703. * Remove an impostor from the engine.
  96704. * This impostor and its mesh will not longer be updated by the physics engine.
  96705. * @param impostor the impostor to remove
  96706. */
  96707. removeImpostor(impostor: PhysicsImpostor): void;
  96708. /**
  96709. * Add a joint to the physics engine
  96710. * @param mainImpostor defines the main impostor to which the joint is added.
  96711. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96712. * @param joint defines the joint that will connect both impostors.
  96713. */
  96714. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96715. /**
  96716. * Removes a joint from the simulation
  96717. * @param mainImpostor defines the impostor used with the joint
  96718. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96719. * @param joint defines the joint to remove
  96720. */
  96721. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96722. /**
  96723. * Gets the current plugin used to run the simulation
  96724. * @returns current plugin
  96725. */
  96726. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96727. /**
  96728. * Gets the list of physic impostors
  96729. * @returns an array of PhysicsImpostor
  96730. */
  96731. getImpostors(): Array<PhysicsImpostor>;
  96732. /**
  96733. * Gets the impostor for a physics enabled object
  96734. * @param object defines the object impersonated by the impostor
  96735. * @returns the PhysicsImpostor or null if not found
  96736. */
  96737. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96738. /**
  96739. * Gets the impostor for a physics body object
  96740. * @param body defines physics body used by the impostor
  96741. * @returns the PhysicsImpostor or null if not found
  96742. */
  96743. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96744. /**
  96745. * Does a raycast in the physics world
  96746. * @param from when should the ray start?
  96747. * @param to when should the ray end?
  96748. * @returns PhysicsRaycastResult
  96749. */
  96750. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96751. /**
  96752. * Called by the scene. No need to call it.
  96753. * @param delta defines the timespam between frames
  96754. */
  96755. _step(delta: number): void;
  96756. }
  96757. }
  96758. declare module BABYLON {
  96759. /**
  96760. * The interface for the physics imposter parameters
  96761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96762. */
  96763. export interface PhysicsImpostorParameters {
  96764. /**
  96765. * The mass of the physics imposter
  96766. */
  96767. mass: number;
  96768. /**
  96769. * The friction of the physics imposter
  96770. */
  96771. friction?: number;
  96772. /**
  96773. * The coefficient of restitution of the physics imposter
  96774. */
  96775. restitution?: number;
  96776. /**
  96777. * The native options of the physics imposter
  96778. */
  96779. nativeOptions?: any;
  96780. /**
  96781. * Specifies if the parent should be ignored
  96782. */
  96783. ignoreParent?: boolean;
  96784. /**
  96785. * Specifies if bi-directional transformations should be disabled
  96786. */
  96787. disableBidirectionalTransformation?: boolean;
  96788. /**
  96789. * The pressure inside the physics imposter, soft object only
  96790. */
  96791. pressure?: number;
  96792. /**
  96793. * The stiffness the physics imposter, soft object only
  96794. */
  96795. stiffness?: number;
  96796. /**
  96797. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96798. */
  96799. velocityIterations?: number;
  96800. /**
  96801. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96802. */
  96803. positionIterations?: number;
  96804. /**
  96805. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96806. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96807. * Add to fix multiple points
  96808. */
  96809. fixedPoints?: number;
  96810. /**
  96811. * The collision margin around a soft object
  96812. */
  96813. margin?: number;
  96814. /**
  96815. * The collision margin around a soft object
  96816. */
  96817. damping?: number;
  96818. /**
  96819. * The path for a rope based on an extrusion
  96820. */
  96821. path?: any;
  96822. /**
  96823. * The shape of an extrusion used for a rope based on an extrusion
  96824. */
  96825. shape?: any;
  96826. }
  96827. /**
  96828. * Interface for a physics-enabled object
  96829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96830. */
  96831. export interface IPhysicsEnabledObject {
  96832. /**
  96833. * The position of the physics-enabled object
  96834. */
  96835. position: Vector3;
  96836. /**
  96837. * The rotation of the physics-enabled object
  96838. */
  96839. rotationQuaternion: Nullable<Quaternion>;
  96840. /**
  96841. * The scale of the physics-enabled object
  96842. */
  96843. scaling: Vector3;
  96844. /**
  96845. * The rotation of the physics-enabled object
  96846. */
  96847. rotation?: Vector3;
  96848. /**
  96849. * The parent of the physics-enabled object
  96850. */
  96851. parent?: any;
  96852. /**
  96853. * The bounding info of the physics-enabled object
  96854. * @returns The bounding info of the physics-enabled object
  96855. */
  96856. getBoundingInfo(): BoundingInfo;
  96857. /**
  96858. * Computes the world matrix
  96859. * @param force Specifies if the world matrix should be computed by force
  96860. * @returns A world matrix
  96861. */
  96862. computeWorldMatrix(force: boolean): Matrix;
  96863. /**
  96864. * Gets the world matrix
  96865. * @returns A world matrix
  96866. */
  96867. getWorldMatrix?(): Matrix;
  96868. /**
  96869. * Gets the child meshes
  96870. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96871. * @returns An array of abstract meshes
  96872. */
  96873. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96874. /**
  96875. * Gets the vertex data
  96876. * @param kind The type of vertex data
  96877. * @returns A nullable array of numbers, or a float32 array
  96878. */
  96879. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96880. /**
  96881. * Gets the indices from the mesh
  96882. * @returns A nullable array of index arrays
  96883. */
  96884. getIndices?(): Nullable<IndicesArray>;
  96885. /**
  96886. * Gets the scene from the mesh
  96887. * @returns the indices array or null
  96888. */
  96889. getScene?(): Scene;
  96890. /**
  96891. * Gets the absolute position from the mesh
  96892. * @returns the absolute position
  96893. */
  96894. getAbsolutePosition(): Vector3;
  96895. /**
  96896. * Gets the absolute pivot point from the mesh
  96897. * @returns the absolute pivot point
  96898. */
  96899. getAbsolutePivotPoint(): Vector3;
  96900. /**
  96901. * Rotates the mesh
  96902. * @param axis The axis of rotation
  96903. * @param amount The amount of rotation
  96904. * @param space The space of the rotation
  96905. * @returns The rotation transform node
  96906. */
  96907. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96908. /**
  96909. * Translates the mesh
  96910. * @param axis The axis of translation
  96911. * @param distance The distance of translation
  96912. * @param space The space of the translation
  96913. * @returns The transform node
  96914. */
  96915. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96916. /**
  96917. * Sets the absolute position of the mesh
  96918. * @param absolutePosition The absolute position of the mesh
  96919. * @returns The transform node
  96920. */
  96921. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96922. /**
  96923. * Gets the class name of the mesh
  96924. * @returns The class name
  96925. */
  96926. getClassName(): string;
  96927. }
  96928. /**
  96929. * Represents a physics imposter
  96930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96931. */
  96932. export class PhysicsImpostor {
  96933. /**
  96934. * The physics-enabled object used as the physics imposter
  96935. */
  96936. object: IPhysicsEnabledObject;
  96937. /**
  96938. * The type of the physics imposter
  96939. */
  96940. type: number;
  96941. private _options;
  96942. private _scene?;
  96943. /**
  96944. * The default object size of the imposter
  96945. */
  96946. static DEFAULT_OBJECT_SIZE: Vector3;
  96947. /**
  96948. * The identity quaternion of the imposter
  96949. */
  96950. static IDENTITY_QUATERNION: Quaternion;
  96951. /** @hidden */
  96952. _pluginData: any;
  96953. private _physicsEngine;
  96954. private _physicsBody;
  96955. private _bodyUpdateRequired;
  96956. private _onBeforePhysicsStepCallbacks;
  96957. private _onAfterPhysicsStepCallbacks;
  96958. /** @hidden */
  96959. _onPhysicsCollideCallbacks: Array<{
  96960. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96961. otherImpostors: Array<PhysicsImpostor>;
  96962. }>;
  96963. private _deltaPosition;
  96964. private _deltaRotation;
  96965. private _deltaRotationConjugated;
  96966. /** @hidden */
  96967. _isFromLine: boolean;
  96968. private _parent;
  96969. private _isDisposed;
  96970. private static _tmpVecs;
  96971. private static _tmpQuat;
  96972. /**
  96973. * Specifies if the physics imposter is disposed
  96974. */
  96975. get isDisposed(): boolean;
  96976. /**
  96977. * Gets the mass of the physics imposter
  96978. */
  96979. get mass(): number;
  96980. set mass(value: number);
  96981. /**
  96982. * Gets the coefficient of friction
  96983. */
  96984. get friction(): number;
  96985. /**
  96986. * Sets the coefficient of friction
  96987. */
  96988. set friction(value: number);
  96989. /**
  96990. * Gets the coefficient of restitution
  96991. */
  96992. get restitution(): number;
  96993. /**
  96994. * Sets the coefficient of restitution
  96995. */
  96996. set restitution(value: number);
  96997. /**
  96998. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96999. */
  97000. get pressure(): number;
  97001. /**
  97002. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97003. */
  97004. set pressure(value: number);
  97005. /**
  97006. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97007. */
  97008. get stiffness(): number;
  97009. /**
  97010. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97011. */
  97012. set stiffness(value: number);
  97013. /**
  97014. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97015. */
  97016. get velocityIterations(): number;
  97017. /**
  97018. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97019. */
  97020. set velocityIterations(value: number);
  97021. /**
  97022. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97023. */
  97024. get positionIterations(): number;
  97025. /**
  97026. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97027. */
  97028. set positionIterations(value: number);
  97029. /**
  97030. * The unique id of the physics imposter
  97031. * set by the physics engine when adding this impostor to the array
  97032. */
  97033. uniqueId: number;
  97034. /**
  97035. * @hidden
  97036. */
  97037. soft: boolean;
  97038. /**
  97039. * @hidden
  97040. */
  97041. segments: number;
  97042. private _joints;
  97043. /**
  97044. * Initializes the physics imposter
  97045. * @param object The physics-enabled object used as the physics imposter
  97046. * @param type The type of the physics imposter
  97047. * @param _options The options for the physics imposter
  97048. * @param _scene The Babylon scene
  97049. */
  97050. constructor(
  97051. /**
  97052. * The physics-enabled object used as the physics imposter
  97053. */
  97054. object: IPhysicsEnabledObject,
  97055. /**
  97056. * The type of the physics imposter
  97057. */
  97058. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97059. /**
  97060. * This function will completly initialize this impostor.
  97061. * It will create a new body - but only if this mesh has no parent.
  97062. * If it has, this impostor will not be used other than to define the impostor
  97063. * of the child mesh.
  97064. * @hidden
  97065. */
  97066. _init(): void;
  97067. private _getPhysicsParent;
  97068. /**
  97069. * Should a new body be generated.
  97070. * @returns boolean specifying if body initialization is required
  97071. */
  97072. isBodyInitRequired(): boolean;
  97073. /**
  97074. * Sets the updated scaling
  97075. * @param updated Specifies if the scaling is updated
  97076. */
  97077. setScalingUpdated(): void;
  97078. /**
  97079. * Force a regeneration of this or the parent's impostor's body.
  97080. * Use under cautious - This will remove all joints already implemented.
  97081. */
  97082. forceUpdate(): void;
  97083. /**
  97084. * Gets the body that holds this impostor. Either its own, or its parent.
  97085. */
  97086. get physicsBody(): any;
  97087. /**
  97088. * Get the parent of the physics imposter
  97089. * @returns Physics imposter or null
  97090. */
  97091. get parent(): Nullable<PhysicsImpostor>;
  97092. /**
  97093. * Sets the parent of the physics imposter
  97094. */
  97095. set parent(value: Nullable<PhysicsImpostor>);
  97096. /**
  97097. * Set the physics body. Used mainly by the physics engine/plugin
  97098. */
  97099. set physicsBody(physicsBody: any);
  97100. /**
  97101. * Resets the update flags
  97102. */
  97103. resetUpdateFlags(): void;
  97104. /**
  97105. * Gets the object extend size
  97106. * @returns the object extend size
  97107. */
  97108. getObjectExtendSize(): Vector3;
  97109. /**
  97110. * Gets the object center
  97111. * @returns The object center
  97112. */
  97113. getObjectCenter(): Vector3;
  97114. /**
  97115. * Get a specific parameter from the options parameters
  97116. * @param paramName The object parameter name
  97117. * @returns The object parameter
  97118. */
  97119. getParam(paramName: string): any;
  97120. /**
  97121. * Sets a specific parameter in the options given to the physics plugin
  97122. * @param paramName The parameter name
  97123. * @param value The value of the parameter
  97124. */
  97125. setParam(paramName: string, value: number): void;
  97126. /**
  97127. * Specifically change the body's mass option. Won't recreate the physics body object
  97128. * @param mass The mass of the physics imposter
  97129. */
  97130. setMass(mass: number): void;
  97131. /**
  97132. * Gets the linear velocity
  97133. * @returns linear velocity or null
  97134. */
  97135. getLinearVelocity(): Nullable<Vector3>;
  97136. /**
  97137. * Sets the linear velocity
  97138. * @param velocity linear velocity or null
  97139. */
  97140. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97141. /**
  97142. * Gets the angular velocity
  97143. * @returns angular velocity or null
  97144. */
  97145. getAngularVelocity(): Nullable<Vector3>;
  97146. /**
  97147. * Sets the angular velocity
  97148. * @param velocity The velocity or null
  97149. */
  97150. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97151. /**
  97152. * Execute a function with the physics plugin native code
  97153. * Provide a function the will have two variables - the world object and the physics body object
  97154. * @param func The function to execute with the physics plugin native code
  97155. */
  97156. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97157. /**
  97158. * Register a function that will be executed before the physics world is stepping forward
  97159. * @param func The function to execute before the physics world is stepped forward
  97160. */
  97161. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97162. /**
  97163. * Unregister a function that will be executed before the physics world is stepping forward
  97164. * @param func The function to execute before the physics world is stepped forward
  97165. */
  97166. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97167. /**
  97168. * Register a function that will be executed after the physics step
  97169. * @param func The function to execute after physics step
  97170. */
  97171. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97172. /**
  97173. * Unregisters a function that will be executed after the physics step
  97174. * @param func The function to execute after physics step
  97175. */
  97176. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97177. /**
  97178. * register a function that will be executed when this impostor collides against a different body
  97179. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97180. * @param func Callback that is executed on collision
  97181. */
  97182. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97183. /**
  97184. * Unregisters the physics imposter on contact
  97185. * @param collideAgainst The physics object to collide against
  97186. * @param func Callback to execute on collision
  97187. */
  97188. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97189. private _tmpQuat;
  97190. private _tmpQuat2;
  97191. /**
  97192. * Get the parent rotation
  97193. * @returns The parent rotation
  97194. */
  97195. getParentsRotation(): Quaternion;
  97196. /**
  97197. * this function is executed by the physics engine.
  97198. */
  97199. beforeStep: () => void;
  97200. /**
  97201. * this function is executed by the physics engine
  97202. */
  97203. afterStep: () => void;
  97204. /**
  97205. * Legacy collision detection event support
  97206. */
  97207. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97208. /**
  97209. * event and body object due to cannon's event-based architecture.
  97210. */
  97211. onCollide: (e: {
  97212. body: any;
  97213. }) => void;
  97214. /**
  97215. * Apply a force
  97216. * @param force The force to apply
  97217. * @param contactPoint The contact point for the force
  97218. * @returns The physics imposter
  97219. */
  97220. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97221. /**
  97222. * Apply an impulse
  97223. * @param force The impulse force
  97224. * @param contactPoint The contact point for the impulse force
  97225. * @returns The physics imposter
  97226. */
  97227. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97228. /**
  97229. * A help function to create a joint
  97230. * @param otherImpostor A physics imposter used to create a joint
  97231. * @param jointType The type of joint
  97232. * @param jointData The data for the joint
  97233. * @returns The physics imposter
  97234. */
  97235. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97236. /**
  97237. * Add a joint to this impostor with a different impostor
  97238. * @param otherImpostor A physics imposter used to add a joint
  97239. * @param joint The joint to add
  97240. * @returns The physics imposter
  97241. */
  97242. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97243. /**
  97244. * Add an anchor to a cloth impostor
  97245. * @param otherImpostor rigid impostor to anchor to
  97246. * @param width ratio across width from 0 to 1
  97247. * @param height ratio up height from 0 to 1
  97248. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97249. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97250. * @returns impostor the soft imposter
  97251. */
  97252. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97253. /**
  97254. * Add a hook to a rope impostor
  97255. * @param otherImpostor rigid impostor to anchor to
  97256. * @param length ratio across rope from 0 to 1
  97257. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97258. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97259. * @returns impostor the rope imposter
  97260. */
  97261. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97262. /**
  97263. * Will keep this body still, in a sleep mode.
  97264. * @returns the physics imposter
  97265. */
  97266. sleep(): PhysicsImpostor;
  97267. /**
  97268. * Wake the body up.
  97269. * @returns The physics imposter
  97270. */
  97271. wakeUp(): PhysicsImpostor;
  97272. /**
  97273. * Clones the physics imposter
  97274. * @param newObject The physics imposter clones to this physics-enabled object
  97275. * @returns A nullable physics imposter
  97276. */
  97277. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97278. /**
  97279. * Disposes the physics imposter
  97280. */
  97281. dispose(): void;
  97282. /**
  97283. * Sets the delta position
  97284. * @param position The delta position amount
  97285. */
  97286. setDeltaPosition(position: Vector3): void;
  97287. /**
  97288. * Sets the delta rotation
  97289. * @param rotation The delta rotation amount
  97290. */
  97291. setDeltaRotation(rotation: Quaternion): void;
  97292. /**
  97293. * Gets the box size of the physics imposter and stores the result in the input parameter
  97294. * @param result Stores the box size
  97295. * @returns The physics imposter
  97296. */
  97297. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97298. /**
  97299. * Gets the radius of the physics imposter
  97300. * @returns Radius of the physics imposter
  97301. */
  97302. getRadius(): number;
  97303. /**
  97304. * Sync a bone with this impostor
  97305. * @param bone The bone to sync to the impostor.
  97306. * @param boneMesh The mesh that the bone is influencing.
  97307. * @param jointPivot The pivot of the joint / bone in local space.
  97308. * @param distToJoint Optional distance from the impostor to the joint.
  97309. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97310. */
  97311. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97312. /**
  97313. * Sync impostor to a bone
  97314. * @param bone The bone that the impostor will be synced to.
  97315. * @param boneMesh The mesh that the bone is influencing.
  97316. * @param jointPivot The pivot of the joint / bone in local space.
  97317. * @param distToJoint Optional distance from the impostor to the joint.
  97318. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97319. * @param boneAxis Optional vector3 axis the bone is aligned with
  97320. */
  97321. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97322. /**
  97323. * No-Imposter type
  97324. */
  97325. static NoImpostor: number;
  97326. /**
  97327. * Sphere-Imposter type
  97328. */
  97329. static SphereImpostor: number;
  97330. /**
  97331. * Box-Imposter type
  97332. */
  97333. static BoxImpostor: number;
  97334. /**
  97335. * Plane-Imposter type
  97336. */
  97337. static PlaneImpostor: number;
  97338. /**
  97339. * Mesh-imposter type
  97340. */
  97341. static MeshImpostor: number;
  97342. /**
  97343. * Capsule-Impostor type (Ammo.js plugin only)
  97344. */
  97345. static CapsuleImpostor: number;
  97346. /**
  97347. * Cylinder-Imposter type
  97348. */
  97349. static CylinderImpostor: number;
  97350. /**
  97351. * Particle-Imposter type
  97352. */
  97353. static ParticleImpostor: number;
  97354. /**
  97355. * Heightmap-Imposter type
  97356. */
  97357. static HeightmapImpostor: number;
  97358. /**
  97359. * ConvexHull-Impostor type (Ammo.js plugin only)
  97360. */
  97361. static ConvexHullImpostor: number;
  97362. /**
  97363. * Custom-Imposter type (Ammo.js plugin only)
  97364. */
  97365. static CustomImpostor: number;
  97366. /**
  97367. * Rope-Imposter type
  97368. */
  97369. static RopeImpostor: number;
  97370. /**
  97371. * Cloth-Imposter type
  97372. */
  97373. static ClothImpostor: number;
  97374. /**
  97375. * Softbody-Imposter type
  97376. */
  97377. static SoftbodyImpostor: number;
  97378. }
  97379. }
  97380. declare module BABYLON {
  97381. /**
  97382. * @hidden
  97383. **/
  97384. export class _CreationDataStorage {
  97385. closePath?: boolean;
  97386. closeArray?: boolean;
  97387. idx: number[];
  97388. dashSize: number;
  97389. gapSize: number;
  97390. path3D: Path3D;
  97391. pathArray: Vector3[][];
  97392. arc: number;
  97393. radius: number;
  97394. cap: number;
  97395. tessellation: number;
  97396. }
  97397. /**
  97398. * @hidden
  97399. **/
  97400. class _InstanceDataStorage {
  97401. visibleInstances: any;
  97402. batchCache: _InstancesBatch;
  97403. instancesBufferSize: number;
  97404. instancesBuffer: Nullable<Buffer>;
  97405. instancesData: Float32Array;
  97406. overridenInstanceCount: number;
  97407. isFrozen: boolean;
  97408. previousBatch: Nullable<_InstancesBatch>;
  97409. hardwareInstancedRendering: boolean;
  97410. sideOrientation: number;
  97411. manualUpdate: boolean;
  97412. }
  97413. /**
  97414. * @hidden
  97415. **/
  97416. export class _InstancesBatch {
  97417. mustReturn: boolean;
  97418. visibleInstances: Nullable<InstancedMesh[]>[];
  97419. renderSelf: boolean[];
  97420. hardwareInstancedRendering: boolean[];
  97421. }
  97422. /**
  97423. * Class used to represent renderable models
  97424. */
  97425. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97426. /**
  97427. * Mesh side orientation : usually the external or front surface
  97428. */
  97429. static readonly FRONTSIDE: number;
  97430. /**
  97431. * Mesh side orientation : usually the internal or back surface
  97432. */
  97433. static readonly BACKSIDE: number;
  97434. /**
  97435. * Mesh side orientation : both internal and external or front and back surfaces
  97436. */
  97437. static readonly DOUBLESIDE: number;
  97438. /**
  97439. * Mesh side orientation : by default, `FRONTSIDE`
  97440. */
  97441. static readonly DEFAULTSIDE: number;
  97442. /**
  97443. * Mesh cap setting : no cap
  97444. */
  97445. static readonly NO_CAP: number;
  97446. /**
  97447. * Mesh cap setting : one cap at the beginning of the mesh
  97448. */
  97449. static readonly CAP_START: number;
  97450. /**
  97451. * Mesh cap setting : one cap at the end of the mesh
  97452. */
  97453. static readonly CAP_END: number;
  97454. /**
  97455. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97456. */
  97457. static readonly CAP_ALL: number;
  97458. /**
  97459. * Mesh pattern setting : no flip or rotate
  97460. */
  97461. static readonly NO_FLIP: number;
  97462. /**
  97463. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97464. */
  97465. static readonly FLIP_TILE: number;
  97466. /**
  97467. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97468. */
  97469. static readonly ROTATE_TILE: number;
  97470. /**
  97471. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97472. */
  97473. static readonly FLIP_ROW: number;
  97474. /**
  97475. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97476. */
  97477. static readonly ROTATE_ROW: number;
  97478. /**
  97479. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97480. */
  97481. static readonly FLIP_N_ROTATE_TILE: number;
  97482. /**
  97483. * Mesh pattern setting : rotate pattern and rotate
  97484. */
  97485. static readonly FLIP_N_ROTATE_ROW: number;
  97486. /**
  97487. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97488. */
  97489. static readonly CENTER: number;
  97490. /**
  97491. * Mesh tile positioning : part tiles on left
  97492. */
  97493. static readonly LEFT: number;
  97494. /**
  97495. * Mesh tile positioning : part tiles on right
  97496. */
  97497. static readonly RIGHT: number;
  97498. /**
  97499. * Mesh tile positioning : part tiles on top
  97500. */
  97501. static readonly TOP: number;
  97502. /**
  97503. * Mesh tile positioning : part tiles on bottom
  97504. */
  97505. static readonly BOTTOM: number;
  97506. /**
  97507. * Gets the default side orientation.
  97508. * @param orientation the orientation to value to attempt to get
  97509. * @returns the default orientation
  97510. * @hidden
  97511. */
  97512. static _GetDefaultSideOrientation(orientation?: number): number;
  97513. private _internalMeshDataInfo;
  97514. /**
  97515. * An event triggered before rendering the mesh
  97516. */
  97517. get onBeforeRenderObservable(): Observable<Mesh>;
  97518. /**
  97519. * An event triggered before binding the mesh
  97520. */
  97521. get onBeforeBindObservable(): Observable<Mesh>;
  97522. /**
  97523. * An event triggered after rendering the mesh
  97524. */
  97525. get onAfterRenderObservable(): Observable<Mesh>;
  97526. /**
  97527. * An event triggered before drawing the mesh
  97528. */
  97529. get onBeforeDrawObservable(): Observable<Mesh>;
  97530. private _onBeforeDrawObserver;
  97531. /**
  97532. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97533. */
  97534. set onBeforeDraw(callback: () => void);
  97535. get hasInstances(): boolean;
  97536. /**
  97537. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97538. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97539. */
  97540. delayLoadState: number;
  97541. /**
  97542. * Gets the list of instances created from this mesh
  97543. * it is not supposed to be modified manually.
  97544. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97545. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97546. */
  97547. instances: InstancedMesh[];
  97548. /**
  97549. * Gets the file containing delay loading data for this mesh
  97550. */
  97551. delayLoadingFile: string;
  97552. /** @hidden */
  97553. _binaryInfo: any;
  97554. /**
  97555. * User defined function used to change how LOD level selection is done
  97556. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97557. */
  97558. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97559. /**
  97560. * Gets or sets the morph target manager
  97561. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97562. */
  97563. get morphTargetManager(): Nullable<MorphTargetManager>;
  97564. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97565. /** @hidden */
  97566. _creationDataStorage: Nullable<_CreationDataStorage>;
  97567. /** @hidden */
  97568. _geometry: Nullable<Geometry>;
  97569. /** @hidden */
  97570. _delayInfo: Array<string>;
  97571. /** @hidden */
  97572. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97573. /** @hidden */
  97574. _instanceDataStorage: _InstanceDataStorage;
  97575. private _effectiveMaterial;
  97576. /** @hidden */
  97577. _shouldGenerateFlatShading: boolean;
  97578. /** @hidden */
  97579. _originalBuilderSideOrientation: number;
  97580. /**
  97581. * Use this property to change the original side orientation defined at construction time
  97582. */
  97583. overrideMaterialSideOrientation: Nullable<number>;
  97584. /**
  97585. * Gets the source mesh (the one used to clone this one from)
  97586. */
  97587. get source(): Nullable<Mesh>;
  97588. /**
  97589. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97590. */
  97591. get isUnIndexed(): boolean;
  97592. set isUnIndexed(value: boolean);
  97593. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97594. get worldMatrixInstancedBuffer(): Float32Array;
  97595. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97596. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97597. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97598. /**
  97599. * @constructor
  97600. * @param name The value used by scene.getMeshByName() to do a lookup.
  97601. * @param scene The scene to add this mesh to.
  97602. * @param parent The parent of this mesh, if it has one
  97603. * @param source An optional Mesh from which geometry is shared, cloned.
  97604. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97605. * When false, achieved by calling a clone(), also passing False.
  97606. * This will make creation of children, recursive.
  97607. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97608. */
  97609. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97610. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97611. doNotInstantiate: boolean;
  97612. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97613. /**
  97614. * Gets the class name
  97615. * @returns the string "Mesh".
  97616. */
  97617. getClassName(): string;
  97618. /** @hidden */
  97619. get _isMesh(): boolean;
  97620. /**
  97621. * Returns a description of this mesh
  97622. * @param fullDetails define if full details about this mesh must be used
  97623. * @returns a descriptive string representing this mesh
  97624. */
  97625. toString(fullDetails?: boolean): string;
  97626. /** @hidden */
  97627. _unBindEffect(): void;
  97628. /**
  97629. * Gets a boolean indicating if this mesh has LOD
  97630. */
  97631. get hasLODLevels(): boolean;
  97632. /**
  97633. * Gets the list of MeshLODLevel associated with the current mesh
  97634. * @returns an array of MeshLODLevel
  97635. */
  97636. getLODLevels(): MeshLODLevel[];
  97637. private _sortLODLevels;
  97638. /**
  97639. * Add a mesh as LOD level triggered at the given distance.
  97640. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97641. * @param distance The distance from the center of the object to show this level
  97642. * @param mesh The mesh to be added as LOD level (can be null)
  97643. * @return This mesh (for chaining)
  97644. */
  97645. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97646. /**
  97647. * Returns the LOD level mesh at the passed distance or null if not found.
  97648. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97649. * @param distance The distance from the center of the object to show this level
  97650. * @returns a Mesh or `null`
  97651. */
  97652. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97653. /**
  97654. * Remove a mesh from the LOD array
  97655. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97656. * @param mesh defines the mesh to be removed
  97657. * @return This mesh (for chaining)
  97658. */
  97659. removeLODLevel(mesh: Mesh): Mesh;
  97660. /**
  97661. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97662. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97663. * @param camera defines the camera to use to compute distance
  97664. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97665. * @return This mesh (for chaining)
  97666. */
  97667. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97668. /**
  97669. * Gets the mesh internal Geometry object
  97670. */
  97671. get geometry(): Nullable<Geometry>;
  97672. /**
  97673. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97674. * @returns the total number of vertices
  97675. */
  97676. getTotalVertices(): number;
  97677. /**
  97678. * Returns the content of an associated vertex buffer
  97679. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97680. * - VertexBuffer.PositionKind
  97681. * - VertexBuffer.UVKind
  97682. * - VertexBuffer.UV2Kind
  97683. * - VertexBuffer.UV3Kind
  97684. * - VertexBuffer.UV4Kind
  97685. * - VertexBuffer.UV5Kind
  97686. * - VertexBuffer.UV6Kind
  97687. * - VertexBuffer.ColorKind
  97688. * - VertexBuffer.MatricesIndicesKind
  97689. * - VertexBuffer.MatricesIndicesExtraKind
  97690. * - VertexBuffer.MatricesWeightsKind
  97691. * - VertexBuffer.MatricesWeightsExtraKind
  97692. * @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
  97693. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97694. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97695. */
  97696. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97697. /**
  97698. * Returns the mesh VertexBuffer object from the requested `kind`
  97699. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97700. * - VertexBuffer.PositionKind
  97701. * - VertexBuffer.NormalKind
  97702. * - VertexBuffer.UVKind
  97703. * - VertexBuffer.UV2Kind
  97704. * - VertexBuffer.UV3Kind
  97705. * - VertexBuffer.UV4Kind
  97706. * - VertexBuffer.UV5Kind
  97707. * - VertexBuffer.UV6Kind
  97708. * - VertexBuffer.ColorKind
  97709. * - VertexBuffer.MatricesIndicesKind
  97710. * - VertexBuffer.MatricesIndicesExtraKind
  97711. * - VertexBuffer.MatricesWeightsKind
  97712. * - VertexBuffer.MatricesWeightsExtraKind
  97713. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97714. */
  97715. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97716. /**
  97717. * Tests if a specific vertex buffer is associated with this mesh
  97718. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97719. * - VertexBuffer.PositionKind
  97720. * - VertexBuffer.NormalKind
  97721. * - VertexBuffer.UVKind
  97722. * - VertexBuffer.UV2Kind
  97723. * - VertexBuffer.UV3Kind
  97724. * - VertexBuffer.UV4Kind
  97725. * - VertexBuffer.UV5Kind
  97726. * - VertexBuffer.UV6Kind
  97727. * - VertexBuffer.ColorKind
  97728. * - VertexBuffer.MatricesIndicesKind
  97729. * - VertexBuffer.MatricesIndicesExtraKind
  97730. * - VertexBuffer.MatricesWeightsKind
  97731. * - VertexBuffer.MatricesWeightsExtraKind
  97732. * @returns a boolean
  97733. */
  97734. isVerticesDataPresent(kind: string): boolean;
  97735. /**
  97736. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97737. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97738. * - VertexBuffer.PositionKind
  97739. * - VertexBuffer.UVKind
  97740. * - VertexBuffer.UV2Kind
  97741. * - VertexBuffer.UV3Kind
  97742. * - VertexBuffer.UV4Kind
  97743. * - VertexBuffer.UV5Kind
  97744. * - VertexBuffer.UV6Kind
  97745. * - VertexBuffer.ColorKind
  97746. * - VertexBuffer.MatricesIndicesKind
  97747. * - VertexBuffer.MatricesIndicesExtraKind
  97748. * - VertexBuffer.MatricesWeightsKind
  97749. * - VertexBuffer.MatricesWeightsExtraKind
  97750. * @returns a boolean
  97751. */
  97752. isVertexBufferUpdatable(kind: string): boolean;
  97753. /**
  97754. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97755. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97756. * - VertexBuffer.PositionKind
  97757. * - VertexBuffer.NormalKind
  97758. * - VertexBuffer.UVKind
  97759. * - VertexBuffer.UV2Kind
  97760. * - VertexBuffer.UV3Kind
  97761. * - VertexBuffer.UV4Kind
  97762. * - VertexBuffer.UV5Kind
  97763. * - VertexBuffer.UV6Kind
  97764. * - VertexBuffer.ColorKind
  97765. * - VertexBuffer.MatricesIndicesKind
  97766. * - VertexBuffer.MatricesIndicesExtraKind
  97767. * - VertexBuffer.MatricesWeightsKind
  97768. * - VertexBuffer.MatricesWeightsExtraKind
  97769. * @returns an array of strings
  97770. */
  97771. getVerticesDataKinds(): string[];
  97772. /**
  97773. * Returns a positive integer : the total number of indices in this mesh geometry.
  97774. * @returns the numner of indices or zero if the mesh has no geometry.
  97775. */
  97776. getTotalIndices(): number;
  97777. /**
  97778. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97779. * @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.
  97780. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97781. * @returns the indices array or an empty array if the mesh has no geometry
  97782. */
  97783. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97784. get isBlocked(): boolean;
  97785. /**
  97786. * Determine if the current mesh is ready to be rendered
  97787. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97788. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97789. * @returns true if all associated assets are ready (material, textures, shaders)
  97790. */
  97791. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97792. /**
  97793. * 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.
  97794. */
  97795. get areNormalsFrozen(): boolean;
  97796. /**
  97797. * 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.
  97798. * @returns the current mesh
  97799. */
  97800. freezeNormals(): Mesh;
  97801. /**
  97802. * 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
  97803. * @returns the current mesh
  97804. */
  97805. unfreezeNormals(): Mesh;
  97806. /**
  97807. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97808. */
  97809. set overridenInstanceCount(count: number);
  97810. /** @hidden */
  97811. _preActivate(): Mesh;
  97812. /** @hidden */
  97813. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97814. /** @hidden */
  97815. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97816. /**
  97817. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97818. * This means the mesh underlying bounding box and sphere are recomputed.
  97819. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97820. * @returns the current mesh
  97821. */
  97822. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97823. /** @hidden */
  97824. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97825. /**
  97826. * This function will subdivide the mesh into multiple submeshes
  97827. * @param count defines the expected number of submeshes
  97828. */
  97829. subdivide(count: number): void;
  97830. /**
  97831. * Copy a FloatArray into a specific associated vertex buffer
  97832. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97833. * - VertexBuffer.PositionKind
  97834. * - VertexBuffer.UVKind
  97835. * - VertexBuffer.UV2Kind
  97836. * - VertexBuffer.UV3Kind
  97837. * - VertexBuffer.UV4Kind
  97838. * - VertexBuffer.UV5Kind
  97839. * - VertexBuffer.UV6Kind
  97840. * - VertexBuffer.ColorKind
  97841. * - VertexBuffer.MatricesIndicesKind
  97842. * - VertexBuffer.MatricesIndicesExtraKind
  97843. * - VertexBuffer.MatricesWeightsKind
  97844. * - VertexBuffer.MatricesWeightsExtraKind
  97845. * @param data defines the data source
  97846. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97847. * @param stride defines the data stride size (can be null)
  97848. * @returns the current mesh
  97849. */
  97850. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97851. /**
  97852. * Delete a vertex buffer associated with this mesh
  97853. * @param kind defines which buffer to delete (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. */
  97867. removeVerticesData(kind: string): void;
  97868. /**
  97869. * Flags an associated vertex buffer as updatable
  97870. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97871. * - VertexBuffer.PositionKind
  97872. * - VertexBuffer.UVKind
  97873. * - VertexBuffer.UV2Kind
  97874. * - VertexBuffer.UV3Kind
  97875. * - VertexBuffer.UV4Kind
  97876. * - VertexBuffer.UV5Kind
  97877. * - VertexBuffer.UV6Kind
  97878. * - VertexBuffer.ColorKind
  97879. * - VertexBuffer.MatricesIndicesKind
  97880. * - VertexBuffer.MatricesIndicesExtraKind
  97881. * - VertexBuffer.MatricesWeightsKind
  97882. * - VertexBuffer.MatricesWeightsExtraKind
  97883. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97884. */
  97885. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97886. /**
  97887. * Sets the mesh global Vertex Buffer
  97888. * @param buffer defines the buffer to use
  97889. * @returns the current mesh
  97890. */
  97891. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97892. /**
  97893. * Update a specific associated vertex buffer
  97894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97895. * - VertexBuffer.PositionKind
  97896. * - VertexBuffer.UVKind
  97897. * - VertexBuffer.UV2Kind
  97898. * - VertexBuffer.UV3Kind
  97899. * - VertexBuffer.UV4Kind
  97900. * - VertexBuffer.UV5Kind
  97901. * - VertexBuffer.UV6Kind
  97902. * - VertexBuffer.ColorKind
  97903. * - VertexBuffer.MatricesIndicesKind
  97904. * - VertexBuffer.MatricesIndicesExtraKind
  97905. * - VertexBuffer.MatricesWeightsKind
  97906. * - VertexBuffer.MatricesWeightsExtraKind
  97907. * @param data defines the data source
  97908. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97909. * @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)
  97910. * @returns the current mesh
  97911. */
  97912. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97913. /**
  97914. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97915. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97916. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97917. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97918. * @returns the current mesh
  97919. */
  97920. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97921. /**
  97922. * Creates a un-shared specific occurence of the geometry for the mesh.
  97923. * @returns the current mesh
  97924. */
  97925. makeGeometryUnique(): Mesh;
  97926. /**
  97927. * Set the index buffer of this mesh
  97928. * @param indices defines the source data
  97929. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97930. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97931. * @returns the current mesh
  97932. */
  97933. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97934. /**
  97935. * Update the current index buffer
  97936. * @param indices defines the source data
  97937. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97938. * @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)
  97939. * @returns the current mesh
  97940. */
  97941. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97942. /**
  97943. * Invert the geometry to move from a right handed system to a left handed one.
  97944. * @returns the current mesh
  97945. */
  97946. toLeftHanded(): Mesh;
  97947. /** @hidden */
  97948. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97949. /** @hidden */
  97950. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97951. /**
  97952. * Registers for this mesh a javascript function called just before the rendering process
  97953. * @param func defines the function to call before rendering this mesh
  97954. * @returns the current mesh
  97955. */
  97956. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97957. /**
  97958. * Disposes a previously registered javascript function called before the rendering
  97959. * @param func defines the function to remove
  97960. * @returns the current mesh
  97961. */
  97962. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97963. /**
  97964. * Registers for this mesh a javascript function called just after the rendering is complete
  97965. * @param func defines the function to call after rendering this mesh
  97966. * @returns the current mesh
  97967. */
  97968. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97969. /**
  97970. * Disposes a previously registered javascript function called after the rendering.
  97971. * @param func defines the function to remove
  97972. * @returns the current mesh
  97973. */
  97974. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97975. /** @hidden */
  97976. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97977. /** @hidden */
  97978. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97979. /** @hidden */
  97980. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97981. /** @hidden */
  97982. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97983. /** @hidden */
  97984. _rebuild(): void;
  97985. /** @hidden */
  97986. _freeze(): void;
  97987. /** @hidden */
  97988. _unFreeze(): void;
  97989. /**
  97990. * 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
  97991. * @param subMesh defines the subMesh to render
  97992. * @param enableAlphaMode defines if alpha mode can be changed
  97993. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97994. * @returns the current mesh
  97995. */
  97996. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97997. private _onBeforeDraw;
  97998. /**
  97999. * Renormalize the mesh and patch it up if there are no weights
  98000. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98001. * However in the case of zero weights then we set just a single influence to 1.
  98002. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98003. */
  98004. cleanMatrixWeights(): void;
  98005. private normalizeSkinFourWeights;
  98006. private normalizeSkinWeightsAndExtra;
  98007. /**
  98008. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98009. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98010. * the user know there was an issue with importing the mesh
  98011. * @returns a validation object with skinned, valid and report string
  98012. */
  98013. validateSkinning(): {
  98014. skinned: boolean;
  98015. valid: boolean;
  98016. report: string;
  98017. };
  98018. /** @hidden */
  98019. _checkDelayState(): Mesh;
  98020. private _queueLoad;
  98021. /**
  98022. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98023. * A mesh is in the frustum if its bounding box intersects the frustum
  98024. * @param frustumPlanes defines the frustum to test
  98025. * @returns true if the mesh is in the frustum planes
  98026. */
  98027. isInFrustum(frustumPlanes: Plane[]): boolean;
  98028. /**
  98029. * Sets the mesh material by the material or multiMaterial `id` property
  98030. * @param id is a string identifying the material or the multiMaterial
  98031. * @returns the current mesh
  98032. */
  98033. setMaterialByID(id: string): Mesh;
  98034. /**
  98035. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98036. * @returns an array of IAnimatable
  98037. */
  98038. getAnimatables(): IAnimatable[];
  98039. /**
  98040. * Modifies the mesh geometry according to the passed transformation matrix.
  98041. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98042. * The mesh normals are modified using the same transformation.
  98043. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98044. * @param transform defines the transform matrix to use
  98045. * @see http://doc.babylonjs.com/resources/baking_transformations
  98046. * @returns the current mesh
  98047. */
  98048. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98049. /**
  98050. * Modifies the mesh geometry according to its own current World Matrix.
  98051. * The mesh World Matrix is then reset.
  98052. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98053. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98054. * @see http://doc.babylonjs.com/resources/baking_transformations
  98055. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98056. * @returns the current mesh
  98057. */
  98058. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98059. /** @hidden */
  98060. get _positions(): Nullable<Vector3[]>;
  98061. /** @hidden */
  98062. _resetPointsArrayCache(): Mesh;
  98063. /** @hidden */
  98064. _generatePointsArray(): boolean;
  98065. /**
  98066. * Returns a new Mesh object generated from the current mesh properties.
  98067. * This method must not get confused with createInstance()
  98068. * @param name is a string, the name given to the new mesh
  98069. * @param newParent can be any Node object (default `null`)
  98070. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98071. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98072. * @returns a new mesh
  98073. */
  98074. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98075. /**
  98076. * Releases resources associated with this mesh.
  98077. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98078. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98079. */
  98080. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98081. /** @hidden */
  98082. _disposeInstanceSpecificData(): void;
  98083. /**
  98084. * Modifies the mesh geometry according to a displacement map.
  98085. * 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.
  98086. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98087. * @param url is a string, the URL from the image file is to be downloaded.
  98088. * @param minHeight is the lower limit of the displacement.
  98089. * @param maxHeight is the upper limit of the displacement.
  98090. * @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.
  98091. * @param uvOffset is an optional vector2 used to offset UV.
  98092. * @param uvScale is an optional vector2 used to scale UV.
  98093. * @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.
  98094. * @returns the Mesh.
  98095. */
  98096. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98097. /**
  98098. * Modifies the mesh geometry according to a displacementMap buffer.
  98099. * 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.
  98100. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98101. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98102. * @param heightMapWidth is the width of the buffer image.
  98103. * @param heightMapHeight is the height of the buffer image.
  98104. * @param minHeight is the lower limit of the displacement.
  98105. * @param maxHeight is the upper limit of the displacement.
  98106. * @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.
  98107. * @param uvOffset is an optional vector2 used to offset UV.
  98108. * @param uvScale is an optional vector2 used to scale UV.
  98109. * @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.
  98110. * @returns the Mesh.
  98111. */
  98112. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98113. /**
  98114. * Modify the mesh to get a flat shading rendering.
  98115. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98116. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98117. * @returns current mesh
  98118. */
  98119. convertToFlatShadedMesh(): Mesh;
  98120. /**
  98121. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98122. * In other words, more vertices, no more indices and a single bigger VBO.
  98123. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98124. * @returns current mesh
  98125. */
  98126. convertToUnIndexedMesh(): Mesh;
  98127. /**
  98128. * Inverses facet orientations.
  98129. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98130. * @param flipNormals will also inverts the normals
  98131. * @returns current mesh
  98132. */
  98133. flipFaces(flipNormals?: boolean): Mesh;
  98134. /**
  98135. * Increase the number of facets and hence vertices in a mesh
  98136. * Vertex normals are interpolated from existing vertex normals
  98137. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98138. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98139. */
  98140. increaseVertices(numberPerEdge: number): void;
  98141. /**
  98142. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98143. * This will undo any application of covertToFlatShadedMesh
  98144. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98145. */
  98146. forceSharedVertices(): void;
  98147. /** @hidden */
  98148. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98149. /** @hidden */
  98150. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98151. /**
  98152. * Creates a new InstancedMesh object from the mesh model.
  98153. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98154. * @param name defines the name of the new instance
  98155. * @returns a new InstancedMesh
  98156. */
  98157. createInstance(name: string): InstancedMesh;
  98158. /**
  98159. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98160. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98161. * @returns the current mesh
  98162. */
  98163. synchronizeInstances(): Mesh;
  98164. /**
  98165. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98166. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98167. * This should be used together with the simplification to avoid disappearing triangles.
  98168. * @param successCallback an optional success callback to be called after the optimization finished.
  98169. * @returns the current mesh
  98170. */
  98171. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98172. /**
  98173. * Serialize current mesh
  98174. * @param serializationObject defines the object which will receive the serialization data
  98175. */
  98176. serialize(serializationObject: any): void;
  98177. /** @hidden */
  98178. _syncGeometryWithMorphTargetManager(): void;
  98179. /** @hidden */
  98180. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98181. /**
  98182. * Returns a new Mesh object parsed from the source provided.
  98183. * @param parsedMesh is the source
  98184. * @param scene defines the hosting scene
  98185. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98186. * @returns a new Mesh
  98187. */
  98188. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98189. /**
  98190. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98191. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98192. * @param name defines the name of the mesh to create
  98193. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98194. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98195. * @param closePath creates a seam between the first and the last points of each path of the path array
  98196. * @param offset is taken in account only if the `pathArray` is containing a single path
  98197. * @param scene defines the hosting scene
  98198. * @param updatable defines if the mesh must be flagged as updatable
  98199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98200. * @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)
  98201. * @returns a new Mesh
  98202. */
  98203. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98204. /**
  98205. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98206. * @param name defines the name of the mesh to create
  98207. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98208. * @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
  98209. * @param scene defines the hosting scene
  98210. * @param updatable defines if the mesh must be flagged as updatable
  98211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98212. * @returns a new Mesh
  98213. */
  98214. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98215. /**
  98216. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98217. * @param name defines the name of the mesh to create
  98218. * @param size sets the size (float) of each box side (default 1)
  98219. * @param scene defines the hosting scene
  98220. * @param updatable defines if the mesh must be flagged as updatable
  98221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98222. * @returns a new Mesh
  98223. */
  98224. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98225. /**
  98226. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98227. * @param name defines the name of the mesh to create
  98228. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98229. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98230. * @param scene defines the hosting scene
  98231. * @param updatable defines if the mesh must be flagged as updatable
  98232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98233. * @returns a new Mesh
  98234. */
  98235. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98236. /**
  98237. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98238. * @param name defines the name of the mesh to create
  98239. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98240. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98241. * @param scene defines the hosting scene
  98242. * @returns a new Mesh
  98243. */
  98244. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98245. /**
  98246. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98247. * @param name defines the name of the mesh to create
  98248. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98249. * @param diameterTop set the top cap diameter (floats, default 1)
  98250. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98251. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98252. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98253. * @param scene defines the hosting scene
  98254. * @param updatable defines if the mesh must be flagged as updatable
  98255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98256. * @returns a new Mesh
  98257. */
  98258. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98259. /**
  98260. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98261. * @param name defines the name of the mesh to create
  98262. * @param diameter sets the diameter size (float) of the torus (default 1)
  98263. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98264. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98265. * @param scene defines the hosting scene
  98266. * @param updatable defines if the mesh must be flagged as updatable
  98267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98268. * @returns a new Mesh
  98269. */
  98270. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98271. /**
  98272. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98273. * @param name defines the name of the mesh to create
  98274. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98275. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98276. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98277. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98278. * @param p the number of windings on X axis (positive integers, default 2)
  98279. * @param q the number of windings on Y axis (positive integers, default 3)
  98280. * @param scene defines the hosting scene
  98281. * @param updatable defines if the mesh must be flagged as updatable
  98282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98283. * @returns a new Mesh
  98284. */
  98285. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98286. /**
  98287. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98288. * @param name defines the name of the mesh to create
  98289. * @param points is an array successive Vector3
  98290. * @param scene defines the hosting scene
  98291. * @param updatable defines if the mesh must be flagged as updatable
  98292. * @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).
  98293. * @returns a new Mesh
  98294. */
  98295. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98296. /**
  98297. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98298. * @param name defines the name of the mesh to create
  98299. * @param points is an array successive Vector3
  98300. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98301. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98302. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98303. * @param scene defines the hosting scene
  98304. * @param updatable defines if the mesh must be flagged as updatable
  98305. * @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)
  98306. * @returns a new Mesh
  98307. */
  98308. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98309. /**
  98310. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98311. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98312. * 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.
  98313. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98314. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98315. * Remember you can only change the shape positions, not their number when updating a polygon.
  98316. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98317. * @param name defines the name of the mesh to create
  98318. * @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
  98319. * @param scene defines the hosting scene
  98320. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98321. * @param updatable defines if the mesh must be flagged as updatable
  98322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98323. * @param earcutInjection can be used to inject your own earcut reference
  98324. * @returns a new Mesh
  98325. */
  98326. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98327. /**
  98328. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98329. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98330. * @param name defines the name of the mesh to create
  98331. * @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
  98332. * @param depth defines the height of extrusion
  98333. * @param scene defines the hosting scene
  98334. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98335. * @param updatable defines if the mesh must be flagged as updatable
  98336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98337. * @param earcutInjection can be used to inject your own earcut reference
  98338. * @returns a new Mesh
  98339. */
  98340. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98341. /**
  98342. * Creates an extruded shape mesh.
  98343. * 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
  98344. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98345. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98346. * @param name defines the name of the mesh to create
  98347. * @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
  98348. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98349. * @param scale is the value to scale the shape
  98350. * @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
  98351. * @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
  98352. * @param scene defines the hosting scene
  98353. * @param updatable defines if the mesh must be flagged as updatable
  98354. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98355. * @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)
  98356. * @returns a new Mesh
  98357. */
  98358. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98359. /**
  98360. * Creates an custom extruded shape mesh.
  98361. * The custom extrusion is a parametric shape.
  98362. * It has no predefined shape. Its final shape will depend on the input parameters.
  98363. * Please consider using the same method from the MeshBuilder class instead
  98364. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98365. * @param name defines the name of the mesh to create
  98366. * @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
  98367. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98368. * @param scaleFunction is a custom Javascript function called on each path point
  98369. * @param rotationFunction is a custom Javascript function called on each path point
  98370. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98371. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98372. * @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
  98373. * @param scene defines the hosting scene
  98374. * @param updatable defines if the mesh must be flagged as updatable
  98375. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98376. * @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)
  98377. * @returns a new Mesh
  98378. */
  98379. 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;
  98380. /**
  98381. * Creates lathe mesh.
  98382. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98383. * Please consider using the same method from the MeshBuilder class instead
  98384. * @param name defines the name of the mesh to create
  98385. * @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
  98386. * @param radius is the radius value of the lathe
  98387. * @param tessellation is the side number of the lathe.
  98388. * @param scene defines the hosting scene
  98389. * @param updatable defines if the mesh must be flagged as updatable
  98390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98391. * @returns a new Mesh
  98392. */
  98393. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98394. /**
  98395. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98396. * @param name defines the name of the mesh to create
  98397. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98398. * @param scene defines the hosting scene
  98399. * @param updatable defines if the mesh must be flagged as updatable
  98400. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98401. * @returns a new Mesh
  98402. */
  98403. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98404. /**
  98405. * Creates a ground mesh.
  98406. * Please consider using the same method from the MeshBuilder class instead
  98407. * @param name defines the name of the mesh to create
  98408. * @param width set the width of the ground
  98409. * @param height set the height of the ground
  98410. * @param subdivisions sets the number of subdivisions per side
  98411. * @param scene defines the hosting scene
  98412. * @param updatable defines if the mesh must be flagged as updatable
  98413. * @returns a new Mesh
  98414. */
  98415. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98416. /**
  98417. * Creates a tiled ground mesh.
  98418. * Please consider using the same method from the MeshBuilder class instead
  98419. * @param name defines the name of the mesh to create
  98420. * @param xmin set the ground minimum X coordinate
  98421. * @param zmin set the ground minimum Y coordinate
  98422. * @param xmax set the ground maximum X coordinate
  98423. * @param zmax set the ground maximum Z coordinate
  98424. * @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
  98425. * @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
  98426. * @param scene defines the hosting scene
  98427. * @param updatable defines if the mesh must be flagged as updatable
  98428. * @returns a new Mesh
  98429. */
  98430. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98431. w: number;
  98432. h: number;
  98433. }, precision: {
  98434. w: number;
  98435. h: number;
  98436. }, scene: Scene, updatable?: boolean): Mesh;
  98437. /**
  98438. * Creates a ground mesh from a height map.
  98439. * Please consider using the same method from the MeshBuilder class instead
  98440. * @see http://doc.babylonjs.com/babylon101/height_map
  98441. * @param name defines the name of the mesh to create
  98442. * @param url sets the URL of the height map image resource
  98443. * @param width set the ground width size
  98444. * @param height set the ground height size
  98445. * @param subdivisions sets the number of subdivision per side
  98446. * @param minHeight is the minimum altitude on the ground
  98447. * @param maxHeight is the maximum altitude on the ground
  98448. * @param scene defines the hosting scene
  98449. * @param updatable defines if the mesh must be flagged as updatable
  98450. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98451. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98452. * @returns a new Mesh
  98453. */
  98454. 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;
  98455. /**
  98456. * Creates a tube mesh.
  98457. * The tube is a parametric shape.
  98458. * It has no predefined shape. Its final shape will depend on the input parameters.
  98459. * Please consider using the same method from the MeshBuilder class instead
  98460. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98461. * @param name defines the name of the mesh to create
  98462. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98463. * @param radius sets the tube radius size
  98464. * @param tessellation is the number of sides on the tubular surface
  98465. * @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
  98466. * @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
  98467. * @param scene defines the hosting scene
  98468. * @param updatable defines if the mesh must be flagged as updatable
  98469. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98470. * @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)
  98471. * @returns a new Mesh
  98472. */
  98473. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98474. (i: number, distance: number): number;
  98475. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98476. /**
  98477. * Creates a polyhedron mesh.
  98478. * Please consider using the same method from the MeshBuilder class instead.
  98479. * * 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
  98480. * * The parameter `size` (positive float, default 1) sets the polygon size
  98481. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98482. * * 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`
  98483. * * 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
  98484. * * 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)`)
  98485. * * 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
  98486. * * 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
  98487. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98488. * * If you create a double-sided mesh, you can choose what parts of 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
  98489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98490. * @param name defines the name of the mesh to create
  98491. * @param options defines the options used to create the mesh
  98492. * @param scene defines the hosting scene
  98493. * @returns a new Mesh
  98494. */
  98495. static CreatePolyhedron(name: string, options: {
  98496. type?: number;
  98497. size?: number;
  98498. sizeX?: number;
  98499. sizeY?: number;
  98500. sizeZ?: number;
  98501. custom?: any;
  98502. faceUV?: Vector4[];
  98503. faceColors?: Color4[];
  98504. updatable?: boolean;
  98505. sideOrientation?: number;
  98506. }, scene: Scene): Mesh;
  98507. /**
  98508. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98509. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98510. * * 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`)
  98511. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98512. * * 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
  98513. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98514. * * If you create a double-sided mesh, you can choose what parts of 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
  98515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98516. * @param name defines the name of the mesh
  98517. * @param options defines the options used to create the mesh
  98518. * @param scene defines the hosting scene
  98519. * @returns a new Mesh
  98520. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98521. */
  98522. static CreateIcoSphere(name: string, options: {
  98523. radius?: number;
  98524. flat?: boolean;
  98525. subdivisions?: number;
  98526. sideOrientation?: number;
  98527. updatable?: boolean;
  98528. }, scene: Scene): Mesh;
  98529. /**
  98530. * Creates a decal mesh.
  98531. * Please consider using the same method from the MeshBuilder class instead.
  98532. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98533. * @param name defines the name of the mesh
  98534. * @param sourceMesh defines the mesh receiving the decal
  98535. * @param position sets the position of the decal in world coordinates
  98536. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98537. * @param size sets the decal scaling
  98538. * @param angle sets the angle to rotate the decal
  98539. * @returns a new Mesh
  98540. */
  98541. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98542. /**
  98543. * Prepare internal position array for software CPU skinning
  98544. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98545. */
  98546. setPositionsForCPUSkinning(): Float32Array;
  98547. /**
  98548. * Prepare internal normal array for software CPU skinning
  98549. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98550. */
  98551. setNormalsForCPUSkinning(): Float32Array;
  98552. /**
  98553. * Updates the vertex buffer by applying transformation from the bones
  98554. * @param skeleton defines the skeleton to apply to current mesh
  98555. * @returns the current mesh
  98556. */
  98557. applySkeleton(skeleton: Skeleton): Mesh;
  98558. /**
  98559. * 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
  98560. * @param meshes defines the list of meshes to scan
  98561. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98562. */
  98563. static MinMax(meshes: AbstractMesh[]): {
  98564. min: Vector3;
  98565. max: Vector3;
  98566. };
  98567. /**
  98568. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98569. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98570. * @returns a vector3
  98571. */
  98572. static Center(meshesOrMinMaxVector: {
  98573. min: Vector3;
  98574. max: Vector3;
  98575. } | AbstractMesh[]): Vector3;
  98576. /**
  98577. * Merge the array of meshes into a single mesh for performance reasons.
  98578. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98579. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98580. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98581. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98582. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98583. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98584. * @returns a new mesh
  98585. */
  98586. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98587. /** @hidden */
  98588. addInstance(instance: InstancedMesh): void;
  98589. /** @hidden */
  98590. removeInstance(instance: InstancedMesh): void;
  98591. }
  98592. }
  98593. declare module BABYLON {
  98594. /**
  98595. * This is the base class of all the camera used in the application.
  98596. * @see http://doc.babylonjs.com/features/cameras
  98597. */
  98598. export class Camera extends Node {
  98599. /** @hidden */
  98600. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98601. /**
  98602. * This is the default projection mode used by the cameras.
  98603. * It helps recreating a feeling of perspective and better appreciate depth.
  98604. * This is the best way to simulate real life cameras.
  98605. */
  98606. static readonly PERSPECTIVE_CAMERA: number;
  98607. /**
  98608. * This helps creating camera with an orthographic mode.
  98609. * 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.
  98610. */
  98611. static readonly ORTHOGRAPHIC_CAMERA: number;
  98612. /**
  98613. * This is the default FOV mode for perspective cameras.
  98614. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98615. */
  98616. static readonly FOVMODE_VERTICAL_FIXED: number;
  98617. /**
  98618. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98619. */
  98620. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98621. /**
  98622. * This specifies ther is no need for a camera rig.
  98623. * Basically only one eye is rendered corresponding to the camera.
  98624. */
  98625. static readonly RIG_MODE_NONE: number;
  98626. /**
  98627. * Simulates a camera Rig with one blue eye and one red eye.
  98628. * This can be use with 3d blue and red glasses.
  98629. */
  98630. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98631. /**
  98632. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98633. */
  98634. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98635. /**
  98636. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98637. */
  98638. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98639. /**
  98640. * Defines that both eyes of the camera will be rendered over under each other.
  98641. */
  98642. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98643. /**
  98644. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98645. */
  98646. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98647. /**
  98648. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98649. */
  98650. static readonly RIG_MODE_VR: number;
  98651. /**
  98652. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98653. */
  98654. static readonly RIG_MODE_WEBVR: number;
  98655. /**
  98656. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98657. */
  98658. static readonly RIG_MODE_CUSTOM: number;
  98659. /**
  98660. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98661. */
  98662. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98663. /**
  98664. * Define the input manager associated with the camera.
  98665. */
  98666. inputs: CameraInputsManager<Camera>;
  98667. /** @hidden */
  98668. _position: Vector3;
  98669. /**
  98670. * Define the current local position of the camera in the scene
  98671. */
  98672. get position(): Vector3;
  98673. set position(newPosition: Vector3);
  98674. /**
  98675. * The vector the camera should consider as up.
  98676. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98677. */
  98678. upVector: Vector3;
  98679. /**
  98680. * Define the current limit on the left side for an orthographic camera
  98681. * In scene unit
  98682. */
  98683. orthoLeft: Nullable<number>;
  98684. /**
  98685. * Define the current limit on the right side for an orthographic camera
  98686. * In scene unit
  98687. */
  98688. orthoRight: Nullable<number>;
  98689. /**
  98690. * Define the current limit on the bottom side for an orthographic camera
  98691. * In scene unit
  98692. */
  98693. orthoBottom: Nullable<number>;
  98694. /**
  98695. * Define the current limit on the top side for an orthographic camera
  98696. * In scene unit
  98697. */
  98698. orthoTop: Nullable<number>;
  98699. /**
  98700. * Field Of View is set in Radians. (default is 0.8)
  98701. */
  98702. fov: number;
  98703. /**
  98704. * Define the minimum distance the camera can see from.
  98705. * This is important to note that the depth buffer are not infinite and the closer it starts
  98706. * the more your scene might encounter depth fighting issue.
  98707. */
  98708. minZ: number;
  98709. /**
  98710. * Define the maximum distance the camera can see to.
  98711. * This is important to note that the depth buffer are not infinite and the further it end
  98712. * the more your scene might encounter depth fighting issue.
  98713. */
  98714. maxZ: number;
  98715. /**
  98716. * Define the default inertia of the camera.
  98717. * This helps giving a smooth feeling to the camera movement.
  98718. */
  98719. inertia: number;
  98720. /**
  98721. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98722. */
  98723. mode: number;
  98724. /**
  98725. * Define whether the camera is intermediate.
  98726. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98727. */
  98728. isIntermediate: boolean;
  98729. /**
  98730. * Define the viewport of the camera.
  98731. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98732. */
  98733. viewport: Viewport;
  98734. /**
  98735. * Restricts the camera to viewing objects with the same layerMask.
  98736. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98737. */
  98738. layerMask: number;
  98739. /**
  98740. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98741. */
  98742. fovMode: number;
  98743. /**
  98744. * Rig mode of the camera.
  98745. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98746. * This is normally controlled byt the camera themselves as internal use.
  98747. */
  98748. cameraRigMode: number;
  98749. /**
  98750. * Defines the distance between both "eyes" in case of a RIG
  98751. */
  98752. interaxialDistance: number;
  98753. /**
  98754. * Defines if stereoscopic rendering is done side by side or over under.
  98755. */
  98756. isStereoscopicSideBySide: boolean;
  98757. /**
  98758. * 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
  98759. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98760. * else in the scene. (Eg. security camera)
  98761. *
  98762. * 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)
  98763. */
  98764. customRenderTargets: RenderTargetTexture[];
  98765. /**
  98766. * When set, the camera will render to this render target instead of the default canvas
  98767. *
  98768. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98769. */
  98770. outputRenderTarget: Nullable<RenderTargetTexture>;
  98771. /**
  98772. * Observable triggered when the camera view matrix has changed.
  98773. */
  98774. onViewMatrixChangedObservable: Observable<Camera>;
  98775. /**
  98776. * Observable triggered when the camera Projection matrix has changed.
  98777. */
  98778. onProjectionMatrixChangedObservable: Observable<Camera>;
  98779. /**
  98780. * Observable triggered when the inputs have been processed.
  98781. */
  98782. onAfterCheckInputsObservable: Observable<Camera>;
  98783. /**
  98784. * Observable triggered when reset has been called and applied to the camera.
  98785. */
  98786. onRestoreStateObservable: Observable<Camera>;
  98787. /**
  98788. * Is this camera a part of a rig system?
  98789. */
  98790. isRigCamera: boolean;
  98791. /**
  98792. * If isRigCamera set to true this will be set with the parent camera.
  98793. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98794. */
  98795. rigParent?: Camera;
  98796. /** @hidden */
  98797. _cameraRigParams: any;
  98798. /** @hidden */
  98799. _rigCameras: Camera[];
  98800. /** @hidden */
  98801. _rigPostProcess: Nullable<PostProcess>;
  98802. protected _webvrViewMatrix: Matrix;
  98803. /** @hidden */
  98804. _skipRendering: boolean;
  98805. /** @hidden */
  98806. _projectionMatrix: Matrix;
  98807. /** @hidden */
  98808. _postProcesses: Nullable<PostProcess>[];
  98809. /** @hidden */
  98810. _activeMeshes: SmartArray<AbstractMesh>;
  98811. protected _globalPosition: Vector3;
  98812. /** @hidden */
  98813. _computedViewMatrix: Matrix;
  98814. private _doNotComputeProjectionMatrix;
  98815. private _transformMatrix;
  98816. private _frustumPlanes;
  98817. private _refreshFrustumPlanes;
  98818. private _storedFov;
  98819. private _stateStored;
  98820. /**
  98821. * Instantiates a new camera object.
  98822. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98823. * @see http://doc.babylonjs.com/features/cameras
  98824. * @param name Defines the name of the camera in the scene
  98825. * @param position Defines the position of the camera
  98826. * @param scene Defines the scene the camera belongs too
  98827. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98828. */
  98829. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98830. /**
  98831. * Store current camera state (fov, position, etc..)
  98832. * @returns the camera
  98833. */
  98834. storeState(): Camera;
  98835. /**
  98836. * Restores the camera state values if it has been stored. You must call storeState() first
  98837. */
  98838. protected _restoreStateValues(): boolean;
  98839. /**
  98840. * Restored camera state. You must call storeState() first.
  98841. * @returns true if restored and false otherwise
  98842. */
  98843. restoreState(): boolean;
  98844. /**
  98845. * Gets the class name of the camera.
  98846. * @returns the class name
  98847. */
  98848. getClassName(): string;
  98849. /** @hidden */
  98850. readonly _isCamera: boolean;
  98851. /**
  98852. * Gets a string representation of the camera useful for debug purpose.
  98853. * @param fullDetails Defines that a more verboe level of logging is required
  98854. * @returns the string representation
  98855. */
  98856. toString(fullDetails?: boolean): string;
  98857. /**
  98858. * Gets the current world space position of the camera.
  98859. */
  98860. get globalPosition(): Vector3;
  98861. /**
  98862. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98863. * @returns the active meshe list
  98864. */
  98865. getActiveMeshes(): SmartArray<AbstractMesh>;
  98866. /**
  98867. * Check whether a mesh is part of the current active mesh list of the camera
  98868. * @param mesh Defines the mesh to check
  98869. * @returns true if active, false otherwise
  98870. */
  98871. isActiveMesh(mesh: Mesh): boolean;
  98872. /**
  98873. * Is this camera ready to be used/rendered
  98874. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98875. * @return true if the camera is ready
  98876. */
  98877. isReady(completeCheck?: boolean): boolean;
  98878. /** @hidden */
  98879. _initCache(): void;
  98880. /** @hidden */
  98881. _updateCache(ignoreParentClass?: boolean): void;
  98882. /** @hidden */
  98883. _isSynchronized(): boolean;
  98884. /** @hidden */
  98885. _isSynchronizedViewMatrix(): boolean;
  98886. /** @hidden */
  98887. _isSynchronizedProjectionMatrix(): boolean;
  98888. /**
  98889. * Attach the input controls to a specific dom element to get the input from.
  98890. * @param element Defines the element the controls should be listened from
  98891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98892. */
  98893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98894. /**
  98895. * Detach the current controls from the specified dom element.
  98896. * @param element Defines the element to stop listening the inputs from
  98897. */
  98898. detachControl(element: HTMLElement): void;
  98899. /**
  98900. * Update the camera state according to the different inputs gathered during the frame.
  98901. */
  98902. update(): void;
  98903. /** @hidden */
  98904. _checkInputs(): void;
  98905. /** @hidden */
  98906. get rigCameras(): Camera[];
  98907. /**
  98908. * Gets the post process used by the rig cameras
  98909. */
  98910. get rigPostProcess(): Nullable<PostProcess>;
  98911. /**
  98912. * Internal, gets the first post proces.
  98913. * @returns the first post process to be run on this camera.
  98914. */
  98915. _getFirstPostProcess(): Nullable<PostProcess>;
  98916. private _cascadePostProcessesToRigCams;
  98917. /**
  98918. * Attach a post process to the camera.
  98919. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98920. * @param postProcess The post process to attach to the camera
  98921. * @param insertAt The position of the post process in case several of them are in use in the scene
  98922. * @returns the position the post process has been inserted at
  98923. */
  98924. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98925. /**
  98926. * Detach a post process to the camera.
  98927. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98928. * @param postProcess The post process to detach from the camera
  98929. */
  98930. detachPostProcess(postProcess: PostProcess): void;
  98931. /**
  98932. * Gets the current world matrix of the camera
  98933. */
  98934. getWorldMatrix(): Matrix;
  98935. /** @hidden */
  98936. _getViewMatrix(): Matrix;
  98937. /**
  98938. * Gets the current view matrix of the camera.
  98939. * @param force forces the camera to recompute the matrix without looking at the cached state
  98940. * @returns the view matrix
  98941. */
  98942. getViewMatrix(force?: boolean): Matrix;
  98943. /**
  98944. * Freeze the projection matrix.
  98945. * It will prevent the cache check of the camera projection compute and can speed up perf
  98946. * if no parameter of the camera are meant to change
  98947. * @param projection Defines manually a projection if necessary
  98948. */
  98949. freezeProjectionMatrix(projection?: Matrix): void;
  98950. /**
  98951. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98952. */
  98953. unfreezeProjectionMatrix(): void;
  98954. /**
  98955. * Gets the current projection matrix of the camera.
  98956. * @param force forces the camera to recompute the matrix without looking at the cached state
  98957. * @returns the projection matrix
  98958. */
  98959. getProjectionMatrix(force?: boolean): Matrix;
  98960. /**
  98961. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98962. * @returns a Matrix
  98963. */
  98964. getTransformationMatrix(): Matrix;
  98965. private _updateFrustumPlanes;
  98966. /**
  98967. * Checks if a cullable object (mesh...) is in the camera frustum
  98968. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98969. * @param target The object to check
  98970. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98971. * @returns true if the object is in frustum otherwise false
  98972. */
  98973. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98974. /**
  98975. * Checks if a cullable object (mesh...) is in the camera frustum
  98976. * Unlike isInFrustum this cheks the full bounding box
  98977. * @param target The object to check
  98978. * @returns true if the object is in frustum otherwise false
  98979. */
  98980. isCompletelyInFrustum(target: ICullable): boolean;
  98981. /**
  98982. * Gets a ray in the forward direction from the camera.
  98983. * @param length Defines the length of the ray to create
  98984. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98985. * @param origin Defines the start point of the ray which defaults to the camera position
  98986. * @returns the forward ray
  98987. */
  98988. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98989. /**
  98990. * Releases resources associated with this node.
  98991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98993. */
  98994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98995. /** @hidden */
  98996. _isLeftCamera: boolean;
  98997. /**
  98998. * Gets the left camera of a rig setup in case of Rigged Camera
  98999. */
  99000. get isLeftCamera(): boolean;
  99001. /** @hidden */
  99002. _isRightCamera: boolean;
  99003. /**
  99004. * Gets the right camera of a rig setup in case of Rigged Camera
  99005. */
  99006. get isRightCamera(): boolean;
  99007. /**
  99008. * Gets the left camera of a rig setup in case of Rigged Camera
  99009. */
  99010. get leftCamera(): Nullable<FreeCamera>;
  99011. /**
  99012. * Gets the right camera of a rig setup in case of Rigged Camera
  99013. */
  99014. get rightCamera(): Nullable<FreeCamera>;
  99015. /**
  99016. * Gets the left camera target of a rig setup in case of Rigged Camera
  99017. * @returns the target position
  99018. */
  99019. getLeftTarget(): Nullable<Vector3>;
  99020. /**
  99021. * Gets the right camera target of a rig setup in case of Rigged Camera
  99022. * @returns the target position
  99023. */
  99024. getRightTarget(): Nullable<Vector3>;
  99025. /**
  99026. * @hidden
  99027. */
  99028. setCameraRigMode(mode: number, rigParams: any): void;
  99029. /** @hidden */
  99030. static _setStereoscopicRigMode(camera: Camera): void;
  99031. /** @hidden */
  99032. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99033. /** @hidden */
  99034. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99035. /** @hidden */
  99036. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99037. /** @hidden */
  99038. _getVRProjectionMatrix(): Matrix;
  99039. protected _updateCameraRotationMatrix(): void;
  99040. protected _updateWebVRCameraRotationMatrix(): void;
  99041. /**
  99042. * This function MUST be overwritten by the different WebVR cameras available.
  99043. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99044. * @hidden
  99045. */
  99046. _getWebVRProjectionMatrix(): Matrix;
  99047. /**
  99048. * This function MUST be overwritten by the different WebVR cameras available.
  99049. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99050. * @hidden
  99051. */
  99052. _getWebVRViewMatrix(): Matrix;
  99053. /** @hidden */
  99054. setCameraRigParameter(name: string, value: any): void;
  99055. /**
  99056. * needs to be overridden by children so sub has required properties to be copied
  99057. * @hidden
  99058. */
  99059. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99060. /**
  99061. * May need to be overridden by children
  99062. * @hidden
  99063. */
  99064. _updateRigCameras(): void;
  99065. /** @hidden */
  99066. _setupInputs(): void;
  99067. /**
  99068. * Serialiaze the camera setup to a json represention
  99069. * @returns the JSON representation
  99070. */
  99071. serialize(): any;
  99072. /**
  99073. * Clones the current camera.
  99074. * @param name The cloned camera name
  99075. * @returns the cloned camera
  99076. */
  99077. clone(name: string): Camera;
  99078. /**
  99079. * Gets the direction of the camera relative to a given local axis.
  99080. * @param localAxis Defines the reference axis to provide a relative direction.
  99081. * @return the direction
  99082. */
  99083. getDirection(localAxis: Vector3): Vector3;
  99084. /**
  99085. * Returns the current camera absolute rotation
  99086. */
  99087. get absoluteRotation(): Quaternion;
  99088. /**
  99089. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99090. * @param localAxis Defines the reference axis to provide a relative direction.
  99091. * @param result Defines the vector to store the result in
  99092. */
  99093. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99094. /**
  99095. * Gets a camera constructor for a given camera type
  99096. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99097. * @param name The name of the camera the result will be able to instantiate
  99098. * @param scene The scene the result will construct the camera in
  99099. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99100. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99101. * @returns a factory method to construc the camera
  99102. */
  99103. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99104. /**
  99105. * Compute the world matrix of the camera.
  99106. * @returns the camera world matrix
  99107. */
  99108. computeWorldMatrix(): Matrix;
  99109. /**
  99110. * Parse a JSON and creates the camera from the parsed information
  99111. * @param parsedCamera The JSON to parse
  99112. * @param scene The scene to instantiate the camera in
  99113. * @returns the newly constructed camera
  99114. */
  99115. static Parse(parsedCamera: any, scene: Scene): Camera;
  99116. }
  99117. }
  99118. declare module BABYLON {
  99119. /**
  99120. * Class containing static functions to help procedurally build meshes
  99121. */
  99122. export class DiscBuilder {
  99123. /**
  99124. * Creates a plane polygonal mesh. By default, this is a disc
  99125. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99126. * * 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
  99127. * * 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
  99128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99131. * @param name defines the name of the mesh
  99132. * @param options defines the options used to create the mesh
  99133. * @param scene defines the hosting scene
  99134. * @returns the plane polygonal mesh
  99135. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99136. */
  99137. static CreateDisc(name: string, options: {
  99138. radius?: number;
  99139. tessellation?: number;
  99140. arc?: number;
  99141. updatable?: boolean;
  99142. sideOrientation?: number;
  99143. frontUVs?: Vector4;
  99144. backUVs?: Vector4;
  99145. }, scene?: Nullable<Scene>): Mesh;
  99146. }
  99147. }
  99148. declare module BABYLON {
  99149. /**
  99150. * This represents all the required information to add a fresnel effect on a material:
  99151. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99152. */
  99153. export class FresnelParameters {
  99154. private _isEnabled;
  99155. /**
  99156. * Define if the fresnel effect is enable or not.
  99157. */
  99158. get isEnabled(): boolean;
  99159. set isEnabled(value: boolean);
  99160. /**
  99161. * Define the color used on edges (grazing angle)
  99162. */
  99163. leftColor: Color3;
  99164. /**
  99165. * Define the color used on center
  99166. */
  99167. rightColor: Color3;
  99168. /**
  99169. * Define bias applied to computed fresnel term
  99170. */
  99171. bias: number;
  99172. /**
  99173. * Defined the power exponent applied to fresnel term
  99174. */
  99175. power: number;
  99176. /**
  99177. * Clones the current fresnel and its valuues
  99178. * @returns a clone fresnel configuration
  99179. */
  99180. clone(): FresnelParameters;
  99181. /**
  99182. * Serializes the current fresnel parameters to a JSON representation.
  99183. * @return the JSON serialization
  99184. */
  99185. serialize(): any;
  99186. /**
  99187. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99188. * @param parsedFresnelParameters Define the JSON representation
  99189. * @returns the parsed parameters
  99190. */
  99191. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99192. }
  99193. }
  99194. declare module BABYLON {
  99195. /**
  99196. * Base class of materials working in push mode in babylon JS
  99197. * @hidden
  99198. */
  99199. export class PushMaterial extends Material {
  99200. protected _activeEffect: Effect;
  99201. protected _normalMatrix: Matrix;
  99202. /**
  99203. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99204. * This means that the material can keep using a previous shader while a new one is being compiled.
  99205. * This is mostly used when shader parallel compilation is supported (true by default)
  99206. */
  99207. allowShaderHotSwapping: boolean;
  99208. constructor(name: string, scene: Scene);
  99209. getEffect(): Effect;
  99210. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99211. /**
  99212. * Binds the given world matrix to the active effect
  99213. *
  99214. * @param world the matrix to bind
  99215. */
  99216. bindOnlyWorldMatrix(world: Matrix): void;
  99217. /**
  99218. * Binds the given normal matrix to the active effect
  99219. *
  99220. * @param normalMatrix the matrix to bind
  99221. */
  99222. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99223. bind(world: Matrix, mesh?: Mesh): void;
  99224. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99225. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99226. }
  99227. }
  99228. declare module BABYLON {
  99229. /**
  99230. * This groups all the flags used to control the materials channel.
  99231. */
  99232. export class MaterialFlags {
  99233. private static _DiffuseTextureEnabled;
  99234. /**
  99235. * Are diffuse textures enabled in the application.
  99236. */
  99237. static get DiffuseTextureEnabled(): boolean;
  99238. static set DiffuseTextureEnabled(value: boolean);
  99239. private static _AmbientTextureEnabled;
  99240. /**
  99241. * Are ambient textures enabled in the application.
  99242. */
  99243. static get AmbientTextureEnabled(): boolean;
  99244. static set AmbientTextureEnabled(value: boolean);
  99245. private static _OpacityTextureEnabled;
  99246. /**
  99247. * Are opacity textures enabled in the application.
  99248. */
  99249. static get OpacityTextureEnabled(): boolean;
  99250. static set OpacityTextureEnabled(value: boolean);
  99251. private static _ReflectionTextureEnabled;
  99252. /**
  99253. * Are reflection textures enabled in the application.
  99254. */
  99255. static get ReflectionTextureEnabled(): boolean;
  99256. static set ReflectionTextureEnabled(value: boolean);
  99257. private static _EmissiveTextureEnabled;
  99258. /**
  99259. * Are emissive textures enabled in the application.
  99260. */
  99261. static get EmissiveTextureEnabled(): boolean;
  99262. static set EmissiveTextureEnabled(value: boolean);
  99263. private static _SpecularTextureEnabled;
  99264. /**
  99265. * Are specular textures enabled in the application.
  99266. */
  99267. static get SpecularTextureEnabled(): boolean;
  99268. static set SpecularTextureEnabled(value: boolean);
  99269. private static _BumpTextureEnabled;
  99270. /**
  99271. * Are bump textures enabled in the application.
  99272. */
  99273. static get BumpTextureEnabled(): boolean;
  99274. static set BumpTextureEnabled(value: boolean);
  99275. private static _LightmapTextureEnabled;
  99276. /**
  99277. * Are lightmap textures enabled in the application.
  99278. */
  99279. static get LightmapTextureEnabled(): boolean;
  99280. static set LightmapTextureEnabled(value: boolean);
  99281. private static _RefractionTextureEnabled;
  99282. /**
  99283. * Are refraction textures enabled in the application.
  99284. */
  99285. static get RefractionTextureEnabled(): boolean;
  99286. static set RefractionTextureEnabled(value: boolean);
  99287. private static _ColorGradingTextureEnabled;
  99288. /**
  99289. * Are color grading textures enabled in the application.
  99290. */
  99291. static get ColorGradingTextureEnabled(): boolean;
  99292. static set ColorGradingTextureEnabled(value: boolean);
  99293. private static _FresnelEnabled;
  99294. /**
  99295. * Are fresnels enabled in the application.
  99296. */
  99297. static get FresnelEnabled(): boolean;
  99298. static set FresnelEnabled(value: boolean);
  99299. private static _ClearCoatTextureEnabled;
  99300. /**
  99301. * Are clear coat textures enabled in the application.
  99302. */
  99303. static get ClearCoatTextureEnabled(): boolean;
  99304. static set ClearCoatTextureEnabled(value: boolean);
  99305. private static _ClearCoatBumpTextureEnabled;
  99306. /**
  99307. * Are clear coat bump textures enabled in the application.
  99308. */
  99309. static get ClearCoatBumpTextureEnabled(): boolean;
  99310. static set ClearCoatBumpTextureEnabled(value: boolean);
  99311. private static _ClearCoatTintTextureEnabled;
  99312. /**
  99313. * Are clear coat tint textures enabled in the application.
  99314. */
  99315. static get ClearCoatTintTextureEnabled(): boolean;
  99316. static set ClearCoatTintTextureEnabled(value: boolean);
  99317. private static _SheenTextureEnabled;
  99318. /**
  99319. * Are sheen textures enabled in the application.
  99320. */
  99321. static get SheenTextureEnabled(): boolean;
  99322. static set SheenTextureEnabled(value: boolean);
  99323. private static _AnisotropicTextureEnabled;
  99324. /**
  99325. * Are anisotropic textures enabled in the application.
  99326. */
  99327. static get AnisotropicTextureEnabled(): boolean;
  99328. static set AnisotropicTextureEnabled(value: boolean);
  99329. private static _ThicknessTextureEnabled;
  99330. /**
  99331. * Are thickness textures enabled in the application.
  99332. */
  99333. static get ThicknessTextureEnabled(): boolean;
  99334. static set ThicknessTextureEnabled(value: boolean);
  99335. }
  99336. }
  99337. declare module BABYLON {
  99338. /** @hidden */
  99339. export var defaultFragmentDeclaration: {
  99340. name: string;
  99341. shader: string;
  99342. };
  99343. }
  99344. declare module BABYLON {
  99345. /** @hidden */
  99346. export var defaultUboDeclaration: {
  99347. name: string;
  99348. shader: string;
  99349. };
  99350. }
  99351. declare module BABYLON {
  99352. /** @hidden */
  99353. export var lightFragmentDeclaration: {
  99354. name: string;
  99355. shader: string;
  99356. };
  99357. }
  99358. declare module BABYLON {
  99359. /** @hidden */
  99360. export var lightUboDeclaration: {
  99361. name: string;
  99362. shader: string;
  99363. };
  99364. }
  99365. declare module BABYLON {
  99366. /** @hidden */
  99367. export var lightsFragmentFunctions: {
  99368. name: string;
  99369. shader: string;
  99370. };
  99371. }
  99372. declare module BABYLON {
  99373. /** @hidden */
  99374. export var shadowsFragmentFunctions: {
  99375. name: string;
  99376. shader: string;
  99377. };
  99378. }
  99379. declare module BABYLON {
  99380. /** @hidden */
  99381. export var fresnelFunction: {
  99382. name: string;
  99383. shader: string;
  99384. };
  99385. }
  99386. declare module BABYLON {
  99387. /** @hidden */
  99388. export var reflectionFunction: {
  99389. name: string;
  99390. shader: string;
  99391. };
  99392. }
  99393. declare module BABYLON {
  99394. /** @hidden */
  99395. export var bumpFragmentFunctions: {
  99396. name: string;
  99397. shader: string;
  99398. };
  99399. }
  99400. declare module BABYLON {
  99401. /** @hidden */
  99402. export var logDepthDeclaration: {
  99403. name: string;
  99404. shader: string;
  99405. };
  99406. }
  99407. declare module BABYLON {
  99408. /** @hidden */
  99409. export var bumpFragment: {
  99410. name: string;
  99411. shader: string;
  99412. };
  99413. }
  99414. declare module BABYLON {
  99415. /** @hidden */
  99416. export var depthPrePass: {
  99417. name: string;
  99418. shader: string;
  99419. };
  99420. }
  99421. declare module BABYLON {
  99422. /** @hidden */
  99423. export var lightFragment: {
  99424. name: string;
  99425. shader: string;
  99426. };
  99427. }
  99428. declare module BABYLON {
  99429. /** @hidden */
  99430. export var logDepthFragment: {
  99431. name: string;
  99432. shader: string;
  99433. };
  99434. }
  99435. declare module BABYLON {
  99436. /** @hidden */
  99437. export var defaultPixelShader: {
  99438. name: string;
  99439. shader: string;
  99440. };
  99441. }
  99442. declare module BABYLON {
  99443. /** @hidden */
  99444. export var defaultVertexDeclaration: {
  99445. name: string;
  99446. shader: string;
  99447. };
  99448. }
  99449. declare module BABYLON {
  99450. /** @hidden */
  99451. export var bumpVertexDeclaration: {
  99452. name: string;
  99453. shader: string;
  99454. };
  99455. }
  99456. declare module BABYLON {
  99457. /** @hidden */
  99458. export var bumpVertex: {
  99459. name: string;
  99460. shader: string;
  99461. };
  99462. }
  99463. declare module BABYLON {
  99464. /** @hidden */
  99465. export var fogVertex: {
  99466. name: string;
  99467. shader: string;
  99468. };
  99469. }
  99470. declare module BABYLON {
  99471. /** @hidden */
  99472. export var shadowsVertex: {
  99473. name: string;
  99474. shader: string;
  99475. };
  99476. }
  99477. declare module BABYLON {
  99478. /** @hidden */
  99479. export var pointCloudVertex: {
  99480. name: string;
  99481. shader: string;
  99482. };
  99483. }
  99484. declare module BABYLON {
  99485. /** @hidden */
  99486. export var logDepthVertex: {
  99487. name: string;
  99488. shader: string;
  99489. };
  99490. }
  99491. declare module BABYLON {
  99492. /** @hidden */
  99493. export var defaultVertexShader: {
  99494. name: string;
  99495. shader: string;
  99496. };
  99497. }
  99498. declare module BABYLON {
  99499. /** @hidden */
  99500. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99501. MAINUV1: boolean;
  99502. MAINUV2: boolean;
  99503. DIFFUSE: boolean;
  99504. DIFFUSEDIRECTUV: number;
  99505. AMBIENT: boolean;
  99506. AMBIENTDIRECTUV: number;
  99507. OPACITY: boolean;
  99508. OPACITYDIRECTUV: number;
  99509. OPACITYRGB: boolean;
  99510. REFLECTION: boolean;
  99511. EMISSIVE: boolean;
  99512. EMISSIVEDIRECTUV: number;
  99513. SPECULAR: boolean;
  99514. SPECULARDIRECTUV: number;
  99515. BUMP: boolean;
  99516. BUMPDIRECTUV: number;
  99517. PARALLAX: boolean;
  99518. PARALLAXOCCLUSION: boolean;
  99519. SPECULAROVERALPHA: boolean;
  99520. CLIPPLANE: boolean;
  99521. CLIPPLANE2: boolean;
  99522. CLIPPLANE3: boolean;
  99523. CLIPPLANE4: boolean;
  99524. CLIPPLANE5: boolean;
  99525. CLIPPLANE6: boolean;
  99526. ALPHATEST: boolean;
  99527. DEPTHPREPASS: boolean;
  99528. ALPHAFROMDIFFUSE: boolean;
  99529. POINTSIZE: boolean;
  99530. FOG: boolean;
  99531. SPECULARTERM: boolean;
  99532. DIFFUSEFRESNEL: boolean;
  99533. OPACITYFRESNEL: boolean;
  99534. REFLECTIONFRESNEL: boolean;
  99535. REFRACTIONFRESNEL: boolean;
  99536. EMISSIVEFRESNEL: boolean;
  99537. FRESNEL: boolean;
  99538. NORMAL: boolean;
  99539. UV1: boolean;
  99540. UV2: boolean;
  99541. VERTEXCOLOR: boolean;
  99542. VERTEXALPHA: boolean;
  99543. NUM_BONE_INFLUENCERS: number;
  99544. BonesPerMesh: number;
  99545. BONETEXTURE: boolean;
  99546. INSTANCES: boolean;
  99547. GLOSSINESS: boolean;
  99548. ROUGHNESS: boolean;
  99549. EMISSIVEASILLUMINATION: boolean;
  99550. LINKEMISSIVEWITHDIFFUSE: boolean;
  99551. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99552. LIGHTMAP: boolean;
  99553. LIGHTMAPDIRECTUV: number;
  99554. OBJECTSPACE_NORMALMAP: boolean;
  99555. USELIGHTMAPASSHADOWMAP: boolean;
  99556. REFLECTIONMAP_3D: boolean;
  99557. REFLECTIONMAP_SPHERICAL: boolean;
  99558. REFLECTIONMAP_PLANAR: boolean;
  99559. REFLECTIONMAP_CUBIC: boolean;
  99560. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99561. REFLECTIONMAP_PROJECTION: boolean;
  99562. REFLECTIONMAP_SKYBOX: boolean;
  99563. REFLECTIONMAP_EXPLICIT: boolean;
  99564. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99565. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99566. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99567. INVERTCUBICMAP: boolean;
  99568. LOGARITHMICDEPTH: boolean;
  99569. REFRACTION: boolean;
  99570. REFRACTIONMAP_3D: boolean;
  99571. REFLECTIONOVERALPHA: boolean;
  99572. TWOSIDEDLIGHTING: boolean;
  99573. SHADOWFLOAT: boolean;
  99574. MORPHTARGETS: boolean;
  99575. MORPHTARGETS_NORMAL: boolean;
  99576. MORPHTARGETS_TANGENT: boolean;
  99577. MORPHTARGETS_UV: boolean;
  99578. NUM_MORPH_INFLUENCERS: number;
  99579. NONUNIFORMSCALING: boolean;
  99580. PREMULTIPLYALPHA: boolean;
  99581. IMAGEPROCESSING: boolean;
  99582. VIGNETTE: boolean;
  99583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99584. VIGNETTEBLENDMODEOPAQUE: boolean;
  99585. TONEMAPPING: boolean;
  99586. TONEMAPPING_ACES: boolean;
  99587. CONTRAST: boolean;
  99588. COLORCURVES: boolean;
  99589. COLORGRADING: boolean;
  99590. COLORGRADING3D: boolean;
  99591. SAMPLER3DGREENDEPTH: boolean;
  99592. SAMPLER3DBGRMAP: boolean;
  99593. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99594. MULTIVIEW: boolean;
  99595. /**
  99596. * If the reflection texture on this material is in linear color space
  99597. * @hidden
  99598. */
  99599. IS_REFLECTION_LINEAR: boolean;
  99600. /**
  99601. * If the refraction texture on this material is in linear color space
  99602. * @hidden
  99603. */
  99604. IS_REFRACTION_LINEAR: boolean;
  99605. EXPOSURE: boolean;
  99606. constructor();
  99607. setReflectionMode(modeToEnable: string): void;
  99608. }
  99609. /**
  99610. * This is the default material used in Babylon. It is the best trade off between quality
  99611. * and performances.
  99612. * @see http://doc.babylonjs.com/babylon101/materials
  99613. */
  99614. export class StandardMaterial extends PushMaterial {
  99615. private _diffuseTexture;
  99616. /**
  99617. * The basic texture of the material as viewed under a light.
  99618. */
  99619. diffuseTexture: Nullable<BaseTexture>;
  99620. private _ambientTexture;
  99621. /**
  99622. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99623. */
  99624. ambientTexture: Nullable<BaseTexture>;
  99625. private _opacityTexture;
  99626. /**
  99627. * Define the transparency of the material from a texture.
  99628. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99629. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99630. */
  99631. opacityTexture: Nullable<BaseTexture>;
  99632. private _reflectionTexture;
  99633. /**
  99634. * Define the texture used to display the reflection.
  99635. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99636. */
  99637. reflectionTexture: Nullable<BaseTexture>;
  99638. private _emissiveTexture;
  99639. /**
  99640. * Define texture of the material as if self lit.
  99641. * This will be mixed in the final result even in the absence of light.
  99642. */
  99643. emissiveTexture: Nullable<BaseTexture>;
  99644. private _specularTexture;
  99645. /**
  99646. * Define how the color and intensity of the highlight given by the light in the material.
  99647. */
  99648. specularTexture: Nullable<BaseTexture>;
  99649. private _bumpTexture;
  99650. /**
  99651. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99652. * 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.
  99653. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99654. */
  99655. bumpTexture: Nullable<BaseTexture>;
  99656. private _lightmapTexture;
  99657. /**
  99658. * Complex lighting can be computationally expensive to compute at runtime.
  99659. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99660. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99661. */
  99662. lightmapTexture: Nullable<BaseTexture>;
  99663. private _refractionTexture;
  99664. /**
  99665. * Define the texture used to display the refraction.
  99666. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99667. */
  99668. refractionTexture: Nullable<BaseTexture>;
  99669. /**
  99670. * The color of the material lit by the environmental background lighting.
  99671. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99672. */
  99673. ambientColor: Color3;
  99674. /**
  99675. * The basic color of the material as viewed under a light.
  99676. */
  99677. diffuseColor: Color3;
  99678. /**
  99679. * Define how the color and intensity of the highlight given by the light in the material.
  99680. */
  99681. specularColor: Color3;
  99682. /**
  99683. * Define the color of the material as if self lit.
  99684. * This will be mixed in the final result even in the absence of light.
  99685. */
  99686. emissiveColor: Color3;
  99687. /**
  99688. * Defines how sharp are the highlights in the material.
  99689. * The bigger the value the sharper giving a more glossy feeling to the result.
  99690. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99691. */
  99692. specularPower: number;
  99693. private _useAlphaFromDiffuseTexture;
  99694. /**
  99695. * Does the transparency come from the diffuse texture alpha channel.
  99696. */
  99697. useAlphaFromDiffuseTexture: boolean;
  99698. private _useEmissiveAsIllumination;
  99699. /**
  99700. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99701. */
  99702. useEmissiveAsIllumination: boolean;
  99703. private _linkEmissiveWithDiffuse;
  99704. /**
  99705. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99706. * the emissive level when the final color is close to one.
  99707. */
  99708. linkEmissiveWithDiffuse: boolean;
  99709. private _useSpecularOverAlpha;
  99710. /**
  99711. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99712. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99713. */
  99714. useSpecularOverAlpha: boolean;
  99715. private _useReflectionOverAlpha;
  99716. /**
  99717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99718. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99719. */
  99720. useReflectionOverAlpha: boolean;
  99721. private _disableLighting;
  99722. /**
  99723. * Does lights from the scene impacts this material.
  99724. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99725. */
  99726. disableLighting: boolean;
  99727. private _useObjectSpaceNormalMap;
  99728. /**
  99729. * Allows using an object space normal map (instead of tangent space).
  99730. */
  99731. useObjectSpaceNormalMap: boolean;
  99732. private _useParallax;
  99733. /**
  99734. * Is parallax enabled or not.
  99735. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99736. */
  99737. useParallax: boolean;
  99738. private _useParallaxOcclusion;
  99739. /**
  99740. * Is parallax occlusion enabled or not.
  99741. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99742. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99743. */
  99744. useParallaxOcclusion: boolean;
  99745. /**
  99746. * 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.
  99747. */
  99748. parallaxScaleBias: number;
  99749. private _roughness;
  99750. /**
  99751. * Helps to define how blurry the reflections should appears in the material.
  99752. */
  99753. roughness: number;
  99754. /**
  99755. * In case of refraction, define the value of the index of refraction.
  99756. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99757. */
  99758. indexOfRefraction: number;
  99759. /**
  99760. * Invert the refraction texture alongside the y axis.
  99761. * It can be useful with procedural textures or probe for instance.
  99762. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99763. */
  99764. invertRefractionY: boolean;
  99765. /**
  99766. * Defines the alpha limits in alpha test mode.
  99767. */
  99768. alphaCutOff: number;
  99769. private _useLightmapAsShadowmap;
  99770. /**
  99771. * In case of light mapping, define whether the map contains light or shadow informations.
  99772. */
  99773. useLightmapAsShadowmap: boolean;
  99774. private _diffuseFresnelParameters;
  99775. /**
  99776. * Define the diffuse fresnel parameters of the material.
  99777. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99778. */
  99779. diffuseFresnelParameters: FresnelParameters;
  99780. private _opacityFresnelParameters;
  99781. /**
  99782. * Define the opacity fresnel parameters of the material.
  99783. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99784. */
  99785. opacityFresnelParameters: FresnelParameters;
  99786. private _reflectionFresnelParameters;
  99787. /**
  99788. * Define the reflection fresnel parameters of the material.
  99789. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99790. */
  99791. reflectionFresnelParameters: FresnelParameters;
  99792. private _refractionFresnelParameters;
  99793. /**
  99794. * Define the refraction fresnel parameters of the material.
  99795. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99796. */
  99797. refractionFresnelParameters: FresnelParameters;
  99798. private _emissiveFresnelParameters;
  99799. /**
  99800. * Define the emissive fresnel parameters of the material.
  99801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99802. */
  99803. emissiveFresnelParameters: FresnelParameters;
  99804. private _useReflectionFresnelFromSpecular;
  99805. /**
  99806. * If true automatically deducts the fresnels values from the material specularity.
  99807. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99808. */
  99809. useReflectionFresnelFromSpecular: boolean;
  99810. private _useGlossinessFromSpecularMapAlpha;
  99811. /**
  99812. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99813. */
  99814. useGlossinessFromSpecularMapAlpha: boolean;
  99815. private _maxSimultaneousLights;
  99816. /**
  99817. * Defines the maximum number of lights that can be used in the material
  99818. */
  99819. maxSimultaneousLights: number;
  99820. private _invertNormalMapX;
  99821. /**
  99822. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99823. */
  99824. invertNormalMapX: boolean;
  99825. private _invertNormalMapY;
  99826. /**
  99827. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99828. */
  99829. invertNormalMapY: boolean;
  99830. private _twoSidedLighting;
  99831. /**
  99832. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99833. */
  99834. twoSidedLighting: boolean;
  99835. /**
  99836. * Default configuration related to image processing available in the standard Material.
  99837. */
  99838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99839. /**
  99840. * Gets the image processing configuration used either in this material.
  99841. */
  99842. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99843. /**
  99844. * Sets the Default image processing configuration used either in the this material.
  99845. *
  99846. * If sets to null, the scene one is in use.
  99847. */
  99848. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99849. /**
  99850. * Keep track of the image processing observer to allow dispose and replace.
  99851. */
  99852. private _imageProcessingObserver;
  99853. /**
  99854. * Attaches a new image processing configuration to the Standard Material.
  99855. * @param configuration
  99856. */
  99857. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99858. /**
  99859. * Gets wether the color curves effect is enabled.
  99860. */
  99861. get cameraColorCurvesEnabled(): boolean;
  99862. /**
  99863. * Sets wether the color curves effect is enabled.
  99864. */
  99865. set cameraColorCurvesEnabled(value: boolean);
  99866. /**
  99867. * Gets wether the color grading effect is enabled.
  99868. */
  99869. get cameraColorGradingEnabled(): boolean;
  99870. /**
  99871. * Gets wether the color grading effect is enabled.
  99872. */
  99873. set cameraColorGradingEnabled(value: boolean);
  99874. /**
  99875. * Gets wether tonemapping is enabled or not.
  99876. */
  99877. get cameraToneMappingEnabled(): boolean;
  99878. /**
  99879. * Sets wether tonemapping is enabled or not
  99880. */
  99881. set cameraToneMappingEnabled(value: boolean);
  99882. /**
  99883. * The camera exposure used on this material.
  99884. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99885. * This corresponds to a photographic exposure.
  99886. */
  99887. get cameraExposure(): number;
  99888. /**
  99889. * The camera exposure used on this material.
  99890. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99891. * This corresponds to a photographic exposure.
  99892. */
  99893. set cameraExposure(value: number);
  99894. /**
  99895. * Gets The camera contrast used on this material.
  99896. */
  99897. get cameraContrast(): number;
  99898. /**
  99899. * Sets The camera contrast used on this material.
  99900. */
  99901. set cameraContrast(value: number);
  99902. /**
  99903. * Gets the Color Grading 2D Lookup Texture.
  99904. */
  99905. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99906. /**
  99907. * Sets the Color Grading 2D Lookup Texture.
  99908. */
  99909. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99910. /**
  99911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99913. * 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;
  99914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99915. */
  99916. get cameraColorCurves(): Nullable<ColorCurves>;
  99917. /**
  99918. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99919. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99920. * 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;
  99921. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99922. */
  99923. set cameraColorCurves(value: Nullable<ColorCurves>);
  99924. /**
  99925. * Custom callback helping to override the default shader used in the material.
  99926. */
  99927. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99928. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99929. protected _worldViewProjectionMatrix: Matrix;
  99930. protected _globalAmbientColor: Color3;
  99931. protected _useLogarithmicDepth: boolean;
  99932. protected _rebuildInParallel: boolean;
  99933. /**
  99934. * Instantiates a new standard material.
  99935. * This is the default material used in Babylon. It is the best trade off between quality
  99936. * and performances.
  99937. * @see http://doc.babylonjs.com/babylon101/materials
  99938. * @param name Define the name of the material in the scene
  99939. * @param scene Define the scene the material belong to
  99940. */
  99941. constructor(name: string, scene: Scene);
  99942. /**
  99943. * Gets a boolean indicating that current material needs to register RTT
  99944. */
  99945. get hasRenderTargetTextures(): boolean;
  99946. /**
  99947. * Gets the current class name of the material e.g. "StandardMaterial"
  99948. * Mainly use in serialization.
  99949. * @returns the class name
  99950. */
  99951. getClassName(): string;
  99952. /**
  99953. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99954. * You can try switching to logarithmic depth.
  99955. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99956. */
  99957. get useLogarithmicDepth(): boolean;
  99958. set useLogarithmicDepth(value: boolean);
  99959. /**
  99960. * Specifies if the material will require alpha blending
  99961. * @returns a boolean specifying if alpha blending is needed
  99962. */
  99963. needAlphaBlending(): boolean;
  99964. /**
  99965. * Specifies if this material should be rendered in alpha test mode
  99966. * @returns a boolean specifying if an alpha test is needed.
  99967. */
  99968. needAlphaTesting(): boolean;
  99969. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99970. /**
  99971. * Get the texture used for alpha test purpose.
  99972. * @returns the diffuse texture in case of the standard material.
  99973. */
  99974. getAlphaTestTexture(): Nullable<BaseTexture>;
  99975. /**
  99976. * Get if the submesh is ready to be used and all its information available.
  99977. * Child classes can use it to update shaders
  99978. * @param mesh defines the mesh to check
  99979. * @param subMesh defines which submesh to check
  99980. * @param useInstances specifies that instances should be used
  99981. * @returns a boolean indicating that the submesh is ready or not
  99982. */
  99983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99984. /**
  99985. * Builds the material UBO layouts.
  99986. * Used internally during the effect preparation.
  99987. */
  99988. buildUniformLayout(): void;
  99989. /**
  99990. * Unbinds the material from the mesh
  99991. */
  99992. unbind(): void;
  99993. /**
  99994. * Binds the submesh to this material by preparing the effect and shader to draw
  99995. * @param world defines the world transformation matrix
  99996. * @param mesh defines the mesh containing the submesh
  99997. * @param subMesh defines the submesh to bind the material to
  99998. */
  99999. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100000. /**
  100001. * Get the list of animatables in the material.
  100002. * @returns the list of animatables object used in the material
  100003. */
  100004. getAnimatables(): IAnimatable[];
  100005. /**
  100006. * Gets the active textures from the material
  100007. * @returns an array of textures
  100008. */
  100009. getActiveTextures(): BaseTexture[];
  100010. /**
  100011. * Specifies if the material uses a texture
  100012. * @param texture defines the texture to check against the material
  100013. * @returns a boolean specifying if the material uses the texture
  100014. */
  100015. hasTexture(texture: BaseTexture): boolean;
  100016. /**
  100017. * Disposes the material
  100018. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100019. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100020. */
  100021. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100022. /**
  100023. * Makes a duplicate of the material, and gives it a new name
  100024. * @param name defines the new name for the duplicated material
  100025. * @returns the cloned material
  100026. */
  100027. clone(name: string): StandardMaterial;
  100028. /**
  100029. * Serializes this material in a JSON representation
  100030. * @returns the serialized material object
  100031. */
  100032. serialize(): any;
  100033. /**
  100034. * Creates a standard material from parsed material data
  100035. * @param source defines the JSON representation of the material
  100036. * @param scene defines the hosting scene
  100037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100038. * @returns a new standard material
  100039. */
  100040. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100041. /**
  100042. * Are diffuse textures enabled in the application.
  100043. */
  100044. static get DiffuseTextureEnabled(): boolean;
  100045. static set DiffuseTextureEnabled(value: boolean);
  100046. /**
  100047. * Are ambient textures enabled in the application.
  100048. */
  100049. static get AmbientTextureEnabled(): boolean;
  100050. static set AmbientTextureEnabled(value: boolean);
  100051. /**
  100052. * Are opacity textures enabled in the application.
  100053. */
  100054. static get OpacityTextureEnabled(): boolean;
  100055. static set OpacityTextureEnabled(value: boolean);
  100056. /**
  100057. * Are reflection textures enabled in the application.
  100058. */
  100059. static get ReflectionTextureEnabled(): boolean;
  100060. static set ReflectionTextureEnabled(value: boolean);
  100061. /**
  100062. * Are emissive textures enabled in the application.
  100063. */
  100064. static get EmissiveTextureEnabled(): boolean;
  100065. static set EmissiveTextureEnabled(value: boolean);
  100066. /**
  100067. * Are specular textures enabled in the application.
  100068. */
  100069. static get SpecularTextureEnabled(): boolean;
  100070. static set SpecularTextureEnabled(value: boolean);
  100071. /**
  100072. * Are bump textures enabled in the application.
  100073. */
  100074. static get BumpTextureEnabled(): boolean;
  100075. static set BumpTextureEnabled(value: boolean);
  100076. /**
  100077. * Are lightmap textures enabled in the application.
  100078. */
  100079. static get LightmapTextureEnabled(): boolean;
  100080. static set LightmapTextureEnabled(value: boolean);
  100081. /**
  100082. * Are refraction textures enabled in the application.
  100083. */
  100084. static get RefractionTextureEnabled(): boolean;
  100085. static set RefractionTextureEnabled(value: boolean);
  100086. /**
  100087. * Are color grading textures enabled in the application.
  100088. */
  100089. static get ColorGradingTextureEnabled(): boolean;
  100090. static set ColorGradingTextureEnabled(value: boolean);
  100091. /**
  100092. * Are fresnels enabled in the application.
  100093. */
  100094. static get FresnelEnabled(): boolean;
  100095. static set FresnelEnabled(value: boolean);
  100096. }
  100097. }
  100098. declare module BABYLON {
  100099. /**
  100100. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100101. *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.
  100102. * The SPS is also a particle system. It provides some methods to manage the particles.
  100103. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100104. *
  100105. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100106. */
  100107. export class SolidParticleSystem implements IDisposable {
  100108. /**
  100109. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100110. * Example : var p = SPS.particles[i];
  100111. */
  100112. particles: SolidParticle[];
  100113. /**
  100114. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100115. */
  100116. nbParticles: number;
  100117. /**
  100118. * If the particles must ever face the camera (default false). Useful for planar particles.
  100119. */
  100120. billboard: boolean;
  100121. /**
  100122. * Recompute normals when adding a shape
  100123. */
  100124. recomputeNormals: boolean;
  100125. /**
  100126. * This a counter ofr your own usage. It's not set by any SPS functions.
  100127. */
  100128. counter: number;
  100129. /**
  100130. * The SPS name. This name is also given to the underlying mesh.
  100131. */
  100132. name: string;
  100133. /**
  100134. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100135. */
  100136. mesh: Mesh;
  100137. /**
  100138. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100139. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100140. */
  100141. vars: any;
  100142. /**
  100143. * This array is populated when the SPS is set as 'pickable'.
  100144. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100145. * Each element of this array is an object `{idx: int, faceId: int}`.
  100146. * `idx` is the picked particle index in the `SPS.particles` array
  100147. * `faceId` is the picked face index counted within this particle.
  100148. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100149. */
  100150. pickedParticles: {
  100151. idx: number;
  100152. faceId: number;
  100153. }[];
  100154. /**
  100155. * This array is populated when `enableDepthSort` is set to true.
  100156. * Each element of this array is an instance of the class DepthSortedParticle.
  100157. */
  100158. depthSortedParticles: DepthSortedParticle[];
  100159. /**
  100160. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100161. * @hidden
  100162. */
  100163. _bSphereOnly: boolean;
  100164. /**
  100165. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100166. * @hidden
  100167. */
  100168. _bSphereRadiusFactor: number;
  100169. private _scene;
  100170. private _positions;
  100171. private _indices;
  100172. private _normals;
  100173. private _colors;
  100174. private _uvs;
  100175. private _indices32;
  100176. private _positions32;
  100177. private _normals32;
  100178. private _fixedNormal32;
  100179. private _colors32;
  100180. private _uvs32;
  100181. private _index;
  100182. private _updatable;
  100183. private _pickable;
  100184. private _isVisibilityBoxLocked;
  100185. private _alwaysVisible;
  100186. private _depthSort;
  100187. private _expandable;
  100188. private _shapeCounter;
  100189. private _copy;
  100190. private _color;
  100191. private _computeParticleColor;
  100192. private _computeParticleTexture;
  100193. private _computeParticleRotation;
  100194. private _computeParticleVertex;
  100195. private _computeBoundingBox;
  100196. private _depthSortParticles;
  100197. private _camera;
  100198. private _mustUnrotateFixedNormals;
  100199. private _particlesIntersect;
  100200. private _needs32Bits;
  100201. private _isNotBuilt;
  100202. private _lastParticleId;
  100203. private _idxOfId;
  100204. private _multimaterialEnabled;
  100205. private _useModelMaterial;
  100206. private _indicesByMaterial;
  100207. private _materialIndexes;
  100208. private _depthSortFunction;
  100209. private _materialSortFunction;
  100210. private _materials;
  100211. private _multimaterial;
  100212. private _materialIndexesById;
  100213. private _defaultMaterial;
  100214. private _autoUpdateSubMeshes;
  100215. /**
  100216. * Creates a SPS (Solid Particle System) object.
  100217. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100218. * @param scene (Scene) is the scene in which the SPS is added.
  100219. * @param options defines the options of the sps e.g.
  100220. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100221. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100222. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100223. * * 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.
  100224. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100225. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100226. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100227. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100228. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100229. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100230. */
  100231. constructor(name: string, scene: Scene, options?: {
  100232. updatable?: boolean;
  100233. isPickable?: boolean;
  100234. enableDepthSort?: boolean;
  100235. particleIntersection?: boolean;
  100236. boundingSphereOnly?: boolean;
  100237. bSphereRadiusFactor?: number;
  100238. expandable?: boolean;
  100239. useModelMaterial?: boolean;
  100240. enableMultiMaterial?: boolean;
  100241. });
  100242. /**
  100243. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100244. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100245. * @returns the created mesh
  100246. */
  100247. buildMesh(): Mesh;
  100248. /**
  100249. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100250. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100251. * Thus the particles generated from `digest()` have their property `position` set yet.
  100252. * @param mesh ( Mesh ) is the mesh to be digested
  100253. * @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
  100254. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100255. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100256. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100257. * @returns the current SPS
  100258. */
  100259. digest(mesh: Mesh, options?: {
  100260. facetNb?: number;
  100261. number?: number;
  100262. delta?: number;
  100263. storage?: [];
  100264. }): SolidParticleSystem;
  100265. /**
  100266. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100267. * @hidden
  100268. */
  100269. private _unrotateFixedNormals;
  100270. /**
  100271. * Resets the temporary working copy particle
  100272. * @hidden
  100273. */
  100274. private _resetCopy;
  100275. /**
  100276. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100277. * @param p the current index in the positions array to be updated
  100278. * @param ind the current index in the indices array
  100279. * @param shape a Vector3 array, the shape geometry
  100280. * @param positions the positions array to be updated
  100281. * @param meshInd the shape indices array
  100282. * @param indices the indices array to be updated
  100283. * @param meshUV the shape uv array
  100284. * @param uvs the uv array to be updated
  100285. * @param meshCol the shape color array
  100286. * @param colors the color array to be updated
  100287. * @param meshNor the shape normals array
  100288. * @param normals the normals array to be updated
  100289. * @param idx the particle index
  100290. * @param idxInShape the particle index in its shape
  100291. * @param options the addShape() method passed options
  100292. * @model the particle model
  100293. * @hidden
  100294. */
  100295. private _meshBuilder;
  100296. /**
  100297. * Returns a shape Vector3 array from positions float array
  100298. * @param positions float array
  100299. * @returns a vector3 array
  100300. * @hidden
  100301. */
  100302. private _posToShape;
  100303. /**
  100304. * Returns a shapeUV array from a float uvs (array deep copy)
  100305. * @param uvs as a float array
  100306. * @returns a shapeUV array
  100307. * @hidden
  100308. */
  100309. private _uvsToShapeUV;
  100310. /**
  100311. * Adds a new particle object in the particles array
  100312. * @param idx particle index in particles array
  100313. * @param id particle id
  100314. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100315. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100316. * @param model particle ModelShape object
  100317. * @param shapeId model shape identifier
  100318. * @param idxInShape index of the particle in the current model
  100319. * @param bInfo model bounding info object
  100320. * @param storage target storage array, if any
  100321. * @hidden
  100322. */
  100323. private _addParticle;
  100324. /**
  100325. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100326. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100327. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100328. * @param nb (positive integer) the number of particles to be created from this model
  100329. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100330. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100331. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100332. * @returns the number of shapes in the system
  100333. */
  100334. addShape(mesh: Mesh, nb: number, options?: {
  100335. positionFunction?: any;
  100336. vertexFunction?: any;
  100337. storage?: [];
  100338. }): number;
  100339. /**
  100340. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100341. * @hidden
  100342. */
  100343. private _rebuildParticle;
  100344. /**
  100345. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100346. * @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.
  100347. * @returns the SPS.
  100348. */
  100349. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100350. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100351. * Returns an array with the removed particles.
  100352. * 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.
  100353. * The SPS can't be empty so at least one particle needs to remain in place.
  100354. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100355. * @param start index of the first particle to remove
  100356. * @param end index of the last particle to remove (included)
  100357. * @returns an array populated with the removed particles
  100358. */
  100359. removeParticles(start: number, end: number): SolidParticle[];
  100360. /**
  100361. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100362. * @param solidParticleArray an array populated with Solid Particles objects
  100363. * @returns the SPS
  100364. */
  100365. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100366. /**
  100367. * Creates a new particle and modifies the SPS mesh geometry :
  100368. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100369. * - calls _addParticle() to populate the particle array
  100370. * factorized code from addShape() and insertParticlesFromArray()
  100371. * @param idx particle index in the particles array
  100372. * @param i particle index in its shape
  100373. * @param modelShape particle ModelShape object
  100374. * @param shape shape vertex array
  100375. * @param meshInd shape indices array
  100376. * @param meshUV shape uv array
  100377. * @param meshCol shape color array
  100378. * @param meshNor shape normals array
  100379. * @param bbInfo shape bounding info
  100380. * @param storage target particle storage
  100381. * @options addShape() passed options
  100382. * @hidden
  100383. */
  100384. private _insertNewParticle;
  100385. /**
  100386. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100387. * This method calls `updateParticle()` for each particle of the SPS.
  100388. * For an animated SPS, it is usually called within the render loop.
  100389. * 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.
  100390. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100391. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100392. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100393. * @returns the SPS.
  100394. */
  100395. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100396. /**
  100397. * Disposes the SPS.
  100398. */
  100399. dispose(): void;
  100400. /**
  100401. * Returns a SolidParticle object from its identifier : particle.id
  100402. * @param id (integer) the particle Id
  100403. * @returns the searched particle or null if not found in the SPS.
  100404. */
  100405. getParticleById(id: number): Nullable<SolidParticle>;
  100406. /**
  100407. * Returns a new array populated with the particles having the passed shapeId.
  100408. * @param shapeId (integer) the shape identifier
  100409. * @returns a new solid particle array
  100410. */
  100411. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100412. /**
  100413. * Populates the passed array "ref" with the particles having the passed shapeId.
  100414. * @param shapeId the shape identifier
  100415. * @returns the SPS
  100416. * @param ref
  100417. */
  100418. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100419. /**
  100420. * Computes the required SubMeshes according the materials assigned to the particles.
  100421. * @returns the solid particle system.
  100422. * Does nothing if called before the SPS mesh is built.
  100423. */
  100424. computeSubMeshes(): SolidParticleSystem;
  100425. /**
  100426. * Sorts the solid particles by material when MultiMaterial is enabled.
  100427. * Updates the indices32 array.
  100428. * Updates the indicesByMaterial array.
  100429. * Updates the mesh indices array.
  100430. * @returns the SPS
  100431. * @hidden
  100432. */
  100433. private _sortParticlesByMaterial;
  100434. /**
  100435. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100436. * @hidden
  100437. */
  100438. private _setMaterialIndexesById;
  100439. /**
  100440. * Returns an array with unique values of Materials from the passed array
  100441. * @param array the material array to be checked and filtered
  100442. * @hidden
  100443. */
  100444. private _filterUniqueMaterialId;
  100445. /**
  100446. * Sets a new Standard Material as _defaultMaterial if not already set.
  100447. * @hidden
  100448. */
  100449. private _setDefaultMaterial;
  100450. /**
  100451. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100452. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100453. * @returns the SPS.
  100454. */
  100455. refreshVisibleSize(): SolidParticleSystem;
  100456. /**
  100457. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100458. * @param size the size (float) of the visibility box
  100459. * note : this doesn't lock the SPS mesh bounding box.
  100460. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100461. */
  100462. setVisibilityBox(size: number): void;
  100463. /**
  100464. * Gets whether the SPS as always visible or not
  100465. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100466. */
  100467. get isAlwaysVisible(): boolean;
  100468. /**
  100469. * Sets the SPS as always visible or not
  100470. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100471. */
  100472. set isAlwaysVisible(val: boolean);
  100473. /**
  100474. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100475. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100476. */
  100477. set isVisibilityBoxLocked(val: boolean);
  100478. /**
  100479. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100480. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100481. */
  100482. get isVisibilityBoxLocked(): boolean;
  100483. /**
  100484. * Tells to `setParticles()` to compute the particle rotations or not.
  100485. * Default value : true. The SPS is faster when it's set to false.
  100486. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100487. */
  100488. set computeParticleRotation(val: boolean);
  100489. /**
  100490. * Tells to `setParticles()` to compute the particle colors or not.
  100491. * Default value : true. The SPS is faster when it's set to false.
  100492. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100493. */
  100494. set computeParticleColor(val: boolean);
  100495. set computeParticleTexture(val: boolean);
  100496. /**
  100497. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100498. * Default value : false. The SPS is faster when it's set to false.
  100499. * Note : the particle custom vertex positions aren't stored values.
  100500. */
  100501. set computeParticleVertex(val: boolean);
  100502. /**
  100503. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100504. */
  100505. set computeBoundingBox(val: boolean);
  100506. /**
  100507. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100508. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100509. * Default : `true`
  100510. */
  100511. set depthSortParticles(val: boolean);
  100512. /**
  100513. * Gets if `setParticles()` computes the particle rotations or not.
  100514. * Default value : true. The SPS is faster when it's set to false.
  100515. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100516. */
  100517. get computeParticleRotation(): boolean;
  100518. /**
  100519. * Gets if `setParticles()` computes the particle colors or not.
  100520. * Default value : true. The SPS is faster when it's set to false.
  100521. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100522. */
  100523. get computeParticleColor(): boolean;
  100524. /**
  100525. * Gets if `setParticles()` computes the particle textures or not.
  100526. * Default value : true. The SPS is faster when it's set to false.
  100527. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100528. */
  100529. get computeParticleTexture(): boolean;
  100530. /**
  100531. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100532. * Default value : false. The SPS is faster when it's set to false.
  100533. * Note : the particle custom vertex positions aren't stored values.
  100534. */
  100535. get computeParticleVertex(): boolean;
  100536. /**
  100537. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100538. */
  100539. get computeBoundingBox(): boolean;
  100540. /**
  100541. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100542. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100543. * Default : `true`
  100544. */
  100545. get depthSortParticles(): boolean;
  100546. /**
  100547. * Gets if the SPS is created as expandable at construction time.
  100548. * Default : `false`
  100549. */
  100550. get expandable(): boolean;
  100551. /**
  100552. * Gets if the SPS supports the Multi Materials
  100553. */
  100554. get multimaterialEnabled(): boolean;
  100555. /**
  100556. * Gets if the SPS uses the model materials for its own multimaterial.
  100557. */
  100558. get useModelMaterial(): boolean;
  100559. /**
  100560. * The SPS used material array.
  100561. */
  100562. get materials(): Material[];
  100563. /**
  100564. * Sets the SPS MultiMaterial from the passed materials.
  100565. * Note : the passed array is internally copied and not used then by reference.
  100566. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100567. */
  100568. setMultiMaterial(materials: Material[]): void;
  100569. /**
  100570. * The SPS computed multimaterial object
  100571. */
  100572. get multimaterial(): MultiMaterial;
  100573. set multimaterial(mm: MultiMaterial);
  100574. /**
  100575. * If the subMeshes must be updated on the next call to setParticles()
  100576. */
  100577. get autoUpdateSubMeshes(): boolean;
  100578. set autoUpdateSubMeshes(val: boolean);
  100579. /**
  100580. * This function does nothing. It may be overwritten to set all the particle first values.
  100581. * The SPS doesn't call this function, you may have to call it by your own.
  100582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100583. */
  100584. initParticles(): void;
  100585. /**
  100586. * This function does nothing. It may be overwritten to recycle a particle.
  100587. * The SPS doesn't call this function, you may have to call it by your own.
  100588. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100589. * @param particle The particle to recycle
  100590. * @returns the recycled particle
  100591. */
  100592. recycleParticle(particle: SolidParticle): SolidParticle;
  100593. /**
  100594. * Updates a particle : this function should be overwritten by the user.
  100595. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100597. * @example : just set a particle position or velocity and recycle conditions
  100598. * @param particle The particle to update
  100599. * @returns the updated particle
  100600. */
  100601. updateParticle(particle: SolidParticle): SolidParticle;
  100602. /**
  100603. * Updates a vertex of a particle : it can be overwritten by the user.
  100604. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100605. * @param particle the current particle
  100606. * @param vertex the current index of the current particle
  100607. * @param pt the index of the current vertex in the particle shape
  100608. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100609. * @example : just set a vertex particle position
  100610. * @returns the updated vertex
  100611. */
  100612. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100613. /**
  100614. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100615. * This does nothing and may be overwritten by the user.
  100616. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100617. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100618. * @param update the boolean update value actually passed to setParticles()
  100619. */
  100620. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100621. /**
  100622. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100623. * This will be passed three parameters.
  100624. * This does nothing and may be overwritten by the user.
  100625. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100626. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100627. * @param update the boolean update value actually passed to setParticles()
  100628. */
  100629. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100630. }
  100631. }
  100632. declare module BABYLON {
  100633. /**
  100634. * Represents one particle of a solid particle system.
  100635. */
  100636. export class SolidParticle {
  100637. /**
  100638. * particle global index
  100639. */
  100640. idx: number;
  100641. /**
  100642. * particle identifier
  100643. */
  100644. id: number;
  100645. /**
  100646. * The color of the particle
  100647. */
  100648. color: Nullable<Color4>;
  100649. /**
  100650. * The world space position of the particle.
  100651. */
  100652. position: Vector3;
  100653. /**
  100654. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100655. */
  100656. rotation: Vector3;
  100657. /**
  100658. * The world space rotation quaternion of the particle.
  100659. */
  100660. rotationQuaternion: Nullable<Quaternion>;
  100661. /**
  100662. * The scaling of the particle.
  100663. */
  100664. scaling: Vector3;
  100665. /**
  100666. * The uvs of the particle.
  100667. */
  100668. uvs: Vector4;
  100669. /**
  100670. * The current speed of the particle.
  100671. */
  100672. velocity: Vector3;
  100673. /**
  100674. * The pivot point in the particle local space.
  100675. */
  100676. pivot: Vector3;
  100677. /**
  100678. * Must the particle be translated from its pivot point in its local space ?
  100679. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100680. * Default : false
  100681. */
  100682. translateFromPivot: boolean;
  100683. /**
  100684. * Is the particle active or not ?
  100685. */
  100686. alive: boolean;
  100687. /**
  100688. * Is the particle visible or not ?
  100689. */
  100690. isVisible: boolean;
  100691. /**
  100692. * Index of this particle in the global "positions" array (Internal use)
  100693. * @hidden
  100694. */
  100695. _pos: number;
  100696. /**
  100697. * @hidden Index of this particle in the global "indices" array (Internal use)
  100698. */
  100699. _ind: number;
  100700. /**
  100701. * @hidden ModelShape of this particle (Internal use)
  100702. */
  100703. _model: ModelShape;
  100704. /**
  100705. * ModelShape id of this particle
  100706. */
  100707. shapeId: number;
  100708. /**
  100709. * Index of the particle in its shape id
  100710. */
  100711. idxInShape: number;
  100712. /**
  100713. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100714. */
  100715. _modelBoundingInfo: BoundingInfo;
  100716. /**
  100717. * @hidden Particle BoundingInfo object (Internal use)
  100718. */
  100719. _boundingInfo: BoundingInfo;
  100720. /**
  100721. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100722. */
  100723. _sps: SolidParticleSystem;
  100724. /**
  100725. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100726. */
  100727. _stillInvisible: boolean;
  100728. /**
  100729. * @hidden Last computed particle rotation matrix
  100730. */
  100731. _rotationMatrix: number[];
  100732. /**
  100733. * Parent particle Id, if any.
  100734. * Default null.
  100735. */
  100736. parentId: Nullable<number>;
  100737. /**
  100738. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100739. */
  100740. materialIndex: Nullable<number>;
  100741. /**
  100742. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100743. * The possible values are :
  100744. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100745. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100746. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100747. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100748. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100749. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100750. * */
  100751. cullingStrategy: number;
  100752. /**
  100753. * @hidden Internal global position in the SPS.
  100754. */
  100755. _globalPosition: Vector3;
  100756. /**
  100757. * Creates a Solid Particle object.
  100758. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100759. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100760. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100761. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100762. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100763. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100764. * @param shapeId (integer) is the model shape identifier in the SPS.
  100765. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100766. * @param sps defines the sps it is associated to
  100767. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100768. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100769. */
  100770. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100771. /**
  100772. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100773. * @param target the particle target
  100774. * @returns the current particle
  100775. */
  100776. copyToRef(target: SolidParticle): SolidParticle;
  100777. /**
  100778. * Legacy support, changed scale to scaling
  100779. */
  100780. get scale(): Vector3;
  100781. /**
  100782. * Legacy support, changed scale to scaling
  100783. */
  100784. set scale(scale: Vector3);
  100785. /**
  100786. * Legacy support, changed quaternion to rotationQuaternion
  100787. */
  100788. get quaternion(): Nullable<Quaternion>;
  100789. /**
  100790. * Legacy support, changed quaternion to rotationQuaternion
  100791. */
  100792. set quaternion(q: Nullable<Quaternion>);
  100793. /**
  100794. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100795. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100796. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100797. * @returns true if it intersects
  100798. */
  100799. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100800. /**
  100801. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100802. * A particle is in the frustum if its bounding box intersects the frustum
  100803. * @param frustumPlanes defines the frustum to test
  100804. * @returns true if the particle is in the frustum planes
  100805. */
  100806. isInFrustum(frustumPlanes: Plane[]): boolean;
  100807. /**
  100808. * get the rotation matrix of the particle
  100809. * @hidden
  100810. */
  100811. getRotationMatrix(m: Matrix): void;
  100812. }
  100813. /**
  100814. * Represents the shape of the model used by one particle of a solid particle system.
  100815. * SPS internal tool, don't use it manually.
  100816. */
  100817. export class ModelShape {
  100818. /**
  100819. * The shape id
  100820. * @hidden
  100821. */
  100822. shapeID: number;
  100823. /**
  100824. * flat array of model positions (internal use)
  100825. * @hidden
  100826. */
  100827. _shape: Vector3[];
  100828. /**
  100829. * flat array of model UVs (internal use)
  100830. * @hidden
  100831. */
  100832. _shapeUV: number[];
  100833. /**
  100834. * color array of the model
  100835. * @hidden
  100836. */
  100837. _shapeColors: number[];
  100838. /**
  100839. * indices array of the model
  100840. * @hidden
  100841. */
  100842. _indices: number[];
  100843. /**
  100844. * normals array of the model
  100845. * @hidden
  100846. */
  100847. _normals: number[];
  100848. /**
  100849. * length of the shape in the model indices array (internal use)
  100850. * @hidden
  100851. */
  100852. _indicesLength: number;
  100853. /**
  100854. * Custom position function (internal use)
  100855. * @hidden
  100856. */
  100857. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100858. /**
  100859. * Custom vertex function (internal use)
  100860. * @hidden
  100861. */
  100862. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100863. /**
  100864. * Model material (internal use)
  100865. * @hidden
  100866. */
  100867. _material: Nullable<Material>;
  100868. /**
  100869. * 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.
  100870. * SPS internal tool, don't use it manually.
  100871. * @hidden
  100872. */
  100873. 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>);
  100874. }
  100875. /**
  100876. * Represents a Depth Sorted Particle in the solid particle system.
  100877. * @hidden
  100878. */
  100879. export class DepthSortedParticle {
  100880. /**
  100881. * Index of the particle in the "indices" array
  100882. */
  100883. ind: number;
  100884. /**
  100885. * Length of the particle shape in the "indices" array
  100886. */
  100887. indicesLength: number;
  100888. /**
  100889. * Squared distance from the particle to the camera
  100890. */
  100891. sqDistance: number;
  100892. /**
  100893. * Material index when used with MultiMaterials
  100894. */
  100895. materialIndex: number;
  100896. /**
  100897. * Creates a new sorted particle
  100898. * @param materialIndex
  100899. */
  100900. constructor(ind: number, indLength: number, materialIndex: number);
  100901. }
  100902. }
  100903. declare module BABYLON {
  100904. /**
  100905. * @hidden
  100906. */
  100907. export class _MeshCollisionData {
  100908. _checkCollisions: boolean;
  100909. _collisionMask: number;
  100910. _collisionGroup: number;
  100911. _collider: Nullable<Collider>;
  100912. _oldPositionForCollisions: Vector3;
  100913. _diffPositionForCollisions: Vector3;
  100914. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100915. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100916. }
  100917. }
  100918. declare module BABYLON {
  100919. /** @hidden */
  100920. class _FacetDataStorage {
  100921. facetPositions: Vector3[];
  100922. facetNormals: Vector3[];
  100923. facetPartitioning: number[][];
  100924. facetNb: number;
  100925. partitioningSubdivisions: number;
  100926. partitioningBBoxRatio: number;
  100927. facetDataEnabled: boolean;
  100928. facetParameters: any;
  100929. bbSize: Vector3;
  100930. subDiv: {
  100931. max: number;
  100932. X: number;
  100933. Y: number;
  100934. Z: number;
  100935. };
  100936. facetDepthSort: boolean;
  100937. facetDepthSortEnabled: boolean;
  100938. depthSortedIndices: IndicesArray;
  100939. depthSortedFacets: {
  100940. ind: number;
  100941. sqDistance: number;
  100942. }[];
  100943. facetDepthSortFunction: (f1: {
  100944. ind: number;
  100945. sqDistance: number;
  100946. }, f2: {
  100947. ind: number;
  100948. sqDistance: number;
  100949. }) => number;
  100950. facetDepthSortFrom: Vector3;
  100951. facetDepthSortOrigin: Vector3;
  100952. invertedMatrix: Matrix;
  100953. }
  100954. /**
  100955. * @hidden
  100956. **/
  100957. class _InternalAbstractMeshDataInfo {
  100958. _hasVertexAlpha: boolean;
  100959. _useVertexColors: boolean;
  100960. _numBoneInfluencers: number;
  100961. _applyFog: boolean;
  100962. _receiveShadows: boolean;
  100963. _facetData: _FacetDataStorage;
  100964. _visibility: number;
  100965. _skeleton: Nullable<Skeleton>;
  100966. _layerMask: number;
  100967. _computeBonesUsingShaders: boolean;
  100968. _isActive: boolean;
  100969. _onlyForInstances: boolean;
  100970. _isActiveIntermediate: boolean;
  100971. _onlyForInstancesIntermediate: boolean;
  100972. _actAsRegularMesh: boolean;
  100973. }
  100974. /**
  100975. * Class used to store all common mesh properties
  100976. */
  100977. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100978. /** No occlusion */
  100979. static OCCLUSION_TYPE_NONE: number;
  100980. /** Occlusion set to optimisitic */
  100981. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100982. /** Occlusion set to strict */
  100983. static OCCLUSION_TYPE_STRICT: number;
  100984. /** Use an accurante occlusion algorithm */
  100985. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100986. /** Use a conservative occlusion algorithm */
  100987. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100988. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100989. * Test order :
  100990. * Is the bounding sphere outside the frustum ?
  100991. * If not, are the bounding box vertices outside the frustum ?
  100992. * It not, then the cullable object is in the frustum.
  100993. */
  100994. static readonly CULLINGSTRATEGY_STANDARD: number;
  100995. /** Culling strategy : Bounding Sphere Only.
  100996. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100997. * It's also less accurate than the standard because some not visible objects can still be selected.
  100998. * Test : is the bounding sphere outside the frustum ?
  100999. * If not, then the cullable object is in the frustum.
  101000. */
  101001. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101002. /** Culling strategy : Optimistic Inclusion.
  101003. * This in an inclusion test first, then the standard exclusion test.
  101004. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101005. * 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.
  101006. * Anyway, it's as accurate as the standard strategy.
  101007. * Test :
  101008. * Is the cullable object bounding sphere center in the frustum ?
  101009. * If not, apply the default culling strategy.
  101010. */
  101011. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101012. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101013. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101014. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101015. * 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.
  101016. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101017. * Test :
  101018. * Is the cullable object bounding sphere center in the frustum ?
  101019. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101020. */
  101021. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101022. /**
  101023. * No billboard
  101024. */
  101025. static get BILLBOARDMODE_NONE(): number;
  101026. /** Billboard on X axis */
  101027. static get BILLBOARDMODE_X(): number;
  101028. /** Billboard on Y axis */
  101029. static get BILLBOARDMODE_Y(): number;
  101030. /** Billboard on Z axis */
  101031. static get BILLBOARDMODE_Z(): number;
  101032. /** Billboard on all axes */
  101033. static get BILLBOARDMODE_ALL(): number;
  101034. /** Billboard on using position instead of orientation */
  101035. static get BILLBOARDMODE_USE_POSITION(): number;
  101036. /** @hidden */
  101037. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101038. /**
  101039. * The culling strategy to use to check whether the mesh must be rendered or not.
  101040. * This value can be changed at any time and will be used on the next render mesh selection.
  101041. * The possible values are :
  101042. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101043. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101044. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101045. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101046. * Please read each static variable documentation to get details about the culling process.
  101047. * */
  101048. cullingStrategy: number;
  101049. /**
  101050. * Gets the number of facets in the mesh
  101051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101052. */
  101053. get facetNb(): number;
  101054. /**
  101055. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101057. */
  101058. get partitioningSubdivisions(): number;
  101059. set partitioningSubdivisions(nb: number);
  101060. /**
  101061. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101062. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101064. */
  101065. get partitioningBBoxRatio(): number;
  101066. set partitioningBBoxRatio(ratio: number);
  101067. /**
  101068. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101069. * Works only for updatable meshes.
  101070. * Doesn't work with multi-materials
  101071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101072. */
  101073. get mustDepthSortFacets(): boolean;
  101074. set mustDepthSortFacets(sort: boolean);
  101075. /**
  101076. * The location (Vector3) where the facet depth sort must be computed from.
  101077. * By default, the active camera position.
  101078. * Used only when facet depth sort is enabled
  101079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101080. */
  101081. get facetDepthSortFrom(): Vector3;
  101082. set facetDepthSortFrom(location: Vector3);
  101083. /**
  101084. * gets a boolean indicating if facetData is enabled
  101085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101086. */
  101087. get isFacetDataEnabled(): boolean;
  101088. /** @hidden */
  101089. _updateNonUniformScalingState(value: boolean): boolean;
  101090. /**
  101091. * An event triggered when this mesh collides with another one
  101092. */
  101093. onCollideObservable: Observable<AbstractMesh>;
  101094. /** Set a function to call when this mesh collides with another one */
  101095. set onCollide(callback: () => void);
  101096. /**
  101097. * An event triggered when the collision's position changes
  101098. */
  101099. onCollisionPositionChangeObservable: Observable<Vector3>;
  101100. /** Set a function to call when the collision's position changes */
  101101. set onCollisionPositionChange(callback: () => void);
  101102. /**
  101103. * An event triggered when material is changed
  101104. */
  101105. onMaterialChangedObservable: Observable<AbstractMesh>;
  101106. /**
  101107. * Gets or sets the orientation for POV movement & rotation
  101108. */
  101109. definedFacingForward: boolean;
  101110. /** @hidden */
  101111. _occlusionQuery: Nullable<WebGLQuery>;
  101112. /** @hidden */
  101113. _renderingGroup: Nullable<RenderingGroup>;
  101114. /**
  101115. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101116. */
  101117. get visibility(): number;
  101118. /**
  101119. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101120. */
  101121. set visibility(value: number);
  101122. /** Gets or sets the alpha index used to sort transparent meshes
  101123. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101124. */
  101125. alphaIndex: number;
  101126. /**
  101127. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101128. */
  101129. isVisible: boolean;
  101130. /**
  101131. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101132. */
  101133. isPickable: boolean;
  101134. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101135. showSubMeshesBoundingBox: boolean;
  101136. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101137. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101138. */
  101139. isBlocker: boolean;
  101140. /**
  101141. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101142. */
  101143. enablePointerMoveEvents: boolean;
  101144. /**
  101145. * Specifies the rendering group id for this mesh (0 by default)
  101146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101147. */
  101148. renderingGroupId: number;
  101149. private _material;
  101150. /** Gets or sets current material */
  101151. get material(): Nullable<Material>;
  101152. set material(value: Nullable<Material>);
  101153. /**
  101154. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101155. * @see http://doc.babylonjs.com/babylon101/shadows
  101156. */
  101157. get receiveShadows(): boolean;
  101158. set receiveShadows(value: boolean);
  101159. /** Defines color to use when rendering outline */
  101160. outlineColor: Color3;
  101161. /** Define width to use when rendering outline */
  101162. outlineWidth: number;
  101163. /** Defines color to use when rendering overlay */
  101164. overlayColor: Color3;
  101165. /** Defines alpha to use when rendering overlay */
  101166. overlayAlpha: number;
  101167. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101168. get hasVertexAlpha(): boolean;
  101169. set hasVertexAlpha(value: boolean);
  101170. /** 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) */
  101171. get useVertexColors(): boolean;
  101172. set useVertexColors(value: boolean);
  101173. /**
  101174. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101175. */
  101176. get computeBonesUsingShaders(): boolean;
  101177. set computeBonesUsingShaders(value: boolean);
  101178. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101179. get numBoneInfluencers(): number;
  101180. set numBoneInfluencers(value: number);
  101181. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101182. get applyFog(): boolean;
  101183. set applyFog(value: boolean);
  101184. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101185. useOctreeForRenderingSelection: boolean;
  101186. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101187. useOctreeForPicking: boolean;
  101188. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101189. useOctreeForCollisions: boolean;
  101190. /**
  101191. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101192. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101193. */
  101194. get layerMask(): number;
  101195. set layerMask(value: number);
  101196. /**
  101197. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101198. */
  101199. alwaysSelectAsActiveMesh: boolean;
  101200. /**
  101201. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101202. */
  101203. doNotSyncBoundingInfo: boolean;
  101204. /**
  101205. * Gets or sets the current action manager
  101206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101207. */
  101208. actionManager: Nullable<AbstractActionManager>;
  101209. private _meshCollisionData;
  101210. /**
  101211. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101213. */
  101214. ellipsoid: Vector3;
  101215. /**
  101216. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101218. */
  101219. ellipsoidOffset: Vector3;
  101220. /**
  101221. * Gets or sets a collision mask used to mask collisions (default is -1).
  101222. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101223. */
  101224. get collisionMask(): number;
  101225. set collisionMask(mask: number);
  101226. /**
  101227. * Gets or sets the current collision group mask (-1 by default).
  101228. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101229. */
  101230. get collisionGroup(): number;
  101231. set collisionGroup(mask: number);
  101232. /**
  101233. * Defines edge width used when edgesRenderer is enabled
  101234. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101235. */
  101236. edgesWidth: number;
  101237. /**
  101238. * Defines edge color used when edgesRenderer is enabled
  101239. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101240. */
  101241. edgesColor: Color4;
  101242. /** @hidden */
  101243. _edgesRenderer: Nullable<IEdgesRenderer>;
  101244. /** @hidden */
  101245. _masterMesh: Nullable<AbstractMesh>;
  101246. /** @hidden */
  101247. _boundingInfo: Nullable<BoundingInfo>;
  101248. /** @hidden */
  101249. _renderId: number;
  101250. /**
  101251. * Gets or sets the list of subMeshes
  101252. * @see http://doc.babylonjs.com/how_to/multi_materials
  101253. */
  101254. subMeshes: SubMesh[];
  101255. /** @hidden */
  101256. _intersectionsInProgress: AbstractMesh[];
  101257. /** @hidden */
  101258. _unIndexed: boolean;
  101259. /** @hidden */
  101260. _lightSources: Light[];
  101261. /** Gets the list of lights affecting that mesh */
  101262. get lightSources(): Light[];
  101263. /** @hidden */
  101264. get _positions(): Nullable<Vector3[]>;
  101265. /** @hidden */
  101266. _waitingData: {
  101267. lods: Nullable<any>;
  101268. actions: Nullable<any>;
  101269. freezeWorldMatrix: Nullable<boolean>;
  101270. };
  101271. /** @hidden */
  101272. _bonesTransformMatrices: Nullable<Float32Array>;
  101273. /** @hidden */
  101274. _transformMatrixTexture: Nullable<RawTexture>;
  101275. /**
  101276. * Gets or sets a skeleton to apply skining transformations
  101277. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101278. */
  101279. set skeleton(value: Nullable<Skeleton>);
  101280. get skeleton(): Nullable<Skeleton>;
  101281. /**
  101282. * An event triggered when the mesh is rebuilt.
  101283. */
  101284. onRebuildObservable: Observable<AbstractMesh>;
  101285. /**
  101286. * Creates a new AbstractMesh
  101287. * @param name defines the name of the mesh
  101288. * @param scene defines the hosting scene
  101289. */
  101290. constructor(name: string, scene?: Nullable<Scene>);
  101291. /**
  101292. * Returns the string "AbstractMesh"
  101293. * @returns "AbstractMesh"
  101294. */
  101295. getClassName(): string;
  101296. /**
  101297. * Gets a string representation of the current mesh
  101298. * @param fullDetails defines a boolean indicating if full details must be included
  101299. * @returns a string representation of the current mesh
  101300. */
  101301. toString(fullDetails?: boolean): string;
  101302. /**
  101303. * @hidden
  101304. */
  101305. protected _getEffectiveParent(): Nullable<Node>;
  101306. /** @hidden */
  101307. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101308. /** @hidden */
  101309. _rebuild(): void;
  101310. /** @hidden */
  101311. _resyncLightSources(): void;
  101312. /** @hidden */
  101313. _resyncLightSource(light: Light): void;
  101314. /** @hidden */
  101315. _unBindEffect(): void;
  101316. /** @hidden */
  101317. _removeLightSource(light: Light, dispose: boolean): void;
  101318. private _markSubMeshesAsDirty;
  101319. /** @hidden */
  101320. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101321. /** @hidden */
  101322. _markSubMeshesAsAttributesDirty(): void;
  101323. /** @hidden */
  101324. _markSubMeshesAsMiscDirty(): void;
  101325. /**
  101326. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101327. */
  101328. get scaling(): Vector3;
  101329. set scaling(newScaling: Vector3);
  101330. /**
  101331. * Returns true if the mesh is blocked. Implemented by child classes
  101332. */
  101333. get isBlocked(): boolean;
  101334. /**
  101335. * Returns the mesh itself by default. Implemented by child classes
  101336. * @param camera defines the camera to use to pick the right LOD level
  101337. * @returns the currentAbstractMesh
  101338. */
  101339. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101340. /**
  101341. * Returns 0 by default. Implemented by child classes
  101342. * @returns an integer
  101343. */
  101344. getTotalVertices(): number;
  101345. /**
  101346. * Returns a positive integer : the total number of indices in this mesh geometry.
  101347. * @returns the numner of indices or zero if the mesh has no geometry.
  101348. */
  101349. getTotalIndices(): number;
  101350. /**
  101351. * Returns null by default. Implemented by child classes
  101352. * @returns null
  101353. */
  101354. getIndices(): Nullable<IndicesArray>;
  101355. /**
  101356. * Returns the array of the requested vertex data kind. Implemented by child classes
  101357. * @param kind defines the vertex data kind to use
  101358. * @returns null
  101359. */
  101360. getVerticesData(kind: string): Nullable<FloatArray>;
  101361. /**
  101362. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101363. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101364. * Note that a new underlying VertexBuffer object is created each call.
  101365. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101366. * @param kind defines vertex data kind:
  101367. * * VertexBuffer.PositionKind
  101368. * * VertexBuffer.UVKind
  101369. * * VertexBuffer.UV2Kind
  101370. * * VertexBuffer.UV3Kind
  101371. * * VertexBuffer.UV4Kind
  101372. * * VertexBuffer.UV5Kind
  101373. * * VertexBuffer.UV6Kind
  101374. * * VertexBuffer.ColorKind
  101375. * * VertexBuffer.MatricesIndicesKind
  101376. * * VertexBuffer.MatricesIndicesExtraKind
  101377. * * VertexBuffer.MatricesWeightsKind
  101378. * * VertexBuffer.MatricesWeightsExtraKind
  101379. * @param data defines the data source
  101380. * @param updatable defines if the data must be flagged as updatable (or static)
  101381. * @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
  101382. * @returns the current mesh
  101383. */
  101384. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101385. /**
  101386. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101387. * If the mesh has no geometry, it is simply returned as it is.
  101388. * @param kind defines vertex data kind:
  101389. * * VertexBuffer.PositionKind
  101390. * * VertexBuffer.UVKind
  101391. * * VertexBuffer.UV2Kind
  101392. * * VertexBuffer.UV3Kind
  101393. * * VertexBuffer.UV4Kind
  101394. * * VertexBuffer.UV5Kind
  101395. * * VertexBuffer.UV6Kind
  101396. * * VertexBuffer.ColorKind
  101397. * * VertexBuffer.MatricesIndicesKind
  101398. * * VertexBuffer.MatricesIndicesExtraKind
  101399. * * VertexBuffer.MatricesWeightsKind
  101400. * * VertexBuffer.MatricesWeightsExtraKind
  101401. * @param data defines the data source
  101402. * @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
  101403. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101404. * @returns the current mesh
  101405. */
  101406. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101407. /**
  101408. * Sets the mesh indices,
  101409. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101410. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101411. * @param totalVertices Defines the total number of vertices
  101412. * @returns the current mesh
  101413. */
  101414. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101415. /**
  101416. * Gets a boolean indicating if specific vertex data is present
  101417. * @param kind defines the vertex data kind to use
  101418. * @returns true is data kind is present
  101419. */
  101420. isVerticesDataPresent(kind: string): boolean;
  101421. /**
  101422. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101423. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101424. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101425. * @returns a BoundingInfo
  101426. */
  101427. getBoundingInfo(): BoundingInfo;
  101428. /**
  101429. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101430. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101431. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101432. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101433. * @returns the current mesh
  101434. */
  101435. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101436. /**
  101437. * Overwrite the current bounding info
  101438. * @param boundingInfo defines the new bounding info
  101439. * @returns the current mesh
  101440. */
  101441. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101442. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101443. get useBones(): boolean;
  101444. /** @hidden */
  101445. _preActivate(): void;
  101446. /** @hidden */
  101447. _preActivateForIntermediateRendering(renderId: number): void;
  101448. /** @hidden */
  101449. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101450. /** @hidden */
  101451. _postActivate(): void;
  101452. /** @hidden */
  101453. _freeze(): void;
  101454. /** @hidden */
  101455. _unFreeze(): void;
  101456. /**
  101457. * Gets the current world matrix
  101458. * @returns a Matrix
  101459. */
  101460. getWorldMatrix(): Matrix;
  101461. /** @hidden */
  101462. _getWorldMatrixDeterminant(): number;
  101463. /**
  101464. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101465. */
  101466. get isAnInstance(): boolean;
  101467. /**
  101468. * Gets a boolean indicating if this mesh has instances
  101469. */
  101470. get hasInstances(): boolean;
  101471. /**
  101472. * Perform relative position change from the point of view of behind the front of the mesh.
  101473. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101474. * Supports definition of mesh facing forward or backward
  101475. * @param amountRight defines the distance on the right axis
  101476. * @param amountUp defines the distance on the up axis
  101477. * @param amountForward defines the distance on the forward axis
  101478. * @returns the current mesh
  101479. */
  101480. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101481. /**
  101482. * Calculate relative position change from the point of view of behind the front of the mesh.
  101483. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101484. * Supports definition of mesh facing forward or backward
  101485. * @param amountRight defines the distance on the right axis
  101486. * @param amountUp defines the distance on the up axis
  101487. * @param amountForward defines the distance on the forward axis
  101488. * @returns the new displacement vector
  101489. */
  101490. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101491. /**
  101492. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101493. * Supports definition of mesh facing forward or backward
  101494. * @param flipBack defines the flip
  101495. * @param twirlClockwise defines the twirl
  101496. * @param tiltRight defines the tilt
  101497. * @returns the current mesh
  101498. */
  101499. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101500. /**
  101501. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101502. * Supports definition of mesh facing forward or backward.
  101503. * @param flipBack defines the flip
  101504. * @param twirlClockwise defines the twirl
  101505. * @param tiltRight defines the tilt
  101506. * @returns the new rotation vector
  101507. */
  101508. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101509. /**
  101510. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101511. * This means the mesh underlying bounding box and sphere are recomputed.
  101512. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101513. * @returns the current mesh
  101514. */
  101515. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101516. /** @hidden */
  101517. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101518. /** @hidden */
  101519. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101520. /** @hidden */
  101521. _updateBoundingInfo(): AbstractMesh;
  101522. /** @hidden */
  101523. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101524. /** @hidden */
  101525. protected _afterComputeWorldMatrix(): void;
  101526. /** @hidden */
  101527. get _effectiveMesh(): AbstractMesh;
  101528. /**
  101529. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101530. * A mesh is in the frustum if its bounding box intersects the frustum
  101531. * @param frustumPlanes defines the frustum to test
  101532. * @returns true if the mesh is in the frustum planes
  101533. */
  101534. isInFrustum(frustumPlanes: Plane[]): boolean;
  101535. /**
  101536. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101537. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101538. * @param frustumPlanes defines the frustum to test
  101539. * @returns true if the mesh is completely in the frustum planes
  101540. */
  101541. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101542. /**
  101543. * True if the mesh intersects another mesh or a SolidParticle object
  101544. * @param mesh defines a target mesh or SolidParticle to test
  101545. * @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)
  101546. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101547. * @returns true if there is an intersection
  101548. */
  101549. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101550. /**
  101551. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101552. * @param point defines the point to test
  101553. * @returns true if there is an intersection
  101554. */
  101555. intersectsPoint(point: Vector3): boolean;
  101556. /**
  101557. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101558. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101559. */
  101560. get checkCollisions(): boolean;
  101561. set checkCollisions(collisionEnabled: boolean);
  101562. /**
  101563. * Gets Collider object used to compute collisions (not physics)
  101564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101565. */
  101566. get collider(): Nullable<Collider>;
  101567. /**
  101568. * Move the mesh using collision engine
  101569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101570. * @param displacement defines the requested displacement vector
  101571. * @returns the current mesh
  101572. */
  101573. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101574. private _onCollisionPositionChange;
  101575. /** @hidden */
  101576. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101577. /** @hidden */
  101578. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101579. /** @hidden */
  101580. _checkCollision(collider: Collider): AbstractMesh;
  101581. /** @hidden */
  101582. _generatePointsArray(): boolean;
  101583. /**
  101584. * Checks if the passed Ray intersects with the mesh
  101585. * @param ray defines the ray to use
  101586. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101588. * @returns the picking info
  101589. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101590. */
  101591. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101592. /**
  101593. * Clones the current mesh
  101594. * @param name defines the mesh name
  101595. * @param newParent defines the new mesh parent
  101596. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101597. * @returns the new mesh
  101598. */
  101599. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101600. /**
  101601. * Disposes all the submeshes of the current meshnp
  101602. * @returns the current mesh
  101603. */
  101604. releaseSubMeshes(): AbstractMesh;
  101605. /**
  101606. * Releases resources associated with this abstract mesh.
  101607. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101608. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101609. */
  101610. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101611. /**
  101612. * Adds the passed mesh as a child to the current mesh
  101613. * @param mesh defines the child mesh
  101614. * @returns the current mesh
  101615. */
  101616. addChild(mesh: AbstractMesh): AbstractMesh;
  101617. /**
  101618. * Removes the passed mesh from the current mesh children list
  101619. * @param mesh defines the child mesh
  101620. * @returns the current mesh
  101621. */
  101622. removeChild(mesh: AbstractMesh): AbstractMesh;
  101623. /** @hidden */
  101624. private _initFacetData;
  101625. /**
  101626. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101627. * This method can be called within the render loop.
  101628. * 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
  101629. * @returns the current mesh
  101630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101631. */
  101632. updateFacetData(): AbstractMesh;
  101633. /**
  101634. * Returns the facetLocalNormals array.
  101635. * The normals are expressed in the mesh local spac
  101636. * @returns an array of Vector3
  101637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101638. */
  101639. getFacetLocalNormals(): Vector3[];
  101640. /**
  101641. * Returns the facetLocalPositions array.
  101642. * The facet positions are expressed in the mesh local space
  101643. * @returns an array of Vector3
  101644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101645. */
  101646. getFacetLocalPositions(): Vector3[];
  101647. /**
  101648. * Returns the facetLocalPartioning array
  101649. * @returns an array of array of numbers
  101650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101651. */
  101652. getFacetLocalPartitioning(): number[][];
  101653. /**
  101654. * Returns the i-th facet position in the world system.
  101655. * This method allocates a new Vector3 per call
  101656. * @param i defines the facet index
  101657. * @returns a new Vector3
  101658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101659. */
  101660. getFacetPosition(i: number): Vector3;
  101661. /**
  101662. * Sets the reference Vector3 with the i-th facet position in the world system
  101663. * @param i defines the facet index
  101664. * @param ref defines the target vector
  101665. * @returns the current mesh
  101666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101667. */
  101668. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101669. /**
  101670. * Returns the i-th facet normal in the world system.
  101671. * This method allocates a new Vector3 per call
  101672. * @param i defines the facet index
  101673. * @returns a new Vector3
  101674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101675. */
  101676. getFacetNormal(i: number): Vector3;
  101677. /**
  101678. * Sets the reference Vector3 with the i-th facet normal in the world system
  101679. * @param i defines the facet index
  101680. * @param ref defines the target vector
  101681. * @returns the current mesh
  101682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101683. */
  101684. getFacetNormalToRef(i: number, ref: Vector3): this;
  101685. /**
  101686. * 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)
  101687. * @param x defines x coordinate
  101688. * @param y defines y coordinate
  101689. * @param z defines z coordinate
  101690. * @returns the array of facet indexes
  101691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101692. */
  101693. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101694. /**
  101695. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101696. * @param projected sets as the (x,y,z) world projection on the facet
  101697. * @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
  101698. * @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
  101699. * @param x defines x coordinate
  101700. * @param y defines y coordinate
  101701. * @param z defines z coordinate
  101702. * @returns the face index if found (or null instead)
  101703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101704. */
  101705. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101706. /**
  101707. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101708. * @param projected sets as the (x,y,z) local projection on the facet
  101709. * @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
  101710. * @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
  101711. * @param x defines x coordinate
  101712. * @param y defines y coordinate
  101713. * @param z defines z coordinate
  101714. * @returns the face index if found (or null instead)
  101715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101716. */
  101717. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101718. /**
  101719. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101720. * @returns the parameters
  101721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101722. */
  101723. getFacetDataParameters(): any;
  101724. /**
  101725. * Disables the feature FacetData and frees the related memory
  101726. * @returns the current mesh
  101727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101728. */
  101729. disableFacetData(): AbstractMesh;
  101730. /**
  101731. * Updates the AbstractMesh indices array
  101732. * @param indices defines the data source
  101733. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101734. * @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)
  101735. * @returns the current mesh
  101736. */
  101737. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101738. /**
  101739. * Creates new normals data for the mesh
  101740. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101741. * @returns the current mesh
  101742. */
  101743. createNormals(updatable: boolean): AbstractMesh;
  101744. /**
  101745. * Align the mesh with a normal
  101746. * @param normal defines the normal to use
  101747. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101748. * @returns the current mesh
  101749. */
  101750. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101751. /** @hidden */
  101752. _checkOcclusionQuery(): boolean;
  101753. /**
  101754. * Disables the mesh edge rendering mode
  101755. * @returns the currentAbstractMesh
  101756. */
  101757. disableEdgesRendering(): AbstractMesh;
  101758. /**
  101759. * Enables the edge rendering mode on the mesh.
  101760. * This mode makes the mesh edges visible
  101761. * @param epsilon defines the maximal distance between two angles to detect a face
  101762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101763. * @returns the currentAbstractMesh
  101764. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101765. */
  101766. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101767. }
  101768. }
  101769. declare module BABYLON {
  101770. /**
  101771. * Interface used to define ActionEvent
  101772. */
  101773. export interface IActionEvent {
  101774. /** The mesh or sprite that triggered the action */
  101775. source: any;
  101776. /** The X mouse cursor position at the time of the event */
  101777. pointerX: number;
  101778. /** The Y mouse cursor position at the time of the event */
  101779. pointerY: number;
  101780. /** The mesh that is currently pointed at (can be null) */
  101781. meshUnderPointer: Nullable<AbstractMesh>;
  101782. /** the original (browser) event that triggered the ActionEvent */
  101783. sourceEvent?: any;
  101784. /** additional data for the event */
  101785. additionalData?: any;
  101786. }
  101787. /**
  101788. * ActionEvent is the event being sent when an action is triggered.
  101789. */
  101790. export class ActionEvent implements IActionEvent {
  101791. /** The mesh or sprite that triggered the action */
  101792. source: any;
  101793. /** The X mouse cursor position at the time of the event */
  101794. pointerX: number;
  101795. /** The Y mouse cursor position at the time of the event */
  101796. pointerY: number;
  101797. /** The mesh that is currently pointed at (can be null) */
  101798. meshUnderPointer: Nullable<AbstractMesh>;
  101799. /** the original (browser) event that triggered the ActionEvent */
  101800. sourceEvent?: any;
  101801. /** additional data for the event */
  101802. additionalData?: any;
  101803. /**
  101804. * Creates a new ActionEvent
  101805. * @param source The mesh or sprite that triggered the action
  101806. * @param pointerX The X mouse cursor position at the time of the event
  101807. * @param pointerY The Y mouse cursor position at the time of the event
  101808. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101809. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101810. * @param additionalData additional data for the event
  101811. */
  101812. constructor(
  101813. /** The mesh or sprite that triggered the action */
  101814. source: any,
  101815. /** The X mouse cursor position at the time of the event */
  101816. pointerX: number,
  101817. /** The Y mouse cursor position at the time of the event */
  101818. pointerY: number,
  101819. /** The mesh that is currently pointed at (can be null) */
  101820. meshUnderPointer: Nullable<AbstractMesh>,
  101821. /** the original (browser) event that triggered the ActionEvent */
  101822. sourceEvent?: any,
  101823. /** additional data for the event */
  101824. additionalData?: any);
  101825. /**
  101826. * Helper function to auto-create an ActionEvent from a source mesh.
  101827. * @param source The source mesh that triggered the event
  101828. * @param evt The original (browser) event
  101829. * @param additionalData additional data for the event
  101830. * @returns the new ActionEvent
  101831. */
  101832. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101833. /**
  101834. * Helper function to auto-create an ActionEvent from a source sprite
  101835. * @param source The source sprite that triggered the event
  101836. * @param scene Scene associated with the sprite
  101837. * @param evt The original (browser) event
  101838. * @param additionalData additional data for the event
  101839. * @returns the new ActionEvent
  101840. */
  101841. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101842. /**
  101843. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101844. * @param scene the scene where the event occurred
  101845. * @param evt The original (browser) event
  101846. * @returns the new ActionEvent
  101847. */
  101848. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101849. /**
  101850. * Helper function to auto-create an ActionEvent from a primitive
  101851. * @param prim defines the target primitive
  101852. * @param pointerPos defines the pointer position
  101853. * @param evt The original (browser) event
  101854. * @param additionalData additional data for the event
  101855. * @returns the new ActionEvent
  101856. */
  101857. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101858. }
  101859. }
  101860. declare module BABYLON {
  101861. /**
  101862. * Abstract class used to decouple action Manager from scene and meshes.
  101863. * Do not instantiate.
  101864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101865. */
  101866. export abstract class AbstractActionManager implements IDisposable {
  101867. /** Gets the list of active triggers */
  101868. static Triggers: {
  101869. [key: string]: number;
  101870. };
  101871. /** Gets the cursor to use when hovering items */
  101872. hoverCursor: string;
  101873. /** Gets the list of actions */
  101874. actions: IAction[];
  101875. /**
  101876. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101877. */
  101878. isRecursive: boolean;
  101879. /**
  101880. * Releases all associated resources
  101881. */
  101882. abstract dispose(): void;
  101883. /**
  101884. * Does this action manager has pointer triggers
  101885. */
  101886. abstract get hasPointerTriggers(): boolean;
  101887. /**
  101888. * Does this action manager has pick triggers
  101889. */
  101890. abstract get hasPickTriggers(): boolean;
  101891. /**
  101892. * Process a specific trigger
  101893. * @param trigger defines the trigger to process
  101894. * @param evt defines the event details to be processed
  101895. */
  101896. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101897. /**
  101898. * Does this action manager handles actions of any of the given triggers
  101899. * @param triggers defines the triggers to be tested
  101900. * @return a boolean indicating whether one (or more) of the triggers is handled
  101901. */
  101902. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101903. /**
  101904. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101905. * speed.
  101906. * @param triggerA defines the trigger to be tested
  101907. * @param triggerB defines the trigger to be tested
  101908. * @return a boolean indicating whether one (or more) of the triggers is handled
  101909. */
  101910. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101911. /**
  101912. * Does this action manager handles actions of a given trigger
  101913. * @param trigger defines the trigger to be tested
  101914. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101915. * @return whether the trigger is handled
  101916. */
  101917. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101918. /**
  101919. * Serialize this manager to a JSON object
  101920. * @param name defines the property name to store this manager
  101921. * @returns a JSON representation of this manager
  101922. */
  101923. abstract serialize(name: string): any;
  101924. /**
  101925. * Registers an action to this action manager
  101926. * @param action defines the action to be registered
  101927. * @return the action amended (prepared) after registration
  101928. */
  101929. abstract registerAction(action: IAction): Nullable<IAction>;
  101930. /**
  101931. * Unregisters an action to this action manager
  101932. * @param action defines the action to be unregistered
  101933. * @return a boolean indicating whether the action has been unregistered
  101934. */
  101935. abstract unregisterAction(action: IAction): Boolean;
  101936. /**
  101937. * Does exist one action manager with at least one trigger
  101938. **/
  101939. static get HasTriggers(): boolean;
  101940. /**
  101941. * Does exist one action manager with at least one pick trigger
  101942. **/
  101943. static get HasPickTriggers(): boolean;
  101944. /**
  101945. * Does exist one action manager that handles actions of a given trigger
  101946. * @param trigger defines the trigger to be tested
  101947. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101948. **/
  101949. static HasSpecificTrigger(trigger: number): boolean;
  101950. }
  101951. }
  101952. declare module BABYLON {
  101953. /**
  101954. * Defines how a node can be built from a string name.
  101955. */
  101956. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101957. /**
  101958. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101959. */
  101960. export class Node implements IBehaviorAware<Node> {
  101961. /** @hidden */
  101962. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101963. private static _NodeConstructors;
  101964. /**
  101965. * Add a new node constructor
  101966. * @param type defines the type name of the node to construct
  101967. * @param constructorFunc defines the constructor function
  101968. */
  101969. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101970. /**
  101971. * Returns a node constructor based on type name
  101972. * @param type defines the type name
  101973. * @param name defines the new node name
  101974. * @param scene defines the hosting scene
  101975. * @param options defines optional options to transmit to constructors
  101976. * @returns the new constructor or null
  101977. */
  101978. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101979. /**
  101980. * Gets or sets the name of the node
  101981. */
  101982. name: string;
  101983. /**
  101984. * Gets or sets the id of the node
  101985. */
  101986. id: string;
  101987. /**
  101988. * Gets or sets the unique id of the node
  101989. */
  101990. uniqueId: number;
  101991. /**
  101992. * Gets or sets a string used to store user defined state for the node
  101993. */
  101994. state: string;
  101995. /**
  101996. * Gets or sets an object used to store user defined information for the node
  101997. */
  101998. metadata: any;
  101999. /**
  102000. * For internal use only. Please do not use.
  102001. */
  102002. reservedDataStore: any;
  102003. /**
  102004. * List of inspectable custom properties (used by the Inspector)
  102005. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102006. */
  102007. inspectableCustomProperties: IInspectable[];
  102008. private _doNotSerialize;
  102009. /**
  102010. * Gets or sets a boolean used to define if the node must be serialized
  102011. */
  102012. get doNotSerialize(): boolean;
  102013. set doNotSerialize(value: boolean);
  102014. /** @hidden */
  102015. _isDisposed: boolean;
  102016. /**
  102017. * Gets a list of Animations associated with the node
  102018. */
  102019. animations: Animation[];
  102020. protected _ranges: {
  102021. [name: string]: Nullable<AnimationRange>;
  102022. };
  102023. /**
  102024. * Callback raised when the node is ready to be used
  102025. */
  102026. onReady: Nullable<(node: Node) => void>;
  102027. private _isEnabled;
  102028. private _isParentEnabled;
  102029. private _isReady;
  102030. /** @hidden */
  102031. _currentRenderId: number;
  102032. private _parentUpdateId;
  102033. /** @hidden */
  102034. _childUpdateId: number;
  102035. /** @hidden */
  102036. _waitingParentId: Nullable<string>;
  102037. /** @hidden */
  102038. _scene: Scene;
  102039. /** @hidden */
  102040. _cache: any;
  102041. private _parentNode;
  102042. private _children;
  102043. /** @hidden */
  102044. _worldMatrix: Matrix;
  102045. /** @hidden */
  102046. _worldMatrixDeterminant: number;
  102047. /** @hidden */
  102048. _worldMatrixDeterminantIsDirty: boolean;
  102049. /** @hidden */
  102050. private _sceneRootNodesIndex;
  102051. /**
  102052. * Gets a boolean indicating if the node has been disposed
  102053. * @returns true if the node was disposed
  102054. */
  102055. isDisposed(): boolean;
  102056. /**
  102057. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102058. * @see https://doc.babylonjs.com/how_to/parenting
  102059. */
  102060. set parent(parent: Nullable<Node>);
  102061. get parent(): Nullable<Node>;
  102062. /** @hidden */
  102063. _addToSceneRootNodes(): void;
  102064. /** @hidden */
  102065. _removeFromSceneRootNodes(): void;
  102066. private _animationPropertiesOverride;
  102067. /**
  102068. * Gets or sets the animation properties override
  102069. */
  102070. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102071. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102072. /**
  102073. * Gets a string idenfifying the name of the class
  102074. * @returns "Node" string
  102075. */
  102076. getClassName(): string;
  102077. /** @hidden */
  102078. readonly _isNode: boolean;
  102079. /**
  102080. * An event triggered when the mesh is disposed
  102081. */
  102082. onDisposeObservable: Observable<Node>;
  102083. private _onDisposeObserver;
  102084. /**
  102085. * Sets a callback that will be raised when the node will be disposed
  102086. */
  102087. set onDispose(callback: () => void);
  102088. /**
  102089. * Creates a new Node
  102090. * @param name the name and id to be given to this node
  102091. * @param scene the scene this node will be added to
  102092. */
  102093. constructor(name: string, scene?: Nullable<Scene>);
  102094. /**
  102095. * Gets the scene of the node
  102096. * @returns a scene
  102097. */
  102098. getScene(): Scene;
  102099. /**
  102100. * Gets the engine of the node
  102101. * @returns a Engine
  102102. */
  102103. getEngine(): Engine;
  102104. private _behaviors;
  102105. /**
  102106. * Attach a behavior to the node
  102107. * @see http://doc.babylonjs.com/features/behaviour
  102108. * @param behavior defines the behavior to attach
  102109. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102110. * @returns the current Node
  102111. */
  102112. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102113. /**
  102114. * Remove an attached behavior
  102115. * @see http://doc.babylonjs.com/features/behaviour
  102116. * @param behavior defines the behavior to attach
  102117. * @returns the current Node
  102118. */
  102119. removeBehavior(behavior: Behavior<Node>): Node;
  102120. /**
  102121. * Gets the list of attached behaviors
  102122. * @see http://doc.babylonjs.com/features/behaviour
  102123. */
  102124. get behaviors(): Behavior<Node>[];
  102125. /**
  102126. * Gets an attached behavior by name
  102127. * @param name defines the name of the behavior to look for
  102128. * @see http://doc.babylonjs.com/features/behaviour
  102129. * @returns null if behavior was not found else the requested behavior
  102130. */
  102131. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102132. /**
  102133. * Returns the latest update of the World matrix
  102134. * @returns a Matrix
  102135. */
  102136. getWorldMatrix(): Matrix;
  102137. /** @hidden */
  102138. _getWorldMatrixDeterminant(): number;
  102139. /**
  102140. * Returns directly the latest state of the mesh World matrix.
  102141. * A Matrix is returned.
  102142. */
  102143. get worldMatrixFromCache(): Matrix;
  102144. /** @hidden */
  102145. _initCache(): void;
  102146. /** @hidden */
  102147. updateCache(force?: boolean): void;
  102148. /** @hidden */
  102149. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102150. /** @hidden */
  102151. _updateCache(ignoreParentClass?: boolean): void;
  102152. /** @hidden */
  102153. _isSynchronized(): boolean;
  102154. /** @hidden */
  102155. _markSyncedWithParent(): void;
  102156. /** @hidden */
  102157. isSynchronizedWithParent(): boolean;
  102158. /** @hidden */
  102159. isSynchronized(): boolean;
  102160. /**
  102161. * Is this node ready to be used/rendered
  102162. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102163. * @return true if the node is ready
  102164. */
  102165. isReady(completeCheck?: boolean): boolean;
  102166. /**
  102167. * Is this node enabled?
  102168. * 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
  102169. * @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
  102170. * @return whether this node (and its parent) is enabled
  102171. */
  102172. isEnabled(checkAncestors?: boolean): boolean;
  102173. /** @hidden */
  102174. protected _syncParentEnabledState(): void;
  102175. /**
  102176. * Set the enabled state of this node
  102177. * @param value defines the new enabled state
  102178. */
  102179. setEnabled(value: boolean): void;
  102180. /**
  102181. * Is this node a descendant of the given node?
  102182. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102183. * @param ancestor defines the parent node to inspect
  102184. * @returns a boolean indicating if this node is a descendant of the given node
  102185. */
  102186. isDescendantOf(ancestor: Node): boolean;
  102187. /** @hidden */
  102188. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102189. /**
  102190. * Will return all nodes that have this node as ascendant
  102191. * @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
  102192. * @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
  102193. * @return all children nodes of all types
  102194. */
  102195. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102196. /**
  102197. * Get all child-meshes of this node
  102198. * @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)
  102199. * @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
  102200. * @returns an array of AbstractMesh
  102201. */
  102202. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102203. /**
  102204. * Get all direct children of this node
  102205. * @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
  102206. * @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)
  102207. * @returns an array of Node
  102208. */
  102209. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102210. /** @hidden */
  102211. _setReady(state: boolean): void;
  102212. /**
  102213. * Get an animation by name
  102214. * @param name defines the name of the animation to look for
  102215. * @returns null if not found else the requested animation
  102216. */
  102217. getAnimationByName(name: string): Nullable<Animation>;
  102218. /**
  102219. * Creates an animation range for this node
  102220. * @param name defines the name of the range
  102221. * @param from defines the starting key
  102222. * @param to defines the end key
  102223. */
  102224. createAnimationRange(name: string, from: number, to: number): void;
  102225. /**
  102226. * Delete a specific animation range
  102227. * @param name defines the name of the range to delete
  102228. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102229. */
  102230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102231. /**
  102232. * Get an animation range by name
  102233. * @param name defines the name of the animation range to look for
  102234. * @returns null if not found else the requested animation range
  102235. */
  102236. getAnimationRange(name: string): Nullable<AnimationRange>;
  102237. /**
  102238. * Gets the list of all animation ranges defined on this node
  102239. * @returns an array
  102240. */
  102241. getAnimationRanges(): Nullable<AnimationRange>[];
  102242. /**
  102243. * Will start the animation sequence
  102244. * @param name defines the range frames for animation sequence
  102245. * @param loop defines if the animation should loop (false by default)
  102246. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102247. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102248. * @returns the object created for this animation. If range does not exist, it will return null
  102249. */
  102250. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102251. /**
  102252. * Serialize animation ranges into a JSON compatible object
  102253. * @returns serialization object
  102254. */
  102255. serializeAnimationRanges(): any;
  102256. /**
  102257. * Computes the world matrix of the node
  102258. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102259. * @returns the world matrix
  102260. */
  102261. computeWorldMatrix(force?: boolean): Matrix;
  102262. /**
  102263. * Releases resources associated with this node.
  102264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102266. */
  102267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102268. /**
  102269. * Parse animation range data from a serialization object and store them into a given node
  102270. * @param node defines where to store the animation ranges
  102271. * @param parsedNode defines the serialization object to read data from
  102272. * @param scene defines the hosting scene
  102273. */
  102274. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102275. /**
  102276. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102277. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102278. * @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
  102279. * @returns the new bounding vectors
  102280. */
  102281. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102282. min: Vector3;
  102283. max: Vector3;
  102284. };
  102285. }
  102286. }
  102287. declare module BABYLON {
  102288. /**
  102289. * @hidden
  102290. */
  102291. export class _IAnimationState {
  102292. key: number;
  102293. repeatCount: number;
  102294. workValue?: any;
  102295. loopMode?: number;
  102296. offsetValue?: any;
  102297. highLimitValue?: any;
  102298. }
  102299. /**
  102300. * Class used to store any kind of animation
  102301. */
  102302. export class Animation {
  102303. /**Name of the animation */
  102304. name: string;
  102305. /**Property to animate */
  102306. targetProperty: string;
  102307. /**The frames per second of the animation */
  102308. framePerSecond: number;
  102309. /**The data type of the animation */
  102310. dataType: number;
  102311. /**The loop mode of the animation */
  102312. loopMode?: number | undefined;
  102313. /**Specifies if blending should be enabled */
  102314. enableBlending?: boolean | undefined;
  102315. /**
  102316. * Use matrix interpolation instead of using direct key value when animating matrices
  102317. */
  102318. static AllowMatricesInterpolation: boolean;
  102319. /**
  102320. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102321. */
  102322. static AllowMatrixDecomposeForInterpolation: boolean;
  102323. /**
  102324. * Stores the key frames of the animation
  102325. */
  102326. private _keys;
  102327. /**
  102328. * Stores the easing function of the animation
  102329. */
  102330. private _easingFunction;
  102331. /**
  102332. * @hidden Internal use only
  102333. */
  102334. _runtimeAnimations: RuntimeAnimation[];
  102335. /**
  102336. * The set of event that will be linked to this animation
  102337. */
  102338. private _events;
  102339. /**
  102340. * Stores an array of target property paths
  102341. */
  102342. targetPropertyPath: string[];
  102343. /**
  102344. * Stores the blending speed of the animation
  102345. */
  102346. blendingSpeed: number;
  102347. /**
  102348. * Stores the animation ranges for the animation
  102349. */
  102350. private _ranges;
  102351. /**
  102352. * @hidden Internal use
  102353. */
  102354. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102355. /**
  102356. * Sets up an animation
  102357. * @param property The property to animate
  102358. * @param animationType The animation type to apply
  102359. * @param framePerSecond The frames per second of the animation
  102360. * @param easingFunction The easing function used in the animation
  102361. * @returns The created animation
  102362. */
  102363. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102364. /**
  102365. * Create and start an animation on a node
  102366. * @param name defines the name of the global animation that will be run on all nodes
  102367. * @param node defines the root node where the animation will take place
  102368. * @param targetProperty defines property to animate
  102369. * @param framePerSecond defines the number of frame per second yo use
  102370. * @param totalFrame defines the number of frames in total
  102371. * @param from defines the initial value
  102372. * @param to defines the final value
  102373. * @param loopMode defines which loop mode you want to use (off by default)
  102374. * @param easingFunction defines the easing function to use (linear by default)
  102375. * @param onAnimationEnd defines the callback to call when animation end
  102376. * @returns the animatable created for this animation
  102377. */
  102378. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102379. /**
  102380. * Create and start an animation on a node and its descendants
  102381. * @param name defines the name of the global animation that will be run on all nodes
  102382. * @param node defines the root node where the animation will take place
  102383. * @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
  102384. * @param targetProperty defines property to animate
  102385. * @param framePerSecond defines the number of frame per second to use
  102386. * @param totalFrame defines the number of frames in total
  102387. * @param from defines the initial value
  102388. * @param to defines the final value
  102389. * @param loopMode defines which loop mode you want to use (off by default)
  102390. * @param easingFunction defines the easing function to use (linear by default)
  102391. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102392. * @returns the list of animatables created for all nodes
  102393. * @example https://www.babylonjs-playground.com/#MH0VLI
  102394. */
  102395. 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[]>;
  102396. /**
  102397. * Creates a new animation, merges it with the existing animations and starts it
  102398. * @param name Name of the animation
  102399. * @param node Node which contains the scene that begins the animations
  102400. * @param targetProperty Specifies which property to animate
  102401. * @param framePerSecond The frames per second of the animation
  102402. * @param totalFrame The total number of frames
  102403. * @param from The frame at the beginning of the animation
  102404. * @param to The frame at the end of the animation
  102405. * @param loopMode Specifies the loop mode of the animation
  102406. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102407. * @param onAnimationEnd Callback to run once the animation is complete
  102408. * @returns Nullable animation
  102409. */
  102410. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102411. /**
  102412. * Transition property of an host to the target Value
  102413. * @param property The property to transition
  102414. * @param targetValue The target Value of the property
  102415. * @param host The object where the property to animate belongs
  102416. * @param scene Scene used to run the animation
  102417. * @param frameRate Framerate (in frame/s) to use
  102418. * @param transition The transition type we want to use
  102419. * @param duration The duration of the animation, in milliseconds
  102420. * @param onAnimationEnd Callback trigger at the end of the animation
  102421. * @returns Nullable animation
  102422. */
  102423. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102424. /**
  102425. * Return the array of runtime animations currently using this animation
  102426. */
  102427. get runtimeAnimations(): RuntimeAnimation[];
  102428. /**
  102429. * Specifies if any of the runtime animations are currently running
  102430. */
  102431. get hasRunningRuntimeAnimations(): boolean;
  102432. /**
  102433. * Initializes the animation
  102434. * @param name Name of the animation
  102435. * @param targetProperty Property to animate
  102436. * @param framePerSecond The frames per second of the animation
  102437. * @param dataType The data type of the animation
  102438. * @param loopMode The loop mode of the animation
  102439. * @param enableBlending Specifies if blending should be enabled
  102440. */
  102441. constructor(
  102442. /**Name of the animation */
  102443. name: string,
  102444. /**Property to animate */
  102445. targetProperty: string,
  102446. /**The frames per second of the animation */
  102447. framePerSecond: number,
  102448. /**The data type of the animation */
  102449. dataType: number,
  102450. /**The loop mode of the animation */
  102451. loopMode?: number | undefined,
  102452. /**Specifies if blending should be enabled */
  102453. enableBlending?: boolean | undefined);
  102454. /**
  102455. * Converts the animation to a string
  102456. * @param fullDetails support for multiple levels of logging within scene loading
  102457. * @returns String form of the animation
  102458. */
  102459. toString(fullDetails?: boolean): string;
  102460. /**
  102461. * Add an event to this animation
  102462. * @param event Event to add
  102463. */
  102464. addEvent(event: AnimationEvent): void;
  102465. /**
  102466. * Remove all events found at the given frame
  102467. * @param frame The frame to remove events from
  102468. */
  102469. removeEvents(frame: number): void;
  102470. /**
  102471. * Retrieves all the events from the animation
  102472. * @returns Events from the animation
  102473. */
  102474. getEvents(): AnimationEvent[];
  102475. /**
  102476. * Creates an animation range
  102477. * @param name Name of the animation range
  102478. * @param from Starting frame of the animation range
  102479. * @param to Ending frame of the animation
  102480. */
  102481. createRange(name: string, from: number, to: number): void;
  102482. /**
  102483. * Deletes an animation range by name
  102484. * @param name Name of the animation range to delete
  102485. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102486. */
  102487. deleteRange(name: string, deleteFrames?: boolean): void;
  102488. /**
  102489. * Gets the animation range by name, or null if not defined
  102490. * @param name Name of the animation range
  102491. * @returns Nullable animation range
  102492. */
  102493. getRange(name: string): Nullable<AnimationRange>;
  102494. /**
  102495. * Gets the key frames from the animation
  102496. * @returns The key frames of the animation
  102497. */
  102498. getKeys(): Array<IAnimationKey>;
  102499. /**
  102500. * Gets the highest frame rate of the animation
  102501. * @returns Highest frame rate of the animation
  102502. */
  102503. getHighestFrame(): number;
  102504. /**
  102505. * Gets the easing function of the animation
  102506. * @returns Easing function of the animation
  102507. */
  102508. getEasingFunction(): IEasingFunction;
  102509. /**
  102510. * Sets the easing function of the animation
  102511. * @param easingFunction A custom mathematical formula for animation
  102512. */
  102513. setEasingFunction(easingFunction: EasingFunction): void;
  102514. /**
  102515. * Interpolates a scalar linearly
  102516. * @param startValue Start value of the animation curve
  102517. * @param endValue End value of the animation curve
  102518. * @param gradient Scalar amount to interpolate
  102519. * @returns Interpolated scalar value
  102520. */
  102521. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102522. /**
  102523. * Interpolates a scalar cubically
  102524. * @param startValue Start value of the animation curve
  102525. * @param outTangent End tangent of the animation
  102526. * @param endValue End value of the animation curve
  102527. * @param inTangent Start tangent of the animation curve
  102528. * @param gradient Scalar amount to interpolate
  102529. * @returns Interpolated scalar value
  102530. */
  102531. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102532. /**
  102533. * Interpolates a quaternion using a spherical linear interpolation
  102534. * @param startValue Start value of the animation curve
  102535. * @param endValue End value of the animation curve
  102536. * @param gradient Scalar amount to interpolate
  102537. * @returns Interpolated quaternion value
  102538. */
  102539. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102540. /**
  102541. * Interpolates a quaternion cubically
  102542. * @param startValue Start value of the animation curve
  102543. * @param outTangent End tangent of the animation curve
  102544. * @param endValue End value of the animation curve
  102545. * @param inTangent Start tangent of the animation curve
  102546. * @param gradient Scalar amount to interpolate
  102547. * @returns Interpolated quaternion value
  102548. */
  102549. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102550. /**
  102551. * Interpolates a Vector3 linearl
  102552. * @param startValue Start value of the animation curve
  102553. * @param endValue End value of the animation curve
  102554. * @param gradient Scalar amount to interpolate
  102555. * @returns Interpolated scalar value
  102556. */
  102557. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102558. /**
  102559. * Interpolates a Vector3 cubically
  102560. * @param startValue Start value of the animation curve
  102561. * @param outTangent End tangent of the animation
  102562. * @param endValue End value of the animation curve
  102563. * @param inTangent Start tangent of the animation curve
  102564. * @param gradient Scalar amount to interpolate
  102565. * @returns InterpolatedVector3 value
  102566. */
  102567. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102568. /**
  102569. * Interpolates a Vector2 linearly
  102570. * @param startValue Start value of the animation curve
  102571. * @param endValue End value of the animation curve
  102572. * @param gradient Scalar amount to interpolate
  102573. * @returns Interpolated Vector2 value
  102574. */
  102575. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102576. /**
  102577. * Interpolates a Vector2 cubically
  102578. * @param startValue Start value of the animation curve
  102579. * @param outTangent End tangent of the animation
  102580. * @param endValue End value of the animation curve
  102581. * @param inTangent Start tangent of the animation curve
  102582. * @param gradient Scalar amount to interpolate
  102583. * @returns Interpolated Vector2 value
  102584. */
  102585. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102586. /**
  102587. * Interpolates a size linearly
  102588. * @param startValue Start value of the animation curve
  102589. * @param endValue End value of the animation curve
  102590. * @param gradient Scalar amount to interpolate
  102591. * @returns Interpolated Size value
  102592. */
  102593. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102594. /**
  102595. * Interpolates a Color3 linearly
  102596. * @param startValue Start value of the animation curve
  102597. * @param endValue End value of the animation curve
  102598. * @param gradient Scalar amount to interpolate
  102599. * @returns Interpolated Color3 value
  102600. */
  102601. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102602. /**
  102603. * Interpolates a Color4 linearly
  102604. * @param startValue Start value of the animation curve
  102605. * @param endValue End value of the animation curve
  102606. * @param gradient Scalar amount to interpolate
  102607. * @returns Interpolated Color3 value
  102608. */
  102609. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102610. /**
  102611. * @hidden Internal use only
  102612. */
  102613. _getKeyValue(value: any): any;
  102614. /**
  102615. * @hidden Internal use only
  102616. */
  102617. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102618. /**
  102619. * Defines the function to use to interpolate matrices
  102620. * @param startValue defines the start matrix
  102621. * @param endValue defines the end matrix
  102622. * @param gradient defines the gradient between both matrices
  102623. * @param result defines an optional target matrix where to store the interpolation
  102624. * @returns the interpolated matrix
  102625. */
  102626. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102627. /**
  102628. * Makes a copy of the animation
  102629. * @returns Cloned animation
  102630. */
  102631. clone(): Animation;
  102632. /**
  102633. * Sets the key frames of the animation
  102634. * @param values The animation key frames to set
  102635. */
  102636. setKeys(values: Array<IAnimationKey>): void;
  102637. /**
  102638. * Serializes the animation to an object
  102639. * @returns Serialized object
  102640. */
  102641. serialize(): any;
  102642. /**
  102643. * Float animation type
  102644. */
  102645. static readonly ANIMATIONTYPE_FLOAT: number;
  102646. /**
  102647. * Vector3 animation type
  102648. */
  102649. static readonly ANIMATIONTYPE_VECTOR3: number;
  102650. /**
  102651. * Quaternion animation type
  102652. */
  102653. static readonly ANIMATIONTYPE_QUATERNION: number;
  102654. /**
  102655. * Matrix animation type
  102656. */
  102657. static readonly ANIMATIONTYPE_MATRIX: number;
  102658. /**
  102659. * Color3 animation type
  102660. */
  102661. static readonly ANIMATIONTYPE_COLOR3: number;
  102662. /**
  102663. * Color3 animation type
  102664. */
  102665. static readonly ANIMATIONTYPE_COLOR4: number;
  102666. /**
  102667. * Vector2 animation type
  102668. */
  102669. static readonly ANIMATIONTYPE_VECTOR2: number;
  102670. /**
  102671. * Size animation type
  102672. */
  102673. static readonly ANIMATIONTYPE_SIZE: number;
  102674. /**
  102675. * Relative Loop Mode
  102676. */
  102677. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102678. /**
  102679. * Cycle Loop Mode
  102680. */
  102681. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102682. /**
  102683. * Constant Loop Mode
  102684. */
  102685. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102686. /** @hidden */
  102687. static _UniversalLerp(left: any, right: any, amount: number): any;
  102688. /**
  102689. * Parses an animation object and creates an animation
  102690. * @param parsedAnimation Parsed animation object
  102691. * @returns Animation object
  102692. */
  102693. static Parse(parsedAnimation: any): Animation;
  102694. /**
  102695. * Appends the serialized animations from the source animations
  102696. * @param source Source containing the animations
  102697. * @param destination Target to store the animations
  102698. */
  102699. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102700. }
  102701. }
  102702. declare module BABYLON {
  102703. /**
  102704. * Interface containing an array of animations
  102705. */
  102706. export interface IAnimatable {
  102707. /**
  102708. * Array of animations
  102709. */
  102710. animations: Nullable<Array<Animation>>;
  102711. }
  102712. }
  102713. declare module BABYLON {
  102714. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102715. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102716. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102717. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102718. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102719. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102720. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102721. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102722. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102723. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102724. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102725. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102726. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102727. /**
  102728. * Decorator used to define property that can be serialized as reference to a camera
  102729. * @param sourceName defines the name of the property to decorate
  102730. */
  102731. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102732. /**
  102733. * Class used to help serialization objects
  102734. */
  102735. export class SerializationHelper {
  102736. /** @hidden */
  102737. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102738. /** @hidden */
  102739. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102740. /** @hidden */
  102741. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102742. /** @hidden */
  102743. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102744. /**
  102745. * Appends the serialized animations from the source animations
  102746. * @param source Source containing the animations
  102747. * @param destination Target to store the animations
  102748. */
  102749. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102750. /**
  102751. * Static function used to serialized a specific entity
  102752. * @param entity defines the entity to serialize
  102753. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102754. * @returns a JSON compatible object representing the serialization of the entity
  102755. */
  102756. static Serialize<T>(entity: T, serializationObject?: any): any;
  102757. /**
  102758. * Creates a new entity from a serialization data object
  102759. * @param creationFunction defines a function used to instanciated the new entity
  102760. * @param source defines the source serialization data
  102761. * @param scene defines the hosting scene
  102762. * @param rootUrl defines the root url for resources
  102763. * @returns a new entity
  102764. */
  102765. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102766. /**
  102767. * Clones an object
  102768. * @param creationFunction defines the function used to instanciate the new object
  102769. * @param source defines the source object
  102770. * @returns the cloned object
  102771. */
  102772. static Clone<T>(creationFunction: () => T, source: T): T;
  102773. /**
  102774. * Instanciates a new object based on a source one (some data will be shared between both object)
  102775. * @param creationFunction defines the function used to instanciate the new object
  102776. * @param source defines the source object
  102777. * @returns the new object
  102778. */
  102779. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102780. }
  102781. }
  102782. declare module BABYLON {
  102783. /**
  102784. * Class used to manipulate GUIDs
  102785. */
  102786. export class GUID {
  102787. /**
  102788. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102789. * Be aware Math.random() could cause collisions, but:
  102790. * "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"
  102791. * @returns a pseudo random id
  102792. */
  102793. static RandomId(): string;
  102794. }
  102795. }
  102796. declare module BABYLON {
  102797. /**
  102798. * Base class of all the textures in babylon.
  102799. * It groups all the common properties the materials, post process, lights... might need
  102800. * in order to make a correct use of the texture.
  102801. */
  102802. export class BaseTexture implements IAnimatable {
  102803. /**
  102804. * Default anisotropic filtering level for the application.
  102805. * It is set to 4 as a good tradeoff between perf and quality.
  102806. */
  102807. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102808. /**
  102809. * Gets or sets the unique id of the texture
  102810. */
  102811. uniqueId: number;
  102812. /**
  102813. * Define the name of the texture.
  102814. */
  102815. name: string;
  102816. /**
  102817. * Gets or sets an object used to store user defined information.
  102818. */
  102819. metadata: any;
  102820. /**
  102821. * For internal use only. Please do not use.
  102822. */
  102823. reservedDataStore: any;
  102824. private _hasAlpha;
  102825. /**
  102826. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102827. */
  102828. set hasAlpha(value: boolean);
  102829. get hasAlpha(): boolean;
  102830. /**
  102831. * Defines if the alpha value should be determined via the rgb values.
  102832. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102833. */
  102834. getAlphaFromRGB: boolean;
  102835. /**
  102836. * Intensity or strength of the texture.
  102837. * It is commonly used by materials to fine tune the intensity of the texture
  102838. */
  102839. level: number;
  102840. /**
  102841. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102842. * This is part of the texture as textures usually maps to one uv set.
  102843. */
  102844. coordinatesIndex: number;
  102845. private _coordinatesMode;
  102846. /**
  102847. * How a texture is mapped.
  102848. *
  102849. * | Value | Type | Description |
  102850. * | ----- | ----------------------------------- | ----------- |
  102851. * | 0 | EXPLICIT_MODE | |
  102852. * | 1 | SPHERICAL_MODE | |
  102853. * | 2 | PLANAR_MODE | |
  102854. * | 3 | CUBIC_MODE | |
  102855. * | 4 | PROJECTION_MODE | |
  102856. * | 5 | SKYBOX_MODE | |
  102857. * | 6 | INVCUBIC_MODE | |
  102858. * | 7 | EQUIRECTANGULAR_MODE | |
  102859. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102860. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102861. */
  102862. set coordinatesMode(value: number);
  102863. get coordinatesMode(): number;
  102864. /**
  102865. * | Value | Type | Description |
  102866. * | ----- | ------------------ | ----------- |
  102867. * | 0 | CLAMP_ADDRESSMODE | |
  102868. * | 1 | WRAP_ADDRESSMODE | |
  102869. * | 2 | MIRROR_ADDRESSMODE | |
  102870. */
  102871. wrapU: number;
  102872. /**
  102873. * | Value | Type | Description |
  102874. * | ----- | ------------------ | ----------- |
  102875. * | 0 | CLAMP_ADDRESSMODE | |
  102876. * | 1 | WRAP_ADDRESSMODE | |
  102877. * | 2 | MIRROR_ADDRESSMODE | |
  102878. */
  102879. wrapV: number;
  102880. /**
  102881. * | Value | Type | Description |
  102882. * | ----- | ------------------ | ----------- |
  102883. * | 0 | CLAMP_ADDRESSMODE | |
  102884. * | 1 | WRAP_ADDRESSMODE | |
  102885. * | 2 | MIRROR_ADDRESSMODE | |
  102886. */
  102887. wrapR: number;
  102888. /**
  102889. * With compliant hardware and browser (supporting anisotropic filtering)
  102890. * this defines the level of anisotropic filtering in the texture.
  102891. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102892. */
  102893. anisotropicFilteringLevel: number;
  102894. /**
  102895. * Define if the texture is a cube texture or if false a 2d texture.
  102896. */
  102897. get isCube(): boolean;
  102898. set isCube(value: boolean);
  102899. /**
  102900. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102901. */
  102902. get is3D(): boolean;
  102903. set is3D(value: boolean);
  102904. /**
  102905. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102906. */
  102907. get is2DArray(): boolean;
  102908. set is2DArray(value: boolean);
  102909. /**
  102910. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102911. * HDR texture are usually stored in linear space.
  102912. * This only impacts the PBR and Background materials
  102913. */
  102914. gammaSpace: boolean;
  102915. /**
  102916. * Gets or sets whether or not the texture contains RGBD data.
  102917. */
  102918. get isRGBD(): boolean;
  102919. set isRGBD(value: boolean);
  102920. /**
  102921. * Is Z inverted in the texture (useful in a cube texture).
  102922. */
  102923. invertZ: boolean;
  102924. /**
  102925. * Are mip maps generated for this texture or not.
  102926. */
  102927. get noMipmap(): boolean;
  102928. /**
  102929. * @hidden
  102930. */
  102931. lodLevelInAlpha: boolean;
  102932. /**
  102933. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102934. */
  102935. get lodGenerationOffset(): number;
  102936. set lodGenerationOffset(value: number);
  102937. /**
  102938. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102939. */
  102940. get lodGenerationScale(): number;
  102941. set lodGenerationScale(value: number);
  102942. /**
  102943. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102944. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102945. * average roughness values.
  102946. */
  102947. get linearSpecularLOD(): boolean;
  102948. set linearSpecularLOD(value: boolean);
  102949. /**
  102950. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102951. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102952. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102953. */
  102954. get irradianceTexture(): Nullable<BaseTexture>;
  102955. set irradianceTexture(value: Nullable<BaseTexture>);
  102956. /**
  102957. * Define if the texture is a render target.
  102958. */
  102959. isRenderTarget: boolean;
  102960. /**
  102961. * Define the unique id of the texture in the scene.
  102962. */
  102963. get uid(): string;
  102964. /**
  102965. * Return a string representation of the texture.
  102966. * @returns the texture as a string
  102967. */
  102968. toString(): string;
  102969. /**
  102970. * Get the class name of the texture.
  102971. * @returns "BaseTexture"
  102972. */
  102973. getClassName(): string;
  102974. /**
  102975. * Define the list of animation attached to the texture.
  102976. */
  102977. animations: Animation[];
  102978. /**
  102979. * An event triggered when the texture is disposed.
  102980. */
  102981. onDisposeObservable: Observable<BaseTexture>;
  102982. private _onDisposeObserver;
  102983. /**
  102984. * Callback triggered when the texture has been disposed.
  102985. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102986. */
  102987. set onDispose(callback: () => void);
  102988. /**
  102989. * Define the current state of the loading sequence when in delayed load mode.
  102990. */
  102991. delayLoadState: number;
  102992. private _scene;
  102993. /** @hidden */
  102994. _texture: Nullable<InternalTexture>;
  102995. private _uid;
  102996. /**
  102997. * Define if the texture is preventinga material to render or not.
  102998. * If not and the texture is not ready, the engine will use a default black texture instead.
  102999. */
  103000. get isBlocking(): boolean;
  103001. /**
  103002. * Instantiates a new BaseTexture.
  103003. * Base class of all the textures in babylon.
  103004. * It groups all the common properties the materials, post process, lights... might need
  103005. * in order to make a correct use of the texture.
  103006. * @param scene Define the scene the texture blongs to
  103007. */
  103008. constructor(scene: Nullable<Scene>);
  103009. /**
  103010. * Get the scene the texture belongs to.
  103011. * @returns the scene or null if undefined
  103012. */
  103013. getScene(): Nullable<Scene>;
  103014. /**
  103015. * Get the texture transform matrix used to offset tile the texture for istance.
  103016. * @returns the transformation matrix
  103017. */
  103018. getTextureMatrix(): Matrix;
  103019. /**
  103020. * Get the texture reflection matrix used to rotate/transform the reflection.
  103021. * @returns the reflection matrix
  103022. */
  103023. getReflectionTextureMatrix(): Matrix;
  103024. /**
  103025. * Get the underlying lower level texture from Babylon.
  103026. * @returns the insternal texture
  103027. */
  103028. getInternalTexture(): Nullable<InternalTexture>;
  103029. /**
  103030. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103031. * @returns true if ready or not blocking
  103032. */
  103033. isReadyOrNotBlocking(): boolean;
  103034. /**
  103035. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103036. * @returns true if fully ready
  103037. */
  103038. isReady(): boolean;
  103039. private _cachedSize;
  103040. /**
  103041. * Get the size of the texture.
  103042. * @returns the texture size.
  103043. */
  103044. getSize(): ISize;
  103045. /**
  103046. * Get the base size of the texture.
  103047. * It can be different from the size if the texture has been resized for POT for instance
  103048. * @returns the base size
  103049. */
  103050. getBaseSize(): ISize;
  103051. /**
  103052. * Update the sampling mode of the texture.
  103053. * Default is Trilinear mode.
  103054. *
  103055. * | Value | Type | Description |
  103056. * | ----- | ------------------ | ----------- |
  103057. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103058. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103059. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103060. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103061. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103062. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103063. * | 7 | NEAREST_LINEAR | |
  103064. * | 8 | NEAREST_NEAREST | |
  103065. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103066. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103067. * | 11 | LINEAR_LINEAR | |
  103068. * | 12 | LINEAR_NEAREST | |
  103069. *
  103070. * > _mag_: magnification filter (close to the viewer)
  103071. * > _min_: minification filter (far from the viewer)
  103072. * > _mip_: filter used between mip map levels
  103073. *@param samplingMode Define the new sampling mode of the texture
  103074. */
  103075. updateSamplingMode(samplingMode: number): void;
  103076. /**
  103077. * Scales the texture if is `canRescale()`
  103078. * @param ratio the resize factor we want to use to rescale
  103079. */
  103080. scale(ratio: number): void;
  103081. /**
  103082. * Get if the texture can rescale.
  103083. */
  103084. get canRescale(): boolean;
  103085. /** @hidden */
  103086. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103087. /** @hidden */
  103088. _rebuild(): void;
  103089. /**
  103090. * Triggers the load sequence in delayed load mode.
  103091. */
  103092. delayLoad(): void;
  103093. /**
  103094. * Clones the texture.
  103095. * @returns the cloned texture
  103096. */
  103097. clone(): Nullable<BaseTexture>;
  103098. /**
  103099. * Get the texture underlying type (INT, FLOAT...)
  103100. */
  103101. get textureType(): number;
  103102. /**
  103103. * Get the texture underlying format (RGB, RGBA...)
  103104. */
  103105. get textureFormat(): number;
  103106. /**
  103107. * Indicates that textures need to be re-calculated for all materials
  103108. */
  103109. protected _markAllSubMeshesAsTexturesDirty(): void;
  103110. /**
  103111. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103112. * This will returns an RGBA array buffer containing either in values (0-255) or
  103113. * float values (0-1) depending of the underlying buffer type.
  103114. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103115. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103116. * @param buffer defines a user defined buffer to fill with data (can be null)
  103117. * @returns The Array buffer containing the pixels data.
  103118. */
  103119. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103120. /**
  103121. * Release and destroy the underlying lower level texture aka internalTexture.
  103122. */
  103123. releaseInternalTexture(): void;
  103124. /** @hidden */
  103125. get _lodTextureHigh(): Nullable<BaseTexture>;
  103126. /** @hidden */
  103127. get _lodTextureMid(): Nullable<BaseTexture>;
  103128. /** @hidden */
  103129. get _lodTextureLow(): Nullable<BaseTexture>;
  103130. /**
  103131. * Dispose the texture and release its associated resources.
  103132. */
  103133. dispose(): void;
  103134. /**
  103135. * Serialize the texture into a JSON representation that can be parsed later on.
  103136. * @returns the JSON representation of the texture
  103137. */
  103138. serialize(): any;
  103139. /**
  103140. * Helper function to be called back once a list of texture contains only ready textures.
  103141. * @param textures Define the list of textures to wait for
  103142. * @param callback Define the callback triggered once the entire list will be ready
  103143. */
  103144. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103145. }
  103146. }
  103147. declare module BABYLON {
  103148. /**
  103149. * Options to be used when creating an effect.
  103150. */
  103151. export interface IEffectCreationOptions {
  103152. /**
  103153. * Atrributes that will be used in the shader.
  103154. */
  103155. attributes: string[];
  103156. /**
  103157. * Uniform varible names that will be set in the shader.
  103158. */
  103159. uniformsNames: string[];
  103160. /**
  103161. * Uniform buffer variable names that will be set in the shader.
  103162. */
  103163. uniformBuffersNames: string[];
  103164. /**
  103165. * Sampler texture variable names that will be set in the shader.
  103166. */
  103167. samplers: string[];
  103168. /**
  103169. * Define statements that will be set in the shader.
  103170. */
  103171. defines: any;
  103172. /**
  103173. * Possible fallbacks for this effect to improve performance when needed.
  103174. */
  103175. fallbacks: Nullable<IEffectFallbacks>;
  103176. /**
  103177. * Callback that will be called when the shader is compiled.
  103178. */
  103179. onCompiled: Nullable<(effect: Effect) => void>;
  103180. /**
  103181. * Callback that will be called if an error occurs during shader compilation.
  103182. */
  103183. onError: Nullable<(effect: Effect, errors: string) => void>;
  103184. /**
  103185. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103186. */
  103187. indexParameters?: any;
  103188. /**
  103189. * Max number of lights that can be used in the shader.
  103190. */
  103191. maxSimultaneousLights?: number;
  103192. /**
  103193. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103194. */
  103195. transformFeedbackVaryings?: Nullable<string[]>;
  103196. }
  103197. /**
  103198. * Effect containing vertex and fragment shader that can be executed on an object.
  103199. */
  103200. export class Effect implements IDisposable {
  103201. /**
  103202. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103203. */
  103204. static ShadersRepository: string;
  103205. /**
  103206. * Name of the effect.
  103207. */
  103208. name: any;
  103209. /**
  103210. * String container all the define statements that should be set on the shader.
  103211. */
  103212. defines: string;
  103213. /**
  103214. * Callback that will be called when the shader is compiled.
  103215. */
  103216. onCompiled: Nullable<(effect: Effect) => void>;
  103217. /**
  103218. * Callback that will be called if an error occurs during shader compilation.
  103219. */
  103220. onError: Nullable<(effect: Effect, errors: string) => void>;
  103221. /**
  103222. * Callback that will be called when effect is bound.
  103223. */
  103224. onBind: Nullable<(effect: Effect) => void>;
  103225. /**
  103226. * Unique ID of the effect.
  103227. */
  103228. uniqueId: number;
  103229. /**
  103230. * Observable that will be called when the shader is compiled.
  103231. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103232. */
  103233. onCompileObservable: Observable<Effect>;
  103234. /**
  103235. * Observable that will be called if an error occurs during shader compilation.
  103236. */
  103237. onErrorObservable: Observable<Effect>;
  103238. /** @hidden */
  103239. _onBindObservable: Nullable<Observable<Effect>>;
  103240. /**
  103241. * @hidden
  103242. * Specifies if the effect was previously ready
  103243. */
  103244. _wasPreviouslyReady: boolean;
  103245. /**
  103246. * Observable that will be called when effect is bound.
  103247. */
  103248. get onBindObservable(): Observable<Effect>;
  103249. /** @hidden */
  103250. _bonesComputationForcedToCPU: boolean;
  103251. private static _uniqueIdSeed;
  103252. private _engine;
  103253. private _uniformBuffersNames;
  103254. private _uniformsNames;
  103255. private _samplerList;
  103256. private _samplers;
  103257. private _isReady;
  103258. private _compilationError;
  103259. private _allFallbacksProcessed;
  103260. private _attributesNames;
  103261. private _attributes;
  103262. private _attributeLocationByName;
  103263. private _uniforms;
  103264. /**
  103265. * Key for the effect.
  103266. * @hidden
  103267. */
  103268. _key: string;
  103269. private _indexParameters;
  103270. private _fallbacks;
  103271. private _vertexSourceCode;
  103272. private _fragmentSourceCode;
  103273. private _vertexSourceCodeOverride;
  103274. private _fragmentSourceCodeOverride;
  103275. private _transformFeedbackVaryings;
  103276. /**
  103277. * Compiled shader to webGL program.
  103278. * @hidden
  103279. */
  103280. _pipelineContext: Nullable<IPipelineContext>;
  103281. private _valueCache;
  103282. private static _baseCache;
  103283. /**
  103284. * Instantiates an effect.
  103285. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103286. * @param baseName Name of the effect.
  103287. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103288. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103289. * @param samplers List of sampler variables that will be passed to the shader.
  103290. * @param engine Engine to be used to render the effect
  103291. * @param defines Define statements to be added to the shader.
  103292. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103293. * @param onCompiled Callback that will be called when the shader is compiled.
  103294. * @param onError Callback that will be called if an error occurs during shader compilation.
  103295. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103296. */
  103297. 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);
  103298. private _useFinalCode;
  103299. /**
  103300. * Unique key for this effect
  103301. */
  103302. get key(): string;
  103303. /**
  103304. * If the effect has been compiled and prepared.
  103305. * @returns if the effect is compiled and prepared.
  103306. */
  103307. isReady(): boolean;
  103308. private _isReadyInternal;
  103309. /**
  103310. * The engine the effect was initialized with.
  103311. * @returns the engine.
  103312. */
  103313. getEngine(): Engine;
  103314. /**
  103315. * The pipeline context for this effect
  103316. * @returns the associated pipeline context
  103317. */
  103318. getPipelineContext(): Nullable<IPipelineContext>;
  103319. /**
  103320. * The set of names of attribute variables for the shader.
  103321. * @returns An array of attribute names.
  103322. */
  103323. getAttributesNames(): string[];
  103324. /**
  103325. * Returns the attribute at the given index.
  103326. * @param index The index of the attribute.
  103327. * @returns The location of the attribute.
  103328. */
  103329. getAttributeLocation(index: number): number;
  103330. /**
  103331. * Returns the attribute based on the name of the variable.
  103332. * @param name of the attribute to look up.
  103333. * @returns the attribute location.
  103334. */
  103335. getAttributeLocationByName(name: string): number;
  103336. /**
  103337. * The number of attributes.
  103338. * @returns the numnber of attributes.
  103339. */
  103340. getAttributesCount(): number;
  103341. /**
  103342. * Gets the index of a uniform variable.
  103343. * @param uniformName of the uniform to look up.
  103344. * @returns the index.
  103345. */
  103346. getUniformIndex(uniformName: string): number;
  103347. /**
  103348. * Returns the attribute based on the name of the variable.
  103349. * @param uniformName of the uniform to look up.
  103350. * @returns the location of the uniform.
  103351. */
  103352. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103353. /**
  103354. * Returns an array of sampler variable names
  103355. * @returns The array of sampler variable neames.
  103356. */
  103357. getSamplers(): string[];
  103358. /**
  103359. * The error from the last compilation.
  103360. * @returns the error string.
  103361. */
  103362. getCompilationError(): string;
  103363. /**
  103364. * Gets a boolean indicating that all fallbacks were used during compilation
  103365. * @returns true if all fallbacks were used
  103366. */
  103367. allFallbacksProcessed(): boolean;
  103368. /**
  103369. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103370. * @param func The callback to be used.
  103371. */
  103372. executeWhenCompiled(func: (effect: Effect) => void): void;
  103373. private _checkIsReady;
  103374. private _loadShader;
  103375. /**
  103376. * Recompiles the webGL program
  103377. * @param vertexSourceCode The source code for the vertex shader.
  103378. * @param fragmentSourceCode The source code for the fragment shader.
  103379. * @param onCompiled Callback called when completed.
  103380. * @param onError Callback called on error.
  103381. * @hidden
  103382. */
  103383. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103384. /**
  103385. * Prepares the effect
  103386. * @hidden
  103387. */
  103388. _prepareEffect(): void;
  103389. private _processCompilationErrors;
  103390. /**
  103391. * Checks if the effect is supported. (Must be called after compilation)
  103392. */
  103393. get isSupported(): boolean;
  103394. /**
  103395. * Binds a texture to the engine to be used as output of the shader.
  103396. * @param channel Name of the output variable.
  103397. * @param texture Texture to bind.
  103398. * @hidden
  103399. */
  103400. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103401. /**
  103402. * Sets a texture on the engine to be used in the shader.
  103403. * @param channel Name of the sampler variable.
  103404. * @param texture Texture to set.
  103405. */
  103406. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103407. /**
  103408. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103409. * @param channel Name of the sampler variable.
  103410. * @param texture Texture to set.
  103411. */
  103412. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103413. /**
  103414. * Sets an array of textures on the engine to be used in the shader.
  103415. * @param channel Name of the variable.
  103416. * @param textures Textures to set.
  103417. */
  103418. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103419. /**
  103420. * 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)
  103421. * @param channel Name of the sampler variable.
  103422. * @param postProcess Post process to get the input texture from.
  103423. */
  103424. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103425. /**
  103426. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103427. * 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)
  103428. * @param channel Name of the sampler variable.
  103429. * @param postProcess Post process to get the output texture from.
  103430. */
  103431. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103432. /** @hidden */
  103433. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103434. /** @hidden */
  103435. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103436. /** @hidden */
  103437. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103438. /** @hidden */
  103439. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103440. /**
  103441. * Binds a buffer to a uniform.
  103442. * @param buffer Buffer to bind.
  103443. * @param name Name of the uniform variable to bind to.
  103444. */
  103445. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103446. /**
  103447. * Binds block to a uniform.
  103448. * @param blockName Name of the block to bind.
  103449. * @param index Index to bind.
  103450. */
  103451. bindUniformBlock(blockName: string, index: number): void;
  103452. /**
  103453. * Sets an interger value on a uniform variable.
  103454. * @param uniformName Name of the variable.
  103455. * @param value Value to be set.
  103456. * @returns this effect.
  103457. */
  103458. setInt(uniformName: string, value: number): Effect;
  103459. /**
  103460. * Sets an int array on a uniform variable.
  103461. * @param uniformName Name of the variable.
  103462. * @param array array to be set.
  103463. * @returns this effect.
  103464. */
  103465. setIntArray(uniformName: string, array: Int32Array): Effect;
  103466. /**
  103467. * 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)
  103468. * @param uniformName Name of the variable.
  103469. * @param array array to be set.
  103470. * @returns this effect.
  103471. */
  103472. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103473. /**
  103474. * 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)
  103475. * @param uniformName Name of the variable.
  103476. * @param array array to be set.
  103477. * @returns this effect.
  103478. */
  103479. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103480. /**
  103481. * 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)
  103482. * @param uniformName Name of the variable.
  103483. * @param array array to be set.
  103484. * @returns this effect.
  103485. */
  103486. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103487. /**
  103488. * Sets an float array on a uniform variable.
  103489. * @param uniformName Name of the variable.
  103490. * @param array array to be set.
  103491. * @returns this effect.
  103492. */
  103493. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103494. /**
  103495. * 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)
  103496. * @param uniformName Name of the variable.
  103497. * @param array array to be set.
  103498. * @returns this effect.
  103499. */
  103500. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103501. /**
  103502. * 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)
  103503. * @param uniformName Name of the variable.
  103504. * @param array array to be set.
  103505. * @returns this effect.
  103506. */
  103507. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103508. /**
  103509. * 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)
  103510. * @param uniformName Name of the variable.
  103511. * @param array array to be set.
  103512. * @returns this effect.
  103513. */
  103514. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103515. /**
  103516. * Sets an array on a uniform variable.
  103517. * @param uniformName Name of the variable.
  103518. * @param array array to be set.
  103519. * @returns this effect.
  103520. */
  103521. setArray(uniformName: string, array: number[]): Effect;
  103522. /**
  103523. * 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)
  103524. * @param uniformName Name of the variable.
  103525. * @param array array to be set.
  103526. * @returns this effect.
  103527. */
  103528. setArray2(uniformName: string, array: number[]): Effect;
  103529. /**
  103530. * 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)
  103531. * @param uniformName Name of the variable.
  103532. * @param array array to be set.
  103533. * @returns this effect.
  103534. */
  103535. setArray3(uniformName: string, array: number[]): Effect;
  103536. /**
  103537. * 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)
  103538. * @param uniformName Name of the variable.
  103539. * @param array array to be set.
  103540. * @returns this effect.
  103541. */
  103542. setArray4(uniformName: string, array: number[]): Effect;
  103543. /**
  103544. * Sets matrices on a uniform variable.
  103545. * @param uniformName Name of the variable.
  103546. * @param matrices matrices to be set.
  103547. * @returns this effect.
  103548. */
  103549. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103550. /**
  103551. * Sets matrix on a uniform variable.
  103552. * @param uniformName Name of the variable.
  103553. * @param matrix matrix to be set.
  103554. * @returns this effect.
  103555. */
  103556. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103557. /**
  103558. * 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)
  103559. * @param uniformName Name of the variable.
  103560. * @param matrix matrix to be set.
  103561. * @returns this effect.
  103562. */
  103563. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103564. /**
  103565. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103566. * @param uniformName Name of the variable.
  103567. * @param matrix matrix to be set.
  103568. * @returns this effect.
  103569. */
  103570. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103571. /**
  103572. * Sets a float on a uniform variable.
  103573. * @param uniformName Name of the variable.
  103574. * @param value value to be set.
  103575. * @returns this effect.
  103576. */
  103577. setFloat(uniformName: string, value: number): Effect;
  103578. /**
  103579. * Sets a boolean on a uniform variable.
  103580. * @param uniformName Name of the variable.
  103581. * @param bool value to be set.
  103582. * @returns this effect.
  103583. */
  103584. setBool(uniformName: string, bool: boolean): Effect;
  103585. /**
  103586. * Sets a Vector2 on a uniform variable.
  103587. * @param uniformName Name of the variable.
  103588. * @param vector2 vector2 to be set.
  103589. * @returns this effect.
  103590. */
  103591. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103592. /**
  103593. * Sets a float2 on a uniform variable.
  103594. * @param uniformName Name of the variable.
  103595. * @param x First float in float2.
  103596. * @param y Second float in float2.
  103597. * @returns this effect.
  103598. */
  103599. setFloat2(uniformName: string, x: number, y: number): Effect;
  103600. /**
  103601. * Sets a Vector3 on a uniform variable.
  103602. * @param uniformName Name of the variable.
  103603. * @param vector3 Value to be set.
  103604. * @returns this effect.
  103605. */
  103606. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103607. /**
  103608. * Sets a float3 on a uniform variable.
  103609. * @param uniformName Name of the variable.
  103610. * @param x First float in float3.
  103611. * @param y Second float in float3.
  103612. * @param z Third float in float3.
  103613. * @returns this effect.
  103614. */
  103615. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103616. /**
  103617. * Sets a Vector4 on a uniform variable.
  103618. * @param uniformName Name of the variable.
  103619. * @param vector4 Value to be set.
  103620. * @returns this effect.
  103621. */
  103622. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103623. /**
  103624. * Sets a float4 on a uniform variable.
  103625. * @param uniformName Name of the variable.
  103626. * @param x First float in float4.
  103627. * @param y Second float in float4.
  103628. * @param z Third float in float4.
  103629. * @param w Fourth float in float4.
  103630. * @returns this effect.
  103631. */
  103632. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103633. /**
  103634. * Sets a Color3 on a uniform variable.
  103635. * @param uniformName Name of the variable.
  103636. * @param color3 Value to be set.
  103637. * @returns this effect.
  103638. */
  103639. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103640. /**
  103641. * Sets a Color4 on a uniform variable.
  103642. * @param uniformName Name of the variable.
  103643. * @param color3 Value to be set.
  103644. * @param alpha Alpha value to be set.
  103645. * @returns this effect.
  103646. */
  103647. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103648. /**
  103649. * Sets a Color4 on a uniform variable
  103650. * @param uniformName defines the name of the variable
  103651. * @param color4 defines the value to be set
  103652. * @returns this effect.
  103653. */
  103654. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103655. /** Release all associated resources */
  103656. dispose(): void;
  103657. /**
  103658. * This function will add a new shader to the shader store
  103659. * @param name the name of the shader
  103660. * @param pixelShader optional pixel shader content
  103661. * @param vertexShader optional vertex shader content
  103662. */
  103663. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103664. /**
  103665. * Store of each shader (The can be looked up using effect.key)
  103666. */
  103667. static ShadersStore: {
  103668. [key: string]: string;
  103669. };
  103670. /**
  103671. * Store of each included file for a shader (The can be looked up using effect.key)
  103672. */
  103673. static IncludesShadersStore: {
  103674. [key: string]: string;
  103675. };
  103676. /**
  103677. * Resets the cache of effects.
  103678. */
  103679. static ResetCache(): void;
  103680. }
  103681. }
  103682. declare module BABYLON {
  103683. /**
  103684. * Interface used to describe the capabilities of the engine relatively to the current browser
  103685. */
  103686. export interface EngineCapabilities {
  103687. /** Maximum textures units per fragment shader */
  103688. maxTexturesImageUnits: number;
  103689. /** Maximum texture units per vertex shader */
  103690. maxVertexTextureImageUnits: number;
  103691. /** Maximum textures units in the entire pipeline */
  103692. maxCombinedTexturesImageUnits: number;
  103693. /** Maximum texture size */
  103694. maxTextureSize: number;
  103695. /** Maximum texture samples */
  103696. maxSamples?: number;
  103697. /** Maximum cube texture size */
  103698. maxCubemapTextureSize: number;
  103699. /** Maximum render texture size */
  103700. maxRenderTextureSize: number;
  103701. /** Maximum number of vertex attributes */
  103702. maxVertexAttribs: number;
  103703. /** Maximum number of varyings */
  103704. maxVaryingVectors: number;
  103705. /** Maximum number of uniforms per vertex shader */
  103706. maxVertexUniformVectors: number;
  103707. /** Maximum number of uniforms per fragment shader */
  103708. maxFragmentUniformVectors: number;
  103709. /** Defines if standard derivates (dx/dy) are supported */
  103710. standardDerivatives: boolean;
  103711. /** Defines if s3tc texture compression is supported */
  103712. s3tc?: WEBGL_compressed_texture_s3tc;
  103713. /** Defines if pvrtc texture compression is supported */
  103714. pvrtc: any;
  103715. /** Defines if etc1 texture compression is supported */
  103716. etc1: any;
  103717. /** Defines if etc2 texture compression is supported */
  103718. etc2: any;
  103719. /** Defines if astc texture compression is supported */
  103720. astc: any;
  103721. /** Defines if float textures are supported */
  103722. textureFloat: boolean;
  103723. /** Defines if vertex array objects are supported */
  103724. vertexArrayObject: boolean;
  103725. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103726. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103727. /** Gets the maximum level of anisotropy supported */
  103728. maxAnisotropy: number;
  103729. /** Defines if instancing is supported */
  103730. instancedArrays: boolean;
  103731. /** Defines if 32 bits indices are supported */
  103732. uintIndices: boolean;
  103733. /** Defines if high precision shaders are supported */
  103734. highPrecisionShaderSupported: boolean;
  103735. /** Defines if depth reading in the fragment shader is supported */
  103736. fragmentDepthSupported: boolean;
  103737. /** Defines if float texture linear filtering is supported*/
  103738. textureFloatLinearFiltering: boolean;
  103739. /** Defines if rendering to float textures is supported */
  103740. textureFloatRender: boolean;
  103741. /** Defines if half float textures are supported*/
  103742. textureHalfFloat: boolean;
  103743. /** Defines if half float texture linear filtering is supported*/
  103744. textureHalfFloatLinearFiltering: boolean;
  103745. /** Defines if rendering to half float textures is supported */
  103746. textureHalfFloatRender: boolean;
  103747. /** Defines if textureLOD shader command is supported */
  103748. textureLOD: boolean;
  103749. /** Defines if draw buffers extension is supported */
  103750. drawBuffersExtension: boolean;
  103751. /** Defines if depth textures are supported */
  103752. depthTextureExtension: boolean;
  103753. /** Defines if float color buffer are supported */
  103754. colorBufferFloat: boolean;
  103755. /** Gets disjoint timer query extension (null if not supported) */
  103756. timerQuery?: EXT_disjoint_timer_query;
  103757. /** Defines if timestamp can be used with timer query */
  103758. canUseTimestampForTimerQuery: boolean;
  103759. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103760. multiview?: any;
  103761. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103762. oculusMultiview?: any;
  103763. /** Function used to let the system compiles shaders in background */
  103764. parallelShaderCompile?: {
  103765. COMPLETION_STATUS_KHR: number;
  103766. };
  103767. /** Max number of texture samples for MSAA */
  103768. maxMSAASamples: number;
  103769. /** Defines if the blend min max extension is supported */
  103770. blendMinMax: boolean;
  103771. }
  103772. }
  103773. declare module BABYLON {
  103774. /**
  103775. * @hidden
  103776. **/
  103777. export class DepthCullingState {
  103778. private _isDepthTestDirty;
  103779. private _isDepthMaskDirty;
  103780. private _isDepthFuncDirty;
  103781. private _isCullFaceDirty;
  103782. private _isCullDirty;
  103783. private _isZOffsetDirty;
  103784. private _isFrontFaceDirty;
  103785. private _depthTest;
  103786. private _depthMask;
  103787. private _depthFunc;
  103788. private _cull;
  103789. private _cullFace;
  103790. private _zOffset;
  103791. private _frontFace;
  103792. /**
  103793. * Initializes the state.
  103794. */
  103795. constructor();
  103796. get isDirty(): boolean;
  103797. get zOffset(): number;
  103798. set zOffset(value: number);
  103799. get cullFace(): Nullable<number>;
  103800. set cullFace(value: Nullable<number>);
  103801. get cull(): Nullable<boolean>;
  103802. set cull(value: Nullable<boolean>);
  103803. get depthFunc(): Nullable<number>;
  103804. set depthFunc(value: Nullable<number>);
  103805. get depthMask(): boolean;
  103806. set depthMask(value: boolean);
  103807. get depthTest(): boolean;
  103808. set depthTest(value: boolean);
  103809. get frontFace(): Nullable<number>;
  103810. set frontFace(value: Nullable<number>);
  103811. reset(): void;
  103812. apply(gl: WebGLRenderingContext): void;
  103813. }
  103814. }
  103815. declare module BABYLON {
  103816. /**
  103817. * @hidden
  103818. **/
  103819. export class StencilState {
  103820. /** 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 */
  103821. static readonly ALWAYS: number;
  103822. /** Passed to stencilOperation to specify that stencil value must be kept */
  103823. static readonly KEEP: number;
  103824. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103825. static readonly REPLACE: number;
  103826. private _isStencilTestDirty;
  103827. private _isStencilMaskDirty;
  103828. private _isStencilFuncDirty;
  103829. private _isStencilOpDirty;
  103830. private _stencilTest;
  103831. private _stencilMask;
  103832. private _stencilFunc;
  103833. private _stencilFuncRef;
  103834. private _stencilFuncMask;
  103835. private _stencilOpStencilFail;
  103836. private _stencilOpDepthFail;
  103837. private _stencilOpStencilDepthPass;
  103838. get isDirty(): boolean;
  103839. get stencilFunc(): number;
  103840. set stencilFunc(value: number);
  103841. get stencilFuncRef(): number;
  103842. set stencilFuncRef(value: number);
  103843. get stencilFuncMask(): number;
  103844. set stencilFuncMask(value: number);
  103845. get stencilOpStencilFail(): number;
  103846. set stencilOpStencilFail(value: number);
  103847. get stencilOpDepthFail(): number;
  103848. set stencilOpDepthFail(value: number);
  103849. get stencilOpStencilDepthPass(): number;
  103850. set stencilOpStencilDepthPass(value: number);
  103851. get stencilMask(): number;
  103852. set stencilMask(value: number);
  103853. get stencilTest(): boolean;
  103854. set stencilTest(value: boolean);
  103855. constructor();
  103856. reset(): void;
  103857. apply(gl: WebGLRenderingContext): void;
  103858. }
  103859. }
  103860. declare module BABYLON {
  103861. /**
  103862. * @hidden
  103863. **/
  103864. export class AlphaState {
  103865. private _isAlphaBlendDirty;
  103866. private _isBlendFunctionParametersDirty;
  103867. private _isBlendEquationParametersDirty;
  103868. private _isBlendConstantsDirty;
  103869. private _alphaBlend;
  103870. private _blendFunctionParameters;
  103871. private _blendEquationParameters;
  103872. private _blendConstants;
  103873. /**
  103874. * Initializes the state.
  103875. */
  103876. constructor();
  103877. get isDirty(): boolean;
  103878. get alphaBlend(): boolean;
  103879. set alphaBlend(value: boolean);
  103880. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103881. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103882. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103883. reset(): void;
  103884. apply(gl: WebGLRenderingContext): void;
  103885. }
  103886. }
  103887. declare module BABYLON {
  103888. /** @hidden */
  103889. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103890. attributeProcessor(attribute: string): string;
  103891. varyingProcessor(varying: string, isFragment: boolean): string;
  103892. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103893. }
  103894. }
  103895. declare module BABYLON {
  103896. /**
  103897. * Interface for attribute information associated with buffer instanciation
  103898. */
  103899. export interface InstancingAttributeInfo {
  103900. /**
  103901. * Name of the GLSL attribute
  103902. * if attribute index is not specified, this is used to retrieve the index from the effect
  103903. */
  103904. attributeName: string;
  103905. /**
  103906. * Index/offset of the attribute in the vertex shader
  103907. * if not specified, this will be computes from the name.
  103908. */
  103909. index?: number;
  103910. /**
  103911. * size of the attribute, 1, 2, 3 or 4
  103912. */
  103913. attributeSize: number;
  103914. /**
  103915. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103916. */
  103917. offset: number;
  103918. /**
  103919. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103920. * default to 1
  103921. */
  103922. divisor?: number;
  103923. /**
  103924. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103925. * default is FLOAT
  103926. */
  103927. attributeType?: number;
  103928. /**
  103929. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103930. */
  103931. normalized?: boolean;
  103932. }
  103933. }
  103934. declare module BABYLON {
  103935. interface ThinEngine {
  103936. /**
  103937. * Update a video texture
  103938. * @param texture defines the texture to update
  103939. * @param video defines the video element to use
  103940. * @param invertY defines if data must be stored with Y axis inverted
  103941. */
  103942. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103943. }
  103944. }
  103945. declare module BABYLON {
  103946. /**
  103947. * Settings for finer control over video usage
  103948. */
  103949. export interface VideoTextureSettings {
  103950. /**
  103951. * Applies `autoplay` to video, if specified
  103952. */
  103953. autoPlay?: boolean;
  103954. /**
  103955. * Applies `loop` to video, if specified
  103956. */
  103957. loop?: boolean;
  103958. /**
  103959. * Automatically updates internal texture from video at every frame in the render loop
  103960. */
  103961. autoUpdateTexture: boolean;
  103962. /**
  103963. * Image src displayed during the video loading or until the user interacts with the video.
  103964. */
  103965. poster?: string;
  103966. }
  103967. /**
  103968. * If you want to display a video in your scene, this is the special texture for that.
  103969. * This special texture works similar to other textures, with the exception of a few parameters.
  103970. * @see https://doc.babylonjs.com/how_to/video_texture
  103971. */
  103972. export class VideoTexture extends Texture {
  103973. /**
  103974. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103975. */
  103976. readonly autoUpdateTexture: boolean;
  103977. /**
  103978. * The video instance used by the texture internally
  103979. */
  103980. readonly video: HTMLVideoElement;
  103981. private _onUserActionRequestedObservable;
  103982. /**
  103983. * Event triggerd when a dom action is required by the user to play the video.
  103984. * This happens due to recent changes in browser policies preventing video to auto start.
  103985. */
  103986. get onUserActionRequestedObservable(): Observable<Texture>;
  103987. private _generateMipMaps;
  103988. private _engine;
  103989. private _stillImageCaptured;
  103990. private _displayingPosterTexture;
  103991. private _settings;
  103992. private _createInternalTextureOnEvent;
  103993. private _frameId;
  103994. private _currentSrc;
  103995. /**
  103996. * Creates a video texture.
  103997. * If you want to display a video in your scene, this is the special texture for that.
  103998. * This special texture works similar to other textures, with the exception of a few parameters.
  103999. * @see https://doc.babylonjs.com/how_to/video_texture
  104000. * @param name optional name, will detect from video source, if not defined
  104001. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104002. * @param scene is obviously the current scene.
  104003. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104004. * @param invertY is false by default but can be used to invert video on Y axis
  104005. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104006. * @param settings allows finer control over video usage
  104007. */
  104008. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104009. private _getName;
  104010. private _getVideo;
  104011. private _createInternalTexture;
  104012. private reset;
  104013. /**
  104014. * @hidden Internal method to initiate `update`.
  104015. */
  104016. _rebuild(): void;
  104017. /**
  104018. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104019. */
  104020. update(): void;
  104021. /**
  104022. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104023. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104024. */
  104025. updateTexture(isVisible: boolean): void;
  104026. protected _updateInternalTexture: () => void;
  104027. /**
  104028. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104029. * @param url New url.
  104030. */
  104031. updateURL(url: string): void;
  104032. /**
  104033. * Clones the texture.
  104034. * @returns the cloned texture
  104035. */
  104036. clone(): VideoTexture;
  104037. /**
  104038. * Dispose the texture and release its associated resources.
  104039. */
  104040. dispose(): void;
  104041. /**
  104042. * Creates a video texture straight from a stream.
  104043. * @param scene Define the scene the texture should be created in
  104044. * @param stream Define the stream the texture should be created from
  104045. * @returns The created video texture as a promise
  104046. */
  104047. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104048. /**
  104049. * Creates a video texture straight from your WebCam video feed.
  104050. * @param scene Define the scene the texture should be created in
  104051. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104052. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104053. * @returns The created video texture as a promise
  104054. */
  104055. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104056. minWidth: number;
  104057. maxWidth: number;
  104058. minHeight: number;
  104059. maxHeight: number;
  104060. deviceId: string;
  104061. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104062. /**
  104063. * Creates a video texture straight from your WebCam video feed.
  104064. * @param scene Define the scene the texture should be created in
  104065. * @param onReady Define a callback to triggered once the texture will be ready
  104066. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104067. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104068. */
  104069. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104070. minWidth: number;
  104071. maxWidth: number;
  104072. minHeight: number;
  104073. maxHeight: number;
  104074. deviceId: string;
  104075. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104076. }
  104077. }
  104078. declare module BABYLON {
  104079. /**
  104080. * Defines the interface used by objects working like Scene
  104081. * @hidden
  104082. */
  104083. export interface ISceneLike {
  104084. _addPendingData(data: any): void;
  104085. _removePendingData(data: any): void;
  104086. offlineProvider: IOfflineProvider;
  104087. }
  104088. /** Interface defining initialization parameters for Engine class */
  104089. export interface EngineOptions extends WebGLContextAttributes {
  104090. /**
  104091. * Defines if the engine should no exceed a specified device ratio
  104092. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104093. */
  104094. limitDeviceRatio?: number;
  104095. /**
  104096. * Defines if webvr should be enabled automatically
  104097. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104098. */
  104099. autoEnableWebVR?: boolean;
  104100. /**
  104101. * Defines if webgl2 should be turned off even if supported
  104102. * @see http://doc.babylonjs.com/features/webgl2
  104103. */
  104104. disableWebGL2Support?: boolean;
  104105. /**
  104106. * Defines if webaudio should be initialized as well
  104107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104108. */
  104109. audioEngine?: boolean;
  104110. /**
  104111. * Defines if animations should run using a deterministic lock step
  104112. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104113. */
  104114. deterministicLockstep?: boolean;
  104115. /** Defines the maximum steps to use with deterministic lock step mode */
  104116. lockstepMaxSteps?: number;
  104117. /** Defines the seconds between each deterministic lock step */
  104118. timeStep?: number;
  104119. /**
  104120. * Defines that engine should ignore context lost events
  104121. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104122. */
  104123. doNotHandleContextLost?: boolean;
  104124. /**
  104125. * Defines that engine should ignore modifying touch action attribute and style
  104126. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104127. */
  104128. doNotHandleTouchAction?: boolean;
  104129. /**
  104130. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104131. */
  104132. useHighPrecisionFloats?: boolean;
  104133. }
  104134. /**
  104135. * The base engine class (root of all engines)
  104136. */
  104137. export class ThinEngine {
  104138. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104139. static ExceptionList: ({
  104140. key: string;
  104141. capture: string;
  104142. captureConstraint: number;
  104143. targets: string[];
  104144. } | {
  104145. key: string;
  104146. capture: null;
  104147. captureConstraint: null;
  104148. targets: string[];
  104149. })[];
  104150. /** @hidden */
  104151. static _TextureLoaders: IInternalTextureLoader[];
  104152. /**
  104153. * Returns the current npm package of the sdk
  104154. */
  104155. static get NpmPackage(): string;
  104156. /**
  104157. * Returns the current version of the framework
  104158. */
  104159. static get Version(): string;
  104160. /**
  104161. * Returns a string describing the current engine
  104162. */
  104163. get description(): string;
  104164. /**
  104165. * Gets or sets the epsilon value used by collision engine
  104166. */
  104167. static CollisionsEpsilon: number;
  104168. /**
  104169. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104170. */
  104171. static get ShadersRepository(): string;
  104172. static set ShadersRepository(value: string);
  104173. /** @hidden */
  104174. _shaderProcessor: IShaderProcessor;
  104175. /**
  104176. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104177. */
  104178. forcePOTTextures: boolean;
  104179. /**
  104180. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104181. */
  104182. isFullscreen: boolean;
  104183. /**
  104184. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104185. */
  104186. cullBackFaces: boolean;
  104187. /**
  104188. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104189. */
  104190. renderEvenInBackground: boolean;
  104191. /**
  104192. * Gets or sets a boolean indicating that cache can be kept between frames
  104193. */
  104194. preventCacheWipeBetweenFrames: boolean;
  104195. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104196. validateShaderPrograms: boolean;
  104197. /**
  104198. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104199. * This can provide greater z depth for distant objects.
  104200. */
  104201. useReverseDepthBuffer: boolean;
  104202. /**
  104203. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104204. */
  104205. disableUniformBuffers: boolean;
  104206. /** @hidden */
  104207. _uniformBuffers: UniformBuffer[];
  104208. /**
  104209. * Gets a boolean indicating that the engine supports uniform buffers
  104210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104211. */
  104212. get supportsUniformBuffers(): boolean;
  104213. /** @hidden */
  104214. _gl: WebGLRenderingContext;
  104215. /** @hidden */
  104216. _webGLVersion: number;
  104217. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104218. protected _windowIsBackground: boolean;
  104219. protected _creationOptions: EngineOptions;
  104220. protected _highPrecisionShadersAllowed: boolean;
  104221. /** @hidden */
  104222. get _shouldUseHighPrecisionShader(): boolean;
  104223. /**
  104224. * Gets a boolean indicating that only power of 2 textures are supported
  104225. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104226. */
  104227. get needPOTTextures(): boolean;
  104228. /** @hidden */
  104229. _badOS: boolean;
  104230. /** @hidden */
  104231. _badDesktopOS: boolean;
  104232. private _hardwareScalingLevel;
  104233. /** @hidden */
  104234. _caps: EngineCapabilities;
  104235. private _isStencilEnable;
  104236. private _glVersion;
  104237. private _glRenderer;
  104238. private _glVendor;
  104239. /** @hidden */
  104240. _videoTextureSupported: boolean;
  104241. protected _renderingQueueLaunched: boolean;
  104242. protected _activeRenderLoops: (() => void)[];
  104243. /**
  104244. * Observable signaled when a context lost event is raised
  104245. */
  104246. onContextLostObservable: Observable<ThinEngine>;
  104247. /**
  104248. * Observable signaled when a context restored event is raised
  104249. */
  104250. onContextRestoredObservable: Observable<ThinEngine>;
  104251. private _onContextLost;
  104252. private _onContextRestored;
  104253. protected _contextWasLost: boolean;
  104254. /** @hidden */
  104255. _doNotHandleContextLost: boolean;
  104256. /**
  104257. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104259. */
  104260. get doNotHandleContextLost(): boolean;
  104261. set doNotHandleContextLost(value: boolean);
  104262. /**
  104263. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104264. */
  104265. disableVertexArrayObjects: boolean;
  104266. /** @hidden */
  104267. protected _colorWrite: boolean;
  104268. /** @hidden */
  104269. protected _colorWriteChanged: boolean;
  104270. /** @hidden */
  104271. protected _depthCullingState: DepthCullingState;
  104272. /** @hidden */
  104273. protected _stencilState: StencilState;
  104274. /** @hidden */
  104275. _alphaState: AlphaState;
  104276. /** @hidden */
  104277. _alphaMode: number;
  104278. /** @hidden */
  104279. _alphaEquation: number;
  104280. /** @hidden */
  104281. _internalTexturesCache: InternalTexture[];
  104282. /** @hidden */
  104283. protected _activeChannel: number;
  104284. private _currentTextureChannel;
  104285. /** @hidden */
  104286. protected _boundTexturesCache: {
  104287. [key: string]: Nullable<InternalTexture>;
  104288. };
  104289. /** @hidden */
  104290. protected _currentEffect: Nullable<Effect>;
  104291. /** @hidden */
  104292. protected _currentProgram: Nullable<WebGLProgram>;
  104293. private _compiledEffects;
  104294. private _vertexAttribArraysEnabled;
  104295. /** @hidden */
  104296. protected _cachedViewport: Nullable<IViewportLike>;
  104297. private _cachedVertexArrayObject;
  104298. /** @hidden */
  104299. protected _cachedVertexBuffers: any;
  104300. /** @hidden */
  104301. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104302. /** @hidden */
  104303. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104304. /** @hidden */
  104305. _currentRenderTarget: Nullable<InternalTexture>;
  104306. private _uintIndicesCurrentlySet;
  104307. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104308. /** @hidden */
  104309. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104310. private _currentBufferPointers;
  104311. private _currentInstanceLocations;
  104312. private _currentInstanceBuffers;
  104313. private _textureUnits;
  104314. /** @hidden */
  104315. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104316. /** @hidden */
  104317. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104318. /** @hidden */
  104319. _boundRenderFunction: any;
  104320. private _vaoRecordInProgress;
  104321. private _mustWipeVertexAttributes;
  104322. private _emptyTexture;
  104323. private _emptyCubeTexture;
  104324. private _emptyTexture3D;
  104325. private _emptyTexture2DArray;
  104326. /** @hidden */
  104327. _frameHandler: number;
  104328. private _nextFreeTextureSlots;
  104329. private _maxSimultaneousTextures;
  104330. private _activeRequests;
  104331. protected _texturesSupported: string[];
  104332. /** @hidden */
  104333. _textureFormatInUse: Nullable<string>;
  104334. protected get _supportsHardwareTextureRescaling(): boolean;
  104335. /**
  104336. * Gets the list of texture formats supported
  104337. */
  104338. get texturesSupported(): Array<string>;
  104339. /**
  104340. * Gets the list of texture formats in use
  104341. */
  104342. get textureFormatInUse(): Nullable<string>;
  104343. /**
  104344. * Gets the current viewport
  104345. */
  104346. get currentViewport(): Nullable<IViewportLike>;
  104347. /**
  104348. * Gets the default empty texture
  104349. */
  104350. get emptyTexture(): InternalTexture;
  104351. /**
  104352. * Gets the default empty 3D texture
  104353. */
  104354. get emptyTexture3D(): InternalTexture;
  104355. /**
  104356. * Gets the default empty 2D array texture
  104357. */
  104358. get emptyTexture2DArray(): InternalTexture;
  104359. /**
  104360. * Gets the default empty cube texture
  104361. */
  104362. get emptyCubeTexture(): InternalTexture;
  104363. /**
  104364. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104365. */
  104366. readonly premultipliedAlpha: boolean;
  104367. /**
  104368. * Observable event triggered before each texture is initialized
  104369. */
  104370. onBeforeTextureInitObservable: Observable<Texture>;
  104371. /**
  104372. * Creates a new engine
  104373. * @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
  104374. * @param antialias defines enable antialiasing (default: false)
  104375. * @param options defines further options to be sent to the getContext() function
  104376. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104377. */
  104378. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104379. private _rebuildInternalTextures;
  104380. private _rebuildEffects;
  104381. /**
  104382. * Gets a boolean indicating if all created effects are ready
  104383. * @returns true if all effects are ready
  104384. */
  104385. areAllEffectsReady(): boolean;
  104386. protected _rebuildBuffers(): void;
  104387. private _initGLContext;
  104388. /**
  104389. * Gets version of the current webGL context
  104390. */
  104391. get webGLVersion(): number;
  104392. /**
  104393. * Gets a string idenfifying the name of the class
  104394. * @returns "Engine" string
  104395. */
  104396. getClassName(): string;
  104397. /**
  104398. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104399. */
  104400. get isStencilEnable(): boolean;
  104401. /** @hidden */
  104402. _prepareWorkingCanvas(): void;
  104403. /**
  104404. * Reset the texture cache to empty state
  104405. */
  104406. resetTextureCache(): void;
  104407. /**
  104408. * Gets an object containing information about the current webGL context
  104409. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104410. */
  104411. getGlInfo(): {
  104412. vendor: string;
  104413. renderer: string;
  104414. version: string;
  104415. };
  104416. /**
  104417. * Defines the hardware scaling level.
  104418. * By default the hardware scaling level is computed from the window device ratio.
  104419. * 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.
  104420. * @param level defines the level to use
  104421. */
  104422. setHardwareScalingLevel(level: number): void;
  104423. /**
  104424. * Gets the current hardware scaling level.
  104425. * By default the hardware scaling level is computed from the window device ratio.
  104426. * 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.
  104427. * @returns a number indicating the current hardware scaling level
  104428. */
  104429. getHardwareScalingLevel(): number;
  104430. /**
  104431. * Gets the list of loaded textures
  104432. * @returns an array containing all loaded textures
  104433. */
  104434. getLoadedTexturesCache(): InternalTexture[];
  104435. /**
  104436. * Gets the object containing all engine capabilities
  104437. * @returns the EngineCapabilities object
  104438. */
  104439. getCaps(): EngineCapabilities;
  104440. /**
  104441. * stop executing a render loop function and remove it from the execution array
  104442. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104443. */
  104444. stopRenderLoop(renderFunction?: () => void): void;
  104445. /** @hidden */
  104446. _renderLoop(): void;
  104447. /**
  104448. * Gets the HTML canvas attached with the current webGL context
  104449. * @returns a HTML canvas
  104450. */
  104451. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104452. /**
  104453. * Gets host window
  104454. * @returns the host window object
  104455. */
  104456. getHostWindow(): Nullable<Window>;
  104457. /**
  104458. * Gets the current render width
  104459. * @param useScreen defines if screen size must be used (or the current render target if any)
  104460. * @returns a number defining the current render width
  104461. */
  104462. getRenderWidth(useScreen?: boolean): number;
  104463. /**
  104464. * Gets the current render height
  104465. * @param useScreen defines if screen size must be used (or the current render target if any)
  104466. * @returns a number defining the current render height
  104467. */
  104468. getRenderHeight(useScreen?: boolean): number;
  104469. /**
  104470. * Can be used to override the current requestAnimationFrame requester.
  104471. * @hidden
  104472. */
  104473. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104474. /**
  104475. * Register and execute a render loop. The engine can have more than one render function
  104476. * @param renderFunction defines the function to continuously execute
  104477. */
  104478. runRenderLoop(renderFunction: () => void): void;
  104479. /**
  104480. * Clear the current render buffer or the current render target (if any is set up)
  104481. * @param color defines the color to use
  104482. * @param backBuffer defines if the back buffer must be cleared
  104483. * @param depth defines if the depth buffer must be cleared
  104484. * @param stencil defines if the stencil buffer must be cleared
  104485. */
  104486. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104487. private _viewportCached;
  104488. /** @hidden */
  104489. _viewport(x: number, y: number, width: number, height: number): void;
  104490. /**
  104491. * Set the WebGL's viewport
  104492. * @param viewport defines the viewport element to be used
  104493. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104494. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104495. */
  104496. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104497. /**
  104498. * Begin a new frame
  104499. */
  104500. beginFrame(): void;
  104501. /**
  104502. * Enf the current frame
  104503. */
  104504. endFrame(): void;
  104505. /**
  104506. * Resize the view according to the canvas' size
  104507. */
  104508. resize(): void;
  104509. /**
  104510. * Force a specific size of the canvas
  104511. * @param width defines the new canvas' width
  104512. * @param height defines the new canvas' height
  104513. */
  104514. setSize(width: number, height: number): void;
  104515. /**
  104516. * Binds the frame buffer to the specified texture.
  104517. * @param texture The texture to render to or null for the default canvas
  104518. * @param faceIndex The face of the texture to render to in case of cube texture
  104519. * @param requiredWidth The width of the target to render to
  104520. * @param requiredHeight The height of the target to render to
  104521. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104522. * @param lodLevel defines the lod level to bind to the frame buffer
  104523. * @param layer defines the 2d array index to bind to frame buffer to
  104524. */
  104525. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104526. /** @hidden */
  104527. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104528. /**
  104529. * Unbind the current render target texture from the webGL context
  104530. * @param texture defines the render target texture to unbind
  104531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104533. */
  104534. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104535. /**
  104536. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104537. */
  104538. flushFramebuffer(): void;
  104539. /**
  104540. * Unbind the current render target and bind the default framebuffer
  104541. */
  104542. restoreDefaultFramebuffer(): void;
  104543. /** @hidden */
  104544. protected _resetVertexBufferBinding(): void;
  104545. /**
  104546. * Creates a vertex buffer
  104547. * @param data the data for the vertex buffer
  104548. * @returns the new WebGL static buffer
  104549. */
  104550. createVertexBuffer(data: DataArray): DataBuffer;
  104551. private _createVertexBuffer;
  104552. /**
  104553. * Creates a dynamic vertex buffer
  104554. * @param data the data for the dynamic vertex buffer
  104555. * @returns the new WebGL dynamic buffer
  104556. */
  104557. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104558. protected _resetIndexBufferBinding(): void;
  104559. /**
  104560. * Creates a new index buffer
  104561. * @param indices defines the content of the index buffer
  104562. * @param updatable defines if the index buffer must be updatable
  104563. * @returns a new webGL buffer
  104564. */
  104565. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104566. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104567. /**
  104568. * Bind a webGL buffer to the webGL context
  104569. * @param buffer defines the buffer to bind
  104570. */
  104571. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104572. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104573. private bindBuffer;
  104574. /**
  104575. * update the bound buffer with the given data
  104576. * @param data defines the data to update
  104577. */
  104578. updateArrayBuffer(data: Float32Array): void;
  104579. private _vertexAttribPointer;
  104580. /** @hidden */
  104581. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104582. private _bindVertexBuffersAttributes;
  104583. /**
  104584. * Records a vertex array object
  104585. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104586. * @param vertexBuffers defines the list of vertex buffers to store
  104587. * @param indexBuffer defines the index buffer to store
  104588. * @param effect defines the effect to store
  104589. * @returns the new vertex array object
  104590. */
  104591. recordVertexArrayObject(vertexBuffers: {
  104592. [key: string]: VertexBuffer;
  104593. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104594. /**
  104595. * Bind a specific vertex array object
  104596. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104597. * @param vertexArrayObject defines the vertex array object to bind
  104598. * @param indexBuffer defines the index buffer to bind
  104599. */
  104600. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104601. /**
  104602. * Bind webGl buffers directly to the webGL context
  104603. * @param vertexBuffer defines the vertex buffer to bind
  104604. * @param indexBuffer defines the index buffer to bind
  104605. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104606. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104607. * @param effect defines the effect associated with the vertex buffer
  104608. */
  104609. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104610. private _unbindVertexArrayObject;
  104611. /**
  104612. * Bind a list of vertex buffers to the webGL context
  104613. * @param vertexBuffers defines the list of vertex buffers to bind
  104614. * @param indexBuffer defines the index buffer to bind
  104615. * @param effect defines the effect associated with the vertex buffers
  104616. */
  104617. bindBuffers(vertexBuffers: {
  104618. [key: string]: Nullable<VertexBuffer>;
  104619. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104620. /**
  104621. * Unbind all instance attributes
  104622. */
  104623. unbindInstanceAttributes(): void;
  104624. /**
  104625. * Release and free the memory of a vertex array object
  104626. * @param vao defines the vertex array object to delete
  104627. */
  104628. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104629. /** @hidden */
  104630. _releaseBuffer(buffer: DataBuffer): boolean;
  104631. protected _deleteBuffer(buffer: DataBuffer): void;
  104632. /**
  104633. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104634. * @param instancesBuffer defines the webGL buffer to update and bind
  104635. * @param data defines the data to store in the buffer
  104636. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104637. */
  104638. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104639. /**
  104640. * Bind the content of a webGL buffer used with instantiation
  104641. * @param instancesBuffer defines the webGL buffer to bind
  104642. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104643. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104644. */
  104645. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104646. /**
  104647. * Disable the instance attribute corresponding to the name in parameter
  104648. * @param name defines the name of the attribute to disable
  104649. */
  104650. disableInstanceAttributeByName(name: string): void;
  104651. /**
  104652. * Disable the instance attribute corresponding to the location in parameter
  104653. * @param attributeLocation defines the attribute location of the attribute to disable
  104654. */
  104655. disableInstanceAttribute(attributeLocation: number): void;
  104656. /**
  104657. * Disable the attribute corresponding to the location in parameter
  104658. * @param attributeLocation defines the attribute location of the attribute to disable
  104659. */
  104660. disableAttributeByIndex(attributeLocation: number): void;
  104661. /**
  104662. * Send a draw order
  104663. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104664. * @param indexStart defines the starting index
  104665. * @param indexCount defines the number of index to draw
  104666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104667. */
  104668. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104669. /**
  104670. * Draw a list of points
  104671. * @param verticesStart defines the index of first vertex to draw
  104672. * @param verticesCount defines the count of vertices to draw
  104673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104674. */
  104675. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104676. /**
  104677. * Draw a list of unindexed primitives
  104678. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104679. * @param verticesStart defines the index of first vertex to draw
  104680. * @param verticesCount defines the count of vertices to draw
  104681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104682. */
  104683. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104684. /**
  104685. * Draw a list of indexed primitives
  104686. * @param fillMode defines the primitive to use
  104687. * @param indexStart defines the starting index
  104688. * @param indexCount defines the number of index to draw
  104689. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104690. */
  104691. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104692. /**
  104693. * Draw a list of unindexed primitives
  104694. * @param fillMode defines the primitive to use
  104695. * @param verticesStart defines the index of first vertex to draw
  104696. * @param verticesCount defines the count of vertices to draw
  104697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104698. */
  104699. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104700. private _drawMode;
  104701. /** @hidden */
  104702. protected _reportDrawCall(): void;
  104703. /** @hidden */
  104704. _releaseEffect(effect: Effect): void;
  104705. /** @hidden */
  104706. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104707. /**
  104708. * Create a new effect (used to store vertex/fragment shaders)
  104709. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104710. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104711. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104712. * @param samplers defines an array of string used to represent textures
  104713. * @param defines defines the string containing the defines to use to compile the shaders
  104714. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104715. * @param onCompiled defines a function to call when the effect creation is successful
  104716. * @param onError defines a function to call when the effect creation has failed
  104717. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104718. * @returns the new Effect
  104719. */
  104720. 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;
  104721. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104722. private _compileShader;
  104723. private _compileRawShader;
  104724. /**
  104725. * Directly creates a webGL program
  104726. * @param pipelineContext defines the pipeline context to attach to
  104727. * @param vertexCode defines the vertex shader code to use
  104728. * @param fragmentCode defines the fragment shader code to use
  104729. * @param context defines the webGL context to use (if not set, the current one will be used)
  104730. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104731. * @returns the new webGL program
  104732. */
  104733. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104734. /**
  104735. * Creates a webGL program
  104736. * @param pipelineContext defines the pipeline context to attach to
  104737. * @param vertexCode defines the vertex shader code to use
  104738. * @param fragmentCode defines the fragment shader code to use
  104739. * @param defines defines the string containing the defines to use to compile the shaders
  104740. * @param context defines the webGL context to use (if not set, the current one will be used)
  104741. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104742. * @returns the new webGL program
  104743. */
  104744. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104745. /**
  104746. * Creates a new pipeline context
  104747. * @returns the new pipeline
  104748. */
  104749. createPipelineContext(): IPipelineContext;
  104750. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104751. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104752. /** @hidden */
  104753. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104754. /** @hidden */
  104755. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104756. /** @hidden */
  104757. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104758. /**
  104759. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104760. * @param pipelineContext defines the pipeline context to use
  104761. * @param uniformsNames defines the list of uniform names
  104762. * @returns an array of webGL uniform locations
  104763. */
  104764. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104765. /**
  104766. * Gets the lsit of active attributes for a given webGL program
  104767. * @param pipelineContext defines the pipeline context to use
  104768. * @param attributesNames defines the list of attribute names to get
  104769. * @returns an array of indices indicating the offset of each attribute
  104770. */
  104771. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104772. /**
  104773. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104774. * @param effect defines the effect to activate
  104775. */
  104776. enableEffect(effect: Nullable<Effect>): void;
  104777. /**
  104778. * Set the value of an uniform to a number (int)
  104779. * @param uniform defines the webGL uniform location where to store the value
  104780. * @param value defines the int number to store
  104781. */
  104782. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104783. /**
  104784. * Set the value of an uniform to an array of int32
  104785. * @param uniform defines the webGL uniform location where to store the value
  104786. * @param array defines the array of int32 to store
  104787. */
  104788. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104789. /**
  104790. * Set the value of an uniform to an array of int32 (stored as vec2)
  104791. * @param uniform defines the webGL uniform location where to store the value
  104792. * @param array defines the array of int32 to store
  104793. */
  104794. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104795. /**
  104796. * Set the value of an uniform to an array of int32 (stored as vec3)
  104797. * @param uniform defines the webGL uniform location where to store the value
  104798. * @param array defines the array of int32 to store
  104799. */
  104800. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104801. /**
  104802. * Set the value of an uniform to an array of int32 (stored as vec4)
  104803. * @param uniform defines the webGL uniform location where to store the value
  104804. * @param array defines the array of int32 to store
  104805. */
  104806. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104807. /**
  104808. * Set the value of an uniform to an array of number
  104809. * @param uniform defines the webGL uniform location where to store the value
  104810. * @param array defines the array of number to store
  104811. */
  104812. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104813. /**
  104814. * Set the value of an uniform to an array of number (stored as vec2)
  104815. * @param uniform defines the webGL uniform location where to store the value
  104816. * @param array defines the array of number to store
  104817. */
  104818. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104819. /**
  104820. * Set the value of an uniform to an array of number (stored as vec3)
  104821. * @param uniform defines the webGL uniform location where to store the value
  104822. * @param array defines the array of number to store
  104823. */
  104824. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104825. /**
  104826. * Set the value of an uniform to an array of number (stored as vec4)
  104827. * @param uniform defines the webGL uniform location where to store the value
  104828. * @param array defines the array of number to store
  104829. */
  104830. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104831. /**
  104832. * Set the value of an uniform to an array of float32 (stored as matrices)
  104833. * @param uniform defines the webGL uniform location where to store the value
  104834. * @param matrices defines the array of float32 to store
  104835. */
  104836. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104837. /**
  104838. * Set the value of an uniform to a matrix (3x3)
  104839. * @param uniform defines the webGL uniform location where to store the value
  104840. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104841. */
  104842. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104843. /**
  104844. * Set the value of an uniform to a matrix (2x2)
  104845. * @param uniform defines the webGL uniform location where to store the value
  104846. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104847. */
  104848. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104849. /**
  104850. * Set the value of an uniform to a number (float)
  104851. * @param uniform defines the webGL uniform location where to store the value
  104852. * @param value defines the float number to store
  104853. */
  104854. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104855. /**
  104856. * Set the value of an uniform to a vec2
  104857. * @param uniform defines the webGL uniform location where to store the value
  104858. * @param x defines the 1st component of the value
  104859. * @param y defines the 2nd component of the value
  104860. */
  104861. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104862. /**
  104863. * Set the value of an uniform to a vec3
  104864. * @param uniform defines the webGL uniform location where to store the value
  104865. * @param x defines the 1st component of the value
  104866. * @param y defines the 2nd component of the value
  104867. * @param z defines the 3rd component of the value
  104868. */
  104869. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104870. /**
  104871. * Set the value of an uniform to a vec4
  104872. * @param uniform defines the webGL uniform location where to store the value
  104873. * @param x defines the 1st component of the value
  104874. * @param y defines the 2nd component of the value
  104875. * @param z defines the 3rd component of the value
  104876. * @param w defines the 4th component of the value
  104877. */
  104878. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104879. /**
  104880. * Apply all cached states (depth, culling, stencil and alpha)
  104881. */
  104882. applyStates(): void;
  104883. /**
  104884. * Enable or disable color writing
  104885. * @param enable defines the state to set
  104886. */
  104887. setColorWrite(enable: boolean): void;
  104888. /**
  104889. * Gets a boolean indicating if color writing is enabled
  104890. * @returns the current color writing state
  104891. */
  104892. getColorWrite(): boolean;
  104893. /**
  104894. * Gets the depth culling state manager
  104895. */
  104896. get depthCullingState(): DepthCullingState;
  104897. /**
  104898. * Gets the alpha state manager
  104899. */
  104900. get alphaState(): AlphaState;
  104901. /**
  104902. * Gets the stencil state manager
  104903. */
  104904. get stencilState(): StencilState;
  104905. /**
  104906. * Clears the list of texture accessible through engine.
  104907. * This can help preventing texture load conflict due to name collision.
  104908. */
  104909. clearInternalTexturesCache(): void;
  104910. /**
  104911. * Force the entire cache to be cleared
  104912. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104913. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104914. */
  104915. wipeCaches(bruteForce?: boolean): void;
  104916. /** @hidden */
  104917. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104918. min: number;
  104919. mag: number;
  104920. };
  104921. /** @hidden */
  104922. _createTexture(): WebGLTexture;
  104923. /**
  104924. * Usually called from Texture.ts.
  104925. * Passed information to create a WebGLTexture
  104926. * @param urlArg defines a value which contains one of the following:
  104927. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104928. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104929. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104930. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104931. * @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)
  104932. * @param scene needed for loading to the correct scene
  104933. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104934. * @param onLoad optional callback to be called upon successful completion
  104935. * @param onError optional callback to be called upon failure
  104936. * @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
  104937. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104938. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104939. * @param forcedExtension defines the extension to use to pick the right loader
  104940. * @param mimeType defines an optional mime type
  104941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104942. */
  104943. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  104944. /**
  104945. * Loads an image as an HTMLImageElement.
  104946. * @param input url string, ArrayBuffer, or Blob to load
  104947. * @param onLoad callback called when the image successfully loads
  104948. * @param onError callback called when the image fails to load
  104949. * @param offlineProvider offline provider for caching
  104950. * @param mimeType optional mime type
  104951. * @returns the HTMLImageElement of the loaded image
  104952. * @hidden
  104953. */
  104954. 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>;
  104955. /**
  104956. * @hidden
  104957. */
  104958. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104959. /**
  104960. * Creates a raw texture
  104961. * @param data defines the data to store in the texture
  104962. * @param width defines the width of the texture
  104963. * @param height defines the height of the texture
  104964. * @param format defines the format of the data
  104965. * @param generateMipMaps defines if the engine should generate the mip levels
  104966. * @param invertY defines if data must be stored with Y axis inverted
  104967. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104968. * @param compression defines the compression used (null by default)
  104969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104970. * @returns the raw texture inside an InternalTexture
  104971. */
  104972. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104973. /**
  104974. * Creates a new raw cube texture
  104975. * @param data defines the array of data to use to create each face
  104976. * @param size defines the size of the textures
  104977. * @param format defines the format of the data
  104978. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104979. * @param generateMipMaps defines if the engine should generate the mip levels
  104980. * @param invertY defines if data must be stored with Y axis inverted
  104981. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104982. * @param compression defines the compression used (null by default)
  104983. * @returns the cube texture as an InternalTexture
  104984. */
  104985. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104986. /**
  104987. * Creates a new raw 3D texture
  104988. * @param data defines the data used to create the texture
  104989. * @param width defines the width of the texture
  104990. * @param height defines the height of the texture
  104991. * @param depth defines the depth of the texture
  104992. * @param format defines the format of the texture
  104993. * @param generateMipMaps defines if the engine must generate mip levels
  104994. * @param invertY defines if data must be stored with Y axis inverted
  104995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104996. * @param compression defines the compressed used (can be null)
  104997. * @param textureType defines the compressed used (can be null)
  104998. * @returns a new raw 3D texture (stored in an InternalTexture)
  104999. */
  105000. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105001. /**
  105002. * Creates a new raw 2D array texture
  105003. * @param data defines the data used to create the texture
  105004. * @param width defines the width of the texture
  105005. * @param height defines the height of the texture
  105006. * @param depth defines the number of layers of the texture
  105007. * @param format defines the format of the texture
  105008. * @param generateMipMaps defines if the engine must generate mip levels
  105009. * @param invertY defines if data must be stored with Y axis inverted
  105010. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105011. * @param compression defines the compressed used (can be null)
  105012. * @param textureType defines the compressed used (can be null)
  105013. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105014. */
  105015. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105016. private _unpackFlipYCached;
  105017. /**
  105018. * In case you are sharing the context with other applications, it might
  105019. * be interested to not cache the unpack flip y state to ensure a consistent
  105020. * value would be set.
  105021. */
  105022. enableUnpackFlipYCached: boolean;
  105023. /** @hidden */
  105024. _unpackFlipY(value: boolean): void;
  105025. /** @hidden */
  105026. _getUnpackAlignement(): number;
  105027. private _getTextureTarget;
  105028. /**
  105029. * Update the sampling mode of a given texture
  105030. * @param samplingMode defines the required sampling mode
  105031. * @param texture defines the texture to update
  105032. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105033. */
  105034. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105035. /**
  105036. * Update the sampling mode of a given texture
  105037. * @param texture defines the texture to update
  105038. * @param wrapU defines the texture wrap mode of the u coordinates
  105039. * @param wrapV defines the texture wrap mode of the v coordinates
  105040. * @param wrapR defines the texture wrap mode of the r coordinates
  105041. */
  105042. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105043. /** @hidden */
  105044. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105045. width: number;
  105046. height: number;
  105047. layers?: number;
  105048. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105049. /** @hidden */
  105050. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105051. /** @hidden */
  105052. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105053. /**
  105054. * Update a portion of an internal texture
  105055. * @param texture defines the texture to update
  105056. * @param imageData defines the data to store into the texture
  105057. * @param xOffset defines the x coordinates of the update rectangle
  105058. * @param yOffset defines the y coordinates of the update rectangle
  105059. * @param width defines the width of the update rectangle
  105060. * @param height defines the height of the update rectangle
  105061. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105062. * @param lod defines the lod level to update (0 by default)
  105063. */
  105064. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105065. /** @hidden */
  105066. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105067. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105068. private _prepareWebGLTexture;
  105069. /** @hidden */
  105070. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105071. private _getDepthStencilBuffer;
  105072. /** @hidden */
  105073. _releaseFramebufferObjects(texture: InternalTexture): void;
  105074. /** @hidden */
  105075. _releaseTexture(texture: InternalTexture): void;
  105076. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105077. protected _setProgram(program: WebGLProgram): void;
  105078. protected _boundUniforms: {
  105079. [key: number]: WebGLUniformLocation;
  105080. };
  105081. /**
  105082. * Binds an effect to the webGL context
  105083. * @param effect defines the effect to bind
  105084. */
  105085. bindSamplers(effect: Effect): void;
  105086. private _activateCurrentTexture;
  105087. /** @hidden */
  105088. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105089. /** @hidden */
  105090. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105091. /**
  105092. * Unbind all textures from the webGL context
  105093. */
  105094. unbindAllTextures(): void;
  105095. /**
  105096. * Sets a texture to the according uniform.
  105097. * @param channel The texture channel
  105098. * @param uniform The uniform to set
  105099. * @param texture The texture to apply
  105100. */
  105101. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105102. private _bindSamplerUniformToChannel;
  105103. private _getTextureWrapMode;
  105104. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105105. /**
  105106. * Sets an array of texture to the webGL context
  105107. * @param channel defines the channel where the texture array must be set
  105108. * @param uniform defines the associated uniform location
  105109. * @param textures defines the array of textures to bind
  105110. */
  105111. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105112. /** @hidden */
  105113. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105114. private _setTextureParameterFloat;
  105115. private _setTextureParameterInteger;
  105116. /**
  105117. * Unbind all vertex attributes from the webGL context
  105118. */
  105119. unbindAllAttributes(): void;
  105120. /**
  105121. * 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
  105122. */
  105123. releaseEffects(): void;
  105124. /**
  105125. * Dispose and release all associated resources
  105126. */
  105127. dispose(): void;
  105128. /**
  105129. * Attach a new callback raised when context lost event is fired
  105130. * @param callback defines the callback to call
  105131. */
  105132. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105133. /**
  105134. * Attach a new callback raised when context restored event is fired
  105135. * @param callback defines the callback to call
  105136. */
  105137. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105138. /**
  105139. * Get the current error code of the webGL context
  105140. * @returns the error code
  105141. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105142. */
  105143. getError(): number;
  105144. private _canRenderToFloatFramebuffer;
  105145. private _canRenderToHalfFloatFramebuffer;
  105146. private _canRenderToFramebuffer;
  105147. /** @hidden */
  105148. _getWebGLTextureType(type: number): number;
  105149. /** @hidden */
  105150. _getInternalFormat(format: number): number;
  105151. /** @hidden */
  105152. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105153. /** @hidden */
  105154. _getRGBAMultiSampleBufferFormat(type: number): number;
  105155. /** @hidden */
  105156. _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;
  105157. /**
  105158. * Loads a file from a url
  105159. * @param url url to load
  105160. * @param onSuccess callback called when the file successfully loads
  105161. * @param onProgress callback called while file is loading (if the server supports this mode)
  105162. * @param offlineProvider defines the offline provider for caching
  105163. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105164. * @param onError callback called when the file fails to load
  105165. * @returns a file request object
  105166. * @hidden
  105167. */
  105168. 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;
  105169. /**
  105170. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105171. * @param x defines the x coordinate of the rectangle where pixels must be read
  105172. * @param y defines the y coordinate of the rectangle where pixels must be read
  105173. * @param width defines the width of the rectangle where pixels must be read
  105174. * @param height defines the height of the rectangle where pixels must be read
  105175. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105176. * @returns a Uint8Array containing RGBA colors
  105177. */
  105178. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105179. private static _isSupported;
  105180. /**
  105181. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105182. * @returns true if the engine can be created
  105183. * @ignorenaming
  105184. */
  105185. static isSupported(): boolean;
  105186. /**
  105187. * Find the next highest power of two.
  105188. * @param x Number to start search from.
  105189. * @return Next highest power of two.
  105190. */
  105191. static CeilingPOT(x: number): number;
  105192. /**
  105193. * Find the next lowest power of two.
  105194. * @param x Number to start search from.
  105195. * @return Next lowest power of two.
  105196. */
  105197. static FloorPOT(x: number): number;
  105198. /**
  105199. * Find the nearest power of two.
  105200. * @param x Number to start search from.
  105201. * @return Next nearest power of two.
  105202. */
  105203. static NearestPOT(x: number): number;
  105204. /**
  105205. * Get the closest exponent of two
  105206. * @param value defines the value to approximate
  105207. * @param max defines the maximum value to return
  105208. * @param mode defines how to define the closest value
  105209. * @returns closest exponent of two of the given value
  105210. */
  105211. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105212. /**
  105213. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105214. * @param func - the function to be called
  105215. * @param requester - the object that will request the next frame. Falls back to window.
  105216. * @returns frame number
  105217. */
  105218. static QueueNewFrame(func: () => void, requester?: any): number;
  105219. /**
  105220. * Gets host document
  105221. * @returns the host document object
  105222. */
  105223. getHostDocument(): Nullable<Document>;
  105224. }
  105225. }
  105226. declare module BABYLON {
  105227. /**
  105228. * Class representing spherical harmonics coefficients to the 3rd degree
  105229. */
  105230. export class SphericalHarmonics {
  105231. /**
  105232. * Defines whether or not the harmonics have been prescaled for rendering.
  105233. */
  105234. preScaled: boolean;
  105235. /**
  105236. * The l0,0 coefficients of the spherical harmonics
  105237. */
  105238. l00: Vector3;
  105239. /**
  105240. * The l1,-1 coefficients of the spherical harmonics
  105241. */
  105242. l1_1: Vector3;
  105243. /**
  105244. * The l1,0 coefficients of the spherical harmonics
  105245. */
  105246. l10: Vector3;
  105247. /**
  105248. * The l1,1 coefficients of the spherical harmonics
  105249. */
  105250. l11: Vector3;
  105251. /**
  105252. * The l2,-2 coefficients of the spherical harmonics
  105253. */
  105254. l2_2: Vector3;
  105255. /**
  105256. * The l2,-1 coefficients of the spherical harmonics
  105257. */
  105258. l2_1: Vector3;
  105259. /**
  105260. * The l2,0 coefficients of the spherical harmonics
  105261. */
  105262. l20: Vector3;
  105263. /**
  105264. * The l2,1 coefficients of the spherical harmonics
  105265. */
  105266. l21: Vector3;
  105267. /**
  105268. * The l2,2 coefficients of the spherical harmonics
  105269. */
  105270. l22: Vector3;
  105271. /**
  105272. * Adds a light to the spherical harmonics
  105273. * @param direction the direction of the light
  105274. * @param color the color of the light
  105275. * @param deltaSolidAngle the delta solid angle of the light
  105276. */
  105277. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105278. /**
  105279. * Scales the spherical harmonics by the given amount
  105280. * @param scale the amount to scale
  105281. */
  105282. scaleInPlace(scale: number): void;
  105283. /**
  105284. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105285. *
  105286. * ```
  105287. * E_lm = A_l * L_lm
  105288. * ```
  105289. *
  105290. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105291. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105292. * the scaling factors are given in equation 9.
  105293. */
  105294. convertIncidentRadianceToIrradiance(): void;
  105295. /**
  105296. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105297. *
  105298. * ```
  105299. * L = (1/pi) * E * rho
  105300. * ```
  105301. *
  105302. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105303. */
  105304. convertIrradianceToLambertianRadiance(): void;
  105305. /**
  105306. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105307. * required operations at run time.
  105308. *
  105309. * This is simply done by scaling back the SH with Ylm constants parameter.
  105310. * The trigonometric part being applied by the shader at run time.
  105311. */
  105312. preScaleForRendering(): void;
  105313. /**
  105314. * Constructs a spherical harmonics from an array.
  105315. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105316. * @returns the spherical harmonics
  105317. */
  105318. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105319. /**
  105320. * Gets the spherical harmonics from polynomial
  105321. * @param polynomial the spherical polynomial
  105322. * @returns the spherical harmonics
  105323. */
  105324. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105325. }
  105326. /**
  105327. * Class representing spherical polynomial coefficients to the 3rd degree
  105328. */
  105329. export class SphericalPolynomial {
  105330. private _harmonics;
  105331. /**
  105332. * The spherical harmonics used to create the polynomials.
  105333. */
  105334. get preScaledHarmonics(): SphericalHarmonics;
  105335. /**
  105336. * The x coefficients of the spherical polynomial
  105337. */
  105338. x: Vector3;
  105339. /**
  105340. * The y coefficients of the spherical polynomial
  105341. */
  105342. y: Vector3;
  105343. /**
  105344. * The z coefficients of the spherical polynomial
  105345. */
  105346. z: Vector3;
  105347. /**
  105348. * The xx coefficients of the spherical polynomial
  105349. */
  105350. xx: Vector3;
  105351. /**
  105352. * The yy coefficients of the spherical polynomial
  105353. */
  105354. yy: Vector3;
  105355. /**
  105356. * The zz coefficients of the spherical polynomial
  105357. */
  105358. zz: Vector3;
  105359. /**
  105360. * The xy coefficients of the spherical polynomial
  105361. */
  105362. xy: Vector3;
  105363. /**
  105364. * The yz coefficients of the spherical polynomial
  105365. */
  105366. yz: Vector3;
  105367. /**
  105368. * The zx coefficients of the spherical polynomial
  105369. */
  105370. zx: Vector3;
  105371. /**
  105372. * Adds an ambient color to the spherical polynomial
  105373. * @param color the color to add
  105374. */
  105375. addAmbient(color: Color3): void;
  105376. /**
  105377. * Scales the spherical polynomial by the given amount
  105378. * @param scale the amount to scale
  105379. */
  105380. scaleInPlace(scale: number): void;
  105381. /**
  105382. * Gets the spherical polynomial from harmonics
  105383. * @param harmonics the spherical harmonics
  105384. * @returns the spherical polynomial
  105385. */
  105386. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105387. /**
  105388. * Constructs a spherical polynomial from an array.
  105389. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105390. * @returns the spherical polynomial
  105391. */
  105392. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105393. }
  105394. }
  105395. declare module BABYLON {
  105396. /**
  105397. * Defines the source of the internal texture
  105398. */
  105399. export enum InternalTextureSource {
  105400. /**
  105401. * The source of the texture data is unknown
  105402. */
  105403. Unknown = 0,
  105404. /**
  105405. * Texture data comes from an URL
  105406. */
  105407. Url = 1,
  105408. /**
  105409. * Texture data is only used for temporary storage
  105410. */
  105411. Temp = 2,
  105412. /**
  105413. * Texture data comes from raw data (ArrayBuffer)
  105414. */
  105415. Raw = 3,
  105416. /**
  105417. * Texture content is dynamic (video or dynamic texture)
  105418. */
  105419. Dynamic = 4,
  105420. /**
  105421. * Texture content is generated by rendering to it
  105422. */
  105423. RenderTarget = 5,
  105424. /**
  105425. * Texture content is part of a multi render target process
  105426. */
  105427. MultiRenderTarget = 6,
  105428. /**
  105429. * Texture data comes from a cube data file
  105430. */
  105431. Cube = 7,
  105432. /**
  105433. * Texture data comes from a raw cube data
  105434. */
  105435. CubeRaw = 8,
  105436. /**
  105437. * Texture data come from a prefiltered cube data file
  105438. */
  105439. CubePrefiltered = 9,
  105440. /**
  105441. * Texture content is raw 3D data
  105442. */
  105443. Raw3D = 10,
  105444. /**
  105445. * Texture content is raw 2D array data
  105446. */
  105447. Raw2DArray = 11,
  105448. /**
  105449. * Texture content is a depth texture
  105450. */
  105451. Depth = 12,
  105452. /**
  105453. * Texture data comes from a raw cube data encoded with RGBD
  105454. */
  105455. CubeRawRGBD = 13
  105456. }
  105457. /**
  105458. * Class used to store data associated with WebGL texture data for the engine
  105459. * This class should not be used directly
  105460. */
  105461. export class InternalTexture {
  105462. /** @hidden */
  105463. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105464. /**
  105465. * Defines if the texture is ready
  105466. */
  105467. isReady: boolean;
  105468. /**
  105469. * Defines if the texture is a cube texture
  105470. */
  105471. isCube: boolean;
  105472. /**
  105473. * Defines if the texture contains 3D data
  105474. */
  105475. is3D: boolean;
  105476. /**
  105477. * Defines if the texture contains 2D array data
  105478. */
  105479. is2DArray: boolean;
  105480. /**
  105481. * Defines if the texture contains multiview data
  105482. */
  105483. isMultiview: boolean;
  105484. /**
  105485. * Gets the URL used to load this texture
  105486. */
  105487. url: string;
  105488. /**
  105489. * Gets the sampling mode of the texture
  105490. */
  105491. samplingMode: number;
  105492. /**
  105493. * Gets a boolean indicating if the texture needs mipmaps generation
  105494. */
  105495. generateMipMaps: boolean;
  105496. /**
  105497. * Gets the number of samples used by the texture (WebGL2+ only)
  105498. */
  105499. samples: number;
  105500. /**
  105501. * Gets the type of the texture (int, float...)
  105502. */
  105503. type: number;
  105504. /**
  105505. * Gets the format of the texture (RGB, RGBA...)
  105506. */
  105507. format: number;
  105508. /**
  105509. * Observable called when the texture is loaded
  105510. */
  105511. onLoadedObservable: Observable<InternalTexture>;
  105512. /**
  105513. * Gets the width of the texture
  105514. */
  105515. width: number;
  105516. /**
  105517. * Gets the height of the texture
  105518. */
  105519. height: number;
  105520. /**
  105521. * Gets the depth of the texture
  105522. */
  105523. depth: number;
  105524. /**
  105525. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105526. */
  105527. baseWidth: number;
  105528. /**
  105529. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105530. */
  105531. baseHeight: number;
  105532. /**
  105533. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105534. */
  105535. baseDepth: number;
  105536. /**
  105537. * Gets a boolean indicating if the texture is inverted on Y axis
  105538. */
  105539. invertY: boolean;
  105540. /** @hidden */
  105541. _invertVScale: boolean;
  105542. /** @hidden */
  105543. _associatedChannel: number;
  105544. /** @hidden */
  105545. _source: InternalTextureSource;
  105546. /** @hidden */
  105547. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105548. /** @hidden */
  105549. _bufferView: Nullable<ArrayBufferView>;
  105550. /** @hidden */
  105551. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105552. /** @hidden */
  105553. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105554. /** @hidden */
  105555. _size: number;
  105556. /** @hidden */
  105557. _extension: string;
  105558. /** @hidden */
  105559. _files: Nullable<string[]>;
  105560. /** @hidden */
  105561. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105562. /** @hidden */
  105563. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105564. /** @hidden */
  105565. _framebuffer: Nullable<WebGLFramebuffer>;
  105566. /** @hidden */
  105567. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105568. /** @hidden */
  105569. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105570. /** @hidden */
  105571. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105572. /** @hidden */
  105573. _attachments: Nullable<number[]>;
  105574. /** @hidden */
  105575. _cachedCoordinatesMode: Nullable<number>;
  105576. /** @hidden */
  105577. _cachedWrapU: Nullable<number>;
  105578. /** @hidden */
  105579. _cachedWrapV: Nullable<number>;
  105580. /** @hidden */
  105581. _cachedWrapR: Nullable<number>;
  105582. /** @hidden */
  105583. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105584. /** @hidden */
  105585. _isDisabled: boolean;
  105586. /** @hidden */
  105587. _compression: Nullable<string>;
  105588. /** @hidden */
  105589. _generateStencilBuffer: boolean;
  105590. /** @hidden */
  105591. _generateDepthBuffer: boolean;
  105592. /** @hidden */
  105593. _comparisonFunction: number;
  105594. /** @hidden */
  105595. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105596. /** @hidden */
  105597. _lodGenerationScale: number;
  105598. /** @hidden */
  105599. _lodGenerationOffset: number;
  105600. /** @hidden */
  105601. _depthStencilTexture: Nullable<InternalTexture>;
  105602. /** @hidden */
  105603. _colorTextureArray: Nullable<WebGLTexture>;
  105604. /** @hidden */
  105605. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105606. /** @hidden */
  105607. _lodTextureHigh: Nullable<BaseTexture>;
  105608. /** @hidden */
  105609. _lodTextureMid: Nullable<BaseTexture>;
  105610. /** @hidden */
  105611. _lodTextureLow: Nullable<BaseTexture>;
  105612. /** @hidden */
  105613. _isRGBD: boolean;
  105614. /** @hidden */
  105615. _linearSpecularLOD: boolean;
  105616. /** @hidden */
  105617. _irradianceTexture: Nullable<BaseTexture>;
  105618. /** @hidden */
  105619. _webGLTexture: Nullable<WebGLTexture>;
  105620. /** @hidden */
  105621. _references: number;
  105622. private _engine;
  105623. /**
  105624. * Gets the Engine the texture belongs to.
  105625. * @returns The babylon engine
  105626. */
  105627. getEngine(): ThinEngine;
  105628. /**
  105629. * Gets the data source type of the texture
  105630. */
  105631. get source(): InternalTextureSource;
  105632. /**
  105633. * Creates a new InternalTexture
  105634. * @param engine defines the engine to use
  105635. * @param source defines the type of data that will be used
  105636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105637. */
  105638. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105639. /**
  105640. * Increments the number of references (ie. the number of Texture that point to it)
  105641. */
  105642. incrementReferences(): void;
  105643. /**
  105644. * Change the size of the texture (not the size of the content)
  105645. * @param width defines the new width
  105646. * @param height defines the new height
  105647. * @param depth defines the new depth (1 by default)
  105648. */
  105649. updateSize(width: int, height: int, depth?: int): void;
  105650. /** @hidden */
  105651. _rebuild(): void;
  105652. /** @hidden */
  105653. _swapAndDie(target: InternalTexture): void;
  105654. /**
  105655. * Dispose the current allocated resources
  105656. */
  105657. dispose(): void;
  105658. }
  105659. }
  105660. declare module BABYLON {
  105661. /**
  105662. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105664. */
  105665. export class Analyser {
  105666. /**
  105667. * Gets or sets the smoothing
  105668. * @ignorenaming
  105669. */
  105670. SMOOTHING: number;
  105671. /**
  105672. * Gets or sets the FFT table size
  105673. * @ignorenaming
  105674. */
  105675. FFT_SIZE: number;
  105676. /**
  105677. * Gets or sets the bar graph amplitude
  105678. * @ignorenaming
  105679. */
  105680. BARGRAPHAMPLITUDE: number;
  105681. /**
  105682. * Gets or sets the position of the debug canvas
  105683. * @ignorenaming
  105684. */
  105685. DEBUGCANVASPOS: {
  105686. x: number;
  105687. y: number;
  105688. };
  105689. /**
  105690. * Gets or sets the debug canvas size
  105691. * @ignorenaming
  105692. */
  105693. DEBUGCANVASSIZE: {
  105694. width: number;
  105695. height: number;
  105696. };
  105697. private _byteFreqs;
  105698. private _byteTime;
  105699. private _floatFreqs;
  105700. private _webAudioAnalyser;
  105701. private _debugCanvas;
  105702. private _debugCanvasContext;
  105703. private _scene;
  105704. private _registerFunc;
  105705. private _audioEngine;
  105706. /**
  105707. * Creates a new analyser
  105708. * @param scene defines hosting scene
  105709. */
  105710. constructor(scene: Scene);
  105711. /**
  105712. * Get the number of data values you will have to play with for the visualization
  105713. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105714. * @returns a number
  105715. */
  105716. getFrequencyBinCount(): number;
  105717. /**
  105718. * Gets the current frequency data as a byte array
  105719. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105720. * @returns a Uint8Array
  105721. */
  105722. getByteFrequencyData(): Uint8Array;
  105723. /**
  105724. * Gets the current waveform as a byte array
  105725. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105726. * @returns a Uint8Array
  105727. */
  105728. getByteTimeDomainData(): Uint8Array;
  105729. /**
  105730. * Gets the current frequency data as a float array
  105731. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105732. * @returns a Float32Array
  105733. */
  105734. getFloatFrequencyData(): Float32Array;
  105735. /**
  105736. * Renders the debug canvas
  105737. */
  105738. drawDebugCanvas(): void;
  105739. /**
  105740. * Stops rendering the debug canvas and removes it
  105741. */
  105742. stopDebugCanvas(): void;
  105743. /**
  105744. * Connects two audio nodes
  105745. * @param inputAudioNode defines first node to connect
  105746. * @param outputAudioNode defines second node to connect
  105747. */
  105748. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105749. /**
  105750. * Releases all associated resources
  105751. */
  105752. dispose(): void;
  105753. }
  105754. }
  105755. declare module BABYLON {
  105756. /**
  105757. * This represents an audio engine and it is responsible
  105758. * to play, synchronize and analyse sounds throughout the application.
  105759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105760. */
  105761. export interface IAudioEngine extends IDisposable {
  105762. /**
  105763. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105764. */
  105765. readonly canUseWebAudio: boolean;
  105766. /**
  105767. * Gets the current AudioContext if available.
  105768. */
  105769. readonly audioContext: Nullable<AudioContext>;
  105770. /**
  105771. * The master gain node defines the global audio volume of your audio engine.
  105772. */
  105773. readonly masterGain: GainNode;
  105774. /**
  105775. * Gets whether or not mp3 are supported by your browser.
  105776. */
  105777. readonly isMP3supported: boolean;
  105778. /**
  105779. * Gets whether or not ogg are supported by your browser.
  105780. */
  105781. readonly isOGGsupported: boolean;
  105782. /**
  105783. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105784. * @ignoreNaming
  105785. */
  105786. WarnedWebAudioUnsupported: boolean;
  105787. /**
  105788. * Defines if the audio engine relies on a custom unlocked button.
  105789. * In this case, the embedded button will not be displayed.
  105790. */
  105791. useCustomUnlockedButton: boolean;
  105792. /**
  105793. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105794. */
  105795. readonly unlocked: boolean;
  105796. /**
  105797. * Event raised when audio has been unlocked on the browser.
  105798. */
  105799. onAudioUnlockedObservable: Observable<AudioEngine>;
  105800. /**
  105801. * Event raised when audio has been locked on the browser.
  105802. */
  105803. onAudioLockedObservable: Observable<AudioEngine>;
  105804. /**
  105805. * Flags the audio engine in Locked state.
  105806. * This happens due to new browser policies preventing audio to autoplay.
  105807. */
  105808. lock(): void;
  105809. /**
  105810. * Unlocks the audio engine once a user action has been done on the dom.
  105811. * This is helpful to resume play once browser policies have been satisfied.
  105812. */
  105813. unlock(): void;
  105814. }
  105815. /**
  105816. * This represents the default audio engine used in babylon.
  105817. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105819. */
  105820. export class AudioEngine implements IAudioEngine {
  105821. private _audioContext;
  105822. private _audioContextInitialized;
  105823. private _muteButton;
  105824. private _hostElement;
  105825. /**
  105826. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105827. */
  105828. canUseWebAudio: boolean;
  105829. /**
  105830. * The master gain node defines the global audio volume of your audio engine.
  105831. */
  105832. masterGain: GainNode;
  105833. /**
  105834. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105835. * @ignoreNaming
  105836. */
  105837. WarnedWebAudioUnsupported: boolean;
  105838. /**
  105839. * Gets whether or not mp3 are supported by your browser.
  105840. */
  105841. isMP3supported: boolean;
  105842. /**
  105843. * Gets whether or not ogg are supported by your browser.
  105844. */
  105845. isOGGsupported: boolean;
  105846. /**
  105847. * Gets whether audio has been unlocked on the device.
  105848. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105849. * a user interaction has happened.
  105850. */
  105851. unlocked: boolean;
  105852. /**
  105853. * Defines if the audio engine relies on a custom unlocked button.
  105854. * In this case, the embedded button will not be displayed.
  105855. */
  105856. useCustomUnlockedButton: boolean;
  105857. /**
  105858. * Event raised when audio has been unlocked on the browser.
  105859. */
  105860. onAudioUnlockedObservable: Observable<AudioEngine>;
  105861. /**
  105862. * Event raised when audio has been locked on the browser.
  105863. */
  105864. onAudioLockedObservable: Observable<AudioEngine>;
  105865. /**
  105866. * Gets the current AudioContext if available.
  105867. */
  105868. get audioContext(): Nullable<AudioContext>;
  105869. private _connectedAnalyser;
  105870. /**
  105871. * Instantiates a new audio engine.
  105872. *
  105873. * There should be only one per page as some browsers restrict the number
  105874. * of audio contexts you can create.
  105875. * @param hostElement defines the host element where to display the mute icon if necessary
  105876. */
  105877. constructor(hostElement?: Nullable<HTMLElement>);
  105878. /**
  105879. * Flags the audio engine in Locked state.
  105880. * This happens due to new browser policies preventing audio to autoplay.
  105881. */
  105882. lock(): void;
  105883. /**
  105884. * Unlocks the audio engine once a user action has been done on the dom.
  105885. * This is helpful to resume play once browser policies have been satisfied.
  105886. */
  105887. unlock(): void;
  105888. private _resumeAudioContext;
  105889. private _initializeAudioContext;
  105890. private _tryToRun;
  105891. private _triggerRunningState;
  105892. private _triggerSuspendedState;
  105893. private _displayMuteButton;
  105894. private _moveButtonToTopLeft;
  105895. private _onResize;
  105896. private _hideMuteButton;
  105897. /**
  105898. * Destroy and release the resources associated with the audio ccontext.
  105899. */
  105900. dispose(): void;
  105901. /**
  105902. * Gets the global volume sets on the master gain.
  105903. * @returns the global volume if set or -1 otherwise
  105904. */
  105905. getGlobalVolume(): number;
  105906. /**
  105907. * Sets the global volume of your experience (sets on the master gain).
  105908. * @param newVolume Defines the new global volume of the application
  105909. */
  105910. setGlobalVolume(newVolume: number): void;
  105911. /**
  105912. * Connect the audio engine to an audio analyser allowing some amazing
  105913. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105915. * @param analyser The analyser to connect to the engine
  105916. */
  105917. connectToAnalyser(analyser: Analyser): void;
  105918. }
  105919. }
  105920. declare module BABYLON {
  105921. /**
  105922. * Interface used to present a loading screen while loading a scene
  105923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105924. */
  105925. export interface ILoadingScreen {
  105926. /**
  105927. * Function called to display the loading screen
  105928. */
  105929. displayLoadingUI: () => void;
  105930. /**
  105931. * Function called to hide the loading screen
  105932. */
  105933. hideLoadingUI: () => void;
  105934. /**
  105935. * Gets or sets the color to use for the background
  105936. */
  105937. loadingUIBackgroundColor: string;
  105938. /**
  105939. * Gets or sets the text to display while loading
  105940. */
  105941. loadingUIText: string;
  105942. }
  105943. /**
  105944. * Class used for the default loading screen
  105945. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105946. */
  105947. export class DefaultLoadingScreen implements ILoadingScreen {
  105948. private _renderingCanvas;
  105949. private _loadingText;
  105950. private _loadingDivBackgroundColor;
  105951. private _loadingDiv;
  105952. private _loadingTextDiv;
  105953. /** Gets or sets the logo url to use for the default loading screen */
  105954. static DefaultLogoUrl: string;
  105955. /** Gets or sets the spinner url to use for the default loading screen */
  105956. static DefaultSpinnerUrl: string;
  105957. /**
  105958. * Creates a new default loading screen
  105959. * @param _renderingCanvas defines the canvas used to render the scene
  105960. * @param _loadingText defines the default text to display
  105961. * @param _loadingDivBackgroundColor defines the default background color
  105962. */
  105963. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105964. /**
  105965. * Function called to display the loading screen
  105966. */
  105967. displayLoadingUI(): void;
  105968. /**
  105969. * Function called to hide the loading screen
  105970. */
  105971. hideLoadingUI(): void;
  105972. /**
  105973. * Gets or sets the text to display while loading
  105974. */
  105975. set loadingUIText(text: string);
  105976. get loadingUIText(): string;
  105977. /**
  105978. * Gets or sets the color to use for the background
  105979. */
  105980. get loadingUIBackgroundColor(): string;
  105981. set loadingUIBackgroundColor(color: string);
  105982. private _resizeLoadingUI;
  105983. }
  105984. }
  105985. declare module BABYLON {
  105986. /**
  105987. * Interface for any object that can request an animation frame
  105988. */
  105989. export interface ICustomAnimationFrameRequester {
  105990. /**
  105991. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105992. */
  105993. renderFunction?: Function;
  105994. /**
  105995. * Called to request the next frame to render to
  105996. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105997. */
  105998. requestAnimationFrame: Function;
  105999. /**
  106000. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106001. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106002. */
  106003. requestID?: number;
  106004. }
  106005. }
  106006. declare module BABYLON {
  106007. /**
  106008. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106009. */
  106010. export class PerformanceMonitor {
  106011. private _enabled;
  106012. private _rollingFrameTime;
  106013. private _lastFrameTimeMs;
  106014. /**
  106015. * constructor
  106016. * @param frameSampleSize The number of samples required to saturate the sliding window
  106017. */
  106018. constructor(frameSampleSize?: number);
  106019. /**
  106020. * Samples current frame
  106021. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106022. */
  106023. sampleFrame(timeMs?: number): void;
  106024. /**
  106025. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106026. */
  106027. get averageFrameTime(): number;
  106028. /**
  106029. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106030. */
  106031. get averageFrameTimeVariance(): number;
  106032. /**
  106033. * Returns the frame time of the most recent frame
  106034. */
  106035. get instantaneousFrameTime(): number;
  106036. /**
  106037. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106038. */
  106039. get averageFPS(): number;
  106040. /**
  106041. * Returns the average framerate in frames per second using the most recent frame time
  106042. */
  106043. get instantaneousFPS(): number;
  106044. /**
  106045. * Returns true if enough samples have been taken to completely fill the sliding window
  106046. */
  106047. get isSaturated(): boolean;
  106048. /**
  106049. * Enables contributions to the sliding window sample set
  106050. */
  106051. enable(): void;
  106052. /**
  106053. * Disables contributions to the sliding window sample set
  106054. * Samples will not be interpolated over the disabled period
  106055. */
  106056. disable(): void;
  106057. /**
  106058. * Returns true if sampling is enabled
  106059. */
  106060. get isEnabled(): boolean;
  106061. /**
  106062. * Resets performance monitor
  106063. */
  106064. reset(): void;
  106065. }
  106066. /**
  106067. * RollingAverage
  106068. *
  106069. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106070. */
  106071. export class RollingAverage {
  106072. /**
  106073. * Current average
  106074. */
  106075. average: number;
  106076. /**
  106077. * Current variance
  106078. */
  106079. variance: number;
  106080. protected _samples: Array<number>;
  106081. protected _sampleCount: number;
  106082. protected _pos: number;
  106083. protected _m2: number;
  106084. /**
  106085. * constructor
  106086. * @param length The number of samples required to saturate the sliding window
  106087. */
  106088. constructor(length: number);
  106089. /**
  106090. * Adds a sample to the sample set
  106091. * @param v The sample value
  106092. */
  106093. add(v: number): void;
  106094. /**
  106095. * Returns previously added values or null if outside of history or outside the sliding window domain
  106096. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106097. * @return Value previously recorded with add() or null if outside of range
  106098. */
  106099. history(i: number): number;
  106100. /**
  106101. * Returns true if enough samples have been taken to completely fill the sliding window
  106102. * @return true if sample-set saturated
  106103. */
  106104. isSaturated(): boolean;
  106105. /**
  106106. * Resets the rolling average (equivalent to 0 samples taken so far)
  106107. */
  106108. reset(): void;
  106109. /**
  106110. * Wraps a value around the sample range boundaries
  106111. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106112. * @return Wrapped position in sample range
  106113. */
  106114. protected _wrapPosition(i: number): number;
  106115. }
  106116. }
  106117. declare module BABYLON {
  106118. /**
  106119. * This class is used to track a performance counter which is number based.
  106120. * The user has access to many properties which give statistics of different nature.
  106121. *
  106122. * The implementer can track two kinds of Performance Counter: time and count.
  106123. * 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.
  106124. * 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.
  106125. */
  106126. export class PerfCounter {
  106127. /**
  106128. * Gets or sets a global boolean to turn on and off all the counters
  106129. */
  106130. static Enabled: boolean;
  106131. /**
  106132. * Returns the smallest value ever
  106133. */
  106134. get min(): number;
  106135. /**
  106136. * Returns the biggest value ever
  106137. */
  106138. get max(): number;
  106139. /**
  106140. * Returns the average value since the performance counter is running
  106141. */
  106142. get average(): number;
  106143. /**
  106144. * Returns the average value of the last second the counter was monitored
  106145. */
  106146. get lastSecAverage(): number;
  106147. /**
  106148. * Returns the current value
  106149. */
  106150. get current(): number;
  106151. /**
  106152. * Gets the accumulated total
  106153. */
  106154. get total(): number;
  106155. /**
  106156. * Gets the total value count
  106157. */
  106158. get count(): number;
  106159. /**
  106160. * Creates a new counter
  106161. */
  106162. constructor();
  106163. /**
  106164. * Call this method to start monitoring a new frame.
  106165. * 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.
  106166. */
  106167. fetchNewFrame(): void;
  106168. /**
  106169. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106170. * @param newCount the count value to add to the monitored count
  106171. * @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.
  106172. */
  106173. addCount(newCount: number, fetchResult: boolean): void;
  106174. /**
  106175. * Start monitoring this performance counter
  106176. */
  106177. beginMonitoring(): void;
  106178. /**
  106179. * Compute the time lapsed since the previous beginMonitoring() call.
  106180. * @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
  106181. */
  106182. endMonitoring(newFrame?: boolean): void;
  106183. private _fetchResult;
  106184. private _startMonitoringTime;
  106185. private _min;
  106186. private _max;
  106187. private _average;
  106188. private _current;
  106189. private _totalValueCount;
  106190. private _totalAccumulated;
  106191. private _lastSecAverage;
  106192. private _lastSecAccumulated;
  106193. private _lastSecTime;
  106194. private _lastSecValueCount;
  106195. }
  106196. }
  106197. declare module BABYLON {
  106198. interface ThinEngine {
  106199. /**
  106200. * Sets alpha constants used by some alpha blending modes
  106201. * @param r defines the red component
  106202. * @param g defines the green component
  106203. * @param b defines the blue component
  106204. * @param a defines the alpha component
  106205. */
  106206. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106207. /**
  106208. * Sets the current alpha mode
  106209. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106210. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106211. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106212. */
  106213. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106214. /**
  106215. * Gets the current alpha mode
  106216. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106217. * @returns the current alpha mode
  106218. */
  106219. getAlphaMode(): number;
  106220. /**
  106221. * Sets the current alpha equation
  106222. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106223. */
  106224. setAlphaEquation(equation: number): void;
  106225. /**
  106226. * Gets the current alpha equation.
  106227. * @returns the current alpha equation
  106228. */
  106229. getAlphaEquation(): number;
  106230. }
  106231. }
  106232. declare module BABYLON {
  106233. /**
  106234. * Defines the interface used by display changed events
  106235. */
  106236. export interface IDisplayChangedEventArgs {
  106237. /** Gets the vrDisplay object (if any) */
  106238. vrDisplay: Nullable<any>;
  106239. /** Gets a boolean indicating if webVR is supported */
  106240. vrSupported: boolean;
  106241. }
  106242. /**
  106243. * Defines the interface used by objects containing a viewport (like a camera)
  106244. */
  106245. interface IViewportOwnerLike {
  106246. /**
  106247. * Gets or sets the viewport
  106248. */
  106249. viewport: IViewportLike;
  106250. }
  106251. /**
  106252. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106253. */
  106254. export class Engine extends ThinEngine {
  106255. /** Defines that alpha blending is disabled */
  106256. static readonly ALPHA_DISABLE: number;
  106257. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106258. static readonly ALPHA_ADD: number;
  106259. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106260. static readonly ALPHA_COMBINE: number;
  106261. /** Defines that alpha blending to DEST - SRC * DEST */
  106262. static readonly ALPHA_SUBTRACT: number;
  106263. /** Defines that alpha blending to SRC * DEST */
  106264. static readonly ALPHA_MULTIPLY: number;
  106265. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106266. static readonly ALPHA_MAXIMIZED: number;
  106267. /** Defines that alpha blending to SRC + DEST */
  106268. static readonly ALPHA_ONEONE: number;
  106269. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106270. static readonly ALPHA_PREMULTIPLIED: number;
  106271. /**
  106272. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106273. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106274. */
  106275. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106276. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106277. static readonly ALPHA_INTERPOLATE: number;
  106278. /**
  106279. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106280. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106281. */
  106282. static readonly ALPHA_SCREENMODE: number;
  106283. /** Defines that the ressource is not delayed*/
  106284. static readonly DELAYLOADSTATE_NONE: number;
  106285. /** Defines that the ressource was successfully delay loaded */
  106286. static readonly DELAYLOADSTATE_LOADED: number;
  106287. /** Defines that the ressource is currently delay loading */
  106288. static readonly DELAYLOADSTATE_LOADING: number;
  106289. /** Defines that the ressource is delayed and has not started loading */
  106290. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106292. static readonly NEVER: number;
  106293. /** 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 */
  106294. static readonly ALWAYS: number;
  106295. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106296. static readonly LESS: number;
  106297. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106298. static readonly EQUAL: number;
  106299. /** 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 */
  106300. static readonly LEQUAL: number;
  106301. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106302. static readonly GREATER: number;
  106303. /** 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 */
  106304. static readonly GEQUAL: number;
  106305. /** 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 */
  106306. static readonly NOTEQUAL: number;
  106307. /** Passed to stencilOperation to specify that stencil value must be kept */
  106308. static readonly KEEP: number;
  106309. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106310. static readonly REPLACE: number;
  106311. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106312. static readonly INCR: number;
  106313. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106314. static readonly DECR: number;
  106315. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106316. static readonly INVERT: number;
  106317. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106318. static readonly INCR_WRAP: number;
  106319. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106320. static readonly DECR_WRAP: number;
  106321. /** Texture is not repeating outside of 0..1 UVs */
  106322. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106323. /** Texture is repeating outside of 0..1 UVs */
  106324. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106325. /** Texture is repeating and mirrored */
  106326. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106327. /** ALPHA */
  106328. static readonly TEXTUREFORMAT_ALPHA: number;
  106329. /** LUMINANCE */
  106330. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106331. /** LUMINANCE_ALPHA */
  106332. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106333. /** RGB */
  106334. static readonly TEXTUREFORMAT_RGB: number;
  106335. /** RGBA */
  106336. static readonly TEXTUREFORMAT_RGBA: number;
  106337. /** RED */
  106338. static readonly TEXTUREFORMAT_RED: number;
  106339. /** RED (2nd reference) */
  106340. static readonly TEXTUREFORMAT_R: number;
  106341. /** RG */
  106342. static readonly TEXTUREFORMAT_RG: number;
  106343. /** RED_INTEGER */
  106344. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106345. /** RED_INTEGER (2nd reference) */
  106346. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106347. /** RG_INTEGER */
  106348. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106349. /** RGB_INTEGER */
  106350. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106351. /** RGBA_INTEGER */
  106352. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106353. /** UNSIGNED_BYTE */
  106354. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106355. /** UNSIGNED_BYTE (2nd reference) */
  106356. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106357. /** FLOAT */
  106358. static readonly TEXTURETYPE_FLOAT: number;
  106359. /** HALF_FLOAT */
  106360. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106361. /** BYTE */
  106362. static readonly TEXTURETYPE_BYTE: number;
  106363. /** SHORT */
  106364. static readonly TEXTURETYPE_SHORT: number;
  106365. /** UNSIGNED_SHORT */
  106366. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106367. /** INT */
  106368. static readonly TEXTURETYPE_INT: number;
  106369. /** UNSIGNED_INT */
  106370. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106371. /** UNSIGNED_SHORT_4_4_4_4 */
  106372. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106373. /** UNSIGNED_SHORT_5_5_5_1 */
  106374. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106375. /** UNSIGNED_SHORT_5_6_5 */
  106376. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106377. /** UNSIGNED_INT_2_10_10_10_REV */
  106378. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106379. /** UNSIGNED_INT_24_8 */
  106380. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106381. /** UNSIGNED_INT_10F_11F_11F_REV */
  106382. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106383. /** UNSIGNED_INT_5_9_9_9_REV */
  106384. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106385. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106386. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106387. /** nearest is mag = nearest and min = nearest and mip = linear */
  106388. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106390. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106391. /** Trilinear is mag = linear and min = linear and mip = linear */
  106392. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106393. /** nearest is mag = nearest and min = nearest and mip = linear */
  106394. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106395. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106396. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106397. /** Trilinear is mag = linear and min = linear and mip = linear */
  106398. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106399. /** mag = nearest and min = nearest and mip = nearest */
  106400. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106401. /** mag = nearest and min = linear and mip = nearest */
  106402. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106403. /** mag = nearest and min = linear and mip = linear */
  106404. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106405. /** mag = nearest and min = linear and mip = none */
  106406. static readonly TEXTURE_NEAREST_LINEAR: number;
  106407. /** mag = nearest and min = nearest and mip = none */
  106408. static readonly TEXTURE_NEAREST_NEAREST: number;
  106409. /** mag = linear and min = nearest and mip = nearest */
  106410. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106411. /** mag = linear and min = nearest and mip = linear */
  106412. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106413. /** mag = linear and min = linear and mip = none */
  106414. static readonly TEXTURE_LINEAR_LINEAR: number;
  106415. /** mag = linear and min = nearest and mip = none */
  106416. static readonly TEXTURE_LINEAR_NEAREST: number;
  106417. /** Explicit coordinates mode */
  106418. static readonly TEXTURE_EXPLICIT_MODE: number;
  106419. /** Spherical coordinates mode */
  106420. static readonly TEXTURE_SPHERICAL_MODE: number;
  106421. /** Planar coordinates mode */
  106422. static readonly TEXTURE_PLANAR_MODE: number;
  106423. /** Cubic coordinates mode */
  106424. static readonly TEXTURE_CUBIC_MODE: number;
  106425. /** Projection coordinates mode */
  106426. static readonly TEXTURE_PROJECTION_MODE: number;
  106427. /** Skybox coordinates mode */
  106428. static readonly TEXTURE_SKYBOX_MODE: number;
  106429. /** Inverse Cubic coordinates mode */
  106430. static readonly TEXTURE_INVCUBIC_MODE: number;
  106431. /** Equirectangular coordinates mode */
  106432. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106433. /** Equirectangular Fixed coordinates mode */
  106434. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106435. /** Equirectangular Fixed Mirrored coordinates mode */
  106436. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106437. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106438. static readonly SCALEMODE_FLOOR: number;
  106439. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106440. static readonly SCALEMODE_NEAREST: number;
  106441. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106442. static readonly SCALEMODE_CEILING: number;
  106443. /**
  106444. * Returns the current npm package of the sdk
  106445. */
  106446. static get NpmPackage(): string;
  106447. /**
  106448. * Returns the current version of the framework
  106449. */
  106450. static get Version(): string;
  106451. /** Gets the list of created engines */
  106452. static get Instances(): Engine[];
  106453. /**
  106454. * Gets the latest created engine
  106455. */
  106456. static get LastCreatedEngine(): Nullable<Engine>;
  106457. /**
  106458. * Gets the latest created scene
  106459. */
  106460. static get LastCreatedScene(): Nullable<Scene>;
  106461. /**
  106462. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106463. * @param flag defines which part of the materials must be marked as dirty
  106464. * @param predicate defines a predicate used to filter which materials should be affected
  106465. */
  106466. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106467. /**
  106468. * Method called to create the default loading screen.
  106469. * This can be overriden in your own app.
  106470. * @param canvas The rendering canvas element
  106471. * @returns The loading screen
  106472. */
  106473. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106474. /**
  106475. * Method called to create the default rescale post process on each engine.
  106476. */
  106477. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106478. /**
  106479. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106480. **/
  106481. enableOfflineSupport: boolean;
  106482. /**
  106483. * 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)
  106484. **/
  106485. disableManifestCheck: boolean;
  106486. /**
  106487. * Gets the list of created scenes
  106488. */
  106489. scenes: Scene[];
  106490. /**
  106491. * Event raised when a new scene is created
  106492. */
  106493. onNewSceneAddedObservable: Observable<Scene>;
  106494. /**
  106495. * Gets the list of created postprocesses
  106496. */
  106497. postProcesses: PostProcess[];
  106498. /**
  106499. * Gets a boolean indicating if the pointer is currently locked
  106500. */
  106501. isPointerLock: boolean;
  106502. /**
  106503. * Observable event triggered each time the rendering canvas is resized
  106504. */
  106505. onResizeObservable: Observable<Engine>;
  106506. /**
  106507. * Observable event triggered each time the canvas loses focus
  106508. */
  106509. onCanvasBlurObservable: Observable<Engine>;
  106510. /**
  106511. * Observable event triggered each time the canvas gains focus
  106512. */
  106513. onCanvasFocusObservable: Observable<Engine>;
  106514. /**
  106515. * Observable event triggered each time the canvas receives pointerout event
  106516. */
  106517. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106518. /**
  106519. * Observable raised when the engine begins a new frame
  106520. */
  106521. onBeginFrameObservable: Observable<Engine>;
  106522. /**
  106523. * If set, will be used to request the next animation frame for the render loop
  106524. */
  106525. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106526. /**
  106527. * Observable raised when the engine ends the current frame
  106528. */
  106529. onEndFrameObservable: Observable<Engine>;
  106530. /**
  106531. * Observable raised when the engine is about to compile a shader
  106532. */
  106533. onBeforeShaderCompilationObservable: Observable<Engine>;
  106534. /**
  106535. * Observable raised when the engine has jsut compiled a shader
  106536. */
  106537. onAfterShaderCompilationObservable: Observable<Engine>;
  106538. /**
  106539. * Gets the audio engine
  106540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106541. * @ignorenaming
  106542. */
  106543. static audioEngine: IAudioEngine;
  106544. /**
  106545. * Default AudioEngine factory responsible of creating the Audio Engine.
  106546. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106547. */
  106548. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106549. /**
  106550. * Default offline support factory responsible of creating a tool used to store data locally.
  106551. * By default, this will create a Database object if the workload has been embedded.
  106552. */
  106553. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106554. private _loadingScreen;
  106555. private _pointerLockRequested;
  106556. private _dummyFramebuffer;
  106557. private _rescalePostProcess;
  106558. private _deterministicLockstep;
  106559. private _lockstepMaxSteps;
  106560. private _timeStep;
  106561. protected get _supportsHardwareTextureRescaling(): boolean;
  106562. private _fps;
  106563. private _deltaTime;
  106564. /** @hidden */
  106565. _drawCalls: PerfCounter;
  106566. /** 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 */
  106567. canvasTabIndex: number;
  106568. /**
  106569. * Turn this value on if you want to pause FPS computation when in background
  106570. */
  106571. disablePerformanceMonitorInBackground: boolean;
  106572. private _performanceMonitor;
  106573. /**
  106574. * Gets the performance monitor attached to this engine
  106575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106576. */
  106577. get performanceMonitor(): PerformanceMonitor;
  106578. private _onFocus;
  106579. private _onBlur;
  106580. private _onCanvasPointerOut;
  106581. private _onCanvasBlur;
  106582. private _onCanvasFocus;
  106583. private _onFullscreenChange;
  106584. private _onPointerLockChange;
  106585. /**
  106586. * Gets the HTML element used to attach event listeners
  106587. * @returns a HTML element
  106588. */
  106589. getInputElement(): Nullable<HTMLElement>;
  106590. /**
  106591. * Creates a new engine
  106592. * @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
  106593. * @param antialias defines enable antialiasing (default: false)
  106594. * @param options defines further options to be sent to the getContext() function
  106595. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106596. */
  106597. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106598. /**
  106599. * Gets current aspect ratio
  106600. * @param viewportOwner defines the camera to use to get the aspect ratio
  106601. * @param useScreen defines if screen size must be used (or the current render target if any)
  106602. * @returns a number defining the aspect ratio
  106603. */
  106604. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106605. /**
  106606. * Gets current screen aspect ratio
  106607. * @returns a number defining the aspect ratio
  106608. */
  106609. getScreenAspectRatio(): number;
  106610. /**
  106611. * Gets the client rect of the HTML canvas attached with the current webGL context
  106612. * @returns a client rectanglee
  106613. */
  106614. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106615. /**
  106616. * Gets the client rect of the HTML element used for events
  106617. * @returns a client rectanglee
  106618. */
  106619. getInputElementClientRect(): Nullable<ClientRect>;
  106620. /**
  106621. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106623. * @returns true if engine is in deterministic lock step mode
  106624. */
  106625. isDeterministicLockStep(): boolean;
  106626. /**
  106627. * Gets the max steps when engine is running in deterministic lock step
  106628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106629. * @returns the max steps
  106630. */
  106631. getLockstepMaxSteps(): number;
  106632. /**
  106633. * Returns the time in ms between steps when using deterministic lock step.
  106634. * @returns time step in (ms)
  106635. */
  106636. getTimeStep(): number;
  106637. /**
  106638. * Force the mipmap generation for the given render target texture
  106639. * @param texture defines the render target texture to use
  106640. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106641. */
  106642. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106643. /** States */
  106644. /**
  106645. * Set various states to the webGL context
  106646. * @param culling defines backface culling state
  106647. * @param zOffset defines the value to apply to zOffset (0 by default)
  106648. * @param force defines if states must be applied even if cache is up to date
  106649. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106650. */
  106651. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106652. /**
  106653. * Set the z offset to apply to current rendering
  106654. * @param value defines the offset to apply
  106655. */
  106656. setZOffset(value: number): void;
  106657. /**
  106658. * Gets the current value of the zOffset
  106659. * @returns the current zOffset state
  106660. */
  106661. getZOffset(): number;
  106662. /**
  106663. * Enable or disable depth buffering
  106664. * @param enable defines the state to set
  106665. */
  106666. setDepthBuffer(enable: boolean): void;
  106667. /**
  106668. * Gets a boolean indicating if depth writing is enabled
  106669. * @returns the current depth writing state
  106670. */
  106671. getDepthWrite(): boolean;
  106672. /**
  106673. * Enable or disable depth writing
  106674. * @param enable defines the state to set
  106675. */
  106676. setDepthWrite(enable: boolean): void;
  106677. /**
  106678. * Gets a boolean indicating if stencil buffer is enabled
  106679. * @returns the current stencil buffer state
  106680. */
  106681. getStencilBuffer(): boolean;
  106682. /**
  106683. * Enable or disable the stencil buffer
  106684. * @param enable defines if the stencil buffer must be enabled or disabled
  106685. */
  106686. setStencilBuffer(enable: boolean): void;
  106687. /**
  106688. * Gets the current stencil mask
  106689. * @returns a number defining the new stencil mask to use
  106690. */
  106691. getStencilMask(): number;
  106692. /**
  106693. * Sets the current stencil mask
  106694. * @param mask defines the new stencil mask to use
  106695. */
  106696. setStencilMask(mask: number): void;
  106697. /**
  106698. * Gets the current stencil function
  106699. * @returns a number defining the stencil function to use
  106700. */
  106701. getStencilFunction(): number;
  106702. /**
  106703. * Gets the current stencil reference value
  106704. * @returns a number defining the stencil reference value to use
  106705. */
  106706. getStencilFunctionReference(): number;
  106707. /**
  106708. * Gets the current stencil mask
  106709. * @returns a number defining the stencil mask to use
  106710. */
  106711. getStencilFunctionMask(): number;
  106712. /**
  106713. * Sets the current stencil function
  106714. * @param stencilFunc defines the new stencil function to use
  106715. */
  106716. setStencilFunction(stencilFunc: number): void;
  106717. /**
  106718. * Sets the current stencil reference
  106719. * @param reference defines the new stencil reference to use
  106720. */
  106721. setStencilFunctionReference(reference: number): void;
  106722. /**
  106723. * Sets the current stencil mask
  106724. * @param mask defines the new stencil mask to use
  106725. */
  106726. setStencilFunctionMask(mask: number): void;
  106727. /**
  106728. * Gets the current stencil operation when stencil fails
  106729. * @returns a number defining stencil operation to use when stencil fails
  106730. */
  106731. getStencilOperationFail(): number;
  106732. /**
  106733. * Gets the current stencil operation when depth fails
  106734. * @returns a number defining stencil operation to use when depth fails
  106735. */
  106736. getStencilOperationDepthFail(): number;
  106737. /**
  106738. * Gets the current stencil operation when stencil passes
  106739. * @returns a number defining stencil operation to use when stencil passes
  106740. */
  106741. getStencilOperationPass(): number;
  106742. /**
  106743. * Sets the stencil operation to use when stencil fails
  106744. * @param operation defines the stencil operation to use when stencil fails
  106745. */
  106746. setStencilOperationFail(operation: number): void;
  106747. /**
  106748. * Sets the stencil operation to use when depth fails
  106749. * @param operation defines the stencil operation to use when depth fails
  106750. */
  106751. setStencilOperationDepthFail(operation: number): void;
  106752. /**
  106753. * Sets the stencil operation to use when stencil passes
  106754. * @param operation defines the stencil operation to use when stencil passes
  106755. */
  106756. setStencilOperationPass(operation: number): void;
  106757. /**
  106758. * Sets a boolean indicating if the dithering state is enabled or disabled
  106759. * @param value defines the dithering state
  106760. */
  106761. setDitheringState(value: boolean): void;
  106762. /**
  106763. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106764. * @param value defines the rasterizer state
  106765. */
  106766. setRasterizerState(value: boolean): void;
  106767. /**
  106768. * Gets the current depth function
  106769. * @returns a number defining the depth function
  106770. */
  106771. getDepthFunction(): Nullable<number>;
  106772. /**
  106773. * Sets the current depth function
  106774. * @param depthFunc defines the function to use
  106775. */
  106776. setDepthFunction(depthFunc: number): void;
  106777. /**
  106778. * Sets the current depth function to GREATER
  106779. */
  106780. setDepthFunctionToGreater(): void;
  106781. /**
  106782. * Sets the current depth function to GEQUAL
  106783. */
  106784. setDepthFunctionToGreaterOrEqual(): void;
  106785. /**
  106786. * Sets the current depth function to LESS
  106787. */
  106788. setDepthFunctionToLess(): void;
  106789. /**
  106790. * Sets the current depth function to LEQUAL
  106791. */
  106792. setDepthFunctionToLessOrEqual(): void;
  106793. private _cachedStencilBuffer;
  106794. private _cachedStencilFunction;
  106795. private _cachedStencilMask;
  106796. private _cachedStencilOperationPass;
  106797. private _cachedStencilOperationFail;
  106798. private _cachedStencilOperationDepthFail;
  106799. private _cachedStencilReference;
  106800. /**
  106801. * Caches the the state of the stencil buffer
  106802. */
  106803. cacheStencilState(): void;
  106804. /**
  106805. * Restores the state of the stencil buffer
  106806. */
  106807. restoreStencilState(): void;
  106808. /**
  106809. * Directly set the WebGL Viewport
  106810. * @param x defines the x coordinate of the viewport (in screen space)
  106811. * @param y defines the y coordinate of the viewport (in screen space)
  106812. * @param width defines the width of the viewport (in screen space)
  106813. * @param height defines the height of the viewport (in screen space)
  106814. * @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
  106815. */
  106816. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106817. /**
  106818. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106819. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106820. * @param y defines the y-coordinate of the corner of the clear rectangle
  106821. * @param width defines the width of the clear rectangle
  106822. * @param height defines the height of the clear rectangle
  106823. * @param clearColor defines the clear color
  106824. */
  106825. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106826. /**
  106827. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106828. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106829. * @param y defines the y-coordinate of the corner of the clear rectangle
  106830. * @param width defines the width of the clear rectangle
  106831. * @param height defines the height of the clear rectangle
  106832. */
  106833. enableScissor(x: number, y: number, width: number, height: number): void;
  106834. /**
  106835. * Disable previously set scissor test rectangle
  106836. */
  106837. disableScissor(): void;
  106838. protected _reportDrawCall(): void;
  106839. /**
  106840. * Initializes a webVR display and starts listening to display change events
  106841. * The onVRDisplayChangedObservable will be notified upon these changes
  106842. * @returns The onVRDisplayChangedObservable
  106843. */
  106844. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106845. /** @hidden */
  106846. _prepareVRComponent(): void;
  106847. /** @hidden */
  106848. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106849. /** @hidden */
  106850. _submitVRFrame(): void;
  106851. /**
  106852. * Call this function to leave webVR mode
  106853. * Will do nothing if webVR is not supported or if there is no webVR device
  106854. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106855. */
  106856. disableVR(): void;
  106857. /**
  106858. * Gets a boolean indicating that the system is in VR mode and is presenting
  106859. * @returns true if VR mode is engaged
  106860. */
  106861. isVRPresenting(): boolean;
  106862. /** @hidden */
  106863. _requestVRFrame(): void;
  106864. /** @hidden */
  106865. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106866. /**
  106867. * Gets the source code of the vertex shader associated with a specific webGL program
  106868. * @param program defines the program to use
  106869. * @returns a string containing the source code of the vertex shader associated with the program
  106870. */
  106871. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106872. /**
  106873. * Gets the source code of the fragment shader associated with a specific webGL program
  106874. * @param program defines the program to use
  106875. * @returns a string containing the source code of the fragment shader associated with the program
  106876. */
  106877. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106878. /**
  106879. * Sets a depth stencil texture from a render target to the according uniform.
  106880. * @param channel The texture channel
  106881. * @param uniform The uniform to set
  106882. * @param texture The render target texture containing the depth stencil texture to apply
  106883. */
  106884. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106885. /**
  106886. * Sets a texture to the webGL context from a postprocess
  106887. * @param channel defines the channel to use
  106888. * @param postProcess defines the source postprocess
  106889. */
  106890. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106891. /**
  106892. * Binds the output of the passed in post process to the texture channel specified
  106893. * @param channel The channel the texture should be bound to
  106894. * @param postProcess The post process which's output should be bound
  106895. */
  106896. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106897. /** @hidden */
  106898. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106899. protected _rebuildBuffers(): void;
  106900. /** @hidden */
  106901. _renderFrame(): void;
  106902. _renderLoop(): void;
  106903. /** @hidden */
  106904. _renderViews(): boolean;
  106905. /**
  106906. * Toggle full screen mode
  106907. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106908. */
  106909. switchFullscreen(requestPointerLock: boolean): void;
  106910. /**
  106911. * Enters full screen mode
  106912. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106913. */
  106914. enterFullscreen(requestPointerLock: boolean): void;
  106915. /**
  106916. * Exits full screen mode
  106917. */
  106918. exitFullscreen(): void;
  106919. /**
  106920. * Enters Pointerlock mode
  106921. */
  106922. enterPointerlock(): void;
  106923. /**
  106924. * Exits Pointerlock mode
  106925. */
  106926. exitPointerlock(): void;
  106927. /**
  106928. * Begin a new frame
  106929. */
  106930. beginFrame(): void;
  106931. /**
  106932. * Enf the current frame
  106933. */
  106934. endFrame(): void;
  106935. resize(): void;
  106936. /**
  106937. * Force a specific size of the canvas
  106938. * @param width defines the new canvas' width
  106939. * @param height defines the new canvas' height
  106940. */
  106941. setSize(width: number, height: number): void;
  106942. /**
  106943. * Updates a dynamic vertex buffer.
  106944. * @param vertexBuffer the vertex buffer to update
  106945. * @param data the data used to update the vertex buffer
  106946. * @param byteOffset the byte offset of the data
  106947. * @param byteLength the byte length of the data
  106948. */
  106949. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106950. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106951. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106952. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106953. _releaseTexture(texture: InternalTexture): void;
  106954. /**
  106955. * @hidden
  106956. * Rescales a texture
  106957. * @param source input texutre
  106958. * @param destination destination texture
  106959. * @param scene scene to use to render the resize
  106960. * @param internalFormat format to use when resizing
  106961. * @param onComplete callback to be called when resize has completed
  106962. */
  106963. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106964. /**
  106965. * Gets the current framerate
  106966. * @returns a number representing the framerate
  106967. */
  106968. getFps(): number;
  106969. /**
  106970. * Gets the time spent between current and previous frame
  106971. * @returns a number representing the delta time in ms
  106972. */
  106973. getDeltaTime(): number;
  106974. private _measureFps;
  106975. /** @hidden */
  106976. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106977. /**
  106978. * Update a dynamic index buffer
  106979. * @param indexBuffer defines the target index buffer
  106980. * @param indices defines the data to update
  106981. * @param offset defines the offset in the target index buffer where update should start
  106982. */
  106983. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106984. /**
  106985. * Updates the sample count of a render target texture
  106986. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106987. * @param texture defines the texture to update
  106988. * @param samples defines the sample count to set
  106989. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106990. */
  106991. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106992. /**
  106993. * Updates a depth texture Comparison Mode and Function.
  106994. * If the comparison Function is equal to 0, the mode will be set to none.
  106995. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106996. * @param texture The texture to set the comparison function for
  106997. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106998. */
  106999. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107000. /**
  107001. * Creates a webGL buffer to use with instanciation
  107002. * @param capacity defines the size of the buffer
  107003. * @returns the webGL buffer
  107004. */
  107005. createInstancesBuffer(capacity: number): DataBuffer;
  107006. /**
  107007. * Delete a webGL buffer used with instanciation
  107008. * @param buffer defines the webGL buffer to delete
  107009. */
  107010. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107011. private _clientWaitAsync;
  107012. /** @hidden */
  107013. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107014. /** @hidden */
  107015. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107016. dispose(): void;
  107017. private _disableTouchAction;
  107018. /**
  107019. * Display the loading screen
  107020. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107021. */
  107022. displayLoadingUI(): void;
  107023. /**
  107024. * Hide the loading screen
  107025. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107026. */
  107027. hideLoadingUI(): void;
  107028. /**
  107029. * Gets the current loading screen object
  107030. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107031. */
  107032. get loadingScreen(): ILoadingScreen;
  107033. /**
  107034. * Sets the current loading screen object
  107035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107036. */
  107037. set loadingScreen(loadingScreen: ILoadingScreen);
  107038. /**
  107039. * Sets the current loading screen text
  107040. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107041. */
  107042. set loadingUIText(text: string);
  107043. /**
  107044. * Sets the current loading screen background color
  107045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107046. */
  107047. set loadingUIBackgroundColor(color: string);
  107048. /** Pointerlock and fullscreen */
  107049. /**
  107050. * Ask the browser to promote the current element to pointerlock mode
  107051. * @param element defines the DOM element to promote
  107052. */
  107053. static _RequestPointerlock(element: HTMLElement): void;
  107054. /**
  107055. * Asks the browser to exit pointerlock mode
  107056. */
  107057. static _ExitPointerlock(): void;
  107058. /**
  107059. * Ask the browser to promote the current element to fullscreen rendering mode
  107060. * @param element defines the DOM element to promote
  107061. */
  107062. static _RequestFullscreen(element: HTMLElement): void;
  107063. /**
  107064. * Asks the browser to exit fullscreen mode
  107065. */
  107066. static _ExitFullscreen(): void;
  107067. }
  107068. }
  107069. declare module BABYLON {
  107070. /**
  107071. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107072. * during the life time of the application.
  107073. */
  107074. export class EngineStore {
  107075. /** Gets the list of created engines */
  107076. static Instances: Engine[];
  107077. /** @hidden */
  107078. static _LastCreatedScene: Nullable<Scene>;
  107079. /**
  107080. * Gets the latest created engine
  107081. */
  107082. static get LastCreatedEngine(): Nullable<Engine>;
  107083. /**
  107084. * Gets the latest created scene
  107085. */
  107086. static get LastCreatedScene(): Nullable<Scene>;
  107087. /**
  107088. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107089. * @ignorenaming
  107090. */
  107091. static UseFallbackTexture: boolean;
  107092. /**
  107093. * Texture content used if a texture cannot loaded
  107094. * @ignorenaming
  107095. */
  107096. static FallbackTexture: string;
  107097. }
  107098. }
  107099. declare module BABYLON {
  107100. /**
  107101. * Helper class that provides a small promise polyfill
  107102. */
  107103. export class PromisePolyfill {
  107104. /**
  107105. * Static function used to check if the polyfill is required
  107106. * If this is the case then the function will inject the polyfill to window.Promise
  107107. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107108. */
  107109. static Apply(force?: boolean): void;
  107110. }
  107111. }
  107112. declare module BABYLON {
  107113. /**
  107114. * Interface for screenshot methods with describe argument called `size` as object with options
  107115. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107116. */
  107117. export interface IScreenshotSize {
  107118. /**
  107119. * number in pixels for canvas height
  107120. */
  107121. height?: number;
  107122. /**
  107123. * multiplier allowing render at a higher or lower resolution
  107124. * If value is defined then height and width will be ignored and taken from camera
  107125. */
  107126. precision?: number;
  107127. /**
  107128. * number in pixels for canvas width
  107129. */
  107130. width?: number;
  107131. }
  107132. }
  107133. declare module BABYLON {
  107134. interface IColor4Like {
  107135. r: float;
  107136. g: float;
  107137. b: float;
  107138. a: float;
  107139. }
  107140. /**
  107141. * Class containing a set of static utilities functions
  107142. */
  107143. export class Tools {
  107144. /**
  107145. * Gets or sets the base URL to use to load assets
  107146. */
  107147. static get BaseUrl(): string;
  107148. static set BaseUrl(value: string);
  107149. /**
  107150. * Enable/Disable Custom HTTP Request Headers globally.
  107151. * default = false
  107152. * @see CustomRequestHeaders
  107153. */
  107154. static UseCustomRequestHeaders: boolean;
  107155. /**
  107156. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107157. * i.e. when loading files, where the server/service expects an Authorization header
  107158. */
  107159. static CustomRequestHeaders: {
  107160. [key: string]: string;
  107161. };
  107162. /**
  107163. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107164. */
  107165. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107166. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107167. /**
  107168. * Default behaviour for cors in the application.
  107169. * It can be a string if the expected behavior is identical in the entire app.
  107170. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107171. */
  107172. static CorsBehavior: string | ((url: string | string[]) => string);
  107173. /**
  107174. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107175. * @ignorenaming
  107176. */
  107177. static get UseFallbackTexture(): boolean;
  107178. static set UseFallbackTexture(value: boolean);
  107179. /**
  107180. * Use this object to register external classes like custom textures or material
  107181. * to allow the laoders to instantiate them
  107182. */
  107183. static get RegisteredExternalClasses(): {
  107184. [key: string]: Object;
  107185. };
  107186. static set RegisteredExternalClasses(classes: {
  107187. [key: string]: Object;
  107188. });
  107189. /**
  107190. * Texture content used if a texture cannot loaded
  107191. * @ignorenaming
  107192. */
  107193. static get fallbackTexture(): string;
  107194. static set fallbackTexture(value: string);
  107195. /**
  107196. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107197. * @param u defines the coordinate on X axis
  107198. * @param v defines the coordinate on Y axis
  107199. * @param width defines the width of the source data
  107200. * @param height defines the height of the source data
  107201. * @param pixels defines the source byte array
  107202. * @param color defines the output color
  107203. */
  107204. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107205. /**
  107206. * Interpolates between a and b via alpha
  107207. * @param a The lower value (returned when alpha = 0)
  107208. * @param b The upper value (returned when alpha = 1)
  107209. * @param alpha The interpolation-factor
  107210. * @return The mixed value
  107211. */
  107212. static Mix(a: number, b: number, alpha: number): number;
  107213. /**
  107214. * Tries to instantiate a new object from a given class name
  107215. * @param className defines the class name to instantiate
  107216. * @returns the new object or null if the system was not able to do the instantiation
  107217. */
  107218. static Instantiate(className: string): any;
  107219. /**
  107220. * Provides a slice function that will work even on IE
  107221. * @param data defines the array to slice
  107222. * @param start defines the start of the data (optional)
  107223. * @param end defines the end of the data (optional)
  107224. * @returns the new sliced array
  107225. */
  107226. static Slice<T>(data: T, start?: number, end?: number): T;
  107227. /**
  107228. * Polyfill for setImmediate
  107229. * @param action defines the action to execute after the current execution block
  107230. */
  107231. static SetImmediate(action: () => void): void;
  107232. /**
  107233. * Function indicating if a number is an exponent of 2
  107234. * @param value defines the value to test
  107235. * @returns true if the value is an exponent of 2
  107236. */
  107237. static IsExponentOfTwo(value: number): boolean;
  107238. private static _tmpFloatArray;
  107239. /**
  107240. * Returns the nearest 32-bit single precision float representation of a Number
  107241. * @param value A Number. If the parameter is of a different type, it will get converted
  107242. * to a number or to NaN if it cannot be converted
  107243. * @returns number
  107244. */
  107245. static FloatRound(value: number): number;
  107246. /**
  107247. * Extracts the filename from a path
  107248. * @param path defines the path to use
  107249. * @returns the filename
  107250. */
  107251. static GetFilename(path: string): string;
  107252. /**
  107253. * Extracts the "folder" part of a path (everything before the filename).
  107254. * @param uri The URI to extract the info from
  107255. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107256. * @returns The "folder" part of the path
  107257. */
  107258. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107259. /**
  107260. * Extracts text content from a DOM element hierarchy
  107261. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107262. */
  107263. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107264. /**
  107265. * Convert an angle in radians to degrees
  107266. * @param angle defines the angle to convert
  107267. * @returns the angle in degrees
  107268. */
  107269. static ToDegrees(angle: number): number;
  107270. /**
  107271. * Convert an angle in degrees to radians
  107272. * @param angle defines the angle to convert
  107273. * @returns the angle in radians
  107274. */
  107275. static ToRadians(angle: number): number;
  107276. /**
  107277. * Returns an array if obj is not an array
  107278. * @param obj defines the object to evaluate as an array
  107279. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107280. * @returns either obj directly if obj is an array or a new array containing obj
  107281. */
  107282. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107283. /**
  107284. * Gets the pointer prefix to use
  107285. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107286. */
  107287. static GetPointerPrefix(): string;
  107288. /**
  107289. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107290. * @param url define the url we are trying
  107291. * @param element define the dom element where to configure the cors policy
  107292. */
  107293. static SetCorsBehavior(url: string | string[], element: {
  107294. crossOrigin: string | null;
  107295. }): void;
  107296. /**
  107297. * Removes unwanted characters from an url
  107298. * @param url defines the url to clean
  107299. * @returns the cleaned url
  107300. */
  107301. static CleanUrl(url: string): string;
  107302. /**
  107303. * Gets or sets a function used to pre-process url before using them to load assets
  107304. */
  107305. static get PreprocessUrl(): (url: string) => string;
  107306. static set PreprocessUrl(processor: (url: string) => string);
  107307. /**
  107308. * Loads an image as an HTMLImageElement.
  107309. * @param input url string, ArrayBuffer, or Blob to load
  107310. * @param onLoad callback called when the image successfully loads
  107311. * @param onError callback called when the image fails to load
  107312. * @param offlineProvider offline provider for caching
  107313. * @param mimeType optional mime type
  107314. * @returns the HTMLImageElement of the loaded image
  107315. */
  107316. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107317. /**
  107318. * Loads a file from a url
  107319. * @param url url string, ArrayBuffer, or Blob to load
  107320. * @param onSuccess callback called when the file successfully loads
  107321. * @param onProgress callback called while file is loading (if the server supports this mode)
  107322. * @param offlineProvider defines the offline provider for caching
  107323. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107324. * @param onError callback called when the file fails to load
  107325. * @returns a file request object
  107326. */
  107327. 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;
  107328. /**
  107329. * Loads a file from a url
  107330. * @param url the file url to load
  107331. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107332. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107333. */
  107334. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107335. /**
  107336. * Load a script (identified by an url). When the url returns, the
  107337. * content of this file is added into a new script element, attached to the DOM (body element)
  107338. * @param scriptUrl defines the url of the script to laod
  107339. * @param onSuccess defines the callback called when the script is loaded
  107340. * @param onError defines the callback to call if an error occurs
  107341. * @param scriptId defines the id of the script element
  107342. */
  107343. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107344. /**
  107345. * Load an asynchronous script (identified by an url). When the url returns, the
  107346. * content of this file is added into a new script element, attached to the DOM (body element)
  107347. * @param scriptUrl defines the url of the script to laod
  107348. * @param scriptId defines the id of the script element
  107349. * @returns a promise request object
  107350. */
  107351. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107352. /**
  107353. * Loads a file from a blob
  107354. * @param fileToLoad defines the blob to use
  107355. * @param callback defines the callback to call when data is loaded
  107356. * @param progressCallback defines the callback to call during loading process
  107357. * @returns a file request object
  107358. */
  107359. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107360. /**
  107361. * Reads a file from a File object
  107362. * @param file defines the file to load
  107363. * @param onSuccess defines the callback to call when data is loaded
  107364. * @param onProgress defines the callback to call during loading process
  107365. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107366. * @param onError defines the callback to call when an error occurs
  107367. * @returns a file request object
  107368. */
  107369. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107370. /**
  107371. * Creates a data url from a given string content
  107372. * @param content defines the content to convert
  107373. * @returns the new data url link
  107374. */
  107375. static FileAsURL(content: string): string;
  107376. /**
  107377. * Format the given number to a specific decimal format
  107378. * @param value defines the number to format
  107379. * @param decimals defines the number of decimals to use
  107380. * @returns the formatted string
  107381. */
  107382. static Format(value: number, decimals?: number): string;
  107383. /**
  107384. * Tries to copy an object by duplicating every property
  107385. * @param source defines the source object
  107386. * @param destination defines the target object
  107387. * @param doNotCopyList defines a list of properties to avoid
  107388. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107389. */
  107390. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107391. /**
  107392. * Gets a boolean indicating if the given object has no own property
  107393. * @param obj defines the object to test
  107394. * @returns true if object has no own property
  107395. */
  107396. static IsEmpty(obj: any): boolean;
  107397. /**
  107398. * Function used to register events at window level
  107399. * @param windowElement defines the Window object to use
  107400. * @param events defines the events to register
  107401. */
  107402. static RegisterTopRootEvents(windowElement: Window, events: {
  107403. name: string;
  107404. handler: Nullable<(e: FocusEvent) => any>;
  107405. }[]): void;
  107406. /**
  107407. * Function used to unregister events from window level
  107408. * @param windowElement defines the Window object to use
  107409. * @param events defines the events to unregister
  107410. */
  107411. static UnregisterTopRootEvents(windowElement: Window, events: {
  107412. name: string;
  107413. handler: Nullable<(e: FocusEvent) => any>;
  107414. }[]): void;
  107415. /**
  107416. * @ignore
  107417. */
  107418. static _ScreenshotCanvas: HTMLCanvasElement;
  107419. /**
  107420. * Dumps the current bound framebuffer
  107421. * @param width defines the rendering width
  107422. * @param height defines the rendering height
  107423. * @param engine defines the hosting engine
  107424. * @param successCallback defines the callback triggered once the data are available
  107425. * @param mimeType defines the mime type of the result
  107426. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107427. */
  107428. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107429. /**
  107430. * Converts the canvas data to blob.
  107431. * This acts as a polyfill for browsers not supporting the to blob function.
  107432. * @param canvas Defines the canvas to extract the data from
  107433. * @param successCallback Defines the callback triggered once the data are available
  107434. * @param mimeType Defines the mime type of the result
  107435. */
  107436. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107437. /**
  107438. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107439. * @param successCallback defines the callback triggered once the data are available
  107440. * @param mimeType defines the mime type of the result
  107441. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107442. */
  107443. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107444. /**
  107445. * Downloads a blob in the browser
  107446. * @param blob defines the blob to download
  107447. * @param fileName defines the name of the downloaded file
  107448. */
  107449. static Download(blob: Blob, fileName: string): void;
  107450. /**
  107451. * Captures a screenshot of the current rendering
  107452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107453. * @param engine defines the rendering engine
  107454. * @param camera defines the source camera
  107455. * @param size This parameter can be set to a single number or to an object with the
  107456. * following (optional) properties: precision, width, height. If a single number is passed,
  107457. * it will be used for both width and height. If an object is passed, the screenshot size
  107458. * will be derived from the parameters. The precision property is a multiplier allowing
  107459. * rendering at a higher or lower resolution
  107460. * @param successCallback defines the callback receives a single parameter which contains the
  107461. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107462. * src parameter of an <img> to display it
  107463. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107464. * Check your browser for supported MIME types
  107465. */
  107466. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107467. /**
  107468. * Captures a screenshot of the current rendering
  107469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107470. * @param engine defines the rendering engine
  107471. * @param camera defines the source camera
  107472. * @param size This parameter can be set to a single number or to an object with the
  107473. * following (optional) properties: precision, width, height. If a single number is passed,
  107474. * it will be used for both width and height. If an object is passed, the screenshot size
  107475. * will be derived from the parameters. The precision property is a multiplier allowing
  107476. * rendering at a higher or lower resolution
  107477. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107478. * Check your browser for supported MIME types
  107479. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107480. * to the src parameter of an <img> to display it
  107481. */
  107482. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107483. /**
  107484. * Generates an image screenshot from the specified camera.
  107485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107486. * @param engine The engine to use for rendering
  107487. * @param camera The camera to use for rendering
  107488. * @param size This parameter can be set to a single number or to an object with the
  107489. * following (optional) properties: precision, width, height. If a single number is passed,
  107490. * it will be used for both width and height. If an object is passed, the screenshot size
  107491. * will be derived from the parameters. The precision property is a multiplier allowing
  107492. * rendering at a higher or lower resolution
  107493. * @param successCallback The callback receives a single parameter which contains the
  107494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107495. * src parameter of an <img> to display it
  107496. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107497. * Check your browser for supported MIME types
  107498. * @param samples Texture samples (default: 1)
  107499. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107500. * @param fileName A name for for the downloaded file.
  107501. */
  107502. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107503. /**
  107504. * Generates an image screenshot from the specified camera.
  107505. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107506. * @param engine The engine to use for rendering
  107507. * @param camera The camera to use for rendering
  107508. * @param size This parameter can be set to a single number or to an object with the
  107509. * following (optional) properties: precision, width, height. If a single number is passed,
  107510. * it will be used for both width and height. If an object is passed, the screenshot size
  107511. * will be derived from the parameters. The precision property is a multiplier allowing
  107512. * rendering at a higher or lower resolution
  107513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107514. * Check your browser for supported MIME types
  107515. * @param samples Texture samples (default: 1)
  107516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107517. * @param fileName A name for for the downloaded file.
  107518. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107519. * to the src parameter of an <img> to display it
  107520. */
  107521. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107522. /**
  107523. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107524. * Be aware Math.random() could cause collisions, but:
  107525. * "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"
  107526. * @returns a pseudo random id
  107527. */
  107528. static RandomId(): string;
  107529. /**
  107530. * Test if the given uri is a base64 string
  107531. * @param uri The uri to test
  107532. * @return True if the uri is a base64 string or false otherwise
  107533. */
  107534. static IsBase64(uri: string): boolean;
  107535. /**
  107536. * Decode the given base64 uri.
  107537. * @param uri The uri to decode
  107538. * @return The decoded base64 data.
  107539. */
  107540. static DecodeBase64(uri: string): ArrayBuffer;
  107541. /**
  107542. * Gets the absolute url.
  107543. * @param url the input url
  107544. * @return the absolute url
  107545. */
  107546. static GetAbsoluteUrl(url: string): string;
  107547. /**
  107548. * No log
  107549. */
  107550. static readonly NoneLogLevel: number;
  107551. /**
  107552. * Only message logs
  107553. */
  107554. static readonly MessageLogLevel: number;
  107555. /**
  107556. * Only warning logs
  107557. */
  107558. static readonly WarningLogLevel: number;
  107559. /**
  107560. * Only error logs
  107561. */
  107562. static readonly ErrorLogLevel: number;
  107563. /**
  107564. * All logs
  107565. */
  107566. static readonly AllLogLevel: number;
  107567. /**
  107568. * Gets a value indicating the number of loading errors
  107569. * @ignorenaming
  107570. */
  107571. static get errorsCount(): number;
  107572. /**
  107573. * Callback called when a new log is added
  107574. */
  107575. static OnNewCacheEntry: (entry: string) => void;
  107576. /**
  107577. * Log a message to the console
  107578. * @param message defines the message to log
  107579. */
  107580. static Log(message: string): void;
  107581. /**
  107582. * Write a warning message to the console
  107583. * @param message defines the message to log
  107584. */
  107585. static Warn(message: string): void;
  107586. /**
  107587. * Write an error message to the console
  107588. * @param message defines the message to log
  107589. */
  107590. static Error(message: string): void;
  107591. /**
  107592. * Gets current log cache (list of logs)
  107593. */
  107594. static get LogCache(): string;
  107595. /**
  107596. * Clears the log cache
  107597. */
  107598. static ClearLogCache(): void;
  107599. /**
  107600. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107601. */
  107602. static set LogLevels(level: number);
  107603. /**
  107604. * Checks if the window object exists
  107605. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107606. */
  107607. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107608. /**
  107609. * No performance log
  107610. */
  107611. static readonly PerformanceNoneLogLevel: number;
  107612. /**
  107613. * Use user marks to log performance
  107614. */
  107615. static readonly PerformanceUserMarkLogLevel: number;
  107616. /**
  107617. * Log performance to the console
  107618. */
  107619. static readonly PerformanceConsoleLogLevel: number;
  107620. private static _performance;
  107621. /**
  107622. * Sets the current performance log level
  107623. */
  107624. static set PerformanceLogLevel(level: number);
  107625. private static _StartPerformanceCounterDisabled;
  107626. private static _EndPerformanceCounterDisabled;
  107627. private static _StartUserMark;
  107628. private static _EndUserMark;
  107629. private static _StartPerformanceConsole;
  107630. private static _EndPerformanceConsole;
  107631. /**
  107632. * Starts a performance counter
  107633. */
  107634. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107635. /**
  107636. * Ends a specific performance coutner
  107637. */
  107638. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107639. /**
  107640. * Gets either window.performance.now() if supported or Date.now() else
  107641. */
  107642. static get Now(): number;
  107643. /**
  107644. * This method will return the name of the class used to create the instance of the given object.
  107645. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107646. * @param object the object to get the class name from
  107647. * @param isType defines if the object is actually a type
  107648. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107649. */
  107650. static GetClassName(object: any, isType?: boolean): string;
  107651. /**
  107652. * Gets the first element of an array satisfying a given predicate
  107653. * @param array defines the array to browse
  107654. * @param predicate defines the predicate to use
  107655. * @returns null if not found or the element
  107656. */
  107657. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107658. /**
  107659. * This method will return the name of the full name of the class, including its owning module (if any).
  107660. * 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).
  107661. * @param object the object to get the class name from
  107662. * @param isType defines if the object is actually a type
  107663. * @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.
  107664. * @ignorenaming
  107665. */
  107666. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107667. /**
  107668. * Returns a promise that resolves after the given amount of time.
  107669. * @param delay Number of milliseconds to delay
  107670. * @returns Promise that resolves after the given amount of time
  107671. */
  107672. static DelayAsync(delay: number): Promise<void>;
  107673. /**
  107674. * Utility function to detect if the current user agent is Safari
  107675. * @returns whether or not the current user agent is safari
  107676. */
  107677. static IsSafari(): boolean;
  107678. }
  107679. /**
  107680. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107681. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107682. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107683. * @param name The name of the class, case should be preserved
  107684. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107685. */
  107686. export function className(name: string, module?: string): (target: Object) => void;
  107687. /**
  107688. * An implementation of a loop for asynchronous functions.
  107689. */
  107690. export class AsyncLoop {
  107691. /**
  107692. * Defines the number of iterations for the loop
  107693. */
  107694. iterations: number;
  107695. /**
  107696. * Defines the current index of the loop.
  107697. */
  107698. index: number;
  107699. private _done;
  107700. private _fn;
  107701. private _successCallback;
  107702. /**
  107703. * Constructor.
  107704. * @param iterations the number of iterations.
  107705. * @param func the function to run each iteration
  107706. * @param successCallback the callback that will be called upon succesful execution
  107707. * @param offset starting offset.
  107708. */
  107709. constructor(
  107710. /**
  107711. * Defines the number of iterations for the loop
  107712. */
  107713. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107714. /**
  107715. * Execute the next iteration. Must be called after the last iteration was finished.
  107716. */
  107717. executeNext(): void;
  107718. /**
  107719. * Break the loop and run the success callback.
  107720. */
  107721. breakLoop(): void;
  107722. /**
  107723. * Create and run an async loop.
  107724. * @param iterations the number of iterations.
  107725. * @param fn the function to run each iteration
  107726. * @param successCallback the callback that will be called upon succesful execution
  107727. * @param offset starting offset.
  107728. * @returns the created async loop object
  107729. */
  107730. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107731. /**
  107732. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107733. * @param iterations total number of iterations
  107734. * @param syncedIterations number of synchronous iterations in each async iteration.
  107735. * @param fn the function to call each iteration.
  107736. * @param callback a success call back that will be called when iterating stops.
  107737. * @param breakFunction a break condition (optional)
  107738. * @param timeout timeout settings for the setTimeout function. default - 0.
  107739. * @returns the created async loop object
  107740. */
  107741. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107742. }
  107743. }
  107744. declare module BABYLON {
  107745. /**
  107746. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107747. * The underlying implementation relies on an associative array to ensure the best performances.
  107748. * The value can be anything including 'null' but except 'undefined'
  107749. */
  107750. export class StringDictionary<T> {
  107751. /**
  107752. * This will clear this dictionary and copy the content from the 'source' one.
  107753. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107754. * @param source the dictionary to take the content from and copy to this dictionary
  107755. */
  107756. copyFrom(source: StringDictionary<T>): void;
  107757. /**
  107758. * Get a value based from its key
  107759. * @param key the given key to get the matching value from
  107760. * @return the value if found, otherwise undefined is returned
  107761. */
  107762. get(key: string): T | undefined;
  107763. /**
  107764. * Get a value from its key or add it if it doesn't exist.
  107765. * This method will ensure you that a given key/data will be present in the dictionary.
  107766. * @param key the given key to get the matching value from
  107767. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107768. * The factory will only be invoked if there's no data for the given key.
  107769. * @return the value corresponding to the key.
  107770. */
  107771. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107772. /**
  107773. * Get a value from its key if present in the dictionary otherwise add it
  107774. * @param key the key to get the value from
  107775. * @param val if there's no such key/value pair in the dictionary add it with this value
  107776. * @return the value corresponding to the key
  107777. */
  107778. getOrAdd(key: string, val: T): T;
  107779. /**
  107780. * Check if there's a given key in the dictionary
  107781. * @param key the key to check for
  107782. * @return true if the key is present, false otherwise
  107783. */
  107784. contains(key: string): boolean;
  107785. /**
  107786. * Add a new key and its corresponding value
  107787. * @param key the key to add
  107788. * @param value the value corresponding to the key
  107789. * @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
  107790. */
  107791. add(key: string, value: T): boolean;
  107792. /**
  107793. * Update a specific value associated to a key
  107794. * @param key defines the key to use
  107795. * @param value defines the value to store
  107796. * @returns true if the value was updated (or false if the key was not found)
  107797. */
  107798. set(key: string, value: T): boolean;
  107799. /**
  107800. * Get the element of the given key and remove it from the dictionary
  107801. * @param key defines the key to search
  107802. * @returns the value associated with the key or null if not found
  107803. */
  107804. getAndRemove(key: string): Nullable<T>;
  107805. /**
  107806. * Remove a key/value from the dictionary.
  107807. * @param key the key to remove
  107808. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107809. */
  107810. remove(key: string): boolean;
  107811. /**
  107812. * Clear the whole content of the dictionary
  107813. */
  107814. clear(): void;
  107815. /**
  107816. * Gets the current count
  107817. */
  107818. get count(): number;
  107819. /**
  107820. * Execute a callback on each key/val of the dictionary.
  107821. * Note that you can remove any element in this dictionary in the callback implementation
  107822. * @param callback the callback to execute on a given key/value pair
  107823. */
  107824. forEach(callback: (key: string, val: T) => void): void;
  107825. /**
  107826. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107827. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107828. * Note that you can remove any element in this dictionary in the callback implementation
  107829. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107830. * @returns the first item
  107831. */
  107832. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107833. private _count;
  107834. private _data;
  107835. }
  107836. }
  107837. declare module BABYLON {
  107838. /** @hidden */
  107839. export interface ICollisionCoordinator {
  107840. createCollider(): Collider;
  107841. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107842. init(scene: Scene): void;
  107843. }
  107844. /** @hidden */
  107845. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107846. private _scene;
  107847. private _scaledPosition;
  107848. private _scaledVelocity;
  107849. private _finalPosition;
  107850. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107851. createCollider(): Collider;
  107852. init(scene: Scene): void;
  107853. private _collideWithWorld;
  107854. }
  107855. }
  107856. declare module BABYLON {
  107857. /**
  107858. * Class used to manage all inputs for the scene.
  107859. */
  107860. export class InputManager {
  107861. /** The distance in pixel that you have to move to prevent some events */
  107862. static DragMovementThreshold: number;
  107863. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107864. static LongPressDelay: number;
  107865. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107866. static DoubleClickDelay: number;
  107867. /** If you need to check double click without raising a single click at first click, enable this flag */
  107868. static ExclusiveDoubleClickMode: boolean;
  107869. private _wheelEventName;
  107870. private _onPointerMove;
  107871. private _onPointerDown;
  107872. private _onPointerUp;
  107873. private _initClickEvent;
  107874. private _initActionManager;
  107875. private _delayedSimpleClick;
  107876. private _delayedSimpleClickTimeout;
  107877. private _previousDelayedSimpleClickTimeout;
  107878. private _meshPickProceed;
  107879. private _previousButtonPressed;
  107880. private _currentPickResult;
  107881. private _previousPickResult;
  107882. private _totalPointersPressed;
  107883. private _doubleClickOccured;
  107884. private _pointerOverMesh;
  107885. private _pickedDownMesh;
  107886. private _pickedUpMesh;
  107887. private _pointerX;
  107888. private _pointerY;
  107889. private _unTranslatedPointerX;
  107890. private _unTranslatedPointerY;
  107891. private _startingPointerPosition;
  107892. private _previousStartingPointerPosition;
  107893. private _startingPointerTime;
  107894. private _previousStartingPointerTime;
  107895. private _pointerCaptures;
  107896. private _onKeyDown;
  107897. private _onKeyUp;
  107898. private _onCanvasFocusObserver;
  107899. private _onCanvasBlurObserver;
  107900. private _scene;
  107901. /**
  107902. * Creates a new InputManager
  107903. * @param scene defines the hosting scene
  107904. */
  107905. constructor(scene: Scene);
  107906. /**
  107907. * Gets the mesh that is currently under the pointer
  107908. */
  107909. get meshUnderPointer(): Nullable<AbstractMesh>;
  107910. /**
  107911. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107912. */
  107913. get unTranslatedPointer(): Vector2;
  107914. /**
  107915. * Gets or sets the current on-screen X position of the pointer
  107916. */
  107917. get pointerX(): number;
  107918. set pointerX(value: number);
  107919. /**
  107920. * Gets or sets the current on-screen Y position of the pointer
  107921. */
  107922. get pointerY(): number;
  107923. set pointerY(value: number);
  107924. private _updatePointerPosition;
  107925. private _processPointerMove;
  107926. private _setRayOnPointerInfo;
  107927. private _checkPrePointerObservable;
  107928. /**
  107929. * Use this method to simulate a pointer move on a mesh
  107930. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107931. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107932. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107933. */
  107934. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107935. /**
  107936. * Use this method to simulate a pointer down on a mesh
  107937. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107938. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107939. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107940. */
  107941. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107942. private _processPointerDown;
  107943. /** @hidden */
  107944. _isPointerSwiping(): boolean;
  107945. /**
  107946. * Use this method to simulate a pointer up on a mesh
  107947. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107948. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107949. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107950. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107951. */
  107952. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107953. private _processPointerUp;
  107954. /**
  107955. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107956. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107957. * @returns true if the pointer was captured
  107958. */
  107959. isPointerCaptured(pointerId?: number): boolean;
  107960. /**
  107961. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107962. * @param attachUp defines if you want to attach events to pointerup
  107963. * @param attachDown defines if you want to attach events to pointerdown
  107964. * @param attachMove defines if you want to attach events to pointermove
  107965. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107966. */
  107967. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107968. /**
  107969. * Detaches all event handlers
  107970. */
  107971. detachControl(): void;
  107972. /**
  107973. * Force the value of meshUnderPointer
  107974. * @param mesh defines the mesh to use
  107975. */
  107976. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107977. /**
  107978. * Gets the mesh under the pointer
  107979. * @returns a Mesh or null if no mesh is under the pointer
  107980. */
  107981. getPointerOverMesh(): Nullable<AbstractMesh>;
  107982. }
  107983. }
  107984. declare module BABYLON {
  107985. /**
  107986. * Helper class used to generate session unique ID
  107987. */
  107988. export class UniqueIdGenerator {
  107989. private static _UniqueIdCounter;
  107990. /**
  107991. * Gets an unique (relatively to the current scene) Id
  107992. */
  107993. static get UniqueId(): number;
  107994. }
  107995. }
  107996. declare module BABYLON {
  107997. /**
  107998. * This class defines the direct association between an animation and a target
  107999. */
  108000. export class TargetedAnimation {
  108001. /**
  108002. * Animation to perform
  108003. */
  108004. animation: Animation;
  108005. /**
  108006. * Target to animate
  108007. */
  108008. target: any;
  108009. /**
  108010. * Serialize the object
  108011. * @returns the JSON object representing the current entity
  108012. */
  108013. serialize(): any;
  108014. }
  108015. /**
  108016. * Use this class to create coordinated animations on multiple targets
  108017. */
  108018. export class AnimationGroup implements IDisposable {
  108019. /** The name of the animation group */
  108020. name: string;
  108021. private _scene;
  108022. private _targetedAnimations;
  108023. private _animatables;
  108024. private _from;
  108025. private _to;
  108026. private _isStarted;
  108027. private _isPaused;
  108028. private _speedRatio;
  108029. private _loopAnimation;
  108030. /**
  108031. * Gets or sets the unique id of the node
  108032. */
  108033. uniqueId: number;
  108034. /**
  108035. * This observable will notify when one animation have ended
  108036. */
  108037. onAnimationEndObservable: Observable<TargetedAnimation>;
  108038. /**
  108039. * Observer raised when one animation loops
  108040. */
  108041. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108042. /**
  108043. * Observer raised when all animations have looped
  108044. */
  108045. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108046. /**
  108047. * This observable will notify when all animations have ended.
  108048. */
  108049. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108050. /**
  108051. * This observable will notify when all animations have paused.
  108052. */
  108053. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108054. /**
  108055. * This observable will notify when all animations are playing.
  108056. */
  108057. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108058. /**
  108059. * Gets the first frame
  108060. */
  108061. get from(): number;
  108062. /**
  108063. * Gets the last frame
  108064. */
  108065. get to(): number;
  108066. /**
  108067. * Define if the animations are started
  108068. */
  108069. get isStarted(): boolean;
  108070. /**
  108071. * Gets a value indicating that the current group is playing
  108072. */
  108073. get isPlaying(): boolean;
  108074. /**
  108075. * Gets or sets the speed ratio to use for all animations
  108076. */
  108077. get speedRatio(): number;
  108078. /**
  108079. * Gets or sets the speed ratio to use for all animations
  108080. */
  108081. set speedRatio(value: number);
  108082. /**
  108083. * Gets or sets if all animations should loop or not
  108084. */
  108085. get loopAnimation(): boolean;
  108086. set loopAnimation(value: boolean);
  108087. /**
  108088. * Gets the targeted animations for this animation group
  108089. */
  108090. get targetedAnimations(): Array<TargetedAnimation>;
  108091. /**
  108092. * returning the list of animatables controlled by this animation group.
  108093. */
  108094. get animatables(): Array<Animatable>;
  108095. /**
  108096. * Instantiates a new Animation Group.
  108097. * This helps managing several animations at once.
  108098. * @see http://doc.babylonjs.com/how_to/group
  108099. * @param name Defines the name of the group
  108100. * @param scene Defines the scene the group belongs to
  108101. */
  108102. constructor(
  108103. /** The name of the animation group */
  108104. name: string, scene?: Nullable<Scene>);
  108105. /**
  108106. * Add an animation (with its target) in the group
  108107. * @param animation defines the animation we want to add
  108108. * @param target defines the target of the animation
  108109. * @returns the TargetedAnimation object
  108110. */
  108111. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108112. /**
  108113. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108114. * It can add constant keys at begin or end
  108115. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108116. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108117. * @returns the animation group
  108118. */
  108119. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108120. private _animationLoopCount;
  108121. private _animationLoopFlags;
  108122. private _processLoop;
  108123. /**
  108124. * Start all animations on given targets
  108125. * @param loop defines if animations must loop
  108126. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108127. * @param from defines the from key (optional)
  108128. * @param to defines the to key (optional)
  108129. * @returns the current animation group
  108130. */
  108131. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108132. /**
  108133. * Pause all animations
  108134. * @returns the animation group
  108135. */
  108136. pause(): AnimationGroup;
  108137. /**
  108138. * Play all animations to initial state
  108139. * This function will start() the animations if they were not started or will restart() them if they were paused
  108140. * @param loop defines if animations must loop
  108141. * @returns the animation group
  108142. */
  108143. play(loop?: boolean): AnimationGroup;
  108144. /**
  108145. * Reset all animations to initial state
  108146. * @returns the animation group
  108147. */
  108148. reset(): AnimationGroup;
  108149. /**
  108150. * Restart animations from key 0
  108151. * @returns the animation group
  108152. */
  108153. restart(): AnimationGroup;
  108154. /**
  108155. * Stop all animations
  108156. * @returns the animation group
  108157. */
  108158. stop(): AnimationGroup;
  108159. /**
  108160. * Set animation weight for all animatables
  108161. * @param weight defines the weight to use
  108162. * @return the animationGroup
  108163. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108164. */
  108165. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108166. /**
  108167. * Synchronize and normalize all animatables with a source animatable
  108168. * @param root defines the root animatable to synchronize with
  108169. * @return the animationGroup
  108170. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108171. */
  108172. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108173. /**
  108174. * Goes to a specific frame in this animation group
  108175. * @param frame the frame number to go to
  108176. * @return the animationGroup
  108177. */
  108178. goToFrame(frame: number): AnimationGroup;
  108179. /**
  108180. * Dispose all associated resources
  108181. */
  108182. dispose(): void;
  108183. private _checkAnimationGroupEnded;
  108184. /**
  108185. * Clone the current animation group and returns a copy
  108186. * @param newName defines the name of the new group
  108187. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108188. * @returns the new aniamtion group
  108189. */
  108190. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108191. /**
  108192. * Serializes the animationGroup to an object
  108193. * @returns Serialized object
  108194. */
  108195. serialize(): any;
  108196. /**
  108197. * Returns a new AnimationGroup object parsed from the source provided.
  108198. * @param parsedAnimationGroup defines the source
  108199. * @param scene defines the scene that will receive the animationGroup
  108200. * @returns a new AnimationGroup
  108201. */
  108202. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108203. /**
  108204. * Returns the string "AnimationGroup"
  108205. * @returns "AnimationGroup"
  108206. */
  108207. getClassName(): string;
  108208. /**
  108209. * Creates a detailled string about the object
  108210. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108211. * @returns a string representing the object
  108212. */
  108213. toString(fullDetails?: boolean): string;
  108214. }
  108215. }
  108216. declare module BABYLON {
  108217. /**
  108218. * Define an interface for all classes that will hold resources
  108219. */
  108220. export interface IDisposable {
  108221. /**
  108222. * Releases all held resources
  108223. */
  108224. dispose(): void;
  108225. }
  108226. /** Interface defining initialization parameters for Scene class */
  108227. export interface SceneOptions {
  108228. /**
  108229. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108230. * It will improve performance when the number of geometries becomes important.
  108231. */
  108232. useGeometryUniqueIdsMap?: boolean;
  108233. /**
  108234. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108235. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108236. */
  108237. useMaterialMeshMap?: boolean;
  108238. /**
  108239. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108240. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108241. */
  108242. useClonedMeshMap?: boolean;
  108243. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108244. virtual?: boolean;
  108245. }
  108246. /**
  108247. * Represents a scene to be rendered by the engine.
  108248. * @see http://doc.babylonjs.com/features/scene
  108249. */
  108250. export class Scene extends AbstractScene implements IAnimatable {
  108251. /** The fog is deactivated */
  108252. static readonly FOGMODE_NONE: number;
  108253. /** The fog density is following an exponential function */
  108254. static readonly FOGMODE_EXP: number;
  108255. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108256. static readonly FOGMODE_EXP2: number;
  108257. /** The fog density is following a linear function. */
  108258. static readonly FOGMODE_LINEAR: number;
  108259. /**
  108260. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108261. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108262. */
  108263. static MinDeltaTime: number;
  108264. /**
  108265. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108266. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108267. */
  108268. static MaxDeltaTime: number;
  108269. /**
  108270. * Factory used to create the default material.
  108271. * @param name The name of the material to create
  108272. * @param scene The scene to create the material for
  108273. * @returns The default material
  108274. */
  108275. static DefaultMaterialFactory(scene: Scene): Material;
  108276. /**
  108277. * Factory used to create the a collision coordinator.
  108278. * @returns The collision coordinator
  108279. */
  108280. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108281. /** @hidden */
  108282. _inputManager: InputManager;
  108283. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108284. cameraToUseForPointers: Nullable<Camera>;
  108285. /** @hidden */
  108286. readonly _isScene: boolean;
  108287. /** @hidden */
  108288. _blockEntityCollection: boolean;
  108289. /**
  108290. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108291. */
  108292. autoClear: boolean;
  108293. /**
  108294. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108295. */
  108296. autoClearDepthAndStencil: boolean;
  108297. /**
  108298. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108299. */
  108300. clearColor: Color4;
  108301. /**
  108302. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108303. */
  108304. ambientColor: Color3;
  108305. /**
  108306. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108307. * It should only be one of the following (if not the default embedded one):
  108308. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108309. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108310. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108311. * The material properties need to be setup according to the type of texture in use.
  108312. */
  108313. environmentBRDFTexture: BaseTexture;
  108314. /** @hidden */
  108315. protected _environmentTexture: Nullable<BaseTexture>;
  108316. /**
  108317. * Texture used in all pbr material as the reflection texture.
  108318. * As in the majority of the scene they are the same (exception for multi room and so on),
  108319. * this is easier to reference from here than from all the materials.
  108320. */
  108321. get environmentTexture(): Nullable<BaseTexture>;
  108322. /**
  108323. * Texture used in all pbr material as the reflection texture.
  108324. * As in the majority of the scene they are the same (exception for multi room and so on),
  108325. * this is easier to set here than in all the materials.
  108326. */
  108327. set environmentTexture(value: Nullable<BaseTexture>);
  108328. /** @hidden */
  108329. protected _environmentIntensity: number;
  108330. /**
  108331. * Intensity of the environment in all pbr material.
  108332. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108333. * As in the majority of the scene they are the same (exception for multi room and so on),
  108334. * this is easier to reference from here than from all the materials.
  108335. */
  108336. get environmentIntensity(): number;
  108337. /**
  108338. * Intensity of the environment in all pbr material.
  108339. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108340. * As in the majority of the scene they are the same (exception for multi room and so on),
  108341. * this is easier to set here than in all the materials.
  108342. */
  108343. set environmentIntensity(value: number);
  108344. /** @hidden */
  108345. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108346. /**
  108347. * Default image processing configuration used either in the rendering
  108348. * Forward main pass or through the imageProcessingPostProcess if present.
  108349. * As in the majority of the scene they are the same (exception for multi camera),
  108350. * this is easier to reference from here than from all the materials and post process.
  108351. *
  108352. * No setter as we it is a shared configuration, you can set the values instead.
  108353. */
  108354. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108355. private _forceWireframe;
  108356. /**
  108357. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108358. */
  108359. set forceWireframe(value: boolean);
  108360. get forceWireframe(): boolean;
  108361. private _skipFrustumClipping;
  108362. /**
  108363. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108364. */
  108365. set skipFrustumClipping(value: boolean);
  108366. get skipFrustumClipping(): boolean;
  108367. private _forcePointsCloud;
  108368. /**
  108369. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108370. */
  108371. set forcePointsCloud(value: boolean);
  108372. get forcePointsCloud(): boolean;
  108373. /**
  108374. * Gets or sets the active clipplane 1
  108375. */
  108376. clipPlane: Nullable<Plane>;
  108377. /**
  108378. * Gets or sets the active clipplane 2
  108379. */
  108380. clipPlane2: Nullable<Plane>;
  108381. /**
  108382. * Gets or sets the active clipplane 3
  108383. */
  108384. clipPlane3: Nullable<Plane>;
  108385. /**
  108386. * Gets or sets the active clipplane 4
  108387. */
  108388. clipPlane4: Nullable<Plane>;
  108389. /**
  108390. * Gets or sets the active clipplane 5
  108391. */
  108392. clipPlane5: Nullable<Plane>;
  108393. /**
  108394. * Gets or sets the active clipplane 6
  108395. */
  108396. clipPlane6: Nullable<Plane>;
  108397. /**
  108398. * Gets or sets a boolean indicating if animations are enabled
  108399. */
  108400. animationsEnabled: boolean;
  108401. private _animationPropertiesOverride;
  108402. /**
  108403. * Gets or sets the animation properties override
  108404. */
  108405. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108406. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108407. /**
  108408. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108409. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108410. */
  108411. useConstantAnimationDeltaTime: boolean;
  108412. /**
  108413. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108414. * Please note that it requires to run a ray cast through the scene on every frame
  108415. */
  108416. constantlyUpdateMeshUnderPointer: boolean;
  108417. /**
  108418. * Defines the HTML cursor to use when hovering over interactive elements
  108419. */
  108420. hoverCursor: string;
  108421. /**
  108422. * Defines the HTML default cursor to use (empty by default)
  108423. */
  108424. defaultCursor: string;
  108425. /**
  108426. * Defines whether cursors are handled by the scene.
  108427. */
  108428. doNotHandleCursors: boolean;
  108429. /**
  108430. * This is used to call preventDefault() on pointer down
  108431. * in order to block unwanted artifacts like system double clicks
  108432. */
  108433. preventDefaultOnPointerDown: boolean;
  108434. /**
  108435. * This is used to call preventDefault() on pointer up
  108436. * in order to block unwanted artifacts like system double clicks
  108437. */
  108438. preventDefaultOnPointerUp: boolean;
  108439. /**
  108440. * Gets or sets user defined metadata
  108441. */
  108442. metadata: any;
  108443. /**
  108444. * For internal use only. Please do not use.
  108445. */
  108446. reservedDataStore: any;
  108447. /**
  108448. * Gets the name of the plugin used to load this scene (null by default)
  108449. */
  108450. loadingPluginName: string;
  108451. /**
  108452. * Use this array to add regular expressions used to disable offline support for specific urls
  108453. */
  108454. disableOfflineSupportExceptionRules: RegExp[];
  108455. /**
  108456. * An event triggered when the scene is disposed.
  108457. */
  108458. onDisposeObservable: Observable<Scene>;
  108459. private _onDisposeObserver;
  108460. /** Sets a function to be executed when this scene is disposed. */
  108461. set onDispose(callback: () => void);
  108462. /**
  108463. * An event triggered before rendering the scene (right after animations and physics)
  108464. */
  108465. onBeforeRenderObservable: Observable<Scene>;
  108466. private _onBeforeRenderObserver;
  108467. /** Sets a function to be executed before rendering this scene */
  108468. set beforeRender(callback: Nullable<() => void>);
  108469. /**
  108470. * An event triggered after rendering the scene
  108471. */
  108472. onAfterRenderObservable: Observable<Scene>;
  108473. /**
  108474. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108475. */
  108476. onAfterRenderCameraObservable: Observable<Camera>;
  108477. private _onAfterRenderObserver;
  108478. /** Sets a function to be executed after rendering this scene */
  108479. set afterRender(callback: Nullable<() => void>);
  108480. /**
  108481. * An event triggered before animating the scene
  108482. */
  108483. onBeforeAnimationsObservable: Observable<Scene>;
  108484. /**
  108485. * An event triggered after animations processing
  108486. */
  108487. onAfterAnimationsObservable: Observable<Scene>;
  108488. /**
  108489. * An event triggered before draw calls are ready to be sent
  108490. */
  108491. onBeforeDrawPhaseObservable: Observable<Scene>;
  108492. /**
  108493. * An event triggered after draw calls have been sent
  108494. */
  108495. onAfterDrawPhaseObservable: Observable<Scene>;
  108496. /**
  108497. * An event triggered when the scene is ready
  108498. */
  108499. onReadyObservable: Observable<Scene>;
  108500. /**
  108501. * An event triggered before rendering a camera
  108502. */
  108503. onBeforeCameraRenderObservable: Observable<Camera>;
  108504. private _onBeforeCameraRenderObserver;
  108505. /** Sets a function to be executed before rendering a camera*/
  108506. set beforeCameraRender(callback: () => void);
  108507. /**
  108508. * An event triggered after rendering a camera
  108509. */
  108510. onAfterCameraRenderObservable: Observable<Camera>;
  108511. private _onAfterCameraRenderObserver;
  108512. /** Sets a function to be executed after rendering a camera*/
  108513. set afterCameraRender(callback: () => void);
  108514. /**
  108515. * An event triggered when active meshes evaluation is about to start
  108516. */
  108517. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108518. /**
  108519. * An event triggered when active meshes evaluation is done
  108520. */
  108521. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108522. /**
  108523. * An event triggered when particles rendering is about to start
  108524. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108525. */
  108526. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108527. /**
  108528. * An event triggered when particles rendering is done
  108529. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108530. */
  108531. onAfterParticlesRenderingObservable: Observable<Scene>;
  108532. /**
  108533. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108534. */
  108535. onDataLoadedObservable: Observable<Scene>;
  108536. /**
  108537. * An event triggered when a camera is created
  108538. */
  108539. onNewCameraAddedObservable: Observable<Camera>;
  108540. /**
  108541. * An event triggered when a camera is removed
  108542. */
  108543. onCameraRemovedObservable: Observable<Camera>;
  108544. /**
  108545. * An event triggered when a light is created
  108546. */
  108547. onNewLightAddedObservable: Observable<Light>;
  108548. /**
  108549. * An event triggered when a light is removed
  108550. */
  108551. onLightRemovedObservable: Observable<Light>;
  108552. /**
  108553. * An event triggered when a geometry is created
  108554. */
  108555. onNewGeometryAddedObservable: Observable<Geometry>;
  108556. /**
  108557. * An event triggered when a geometry is removed
  108558. */
  108559. onGeometryRemovedObservable: Observable<Geometry>;
  108560. /**
  108561. * An event triggered when a transform node is created
  108562. */
  108563. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108564. /**
  108565. * An event triggered when a transform node is removed
  108566. */
  108567. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108568. /**
  108569. * An event triggered when a mesh is created
  108570. */
  108571. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108572. /**
  108573. * An event triggered when a mesh is removed
  108574. */
  108575. onMeshRemovedObservable: Observable<AbstractMesh>;
  108576. /**
  108577. * An event triggered when a skeleton is created
  108578. */
  108579. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108580. /**
  108581. * An event triggered when a skeleton is removed
  108582. */
  108583. onSkeletonRemovedObservable: Observable<Skeleton>;
  108584. /**
  108585. * An event triggered when a material is created
  108586. */
  108587. onNewMaterialAddedObservable: Observable<Material>;
  108588. /**
  108589. * An event triggered when a material is removed
  108590. */
  108591. onMaterialRemovedObservable: Observable<Material>;
  108592. /**
  108593. * An event triggered when a texture is created
  108594. */
  108595. onNewTextureAddedObservable: Observable<BaseTexture>;
  108596. /**
  108597. * An event triggered when a texture is removed
  108598. */
  108599. onTextureRemovedObservable: Observable<BaseTexture>;
  108600. /**
  108601. * An event triggered when render targets are about to be rendered
  108602. * Can happen multiple times per frame.
  108603. */
  108604. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108605. /**
  108606. * An event triggered when render targets were rendered.
  108607. * Can happen multiple times per frame.
  108608. */
  108609. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108610. /**
  108611. * An event triggered before calculating deterministic simulation step
  108612. */
  108613. onBeforeStepObservable: Observable<Scene>;
  108614. /**
  108615. * An event triggered after calculating deterministic simulation step
  108616. */
  108617. onAfterStepObservable: Observable<Scene>;
  108618. /**
  108619. * An event triggered when the activeCamera property is updated
  108620. */
  108621. onActiveCameraChanged: Observable<Scene>;
  108622. /**
  108623. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108624. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108625. * 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)
  108626. */
  108627. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108628. /**
  108629. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108630. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108631. * 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)
  108632. */
  108633. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108634. /**
  108635. * This Observable will when a mesh has been imported into the scene.
  108636. */
  108637. onMeshImportedObservable: Observable<AbstractMesh>;
  108638. /**
  108639. * This Observable will when an animation file has been imported into the scene.
  108640. */
  108641. onAnimationFileImportedObservable: Observable<Scene>;
  108642. /**
  108643. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108644. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108645. */
  108646. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108647. /** @hidden */
  108648. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108649. /**
  108650. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108651. */
  108652. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108653. /**
  108654. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108655. */
  108656. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108657. /**
  108658. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108659. */
  108660. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108661. /** Callback called when a pointer move is detected */
  108662. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108663. /** Callback called when a pointer down is detected */
  108664. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108665. /** Callback called when a pointer up is detected */
  108666. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108667. /** Callback called when a pointer pick is detected */
  108668. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108669. /**
  108670. * 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).
  108671. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108672. */
  108673. onPrePointerObservable: Observable<PointerInfoPre>;
  108674. /**
  108675. * Observable event triggered each time an input event is received from the rendering canvas
  108676. */
  108677. onPointerObservable: Observable<PointerInfo>;
  108678. /**
  108679. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108680. */
  108681. get unTranslatedPointer(): Vector2;
  108682. /**
  108683. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108684. */
  108685. static get DragMovementThreshold(): number;
  108686. static set DragMovementThreshold(value: number);
  108687. /**
  108688. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108689. */
  108690. static get LongPressDelay(): number;
  108691. static set LongPressDelay(value: number);
  108692. /**
  108693. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108694. */
  108695. static get DoubleClickDelay(): number;
  108696. static set DoubleClickDelay(value: number);
  108697. /** If you need to check double click without raising a single click at first click, enable this flag */
  108698. static get ExclusiveDoubleClickMode(): boolean;
  108699. static set ExclusiveDoubleClickMode(value: boolean);
  108700. /** @hidden */
  108701. _mirroredCameraPosition: Nullable<Vector3>;
  108702. /**
  108703. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108704. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108705. */
  108706. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108707. /**
  108708. * Observable event triggered each time an keyboard event is received from the hosting window
  108709. */
  108710. onKeyboardObservable: Observable<KeyboardInfo>;
  108711. private _useRightHandedSystem;
  108712. /**
  108713. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108714. */
  108715. set useRightHandedSystem(value: boolean);
  108716. get useRightHandedSystem(): boolean;
  108717. private _timeAccumulator;
  108718. private _currentStepId;
  108719. private _currentInternalStep;
  108720. /**
  108721. * Sets the step Id used by deterministic lock step
  108722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108723. * @param newStepId defines the step Id
  108724. */
  108725. setStepId(newStepId: number): void;
  108726. /**
  108727. * Gets the step Id used by deterministic lock step
  108728. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108729. * @returns the step Id
  108730. */
  108731. getStepId(): number;
  108732. /**
  108733. * Gets the internal step used by deterministic lock step
  108734. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108735. * @returns the internal step
  108736. */
  108737. getInternalStep(): number;
  108738. private _fogEnabled;
  108739. /**
  108740. * Gets or sets a boolean indicating if fog is enabled on this scene
  108741. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108742. * (Default is true)
  108743. */
  108744. set fogEnabled(value: boolean);
  108745. get fogEnabled(): boolean;
  108746. private _fogMode;
  108747. /**
  108748. * Gets or sets the fog mode to use
  108749. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108750. * | mode | value |
  108751. * | --- | --- |
  108752. * | FOGMODE_NONE | 0 |
  108753. * | FOGMODE_EXP | 1 |
  108754. * | FOGMODE_EXP2 | 2 |
  108755. * | FOGMODE_LINEAR | 3 |
  108756. */
  108757. set fogMode(value: number);
  108758. get fogMode(): number;
  108759. /**
  108760. * Gets or sets the fog color to use
  108761. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108762. * (Default is Color3(0.2, 0.2, 0.3))
  108763. */
  108764. fogColor: Color3;
  108765. /**
  108766. * Gets or sets the fog density to use
  108767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108768. * (Default is 0.1)
  108769. */
  108770. fogDensity: number;
  108771. /**
  108772. * Gets or sets the fog start distance to use
  108773. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108774. * (Default is 0)
  108775. */
  108776. fogStart: number;
  108777. /**
  108778. * Gets or sets the fog end distance to use
  108779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108780. * (Default is 1000)
  108781. */
  108782. fogEnd: number;
  108783. private _shadowsEnabled;
  108784. /**
  108785. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108786. */
  108787. set shadowsEnabled(value: boolean);
  108788. get shadowsEnabled(): boolean;
  108789. private _lightsEnabled;
  108790. /**
  108791. * Gets or sets a boolean indicating if lights are enabled on this scene
  108792. */
  108793. set lightsEnabled(value: boolean);
  108794. get lightsEnabled(): boolean;
  108795. /** All of the active cameras added to this scene. */
  108796. activeCameras: Camera[];
  108797. /** @hidden */
  108798. _activeCamera: Nullable<Camera>;
  108799. /** Gets or sets the current active camera */
  108800. get activeCamera(): Nullable<Camera>;
  108801. set activeCamera(value: Nullable<Camera>);
  108802. private _defaultMaterial;
  108803. /** The default material used on meshes when no material is affected */
  108804. get defaultMaterial(): Material;
  108805. /** The default material used on meshes when no material is affected */
  108806. set defaultMaterial(value: Material);
  108807. private _texturesEnabled;
  108808. /**
  108809. * Gets or sets a boolean indicating if textures are enabled on this scene
  108810. */
  108811. set texturesEnabled(value: boolean);
  108812. get texturesEnabled(): boolean;
  108813. /**
  108814. * Gets or sets a boolean indicating if particles are enabled on this scene
  108815. */
  108816. particlesEnabled: boolean;
  108817. /**
  108818. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108819. */
  108820. spritesEnabled: boolean;
  108821. private _skeletonsEnabled;
  108822. /**
  108823. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108824. */
  108825. set skeletonsEnabled(value: boolean);
  108826. get skeletonsEnabled(): boolean;
  108827. /**
  108828. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108829. */
  108830. lensFlaresEnabled: boolean;
  108831. /**
  108832. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108833. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108834. */
  108835. collisionsEnabled: boolean;
  108836. private _collisionCoordinator;
  108837. /** @hidden */
  108838. get collisionCoordinator(): ICollisionCoordinator;
  108839. /**
  108840. * Defines the gravity applied to this scene (used only for collisions)
  108841. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108842. */
  108843. gravity: Vector3;
  108844. /**
  108845. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108846. */
  108847. postProcessesEnabled: boolean;
  108848. /**
  108849. * The list of postprocesses added to the scene
  108850. */
  108851. postProcesses: PostProcess[];
  108852. /**
  108853. * Gets the current postprocess manager
  108854. */
  108855. postProcessManager: PostProcessManager;
  108856. /**
  108857. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108858. */
  108859. renderTargetsEnabled: boolean;
  108860. /**
  108861. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108862. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108863. */
  108864. dumpNextRenderTargets: boolean;
  108865. /**
  108866. * The list of user defined render targets added to the scene
  108867. */
  108868. customRenderTargets: RenderTargetTexture[];
  108869. /**
  108870. * Defines if texture loading must be delayed
  108871. * If true, textures will only be loaded when they need to be rendered
  108872. */
  108873. useDelayedTextureLoading: boolean;
  108874. /**
  108875. * Gets the list of meshes imported to the scene through SceneLoader
  108876. */
  108877. importedMeshesFiles: String[];
  108878. /**
  108879. * Gets or sets a boolean indicating if probes are enabled on this scene
  108880. */
  108881. probesEnabled: boolean;
  108882. /**
  108883. * Gets or sets the current offline provider to use to store scene data
  108884. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108885. */
  108886. offlineProvider: IOfflineProvider;
  108887. /**
  108888. * Gets or sets the action manager associated with the scene
  108889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108890. */
  108891. actionManager: AbstractActionManager;
  108892. private _meshesForIntersections;
  108893. /**
  108894. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108895. */
  108896. proceduralTexturesEnabled: boolean;
  108897. private _engine;
  108898. private _totalVertices;
  108899. /** @hidden */
  108900. _activeIndices: PerfCounter;
  108901. /** @hidden */
  108902. _activeParticles: PerfCounter;
  108903. /** @hidden */
  108904. _activeBones: PerfCounter;
  108905. private _animationRatio;
  108906. /** @hidden */
  108907. _animationTimeLast: number;
  108908. /** @hidden */
  108909. _animationTime: number;
  108910. /**
  108911. * Gets or sets a general scale for animation speed
  108912. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108913. */
  108914. animationTimeScale: number;
  108915. /** @hidden */
  108916. _cachedMaterial: Nullable<Material>;
  108917. /** @hidden */
  108918. _cachedEffect: Nullable<Effect>;
  108919. /** @hidden */
  108920. _cachedVisibility: Nullable<number>;
  108921. private _renderId;
  108922. private _frameId;
  108923. private _executeWhenReadyTimeoutId;
  108924. private _intermediateRendering;
  108925. private _viewUpdateFlag;
  108926. private _projectionUpdateFlag;
  108927. /** @hidden */
  108928. _toBeDisposed: Nullable<IDisposable>[];
  108929. private _activeRequests;
  108930. /** @hidden */
  108931. _pendingData: any[];
  108932. private _isDisposed;
  108933. /**
  108934. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108935. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108936. */
  108937. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108938. private _activeMeshes;
  108939. private _processedMaterials;
  108940. private _renderTargets;
  108941. /** @hidden */
  108942. _activeParticleSystems: SmartArray<IParticleSystem>;
  108943. private _activeSkeletons;
  108944. private _softwareSkinnedMeshes;
  108945. private _renderingManager;
  108946. /** @hidden */
  108947. _activeAnimatables: Animatable[];
  108948. private _transformMatrix;
  108949. private _sceneUbo;
  108950. /** @hidden */
  108951. _viewMatrix: Matrix;
  108952. private _projectionMatrix;
  108953. /** @hidden */
  108954. _forcedViewPosition: Nullable<Vector3>;
  108955. /** @hidden */
  108956. _frustumPlanes: Plane[];
  108957. /**
  108958. * Gets the list of frustum planes (built from the active camera)
  108959. */
  108960. get frustumPlanes(): Plane[];
  108961. /**
  108962. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108963. * This is useful if there are more lights that the maximum simulteanous authorized
  108964. */
  108965. requireLightSorting: boolean;
  108966. /** @hidden */
  108967. readonly useMaterialMeshMap: boolean;
  108968. /** @hidden */
  108969. readonly useClonedMeshMap: boolean;
  108970. private _externalData;
  108971. private _uid;
  108972. /**
  108973. * @hidden
  108974. * Backing store of defined scene components.
  108975. */
  108976. _components: ISceneComponent[];
  108977. /**
  108978. * @hidden
  108979. * Backing store of defined scene components.
  108980. */
  108981. _serializableComponents: ISceneSerializableComponent[];
  108982. /**
  108983. * List of components to register on the next registration step.
  108984. */
  108985. private _transientComponents;
  108986. /**
  108987. * Registers the transient components if needed.
  108988. */
  108989. private _registerTransientComponents;
  108990. /**
  108991. * @hidden
  108992. * Add a component to the scene.
  108993. * Note that the ccomponent could be registered on th next frame if this is called after
  108994. * the register component stage.
  108995. * @param component Defines the component to add to the scene
  108996. */
  108997. _addComponent(component: ISceneComponent): void;
  108998. /**
  108999. * @hidden
  109000. * Gets a component from the scene.
  109001. * @param name defines the name of the component to retrieve
  109002. * @returns the component or null if not present
  109003. */
  109004. _getComponent(name: string): Nullable<ISceneComponent>;
  109005. /**
  109006. * @hidden
  109007. * Defines the actions happening before camera updates.
  109008. */
  109009. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109010. /**
  109011. * @hidden
  109012. * Defines the actions happening before clear the canvas.
  109013. */
  109014. _beforeClearStage: Stage<SimpleStageAction>;
  109015. /**
  109016. * @hidden
  109017. * Defines the actions when collecting render targets for the frame.
  109018. */
  109019. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109020. /**
  109021. * @hidden
  109022. * Defines the actions happening for one camera in the frame.
  109023. */
  109024. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109025. /**
  109026. * @hidden
  109027. * Defines the actions happening during the per mesh ready checks.
  109028. */
  109029. _isReadyForMeshStage: Stage<MeshStageAction>;
  109030. /**
  109031. * @hidden
  109032. * Defines the actions happening before evaluate active mesh checks.
  109033. */
  109034. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109035. /**
  109036. * @hidden
  109037. * Defines the actions happening during the evaluate sub mesh checks.
  109038. */
  109039. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109040. /**
  109041. * @hidden
  109042. * Defines the actions happening during the active mesh stage.
  109043. */
  109044. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109045. /**
  109046. * @hidden
  109047. * Defines the actions happening during the per camera render target step.
  109048. */
  109049. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109050. /**
  109051. * @hidden
  109052. * Defines the actions happening just before the active camera is drawing.
  109053. */
  109054. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109055. /**
  109056. * @hidden
  109057. * Defines the actions happening just before a render target is drawing.
  109058. */
  109059. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109060. /**
  109061. * @hidden
  109062. * Defines the actions happening just before a rendering group is drawing.
  109063. */
  109064. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109065. /**
  109066. * @hidden
  109067. * Defines the actions happening just before a mesh is drawing.
  109068. */
  109069. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109070. /**
  109071. * @hidden
  109072. * Defines the actions happening just after a mesh has been drawn.
  109073. */
  109074. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109075. /**
  109076. * @hidden
  109077. * Defines the actions happening just after a rendering group has been drawn.
  109078. */
  109079. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109080. /**
  109081. * @hidden
  109082. * Defines the actions happening just after the active camera has been drawn.
  109083. */
  109084. _afterCameraDrawStage: Stage<CameraStageAction>;
  109085. /**
  109086. * @hidden
  109087. * Defines the actions happening just after a render target has been drawn.
  109088. */
  109089. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109090. /**
  109091. * @hidden
  109092. * Defines the actions happening just after rendering all cameras and computing intersections.
  109093. */
  109094. _afterRenderStage: Stage<SimpleStageAction>;
  109095. /**
  109096. * @hidden
  109097. * Defines the actions happening when a pointer move event happens.
  109098. */
  109099. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109100. /**
  109101. * @hidden
  109102. * Defines the actions happening when a pointer down event happens.
  109103. */
  109104. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109105. /**
  109106. * @hidden
  109107. * Defines the actions happening when a pointer up event happens.
  109108. */
  109109. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109110. /**
  109111. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109112. */
  109113. private geometriesByUniqueId;
  109114. /**
  109115. * Creates a new Scene
  109116. * @param engine defines the engine to use to render this scene
  109117. * @param options defines the scene options
  109118. */
  109119. constructor(engine: Engine, options?: SceneOptions);
  109120. /**
  109121. * Gets a string idenfifying the name of the class
  109122. * @returns "Scene" string
  109123. */
  109124. getClassName(): string;
  109125. private _defaultMeshCandidates;
  109126. /**
  109127. * @hidden
  109128. */
  109129. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109130. private _defaultSubMeshCandidates;
  109131. /**
  109132. * @hidden
  109133. */
  109134. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109135. /**
  109136. * Sets the default candidate providers for the scene.
  109137. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109138. * and getCollidingSubMeshCandidates to their default function
  109139. */
  109140. setDefaultCandidateProviders(): void;
  109141. /**
  109142. * Gets the mesh that is currently under the pointer
  109143. */
  109144. get meshUnderPointer(): Nullable<AbstractMesh>;
  109145. /**
  109146. * Gets or sets the current on-screen X position of the pointer
  109147. */
  109148. get pointerX(): number;
  109149. set pointerX(value: number);
  109150. /**
  109151. * Gets or sets the current on-screen Y position of the pointer
  109152. */
  109153. get pointerY(): number;
  109154. set pointerY(value: number);
  109155. /**
  109156. * Gets the cached material (ie. the latest rendered one)
  109157. * @returns the cached material
  109158. */
  109159. getCachedMaterial(): Nullable<Material>;
  109160. /**
  109161. * Gets the cached effect (ie. the latest rendered one)
  109162. * @returns the cached effect
  109163. */
  109164. getCachedEffect(): Nullable<Effect>;
  109165. /**
  109166. * Gets the cached visibility state (ie. the latest rendered one)
  109167. * @returns the cached visibility state
  109168. */
  109169. getCachedVisibility(): Nullable<number>;
  109170. /**
  109171. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109172. * @param material defines the current material
  109173. * @param effect defines the current effect
  109174. * @param visibility defines the current visibility state
  109175. * @returns true if one parameter is not cached
  109176. */
  109177. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109178. /**
  109179. * Gets the engine associated with the scene
  109180. * @returns an Engine
  109181. */
  109182. getEngine(): Engine;
  109183. /**
  109184. * Gets the total number of vertices rendered per frame
  109185. * @returns the total number of vertices rendered per frame
  109186. */
  109187. getTotalVertices(): number;
  109188. /**
  109189. * Gets the performance counter for total vertices
  109190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109191. */
  109192. get totalVerticesPerfCounter(): PerfCounter;
  109193. /**
  109194. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109195. * @returns the total number of active indices rendered per frame
  109196. */
  109197. getActiveIndices(): number;
  109198. /**
  109199. * Gets the performance counter for active indices
  109200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109201. */
  109202. get totalActiveIndicesPerfCounter(): PerfCounter;
  109203. /**
  109204. * Gets the total number of active particles rendered per frame
  109205. * @returns the total number of active particles rendered per frame
  109206. */
  109207. getActiveParticles(): number;
  109208. /**
  109209. * Gets the performance counter for active particles
  109210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109211. */
  109212. get activeParticlesPerfCounter(): PerfCounter;
  109213. /**
  109214. * Gets the total number of active bones rendered per frame
  109215. * @returns the total number of active bones rendered per frame
  109216. */
  109217. getActiveBones(): number;
  109218. /**
  109219. * Gets the performance counter for active bones
  109220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109221. */
  109222. get activeBonesPerfCounter(): PerfCounter;
  109223. /**
  109224. * Gets the array of active meshes
  109225. * @returns an array of AbstractMesh
  109226. */
  109227. getActiveMeshes(): SmartArray<AbstractMesh>;
  109228. /**
  109229. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109230. * @returns a number
  109231. */
  109232. getAnimationRatio(): number;
  109233. /**
  109234. * Gets an unique Id for the current render phase
  109235. * @returns a number
  109236. */
  109237. getRenderId(): number;
  109238. /**
  109239. * Gets an unique Id for the current frame
  109240. * @returns a number
  109241. */
  109242. getFrameId(): number;
  109243. /** Call this function if you want to manually increment the render Id*/
  109244. incrementRenderId(): void;
  109245. private _createUbo;
  109246. /**
  109247. * Use this method to simulate a pointer move on a mesh
  109248. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109249. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109250. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109251. * @returns the current scene
  109252. */
  109253. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109254. /**
  109255. * Use this method to simulate a pointer down on a mesh
  109256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109259. * @returns the current scene
  109260. */
  109261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109262. /**
  109263. * Use this method to simulate a pointer up on a mesh
  109264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109267. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109268. * @returns the current scene
  109269. */
  109270. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109271. /**
  109272. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109273. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109274. * @returns true if the pointer was captured
  109275. */
  109276. isPointerCaptured(pointerId?: number): boolean;
  109277. /**
  109278. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109279. * @param attachUp defines if you want to attach events to pointerup
  109280. * @param attachDown defines if you want to attach events to pointerdown
  109281. * @param attachMove defines if you want to attach events to pointermove
  109282. */
  109283. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109284. /** Detaches all event handlers*/
  109285. detachControl(): void;
  109286. /**
  109287. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109288. * Delay loaded resources are not taking in account
  109289. * @return true if all required resources are ready
  109290. */
  109291. isReady(): boolean;
  109292. /** Resets all cached information relative to material (including effect and visibility) */
  109293. resetCachedMaterial(): void;
  109294. /**
  109295. * Registers a function to be called before every frame render
  109296. * @param func defines the function to register
  109297. */
  109298. registerBeforeRender(func: () => void): void;
  109299. /**
  109300. * Unregisters a function called before every frame render
  109301. * @param func defines the function to unregister
  109302. */
  109303. unregisterBeforeRender(func: () => void): void;
  109304. /**
  109305. * Registers a function to be called after every frame render
  109306. * @param func defines the function to register
  109307. */
  109308. registerAfterRender(func: () => void): void;
  109309. /**
  109310. * Unregisters a function called after every frame render
  109311. * @param func defines the function to unregister
  109312. */
  109313. unregisterAfterRender(func: () => void): void;
  109314. private _executeOnceBeforeRender;
  109315. /**
  109316. * The provided function will run before render once and will be disposed afterwards.
  109317. * A timeout delay can be provided so that the function will be executed in N ms.
  109318. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109319. * @param func The function to be executed.
  109320. * @param timeout optional delay in ms
  109321. */
  109322. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109323. /** @hidden */
  109324. _addPendingData(data: any): void;
  109325. /** @hidden */
  109326. _removePendingData(data: any): void;
  109327. /**
  109328. * Returns the number of items waiting to be loaded
  109329. * @returns the number of items waiting to be loaded
  109330. */
  109331. getWaitingItemsCount(): number;
  109332. /**
  109333. * Returns a boolean indicating if the scene is still loading data
  109334. */
  109335. get isLoading(): boolean;
  109336. /**
  109337. * Registers a function to be executed when the scene is ready
  109338. * @param {Function} func - the function to be executed
  109339. */
  109340. executeWhenReady(func: () => void): void;
  109341. /**
  109342. * Returns a promise that resolves when the scene is ready
  109343. * @returns A promise that resolves when the scene is ready
  109344. */
  109345. whenReadyAsync(): Promise<void>;
  109346. /** @hidden */
  109347. _checkIsReady(): void;
  109348. /**
  109349. * Gets all animatable attached to the scene
  109350. */
  109351. get animatables(): Animatable[];
  109352. /**
  109353. * Resets the last animation time frame.
  109354. * Useful to override when animations start running when loading a scene for the first time.
  109355. */
  109356. resetLastAnimationTimeFrame(): void;
  109357. /**
  109358. * Gets the current view matrix
  109359. * @returns a Matrix
  109360. */
  109361. getViewMatrix(): Matrix;
  109362. /**
  109363. * Gets the current projection matrix
  109364. * @returns a Matrix
  109365. */
  109366. getProjectionMatrix(): Matrix;
  109367. /**
  109368. * Gets the current transform matrix
  109369. * @returns a Matrix made of View * Projection
  109370. */
  109371. getTransformMatrix(): Matrix;
  109372. /**
  109373. * Sets the current transform matrix
  109374. * @param viewL defines the View matrix to use
  109375. * @param projectionL defines the Projection matrix to use
  109376. * @param viewR defines the right View matrix to use (if provided)
  109377. * @param projectionR defines the right Projection matrix to use (if provided)
  109378. */
  109379. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109380. /**
  109381. * Gets the uniform buffer used to store scene data
  109382. * @returns a UniformBuffer
  109383. */
  109384. getSceneUniformBuffer(): UniformBuffer;
  109385. /**
  109386. * Gets an unique (relatively to the current scene) Id
  109387. * @returns an unique number for the scene
  109388. */
  109389. getUniqueId(): number;
  109390. /**
  109391. * Add a mesh to the list of scene's meshes
  109392. * @param newMesh defines the mesh to add
  109393. * @param recursive if all child meshes should also be added to the scene
  109394. */
  109395. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109396. /**
  109397. * Remove a mesh for the list of scene's meshes
  109398. * @param toRemove defines the mesh to remove
  109399. * @param recursive if all child meshes should also be removed from the scene
  109400. * @returns the index where the mesh was in the mesh list
  109401. */
  109402. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109403. /**
  109404. * Add a transform node to the list of scene's transform nodes
  109405. * @param newTransformNode defines the transform node to add
  109406. */
  109407. addTransformNode(newTransformNode: TransformNode): void;
  109408. /**
  109409. * Remove a transform node for the list of scene's transform nodes
  109410. * @param toRemove defines the transform node to remove
  109411. * @returns the index where the transform node was in the transform node list
  109412. */
  109413. removeTransformNode(toRemove: TransformNode): number;
  109414. /**
  109415. * Remove a skeleton for the list of scene's skeletons
  109416. * @param toRemove defines the skeleton to remove
  109417. * @returns the index where the skeleton was in the skeleton list
  109418. */
  109419. removeSkeleton(toRemove: Skeleton): number;
  109420. /**
  109421. * Remove a morph target for the list of scene's morph targets
  109422. * @param toRemove defines the morph target to remove
  109423. * @returns the index where the morph target was in the morph target list
  109424. */
  109425. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109426. /**
  109427. * Remove a light for the list of scene's lights
  109428. * @param toRemove defines the light to remove
  109429. * @returns the index where the light was in the light list
  109430. */
  109431. removeLight(toRemove: Light): number;
  109432. /**
  109433. * Remove a camera for the list of scene's cameras
  109434. * @param toRemove defines the camera to remove
  109435. * @returns the index where the camera was in the camera list
  109436. */
  109437. removeCamera(toRemove: Camera): number;
  109438. /**
  109439. * Remove a particle system for the list of scene's particle systems
  109440. * @param toRemove defines the particle system to remove
  109441. * @returns the index where the particle system was in the particle system list
  109442. */
  109443. removeParticleSystem(toRemove: IParticleSystem): number;
  109444. /**
  109445. * Remove a animation for the list of scene's animations
  109446. * @param toRemove defines the animation to remove
  109447. * @returns the index where the animation was in the animation list
  109448. */
  109449. removeAnimation(toRemove: Animation): number;
  109450. /**
  109451. * Will stop the animation of the given target
  109452. * @param target - the target
  109453. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109454. * @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)
  109455. */
  109456. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109457. /**
  109458. * Removes the given animation group from this scene.
  109459. * @param toRemove The animation group to remove
  109460. * @returns The index of the removed animation group
  109461. */
  109462. removeAnimationGroup(toRemove: AnimationGroup): number;
  109463. /**
  109464. * Removes the given multi-material from this scene.
  109465. * @param toRemove The multi-material to remove
  109466. * @returns The index of the removed multi-material
  109467. */
  109468. removeMultiMaterial(toRemove: MultiMaterial): number;
  109469. /**
  109470. * Removes the given material from this scene.
  109471. * @param toRemove The material to remove
  109472. * @returns The index of the removed material
  109473. */
  109474. removeMaterial(toRemove: Material): number;
  109475. /**
  109476. * Removes the given action manager from this scene.
  109477. * @param toRemove The action manager to remove
  109478. * @returns The index of the removed action manager
  109479. */
  109480. removeActionManager(toRemove: AbstractActionManager): number;
  109481. /**
  109482. * Removes the given texture from this scene.
  109483. * @param toRemove The texture to remove
  109484. * @returns The index of the removed texture
  109485. */
  109486. removeTexture(toRemove: BaseTexture): number;
  109487. /**
  109488. * Adds the given light to this scene
  109489. * @param newLight The light to add
  109490. */
  109491. addLight(newLight: Light): void;
  109492. /**
  109493. * Sorts the list list based on light priorities
  109494. */
  109495. sortLightsByPriority(): void;
  109496. /**
  109497. * Adds the given camera to this scene
  109498. * @param newCamera The camera to add
  109499. */
  109500. addCamera(newCamera: Camera): void;
  109501. /**
  109502. * Adds the given skeleton to this scene
  109503. * @param newSkeleton The skeleton to add
  109504. */
  109505. addSkeleton(newSkeleton: Skeleton): void;
  109506. /**
  109507. * Adds the given particle system to this scene
  109508. * @param newParticleSystem The particle system to add
  109509. */
  109510. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109511. /**
  109512. * Adds the given animation to this scene
  109513. * @param newAnimation The animation to add
  109514. */
  109515. addAnimation(newAnimation: Animation): void;
  109516. /**
  109517. * Adds the given animation group to this scene.
  109518. * @param newAnimationGroup The animation group to add
  109519. */
  109520. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109521. /**
  109522. * Adds the given multi-material to this scene
  109523. * @param newMultiMaterial The multi-material to add
  109524. */
  109525. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109526. /**
  109527. * Adds the given material to this scene
  109528. * @param newMaterial The material to add
  109529. */
  109530. addMaterial(newMaterial: Material): void;
  109531. /**
  109532. * Adds the given morph target to this scene
  109533. * @param newMorphTargetManager The morph target to add
  109534. */
  109535. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109536. /**
  109537. * Adds the given geometry to this scene
  109538. * @param newGeometry The geometry to add
  109539. */
  109540. addGeometry(newGeometry: Geometry): void;
  109541. /**
  109542. * Adds the given action manager to this scene
  109543. * @param newActionManager The action manager to add
  109544. */
  109545. addActionManager(newActionManager: AbstractActionManager): void;
  109546. /**
  109547. * Adds the given texture to this scene.
  109548. * @param newTexture The texture to add
  109549. */
  109550. addTexture(newTexture: BaseTexture): void;
  109551. /**
  109552. * Switch active camera
  109553. * @param newCamera defines the new active camera
  109554. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109555. */
  109556. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109557. /**
  109558. * sets the active camera of the scene using its ID
  109559. * @param id defines the camera's ID
  109560. * @return the new active camera or null if none found.
  109561. */
  109562. setActiveCameraByID(id: string): Nullable<Camera>;
  109563. /**
  109564. * sets the active camera of the scene using its name
  109565. * @param name defines the camera's name
  109566. * @returns the new active camera or null if none found.
  109567. */
  109568. setActiveCameraByName(name: string): Nullable<Camera>;
  109569. /**
  109570. * get an animation group using its name
  109571. * @param name defines the material's name
  109572. * @return the animation group or null if none found.
  109573. */
  109574. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109575. /**
  109576. * Get a material using its unique id
  109577. * @param uniqueId defines the material's unique id
  109578. * @return the material or null if none found.
  109579. */
  109580. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109581. /**
  109582. * get a material using its id
  109583. * @param id defines the material's ID
  109584. * @return the material or null if none found.
  109585. */
  109586. getMaterialByID(id: string): Nullable<Material>;
  109587. /**
  109588. * Gets a the last added material using a given id
  109589. * @param id defines the material's ID
  109590. * @return the last material with the given id or null if none found.
  109591. */
  109592. getLastMaterialByID(id: string): Nullable<Material>;
  109593. /**
  109594. * Gets a material using its name
  109595. * @param name defines the material's name
  109596. * @return the material or null if none found.
  109597. */
  109598. getMaterialByName(name: string): Nullable<Material>;
  109599. /**
  109600. * Get a texture using its unique id
  109601. * @param uniqueId defines the texture's unique id
  109602. * @return the texture or null if none found.
  109603. */
  109604. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109605. /**
  109606. * Gets a camera using its id
  109607. * @param id defines the id to look for
  109608. * @returns the camera or null if not found
  109609. */
  109610. getCameraByID(id: string): Nullable<Camera>;
  109611. /**
  109612. * Gets a camera using its unique id
  109613. * @param uniqueId defines the unique id to look for
  109614. * @returns the camera or null if not found
  109615. */
  109616. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109617. /**
  109618. * Gets a camera using its name
  109619. * @param name defines the camera's name
  109620. * @return the camera or null if none found.
  109621. */
  109622. getCameraByName(name: string): Nullable<Camera>;
  109623. /**
  109624. * Gets a bone using its id
  109625. * @param id defines the bone's id
  109626. * @return the bone or null if not found
  109627. */
  109628. getBoneByID(id: string): Nullable<Bone>;
  109629. /**
  109630. * Gets a bone using its id
  109631. * @param name defines the bone's name
  109632. * @return the bone or null if not found
  109633. */
  109634. getBoneByName(name: string): Nullable<Bone>;
  109635. /**
  109636. * Gets a light node using its name
  109637. * @param name defines the the light's name
  109638. * @return the light or null if none found.
  109639. */
  109640. getLightByName(name: string): Nullable<Light>;
  109641. /**
  109642. * Gets a light node using its id
  109643. * @param id defines the light's id
  109644. * @return the light or null if none found.
  109645. */
  109646. getLightByID(id: string): Nullable<Light>;
  109647. /**
  109648. * Gets a light node using its scene-generated unique ID
  109649. * @param uniqueId defines the light's unique id
  109650. * @return the light or null if none found.
  109651. */
  109652. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109653. /**
  109654. * Gets a particle system by id
  109655. * @param id defines the particle system id
  109656. * @return the corresponding system or null if none found
  109657. */
  109658. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109659. /**
  109660. * Gets a geometry using its ID
  109661. * @param id defines the geometry's id
  109662. * @return the geometry or null if none found.
  109663. */
  109664. getGeometryByID(id: string): Nullable<Geometry>;
  109665. private _getGeometryByUniqueID;
  109666. /**
  109667. * Add a new geometry to this scene
  109668. * @param geometry defines the geometry to be added to the scene.
  109669. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109670. * @return a boolean defining if the geometry was added or not
  109671. */
  109672. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109673. /**
  109674. * Removes an existing geometry
  109675. * @param geometry defines the geometry to be removed from the scene
  109676. * @return a boolean defining if the geometry was removed or not
  109677. */
  109678. removeGeometry(geometry: Geometry): boolean;
  109679. /**
  109680. * Gets the list of geometries attached to the scene
  109681. * @returns an array of Geometry
  109682. */
  109683. getGeometries(): Geometry[];
  109684. /**
  109685. * Gets the first added mesh found of a given ID
  109686. * @param id defines the id to search for
  109687. * @return the mesh found or null if not found at all
  109688. */
  109689. getMeshByID(id: string): Nullable<AbstractMesh>;
  109690. /**
  109691. * Gets a list of meshes using their id
  109692. * @param id defines the id to search for
  109693. * @returns a list of meshes
  109694. */
  109695. getMeshesByID(id: string): Array<AbstractMesh>;
  109696. /**
  109697. * Gets the first added transform node found of a given ID
  109698. * @param id defines the id to search for
  109699. * @return the found transform node or null if not found at all.
  109700. */
  109701. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109702. /**
  109703. * Gets a transform node with its auto-generated unique id
  109704. * @param uniqueId efines the unique id to search for
  109705. * @return the found transform node or null if not found at all.
  109706. */
  109707. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109708. /**
  109709. * Gets a list of transform nodes using their id
  109710. * @param id defines the id to search for
  109711. * @returns a list of transform nodes
  109712. */
  109713. getTransformNodesByID(id: string): Array<TransformNode>;
  109714. /**
  109715. * Gets a mesh with its auto-generated unique id
  109716. * @param uniqueId defines the unique id to search for
  109717. * @return the found mesh or null if not found at all.
  109718. */
  109719. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109720. /**
  109721. * Gets a the last added mesh using a given id
  109722. * @param id defines the id to search for
  109723. * @return the found mesh or null if not found at all.
  109724. */
  109725. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109726. /**
  109727. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109728. * @param id defines the id to search for
  109729. * @return the found node or null if not found at all
  109730. */
  109731. getLastEntryByID(id: string): Nullable<Node>;
  109732. /**
  109733. * Gets a node (Mesh, Camera, Light) using a given id
  109734. * @param id defines the id to search for
  109735. * @return the found node or null if not found at all
  109736. */
  109737. getNodeByID(id: string): Nullable<Node>;
  109738. /**
  109739. * Gets a node (Mesh, Camera, Light) using a given name
  109740. * @param name defines the name to search for
  109741. * @return the found node or null if not found at all.
  109742. */
  109743. getNodeByName(name: string): Nullable<Node>;
  109744. /**
  109745. * Gets a mesh using a given name
  109746. * @param name defines the name to search for
  109747. * @return the found mesh or null if not found at all.
  109748. */
  109749. getMeshByName(name: string): Nullable<AbstractMesh>;
  109750. /**
  109751. * Gets a transform node using a given name
  109752. * @param name defines the name to search for
  109753. * @return the found transform node or null if not found at all.
  109754. */
  109755. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109756. /**
  109757. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109758. * @param id defines the id to search for
  109759. * @return the found skeleton or null if not found at all.
  109760. */
  109761. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109762. /**
  109763. * Gets a skeleton using a given auto generated unique id
  109764. * @param uniqueId defines the unique id to search for
  109765. * @return the found skeleton or null if not found at all.
  109766. */
  109767. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109768. /**
  109769. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109770. * @param id defines the id to search for
  109771. * @return the found skeleton or null if not found at all.
  109772. */
  109773. getSkeletonById(id: string): Nullable<Skeleton>;
  109774. /**
  109775. * Gets a skeleton using a given name
  109776. * @param name defines the name to search for
  109777. * @return the found skeleton or null if not found at all.
  109778. */
  109779. getSkeletonByName(name: string): Nullable<Skeleton>;
  109780. /**
  109781. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109782. * @param id defines the id to search for
  109783. * @return the found morph target manager or null if not found at all.
  109784. */
  109785. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109786. /**
  109787. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109788. * @param id defines the id to search for
  109789. * @return the found morph target or null if not found at all.
  109790. */
  109791. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109792. /**
  109793. * Gets a boolean indicating if the given mesh is active
  109794. * @param mesh defines the mesh to look for
  109795. * @returns true if the mesh is in the active list
  109796. */
  109797. isActiveMesh(mesh: AbstractMesh): boolean;
  109798. /**
  109799. * Return a unique id as a string which can serve as an identifier for the scene
  109800. */
  109801. get uid(): string;
  109802. /**
  109803. * Add an externaly attached data from its key.
  109804. * This method call will fail and return false, if such key already exists.
  109805. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109806. * @param key the unique key that identifies the data
  109807. * @param data the data object to associate to the key for this Engine instance
  109808. * @return true if no such key were already present and the data was added successfully, false otherwise
  109809. */
  109810. addExternalData<T>(key: string, data: T): boolean;
  109811. /**
  109812. * Get an externaly attached data from its key
  109813. * @param key the unique key that identifies the data
  109814. * @return the associated data, if present (can be null), or undefined if not present
  109815. */
  109816. getExternalData<T>(key: string): Nullable<T>;
  109817. /**
  109818. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109819. * @param key the unique key that identifies the data
  109820. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109821. * @return the associated data, can be null if the factory returned null.
  109822. */
  109823. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109824. /**
  109825. * Remove an externaly attached data from the Engine instance
  109826. * @param key the unique key that identifies the data
  109827. * @return true if the data was successfully removed, false if it doesn't exist
  109828. */
  109829. removeExternalData(key: string): boolean;
  109830. private _evaluateSubMesh;
  109831. /**
  109832. * Clear the processed materials smart array preventing retention point in material dispose.
  109833. */
  109834. freeProcessedMaterials(): void;
  109835. private _preventFreeActiveMeshesAndRenderingGroups;
  109836. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109837. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109838. * when disposing several meshes in a row or a hierarchy of meshes.
  109839. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109840. */
  109841. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109842. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109843. /**
  109844. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109845. */
  109846. freeActiveMeshes(): void;
  109847. /**
  109848. * Clear the info related to rendering groups preventing retention points during dispose.
  109849. */
  109850. freeRenderingGroups(): void;
  109851. /** @hidden */
  109852. _isInIntermediateRendering(): boolean;
  109853. /**
  109854. * Lambda returning the list of potentially active meshes.
  109855. */
  109856. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109857. /**
  109858. * Lambda returning the list of potentially active sub meshes.
  109859. */
  109860. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109861. /**
  109862. * Lambda returning the list of potentially intersecting sub meshes.
  109863. */
  109864. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109865. /**
  109866. * Lambda returning the list of potentially colliding sub meshes.
  109867. */
  109868. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109869. private _activeMeshesFrozen;
  109870. private _skipEvaluateActiveMeshesCompletely;
  109871. /**
  109872. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109873. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109874. * @returns the current scene
  109875. */
  109876. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109877. /**
  109878. * Use this function to restart evaluating active meshes on every frame
  109879. * @returns the current scene
  109880. */
  109881. unfreezeActiveMeshes(): Scene;
  109882. private _evaluateActiveMeshes;
  109883. private _activeMesh;
  109884. /**
  109885. * Update the transform matrix to update from the current active camera
  109886. * @param force defines a boolean used to force the update even if cache is up to date
  109887. */
  109888. updateTransformMatrix(force?: boolean): void;
  109889. private _bindFrameBuffer;
  109890. /** @hidden */
  109891. _allowPostProcessClearColor: boolean;
  109892. /** @hidden */
  109893. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109894. private _processSubCameras;
  109895. private _checkIntersections;
  109896. /** @hidden */
  109897. _advancePhysicsEngineStep(step: number): void;
  109898. /**
  109899. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109900. */
  109901. getDeterministicFrameTime: () => number;
  109902. /** @hidden */
  109903. _animate(): void;
  109904. /** Execute all animations (for a frame) */
  109905. animate(): void;
  109906. /**
  109907. * Render the scene
  109908. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109909. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109910. */
  109911. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109912. /**
  109913. * Freeze all materials
  109914. * A frozen material will not be updatable but should be faster to render
  109915. */
  109916. freezeMaterials(): void;
  109917. /**
  109918. * Unfreeze all materials
  109919. * A frozen material will not be updatable but should be faster to render
  109920. */
  109921. unfreezeMaterials(): void;
  109922. /**
  109923. * Releases all held ressources
  109924. */
  109925. dispose(): void;
  109926. /**
  109927. * Gets if the scene is already disposed
  109928. */
  109929. get isDisposed(): boolean;
  109930. /**
  109931. * Call this function to reduce memory footprint of the scene.
  109932. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109933. */
  109934. clearCachedVertexData(): void;
  109935. /**
  109936. * This function will remove the local cached buffer data from texture.
  109937. * It will save memory but will prevent the texture from being rebuilt
  109938. */
  109939. cleanCachedTextureBuffer(): void;
  109940. /**
  109941. * Get the world extend vectors with an optional filter
  109942. *
  109943. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109944. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109945. */
  109946. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109947. min: Vector3;
  109948. max: Vector3;
  109949. };
  109950. /**
  109951. * Creates a ray that can be used to pick in the scene
  109952. * @param x defines the x coordinate of the origin (on-screen)
  109953. * @param y defines the y coordinate of the origin (on-screen)
  109954. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109955. * @param camera defines the camera to use for the picking
  109956. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109957. * @returns a Ray
  109958. */
  109959. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109960. /**
  109961. * Creates a ray that can be used to pick in the scene
  109962. * @param x defines the x coordinate of the origin (on-screen)
  109963. * @param y defines the y coordinate of the origin (on-screen)
  109964. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109965. * @param result defines the ray where to store the picking ray
  109966. * @param camera defines the camera to use for the picking
  109967. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109968. * @returns the current scene
  109969. */
  109970. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109971. /**
  109972. * Creates a ray that can be used to pick in the scene
  109973. * @param x defines the x coordinate of the origin (on-screen)
  109974. * @param y defines the y coordinate of the origin (on-screen)
  109975. * @param camera defines the camera to use for the picking
  109976. * @returns a Ray
  109977. */
  109978. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109979. /**
  109980. * Creates a ray that can be used to pick in the scene
  109981. * @param x defines the x coordinate of the origin (on-screen)
  109982. * @param y defines the y coordinate of the origin (on-screen)
  109983. * @param result defines the ray where to store the picking ray
  109984. * @param camera defines the camera to use for the picking
  109985. * @returns the current scene
  109986. */
  109987. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109988. /** Launch a ray to try to pick a mesh in the scene
  109989. * @param x position on screen
  109990. * @param y position on screen
  109991. * @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
  109992. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109993. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109995. * @returns a PickingInfo
  109996. */
  109997. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109998. /** Use the given ray to pick a mesh in the scene
  109999. * @param ray The ray to use to pick meshes
  110000. * @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
  110001. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110002. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110003. * @returns a PickingInfo
  110004. */
  110005. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110006. /**
  110007. * Launch a ray to try to pick a mesh in the scene
  110008. * @param x X position on screen
  110009. * @param y Y position on screen
  110010. * @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
  110011. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110013. * @returns an array of PickingInfo
  110014. */
  110015. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110016. /**
  110017. * Launch a ray to try to pick a mesh in the scene
  110018. * @param ray Ray to use
  110019. * @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
  110020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110021. * @returns an array of PickingInfo
  110022. */
  110023. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110024. /**
  110025. * Force the value of meshUnderPointer
  110026. * @param mesh defines the mesh to use
  110027. */
  110028. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110029. /**
  110030. * Gets the mesh under the pointer
  110031. * @returns a Mesh or null if no mesh is under the pointer
  110032. */
  110033. getPointerOverMesh(): Nullable<AbstractMesh>;
  110034. /** @hidden */
  110035. _rebuildGeometries(): void;
  110036. /** @hidden */
  110037. _rebuildTextures(): void;
  110038. private _getByTags;
  110039. /**
  110040. * Get a list of meshes by tags
  110041. * @param tagsQuery defines the tags query to use
  110042. * @param forEach defines a predicate used to filter results
  110043. * @returns an array of Mesh
  110044. */
  110045. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110046. /**
  110047. * Get a list of cameras by tags
  110048. * @param tagsQuery defines the tags query to use
  110049. * @param forEach defines a predicate used to filter results
  110050. * @returns an array of Camera
  110051. */
  110052. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110053. /**
  110054. * Get a list of lights by tags
  110055. * @param tagsQuery defines the tags query to use
  110056. * @param forEach defines a predicate used to filter results
  110057. * @returns an array of Light
  110058. */
  110059. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110060. /**
  110061. * Get a list of materials by tags
  110062. * @param tagsQuery defines the tags query to use
  110063. * @param forEach defines a predicate used to filter results
  110064. * @returns an array of Material
  110065. */
  110066. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110067. /**
  110068. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110069. * This allowed control for front to back rendering or reversly depending of the special needs.
  110070. *
  110071. * @param renderingGroupId The rendering group id corresponding to its index
  110072. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110073. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110074. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110075. */
  110076. 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;
  110077. /**
  110078. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110079. *
  110080. * @param renderingGroupId The rendering group id corresponding to its index
  110081. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110082. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110083. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110084. */
  110085. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110086. /**
  110087. * Gets the current auto clear configuration for one rendering group of the rendering
  110088. * manager.
  110089. * @param index the rendering group index to get the information for
  110090. * @returns The auto clear setup for the requested rendering group
  110091. */
  110092. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110093. private _blockMaterialDirtyMechanism;
  110094. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110095. get blockMaterialDirtyMechanism(): boolean;
  110096. set blockMaterialDirtyMechanism(value: boolean);
  110097. /**
  110098. * Will flag all materials as dirty to trigger new shader compilation
  110099. * @param flag defines the flag used to specify which material part must be marked as dirty
  110100. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110101. */
  110102. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110103. /** @hidden */
  110104. _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;
  110105. /** @hidden */
  110106. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110107. /** @hidden */
  110108. _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;
  110109. /** @hidden */
  110110. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110111. /** @hidden */
  110112. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110113. /** @hidden */
  110114. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110115. }
  110116. }
  110117. declare module BABYLON {
  110118. /**
  110119. * Set of assets to keep when moving a scene into an asset container.
  110120. */
  110121. export class KeepAssets extends AbstractScene {
  110122. }
  110123. /**
  110124. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110125. */
  110126. export class InstantiatedEntries {
  110127. /**
  110128. * List of new root nodes (eg. nodes with no parent)
  110129. */
  110130. rootNodes: TransformNode[];
  110131. /**
  110132. * List of new skeletons
  110133. */
  110134. skeletons: Skeleton[];
  110135. /**
  110136. * List of new animation groups
  110137. */
  110138. animationGroups: AnimationGroup[];
  110139. }
  110140. /**
  110141. * Container with a set of assets that can be added or removed from a scene.
  110142. */
  110143. export class AssetContainer extends AbstractScene {
  110144. private _wasAddedToScene;
  110145. /**
  110146. * The scene the AssetContainer belongs to.
  110147. */
  110148. scene: Scene;
  110149. /**
  110150. * Instantiates an AssetContainer.
  110151. * @param scene The scene the AssetContainer belongs to.
  110152. */
  110153. constructor(scene: Scene);
  110154. /**
  110155. * Instantiate or clone all meshes and add the new ones to the scene.
  110156. * Skeletons and animation groups will all be cloned
  110157. * @param nameFunction defines an optional function used to get new names for clones
  110158. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110159. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110160. */
  110161. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110162. /**
  110163. * Adds all the assets from the container to the scene.
  110164. */
  110165. addAllToScene(): void;
  110166. /**
  110167. * Removes all the assets in the container from the scene
  110168. */
  110169. removeAllFromScene(): void;
  110170. /**
  110171. * Disposes all the assets in the container
  110172. */
  110173. dispose(): void;
  110174. private _moveAssets;
  110175. /**
  110176. * Removes all the assets contained in the scene and adds them to the container.
  110177. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110178. */
  110179. moveAllFromScene(keepAssets?: KeepAssets): void;
  110180. /**
  110181. * 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.
  110182. * @returns the root mesh
  110183. */
  110184. createRootMesh(): Mesh;
  110185. /**
  110186. * Merge animations from this asset container into a scene
  110187. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110188. * @param animatables set of animatables to retarget to a node from the scene
  110189. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110190. */
  110191. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110192. }
  110193. }
  110194. declare module BABYLON {
  110195. /**
  110196. * Defines how the parser contract is defined.
  110197. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110198. */
  110199. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110200. /**
  110201. * Defines how the individual parser contract is defined.
  110202. * These parser can parse an individual asset
  110203. */
  110204. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110205. /**
  110206. * Base class of the scene acting as a container for the different elements composing a scene.
  110207. * This class is dynamically extended by the different components of the scene increasing
  110208. * flexibility and reducing coupling
  110209. */
  110210. export abstract class AbstractScene {
  110211. /**
  110212. * Stores the list of available parsers in the application.
  110213. */
  110214. private static _BabylonFileParsers;
  110215. /**
  110216. * Stores the list of available individual parsers in the application.
  110217. */
  110218. private static _IndividualBabylonFileParsers;
  110219. /**
  110220. * Adds a parser in the list of available ones
  110221. * @param name Defines the name of the parser
  110222. * @param parser Defines the parser to add
  110223. */
  110224. static AddParser(name: string, parser: BabylonFileParser): void;
  110225. /**
  110226. * Gets a general parser from the list of avaialble ones
  110227. * @param name Defines the name of the parser
  110228. * @returns the requested parser or null
  110229. */
  110230. static GetParser(name: string): Nullable<BabylonFileParser>;
  110231. /**
  110232. * Adds n individual parser in the list of available ones
  110233. * @param name Defines the name of the parser
  110234. * @param parser Defines the parser to add
  110235. */
  110236. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110237. /**
  110238. * Gets an individual parser from the list of avaialble ones
  110239. * @param name Defines the name of the parser
  110240. * @returns the requested parser or null
  110241. */
  110242. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110243. /**
  110244. * Parser json data and populate both a scene and its associated container object
  110245. * @param jsonData Defines the data to parse
  110246. * @param scene Defines the scene to parse the data for
  110247. * @param container Defines the container attached to the parsing sequence
  110248. * @param rootUrl Defines the root url of the data
  110249. */
  110250. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110251. /**
  110252. * Gets the list of root nodes (ie. nodes with no parent)
  110253. */
  110254. rootNodes: Node[];
  110255. /** All of the cameras added to this scene
  110256. * @see http://doc.babylonjs.com/babylon101/cameras
  110257. */
  110258. cameras: Camera[];
  110259. /**
  110260. * All of the lights added to this scene
  110261. * @see http://doc.babylonjs.com/babylon101/lights
  110262. */
  110263. lights: Light[];
  110264. /**
  110265. * All of the (abstract) meshes added to this scene
  110266. */
  110267. meshes: AbstractMesh[];
  110268. /**
  110269. * The list of skeletons added to the scene
  110270. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110271. */
  110272. skeletons: Skeleton[];
  110273. /**
  110274. * All of the particle systems added to this scene
  110275. * @see http://doc.babylonjs.com/babylon101/particles
  110276. */
  110277. particleSystems: IParticleSystem[];
  110278. /**
  110279. * Gets a list of Animations associated with the scene
  110280. */
  110281. animations: Animation[];
  110282. /**
  110283. * All of the animation groups added to this scene
  110284. * @see http://doc.babylonjs.com/how_to/group
  110285. */
  110286. animationGroups: AnimationGroup[];
  110287. /**
  110288. * All of the multi-materials added to this scene
  110289. * @see http://doc.babylonjs.com/how_to/multi_materials
  110290. */
  110291. multiMaterials: MultiMaterial[];
  110292. /**
  110293. * All of the materials added to this scene
  110294. * In the context of a Scene, it is not supposed to be modified manually.
  110295. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110296. * Note also that the order of the Material within the array is not significant and might change.
  110297. * @see http://doc.babylonjs.com/babylon101/materials
  110298. */
  110299. materials: Material[];
  110300. /**
  110301. * The list of morph target managers added to the scene
  110302. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110303. */
  110304. morphTargetManagers: MorphTargetManager[];
  110305. /**
  110306. * The list of geometries used in the scene.
  110307. */
  110308. geometries: Geometry[];
  110309. /**
  110310. * All of the tranform nodes added to this scene
  110311. * In the context of a Scene, it is not supposed to be modified manually.
  110312. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110313. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110314. * @see http://doc.babylonjs.com/how_to/transformnode
  110315. */
  110316. transformNodes: TransformNode[];
  110317. /**
  110318. * ActionManagers available on the scene.
  110319. */
  110320. actionManagers: AbstractActionManager[];
  110321. /**
  110322. * Textures to keep.
  110323. */
  110324. textures: BaseTexture[];
  110325. /**
  110326. * Environment texture for the scene
  110327. */
  110328. environmentTexture: Nullable<BaseTexture>;
  110329. /**
  110330. * @returns all meshes, lights, cameras, transformNodes and bones
  110331. */
  110332. getNodes(): Array<Node>;
  110333. }
  110334. }
  110335. declare module BABYLON {
  110336. /**
  110337. * Interface used to define options for Sound class
  110338. */
  110339. export interface ISoundOptions {
  110340. /**
  110341. * Does the sound autoplay once loaded.
  110342. */
  110343. autoplay?: boolean;
  110344. /**
  110345. * Does the sound loop after it finishes playing once.
  110346. */
  110347. loop?: boolean;
  110348. /**
  110349. * Sound's volume
  110350. */
  110351. volume?: number;
  110352. /**
  110353. * Is it a spatial sound?
  110354. */
  110355. spatialSound?: boolean;
  110356. /**
  110357. * Maximum distance to hear that sound
  110358. */
  110359. maxDistance?: number;
  110360. /**
  110361. * Uses user defined attenuation function
  110362. */
  110363. useCustomAttenuation?: boolean;
  110364. /**
  110365. * Define the roll off factor of spatial sounds.
  110366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110367. */
  110368. rolloffFactor?: number;
  110369. /**
  110370. * Define the reference distance the sound should be heard perfectly.
  110371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110372. */
  110373. refDistance?: number;
  110374. /**
  110375. * Define the distance attenuation model the sound will follow.
  110376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110377. */
  110378. distanceModel?: string;
  110379. /**
  110380. * Defines the playback speed (1 by default)
  110381. */
  110382. playbackRate?: number;
  110383. /**
  110384. * Defines if the sound is from a streaming source
  110385. */
  110386. streaming?: boolean;
  110387. /**
  110388. * Defines an optional length (in seconds) inside the sound file
  110389. */
  110390. length?: number;
  110391. /**
  110392. * Defines an optional offset (in seconds) inside the sound file
  110393. */
  110394. offset?: number;
  110395. /**
  110396. * If true, URLs will not be required to state the audio file codec to use.
  110397. */
  110398. skipCodecCheck?: boolean;
  110399. }
  110400. /**
  110401. * Defines a sound that can be played in the application.
  110402. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110404. */
  110405. export class Sound {
  110406. /**
  110407. * The name of the sound in the scene.
  110408. */
  110409. name: string;
  110410. /**
  110411. * Does the sound autoplay once loaded.
  110412. */
  110413. autoplay: boolean;
  110414. /**
  110415. * Does the sound loop after it finishes playing once.
  110416. */
  110417. loop: boolean;
  110418. /**
  110419. * Does the sound use a custom attenuation curve to simulate the falloff
  110420. * happening when the source gets further away from the camera.
  110421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110422. */
  110423. useCustomAttenuation: boolean;
  110424. /**
  110425. * The sound track id this sound belongs to.
  110426. */
  110427. soundTrackId: number;
  110428. /**
  110429. * Is this sound currently played.
  110430. */
  110431. isPlaying: boolean;
  110432. /**
  110433. * Is this sound currently paused.
  110434. */
  110435. isPaused: boolean;
  110436. /**
  110437. * Does this sound enables spatial sound.
  110438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110439. */
  110440. spatialSound: boolean;
  110441. /**
  110442. * Define the reference distance the sound should be heard perfectly.
  110443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110444. */
  110445. refDistance: number;
  110446. /**
  110447. * Define the roll off factor of spatial sounds.
  110448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110449. */
  110450. rolloffFactor: number;
  110451. /**
  110452. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110454. */
  110455. maxDistance: number;
  110456. /**
  110457. * Define the distance attenuation model the sound will follow.
  110458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110459. */
  110460. distanceModel: string;
  110461. /**
  110462. * @hidden
  110463. * Back Compat
  110464. **/
  110465. onended: () => any;
  110466. /**
  110467. * Observable event when the current playing sound finishes.
  110468. */
  110469. onEndedObservable: Observable<Sound>;
  110470. private _panningModel;
  110471. private _playbackRate;
  110472. private _streaming;
  110473. private _startTime;
  110474. private _startOffset;
  110475. private _position;
  110476. /** @hidden */
  110477. _positionInEmitterSpace: boolean;
  110478. private _localDirection;
  110479. private _volume;
  110480. private _isReadyToPlay;
  110481. private _isDirectional;
  110482. private _readyToPlayCallback;
  110483. private _audioBuffer;
  110484. private _soundSource;
  110485. private _streamingSource;
  110486. private _soundPanner;
  110487. private _soundGain;
  110488. private _inputAudioNode;
  110489. private _outputAudioNode;
  110490. private _coneInnerAngle;
  110491. private _coneOuterAngle;
  110492. private _coneOuterGain;
  110493. private _scene;
  110494. private _connectedTransformNode;
  110495. private _customAttenuationFunction;
  110496. private _registerFunc;
  110497. private _isOutputConnected;
  110498. private _htmlAudioElement;
  110499. private _urlType;
  110500. private _length?;
  110501. private _offset?;
  110502. /** @hidden */
  110503. static _SceneComponentInitialization: (scene: Scene) => void;
  110504. /**
  110505. * Create a sound and attach it to a scene
  110506. * @param name Name of your sound
  110507. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110508. * @param scene defines the scene the sound belongs to
  110509. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110510. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110511. */
  110512. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110513. /**
  110514. * Release the sound and its associated resources
  110515. */
  110516. dispose(): void;
  110517. /**
  110518. * Gets if the sounds is ready to be played or not.
  110519. * @returns true if ready, otherwise false
  110520. */
  110521. isReady(): boolean;
  110522. private _soundLoaded;
  110523. /**
  110524. * Sets the data of the sound from an audiobuffer
  110525. * @param audioBuffer The audioBuffer containing the data
  110526. */
  110527. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110528. /**
  110529. * Updates the current sounds options such as maxdistance, loop...
  110530. * @param options A JSON object containing values named as the object properties
  110531. */
  110532. updateOptions(options: ISoundOptions): void;
  110533. private _createSpatialParameters;
  110534. private _updateSpatialParameters;
  110535. /**
  110536. * Switch the panning model to HRTF:
  110537. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110539. */
  110540. switchPanningModelToHRTF(): void;
  110541. /**
  110542. * Switch the panning model to Equal Power:
  110543. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110545. */
  110546. switchPanningModelToEqualPower(): void;
  110547. private _switchPanningModel;
  110548. /**
  110549. * Connect this sound to a sound track audio node like gain...
  110550. * @param soundTrackAudioNode the sound track audio node to connect to
  110551. */
  110552. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110553. /**
  110554. * Transform this sound into a directional source
  110555. * @param coneInnerAngle Size of the inner cone in degree
  110556. * @param coneOuterAngle Size of the outer cone in degree
  110557. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110558. */
  110559. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110560. /**
  110561. * Gets or sets the inner angle for the directional cone.
  110562. */
  110563. get directionalConeInnerAngle(): number;
  110564. /**
  110565. * Gets or sets the inner angle for the directional cone.
  110566. */
  110567. set directionalConeInnerAngle(value: number);
  110568. /**
  110569. * Gets or sets the outer angle for the directional cone.
  110570. */
  110571. get directionalConeOuterAngle(): number;
  110572. /**
  110573. * Gets or sets the outer angle for the directional cone.
  110574. */
  110575. set directionalConeOuterAngle(value: number);
  110576. /**
  110577. * Sets the position of the emitter if spatial sound is enabled
  110578. * @param newPosition Defines the new posisiton
  110579. */
  110580. setPosition(newPosition: Vector3): void;
  110581. /**
  110582. * Sets the local direction of the emitter if spatial sound is enabled
  110583. * @param newLocalDirection Defines the new local direction
  110584. */
  110585. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110586. private _updateDirection;
  110587. /** @hidden */
  110588. updateDistanceFromListener(): void;
  110589. /**
  110590. * Sets a new custom attenuation function for the sound.
  110591. * @param callback Defines the function used for the attenuation
  110592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110593. */
  110594. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110595. /**
  110596. * Play the sound
  110597. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110598. * @param offset (optional) Start the sound at a specific time in seconds
  110599. * @param length (optional) Sound duration (in seconds)
  110600. */
  110601. play(time?: number, offset?: number, length?: number): void;
  110602. private _onended;
  110603. /**
  110604. * Stop the sound
  110605. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110606. */
  110607. stop(time?: number): void;
  110608. /**
  110609. * Put the sound in pause
  110610. */
  110611. pause(): void;
  110612. /**
  110613. * Sets a dedicated volume for this sounds
  110614. * @param newVolume Define the new volume of the sound
  110615. * @param time Define time for gradual change to new volume
  110616. */
  110617. setVolume(newVolume: number, time?: number): void;
  110618. /**
  110619. * Set the sound play back rate
  110620. * @param newPlaybackRate Define the playback rate the sound should be played at
  110621. */
  110622. setPlaybackRate(newPlaybackRate: number): void;
  110623. /**
  110624. * Gets the volume of the sound.
  110625. * @returns the volume of the sound
  110626. */
  110627. getVolume(): number;
  110628. /**
  110629. * Attach the sound to a dedicated mesh
  110630. * @param transformNode The transform node to connect the sound with
  110631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110632. */
  110633. attachToMesh(transformNode: TransformNode): void;
  110634. /**
  110635. * Detach the sound from the previously attached mesh
  110636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110637. */
  110638. detachFromMesh(): void;
  110639. private _onRegisterAfterWorldMatrixUpdate;
  110640. /**
  110641. * Clone the current sound in the scene.
  110642. * @returns the new sound clone
  110643. */
  110644. clone(): Nullable<Sound>;
  110645. /**
  110646. * Gets the current underlying audio buffer containing the data
  110647. * @returns the audio buffer
  110648. */
  110649. getAudioBuffer(): Nullable<AudioBuffer>;
  110650. /**
  110651. * Serializes the Sound in a JSON representation
  110652. * @returns the JSON representation of the sound
  110653. */
  110654. serialize(): any;
  110655. /**
  110656. * Parse a JSON representation of a sound to innstantiate in a given scene
  110657. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110658. * @param scene Define the scene the new parsed sound should be created in
  110659. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110660. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110661. * @returns the newly parsed sound
  110662. */
  110663. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110664. }
  110665. }
  110666. declare module BABYLON {
  110667. /**
  110668. * This defines an action helpful to play a defined sound on a triggered action.
  110669. */
  110670. export class PlaySoundAction extends Action {
  110671. private _sound;
  110672. /**
  110673. * Instantiate the action
  110674. * @param triggerOptions defines the trigger options
  110675. * @param sound defines the sound to play
  110676. * @param condition defines the trigger related conditions
  110677. */
  110678. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110679. /** @hidden */
  110680. _prepare(): void;
  110681. /**
  110682. * Execute the action and play the sound.
  110683. */
  110684. execute(): void;
  110685. /**
  110686. * Serializes the actions and its related information.
  110687. * @param parent defines the object to serialize in
  110688. * @returns the serialized object
  110689. */
  110690. serialize(parent: any): any;
  110691. }
  110692. /**
  110693. * This defines an action helpful to stop a defined sound on a triggered action.
  110694. */
  110695. export class StopSoundAction extends Action {
  110696. private _sound;
  110697. /**
  110698. * Instantiate the action
  110699. * @param triggerOptions defines the trigger options
  110700. * @param sound defines the sound to stop
  110701. * @param condition defines the trigger related conditions
  110702. */
  110703. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110704. /** @hidden */
  110705. _prepare(): void;
  110706. /**
  110707. * Execute the action and stop the sound.
  110708. */
  110709. execute(): void;
  110710. /**
  110711. * Serializes the actions and its related information.
  110712. * @param parent defines the object to serialize in
  110713. * @returns the serialized object
  110714. */
  110715. serialize(parent: any): any;
  110716. }
  110717. }
  110718. declare module BABYLON {
  110719. /**
  110720. * This defines an action responsible to change the value of a property
  110721. * by interpolating between its current value and the newly set one once triggered.
  110722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110723. */
  110724. export class InterpolateValueAction extends Action {
  110725. /**
  110726. * Defines the path of the property where the value should be interpolated
  110727. */
  110728. propertyPath: string;
  110729. /**
  110730. * Defines the target value at the end of the interpolation.
  110731. */
  110732. value: any;
  110733. /**
  110734. * Defines the time it will take for the property to interpolate to the value.
  110735. */
  110736. duration: number;
  110737. /**
  110738. * Defines if the other scene animations should be stopped when the action has been triggered
  110739. */
  110740. stopOtherAnimations?: boolean;
  110741. /**
  110742. * Defines a callback raised once the interpolation animation has been done.
  110743. */
  110744. onInterpolationDone?: () => void;
  110745. /**
  110746. * Observable triggered once the interpolation animation has been done.
  110747. */
  110748. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110749. private _target;
  110750. private _effectiveTarget;
  110751. private _property;
  110752. /**
  110753. * Instantiate the action
  110754. * @param triggerOptions defines the trigger options
  110755. * @param target defines the object containing the value to interpolate
  110756. * @param propertyPath defines the path to the property in the target object
  110757. * @param value defines the target value at the end of the interpolation
  110758. * @param duration deines the time it will take for the property to interpolate to the value.
  110759. * @param condition defines the trigger related conditions
  110760. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110761. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110762. */
  110763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110764. /** @hidden */
  110765. _prepare(): void;
  110766. /**
  110767. * Execute the action starts the value interpolation.
  110768. */
  110769. execute(): void;
  110770. /**
  110771. * Serializes the actions and its related information.
  110772. * @param parent defines the object to serialize in
  110773. * @returns the serialized object
  110774. */
  110775. serialize(parent: any): any;
  110776. }
  110777. }
  110778. declare module BABYLON {
  110779. /**
  110780. * Options allowed during the creation of a sound track.
  110781. */
  110782. export interface ISoundTrackOptions {
  110783. /**
  110784. * The volume the sound track should take during creation
  110785. */
  110786. volume?: number;
  110787. /**
  110788. * Define if the sound track is the main sound track of the scene
  110789. */
  110790. mainTrack?: boolean;
  110791. }
  110792. /**
  110793. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110794. * It will be also used in a future release to apply effects on a specific track.
  110795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110796. */
  110797. export class SoundTrack {
  110798. /**
  110799. * The unique identifier of the sound track in the scene.
  110800. */
  110801. id: number;
  110802. /**
  110803. * The list of sounds included in the sound track.
  110804. */
  110805. soundCollection: Array<Sound>;
  110806. private _outputAudioNode;
  110807. private _scene;
  110808. private _connectedAnalyser;
  110809. private _options;
  110810. private _isInitialized;
  110811. /**
  110812. * Creates a new sound track.
  110813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110814. * @param scene Define the scene the sound track belongs to
  110815. * @param options
  110816. */
  110817. constructor(scene: Scene, options?: ISoundTrackOptions);
  110818. private _initializeSoundTrackAudioGraph;
  110819. /**
  110820. * Release the sound track and its associated resources
  110821. */
  110822. dispose(): void;
  110823. /**
  110824. * Adds a sound to this sound track
  110825. * @param sound define the cound to add
  110826. * @ignoreNaming
  110827. */
  110828. AddSound(sound: Sound): void;
  110829. /**
  110830. * Removes a sound to this sound track
  110831. * @param sound define the cound to remove
  110832. * @ignoreNaming
  110833. */
  110834. RemoveSound(sound: Sound): void;
  110835. /**
  110836. * Set a global volume for the full sound track.
  110837. * @param newVolume Define the new volume of the sound track
  110838. */
  110839. setVolume(newVolume: number): void;
  110840. /**
  110841. * Switch the panning model to HRTF:
  110842. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110844. */
  110845. switchPanningModelToHRTF(): void;
  110846. /**
  110847. * Switch the panning model to Equal Power:
  110848. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110850. */
  110851. switchPanningModelToEqualPower(): void;
  110852. /**
  110853. * Connect the sound track to an audio analyser allowing some amazing
  110854. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110856. * @param analyser The analyser to connect to the engine
  110857. */
  110858. connectToAnalyser(analyser: Analyser): void;
  110859. }
  110860. }
  110861. declare module BABYLON {
  110862. interface AbstractScene {
  110863. /**
  110864. * The list of sounds used in the scene.
  110865. */
  110866. sounds: Nullable<Array<Sound>>;
  110867. }
  110868. interface Scene {
  110869. /**
  110870. * @hidden
  110871. * Backing field
  110872. */
  110873. _mainSoundTrack: SoundTrack;
  110874. /**
  110875. * The main sound track played by the scene.
  110876. * It cotains your primary collection of sounds.
  110877. */
  110878. mainSoundTrack: SoundTrack;
  110879. /**
  110880. * The list of sound tracks added to the scene
  110881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110882. */
  110883. soundTracks: Nullable<Array<SoundTrack>>;
  110884. /**
  110885. * Gets a sound using a given name
  110886. * @param name defines the name to search for
  110887. * @return the found sound or null if not found at all.
  110888. */
  110889. getSoundByName(name: string): Nullable<Sound>;
  110890. /**
  110891. * Gets or sets if audio support is enabled
  110892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110893. */
  110894. audioEnabled: boolean;
  110895. /**
  110896. * Gets or sets if audio will be output to headphones
  110897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110898. */
  110899. headphone: boolean;
  110900. /**
  110901. * Gets or sets custom audio listener position provider
  110902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110903. */
  110904. audioListenerPositionProvider: Nullable<() => Vector3>;
  110905. /**
  110906. * Gets or sets a refresh rate when using 3D audio positioning
  110907. */
  110908. audioPositioningRefreshRate: number;
  110909. }
  110910. /**
  110911. * Defines the sound scene component responsible to manage any sounds
  110912. * in a given scene.
  110913. */
  110914. export class AudioSceneComponent implements ISceneSerializableComponent {
  110915. /**
  110916. * The component name helpfull to identify the component in the list of scene components.
  110917. */
  110918. readonly name: string;
  110919. /**
  110920. * The scene the component belongs to.
  110921. */
  110922. scene: Scene;
  110923. private _audioEnabled;
  110924. /**
  110925. * Gets whether audio is enabled or not.
  110926. * Please use related enable/disable method to switch state.
  110927. */
  110928. get audioEnabled(): boolean;
  110929. private _headphone;
  110930. /**
  110931. * Gets whether audio is outputing to headphone or not.
  110932. * Please use the according Switch methods to change output.
  110933. */
  110934. get headphone(): boolean;
  110935. /**
  110936. * Gets or sets a refresh rate when using 3D audio positioning
  110937. */
  110938. audioPositioningRefreshRate: number;
  110939. private _audioListenerPositionProvider;
  110940. /**
  110941. * Gets the current audio listener position provider
  110942. */
  110943. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110944. /**
  110945. * Sets a custom listener position for all sounds in the scene
  110946. * By default, this is the position of the first active camera
  110947. */
  110948. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110949. /**
  110950. * Creates a new instance of the component for the given scene
  110951. * @param scene Defines the scene to register the component in
  110952. */
  110953. constructor(scene: Scene);
  110954. /**
  110955. * Registers the component in a given scene
  110956. */
  110957. register(): void;
  110958. /**
  110959. * Rebuilds the elements related to this component in case of
  110960. * context lost for instance.
  110961. */
  110962. rebuild(): void;
  110963. /**
  110964. * Serializes the component data to the specified json object
  110965. * @param serializationObject The object to serialize to
  110966. */
  110967. serialize(serializationObject: any): void;
  110968. /**
  110969. * Adds all the elements from the container to the scene
  110970. * @param container the container holding the elements
  110971. */
  110972. addFromContainer(container: AbstractScene): void;
  110973. /**
  110974. * Removes all the elements in the container from the scene
  110975. * @param container contains the elements to remove
  110976. * @param dispose if the removed element should be disposed (default: false)
  110977. */
  110978. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110979. /**
  110980. * Disposes the component and the associated ressources.
  110981. */
  110982. dispose(): void;
  110983. /**
  110984. * Disables audio in the associated scene.
  110985. */
  110986. disableAudio(): void;
  110987. /**
  110988. * Enables audio in the associated scene.
  110989. */
  110990. enableAudio(): void;
  110991. /**
  110992. * Switch audio to headphone output.
  110993. */
  110994. switchAudioModeForHeadphones(): void;
  110995. /**
  110996. * Switch audio to normal speakers.
  110997. */
  110998. switchAudioModeForNormalSpeakers(): void;
  110999. private _cachedCameraDirection;
  111000. private _cachedCameraPosition;
  111001. private _lastCheck;
  111002. private _afterRender;
  111003. }
  111004. }
  111005. declare module BABYLON {
  111006. /**
  111007. * Wraps one or more Sound objects and selects one with random weight for playback.
  111008. */
  111009. export class WeightedSound {
  111010. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111011. loop: boolean;
  111012. private _coneInnerAngle;
  111013. private _coneOuterAngle;
  111014. private _volume;
  111015. /** A Sound is currently playing. */
  111016. isPlaying: boolean;
  111017. /** A Sound is currently paused. */
  111018. isPaused: boolean;
  111019. private _sounds;
  111020. private _weights;
  111021. private _currentIndex?;
  111022. /**
  111023. * Creates a new WeightedSound from the list of sounds given.
  111024. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111025. * @param sounds Array of Sounds that will be selected from.
  111026. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111027. */
  111028. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111029. /**
  111030. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111031. */
  111032. get directionalConeInnerAngle(): number;
  111033. /**
  111034. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111035. */
  111036. set directionalConeInnerAngle(value: number);
  111037. /**
  111038. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111039. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111040. */
  111041. get directionalConeOuterAngle(): number;
  111042. /**
  111043. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111044. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111045. */
  111046. set directionalConeOuterAngle(value: number);
  111047. /**
  111048. * Playback volume.
  111049. */
  111050. get volume(): number;
  111051. /**
  111052. * Playback volume.
  111053. */
  111054. set volume(value: number);
  111055. private _onended;
  111056. /**
  111057. * Suspend playback
  111058. */
  111059. pause(): void;
  111060. /**
  111061. * Stop playback
  111062. */
  111063. stop(): void;
  111064. /**
  111065. * Start playback.
  111066. * @param startOffset Position the clip head at a specific time in seconds.
  111067. */
  111068. play(startOffset?: number): void;
  111069. }
  111070. }
  111071. declare module BABYLON {
  111072. /**
  111073. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111074. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111075. */
  111076. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111077. /**
  111078. * Gets the name of the behavior.
  111079. */
  111080. get name(): string;
  111081. /**
  111082. * The easing function used by animations
  111083. */
  111084. static EasingFunction: BackEase;
  111085. /**
  111086. * The easing mode used by animations
  111087. */
  111088. static EasingMode: number;
  111089. /**
  111090. * The duration of the animation, in milliseconds
  111091. */
  111092. transitionDuration: number;
  111093. /**
  111094. * Length of the distance animated by the transition when lower radius is reached
  111095. */
  111096. lowerRadiusTransitionRange: number;
  111097. /**
  111098. * Length of the distance animated by the transition when upper radius is reached
  111099. */
  111100. upperRadiusTransitionRange: number;
  111101. private _autoTransitionRange;
  111102. /**
  111103. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111104. */
  111105. get autoTransitionRange(): boolean;
  111106. /**
  111107. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111108. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111109. */
  111110. set autoTransitionRange(value: boolean);
  111111. private _attachedCamera;
  111112. private _onAfterCheckInputsObserver;
  111113. private _onMeshTargetChangedObserver;
  111114. /**
  111115. * Initializes the behavior.
  111116. */
  111117. init(): void;
  111118. /**
  111119. * Attaches the behavior to its arc rotate camera.
  111120. * @param camera Defines the camera to attach the behavior to
  111121. */
  111122. attach(camera: ArcRotateCamera): void;
  111123. /**
  111124. * Detaches the behavior from its current arc rotate camera.
  111125. */
  111126. detach(): void;
  111127. private _radiusIsAnimating;
  111128. private _radiusBounceTransition;
  111129. private _animatables;
  111130. private _cachedWheelPrecision;
  111131. /**
  111132. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111133. * @param radiusLimit The limit to check against.
  111134. * @return Bool to indicate if at limit.
  111135. */
  111136. private _isRadiusAtLimit;
  111137. /**
  111138. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111139. * @param radiusDelta The delta by which to animate to. Can be negative.
  111140. */
  111141. private _applyBoundRadiusAnimation;
  111142. /**
  111143. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111144. */
  111145. protected _clearAnimationLocks(): void;
  111146. /**
  111147. * Stops and removes all animations that have been applied to the camera
  111148. */
  111149. stopAllAnimations(): void;
  111150. }
  111151. }
  111152. declare module BABYLON {
  111153. /**
  111154. * 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.
  111155. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111156. */
  111157. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111158. /**
  111159. * Gets the name of the behavior.
  111160. */
  111161. get name(): string;
  111162. private _mode;
  111163. private _radiusScale;
  111164. private _positionScale;
  111165. private _defaultElevation;
  111166. private _elevationReturnTime;
  111167. private _elevationReturnWaitTime;
  111168. private _zoomStopsAnimation;
  111169. private _framingTime;
  111170. /**
  111171. * The easing function used by animations
  111172. */
  111173. static EasingFunction: ExponentialEase;
  111174. /**
  111175. * The easing mode used by animations
  111176. */
  111177. static EasingMode: number;
  111178. /**
  111179. * Sets the current mode used by the behavior
  111180. */
  111181. set mode(mode: number);
  111182. /**
  111183. * Gets current mode used by the behavior.
  111184. */
  111185. get mode(): number;
  111186. /**
  111187. * Sets the scale applied to the radius (1 by default)
  111188. */
  111189. set radiusScale(radius: number);
  111190. /**
  111191. * Gets the scale applied to the radius
  111192. */
  111193. get radiusScale(): number;
  111194. /**
  111195. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111196. */
  111197. set positionScale(scale: number);
  111198. /**
  111199. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111200. */
  111201. get positionScale(): number;
  111202. /**
  111203. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111204. * behaviour is triggered, in radians.
  111205. */
  111206. set defaultElevation(elevation: number);
  111207. /**
  111208. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111209. * behaviour is triggered, in radians.
  111210. */
  111211. get defaultElevation(): number;
  111212. /**
  111213. * Sets the time (in milliseconds) taken to return to the default beta position.
  111214. * Negative value indicates camera should not return to default.
  111215. */
  111216. set elevationReturnTime(speed: number);
  111217. /**
  111218. * Gets the time (in milliseconds) taken to return to the default beta position.
  111219. * Negative value indicates camera should not return to default.
  111220. */
  111221. get elevationReturnTime(): number;
  111222. /**
  111223. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111224. */
  111225. set elevationReturnWaitTime(time: number);
  111226. /**
  111227. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111228. */
  111229. get elevationReturnWaitTime(): number;
  111230. /**
  111231. * Sets the flag that indicates if user zooming should stop animation.
  111232. */
  111233. set zoomStopsAnimation(flag: boolean);
  111234. /**
  111235. * Gets the flag that indicates if user zooming should stop animation.
  111236. */
  111237. get zoomStopsAnimation(): boolean;
  111238. /**
  111239. * Sets the transition time when framing the mesh, in milliseconds
  111240. */
  111241. set framingTime(time: number);
  111242. /**
  111243. * Gets the transition time when framing the mesh, in milliseconds
  111244. */
  111245. get framingTime(): number;
  111246. /**
  111247. * Define if the behavior should automatically change the configured
  111248. * camera limits and sensibilities.
  111249. */
  111250. autoCorrectCameraLimitsAndSensibility: boolean;
  111251. private _onPrePointerObservableObserver;
  111252. private _onAfterCheckInputsObserver;
  111253. private _onMeshTargetChangedObserver;
  111254. private _attachedCamera;
  111255. private _isPointerDown;
  111256. private _lastInteractionTime;
  111257. /**
  111258. * Initializes the behavior.
  111259. */
  111260. init(): void;
  111261. /**
  111262. * Attaches the behavior to its arc rotate camera.
  111263. * @param camera Defines the camera to attach the behavior to
  111264. */
  111265. attach(camera: ArcRotateCamera): void;
  111266. /**
  111267. * Detaches the behavior from its current arc rotate camera.
  111268. */
  111269. detach(): void;
  111270. private _animatables;
  111271. private _betaIsAnimating;
  111272. private _betaTransition;
  111273. private _radiusTransition;
  111274. private _vectorTransition;
  111275. /**
  111276. * Targets the given mesh and updates zoom level accordingly.
  111277. * @param mesh The mesh to target.
  111278. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111279. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111280. */
  111281. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111282. /**
  111283. * Targets the given mesh with its children and updates zoom level accordingly.
  111284. * @param mesh The mesh to target.
  111285. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111286. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111287. */
  111288. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111289. /**
  111290. * Targets the given meshes with their children and updates zoom level accordingly.
  111291. * @param meshes The mesh to target.
  111292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111294. */
  111295. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111296. /**
  111297. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111298. * @param minimumWorld Determines the smaller position of the bounding box extend
  111299. * @param maximumWorld Determines the bigger position of the bounding box extend
  111300. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111301. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111302. */
  111303. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111304. /**
  111305. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111306. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111307. * frustum width.
  111308. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111309. * to fully enclose the mesh in the viewing frustum.
  111310. */
  111311. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111312. /**
  111313. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111314. * is automatically returned to its default position (expected to be above ground plane).
  111315. */
  111316. private _maintainCameraAboveGround;
  111317. /**
  111318. * Returns the frustum slope based on the canvas ratio and camera FOV
  111319. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111320. */
  111321. private _getFrustumSlope;
  111322. /**
  111323. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111324. */
  111325. private _clearAnimationLocks;
  111326. /**
  111327. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111328. */
  111329. private _applyUserInteraction;
  111330. /**
  111331. * Stops and removes all animations that have been applied to the camera
  111332. */
  111333. stopAllAnimations(): void;
  111334. /**
  111335. * Gets a value indicating if the user is moving the camera
  111336. */
  111337. get isUserIsMoving(): boolean;
  111338. /**
  111339. * The camera can move all the way towards the mesh.
  111340. */
  111341. static IgnoreBoundsSizeMode: number;
  111342. /**
  111343. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111344. */
  111345. static FitFrustumSidesMode: number;
  111346. }
  111347. }
  111348. declare module BABYLON {
  111349. /**
  111350. * Base class for Camera Pointer Inputs.
  111351. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111352. * for example usage.
  111353. */
  111354. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111355. /**
  111356. * Defines the camera the input is attached to.
  111357. */
  111358. abstract camera: Camera;
  111359. /**
  111360. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111361. */
  111362. protected _altKey: boolean;
  111363. protected _ctrlKey: boolean;
  111364. protected _metaKey: boolean;
  111365. protected _shiftKey: boolean;
  111366. /**
  111367. * Which mouse buttons were pressed at time of last mouse event.
  111368. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111369. */
  111370. protected _buttonsPressed: number;
  111371. /**
  111372. * Defines the buttons associated with the input to handle camera move.
  111373. */
  111374. buttons: number[];
  111375. /**
  111376. * Attach the input controls to a specific dom element to get the input from.
  111377. * @param element Defines the element the controls should be listened from
  111378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111379. */
  111380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111381. /**
  111382. * Detach the current controls from the specified dom element.
  111383. * @param element Defines the element to stop listening the inputs from
  111384. */
  111385. detachControl(element: Nullable<HTMLElement>): void;
  111386. /**
  111387. * Gets the class name of the current input.
  111388. * @returns the class name
  111389. */
  111390. getClassName(): string;
  111391. /**
  111392. * Get the friendly name associated with the input class.
  111393. * @returns the input friendly name
  111394. */
  111395. getSimpleName(): string;
  111396. /**
  111397. * Called on pointer POINTERDOUBLETAP event.
  111398. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111399. */
  111400. protected onDoubleTap(type: string): void;
  111401. /**
  111402. * Called on pointer POINTERMOVE event if only a single touch is active.
  111403. * Override this method to provide functionality.
  111404. */
  111405. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111406. /**
  111407. * Called on pointer POINTERMOVE event if multiple touches are active.
  111408. * Override this method to provide functionality.
  111409. */
  111410. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111411. /**
  111412. * Called on JS contextmenu event.
  111413. * Override this method to provide functionality.
  111414. */
  111415. protected onContextMenu(evt: PointerEvent): void;
  111416. /**
  111417. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111418. * press.
  111419. * Override this method to provide functionality.
  111420. */
  111421. protected onButtonDown(evt: PointerEvent): void;
  111422. /**
  111423. * Called each time a new POINTERUP event occurs. Ie, for each button
  111424. * release.
  111425. * Override this method to provide functionality.
  111426. */
  111427. protected onButtonUp(evt: PointerEvent): void;
  111428. /**
  111429. * Called when window becomes inactive.
  111430. * Override this method to provide functionality.
  111431. */
  111432. protected onLostFocus(): void;
  111433. private _pointerInput;
  111434. private _observer;
  111435. private _onLostFocus;
  111436. private pointA;
  111437. private pointB;
  111438. }
  111439. }
  111440. declare module BABYLON {
  111441. /**
  111442. * Manage the pointers inputs to control an arc rotate camera.
  111443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111444. */
  111445. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111446. /**
  111447. * Defines the camera the input is attached to.
  111448. */
  111449. camera: ArcRotateCamera;
  111450. /**
  111451. * Gets the class name of the current input.
  111452. * @returns the class name
  111453. */
  111454. getClassName(): string;
  111455. /**
  111456. * Defines the buttons associated with the input to handle camera move.
  111457. */
  111458. buttons: number[];
  111459. /**
  111460. * Defines the pointer angular sensibility along the X axis or how fast is
  111461. * the camera rotating.
  111462. */
  111463. angularSensibilityX: number;
  111464. /**
  111465. * Defines the pointer angular sensibility along the Y axis or how fast is
  111466. * the camera rotating.
  111467. */
  111468. angularSensibilityY: number;
  111469. /**
  111470. * Defines the pointer pinch precision or how fast is the camera zooming.
  111471. */
  111472. pinchPrecision: number;
  111473. /**
  111474. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111475. * from 0.
  111476. * It defines the percentage of current camera.radius to use as delta when
  111477. * pinch zoom is used.
  111478. */
  111479. pinchDeltaPercentage: number;
  111480. /**
  111481. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111482. * that any object in the plane at the camera's target point will scale
  111483. * perfectly with finger motion.
  111484. * Overrides pinchDeltaPercentage and pinchPrecision.
  111485. */
  111486. useNaturalPinchZoom: boolean;
  111487. /**
  111488. * Defines the pointer panning sensibility or how fast is the camera moving.
  111489. */
  111490. panningSensibility: number;
  111491. /**
  111492. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111493. */
  111494. multiTouchPanning: boolean;
  111495. /**
  111496. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111497. * zoom (pinch) through multitouch.
  111498. */
  111499. multiTouchPanAndZoom: boolean;
  111500. /**
  111501. * Revers pinch action direction.
  111502. */
  111503. pinchInwards: boolean;
  111504. private _isPanClick;
  111505. private _twoFingerActivityCount;
  111506. private _isPinching;
  111507. /**
  111508. * Called on pointer POINTERMOVE event if only a single touch is active.
  111509. */
  111510. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111511. /**
  111512. * Called on pointer POINTERDOUBLETAP event.
  111513. */
  111514. protected onDoubleTap(type: string): void;
  111515. /**
  111516. * Called on pointer POINTERMOVE event if multiple touches are active.
  111517. */
  111518. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111519. /**
  111520. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111521. * press.
  111522. */
  111523. protected onButtonDown(evt: PointerEvent): void;
  111524. /**
  111525. * Called each time a new POINTERUP event occurs. Ie, for each button
  111526. * release.
  111527. */
  111528. protected onButtonUp(evt: PointerEvent): void;
  111529. /**
  111530. * Called when window becomes inactive.
  111531. */
  111532. protected onLostFocus(): void;
  111533. }
  111534. }
  111535. declare module BABYLON {
  111536. /**
  111537. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111539. */
  111540. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111541. /**
  111542. * Defines the camera the input is attached to.
  111543. */
  111544. camera: ArcRotateCamera;
  111545. /**
  111546. * Defines the list of key codes associated with the up action (increase alpha)
  111547. */
  111548. keysUp: number[];
  111549. /**
  111550. * Defines the list of key codes associated with the down action (decrease alpha)
  111551. */
  111552. keysDown: number[];
  111553. /**
  111554. * Defines the list of key codes associated with the left action (increase beta)
  111555. */
  111556. keysLeft: number[];
  111557. /**
  111558. * Defines the list of key codes associated with the right action (decrease beta)
  111559. */
  111560. keysRight: number[];
  111561. /**
  111562. * Defines the list of key codes associated with the reset action.
  111563. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111564. */
  111565. keysReset: number[];
  111566. /**
  111567. * Defines the panning sensibility of the inputs.
  111568. * (How fast is the camera panning)
  111569. */
  111570. panningSensibility: number;
  111571. /**
  111572. * Defines the zooming sensibility of the inputs.
  111573. * (How fast is the camera zooming)
  111574. */
  111575. zoomingSensibility: number;
  111576. /**
  111577. * Defines whether maintaining the alt key down switch the movement mode from
  111578. * orientation to zoom.
  111579. */
  111580. useAltToZoom: boolean;
  111581. /**
  111582. * Rotation speed of the camera
  111583. */
  111584. angularSpeed: number;
  111585. private _keys;
  111586. private _ctrlPressed;
  111587. private _altPressed;
  111588. private _onCanvasBlurObserver;
  111589. private _onKeyboardObserver;
  111590. private _engine;
  111591. private _scene;
  111592. /**
  111593. * Attach the input controls to a specific dom element to get the input from.
  111594. * @param element Defines the element the controls should be listened from
  111595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111596. */
  111597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111598. /**
  111599. * Detach the current controls from the specified dom element.
  111600. * @param element Defines the element to stop listening the inputs from
  111601. */
  111602. detachControl(element: Nullable<HTMLElement>): void;
  111603. /**
  111604. * Update the current camera state depending on the inputs that have been used this frame.
  111605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111606. */
  111607. checkInputs(): void;
  111608. /**
  111609. * Gets the class name of the current intput.
  111610. * @returns the class name
  111611. */
  111612. getClassName(): string;
  111613. /**
  111614. * Get the friendly name associated with the input class.
  111615. * @returns the input friendly name
  111616. */
  111617. getSimpleName(): string;
  111618. }
  111619. }
  111620. declare module BABYLON {
  111621. /**
  111622. * Manage the mouse wheel inputs to control an arc rotate camera.
  111623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111624. */
  111625. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111626. /**
  111627. * Defines the camera the input is attached to.
  111628. */
  111629. camera: ArcRotateCamera;
  111630. /**
  111631. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111632. */
  111633. wheelPrecision: number;
  111634. /**
  111635. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111636. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111637. */
  111638. wheelDeltaPercentage: number;
  111639. private _wheel;
  111640. private _observer;
  111641. private computeDeltaFromMouseWheelLegacyEvent;
  111642. /**
  111643. * Attach the input controls to a specific dom element to get the input from.
  111644. * @param element Defines the element the controls should be listened from
  111645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111646. */
  111647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111648. /**
  111649. * Detach the current controls from the specified dom element.
  111650. * @param element Defines the element to stop listening the inputs from
  111651. */
  111652. detachControl(element: Nullable<HTMLElement>): void;
  111653. /**
  111654. * Gets the class name of the current intput.
  111655. * @returns the class name
  111656. */
  111657. getClassName(): string;
  111658. /**
  111659. * Get the friendly name associated with the input class.
  111660. * @returns the input friendly name
  111661. */
  111662. getSimpleName(): string;
  111663. }
  111664. }
  111665. declare module BABYLON {
  111666. /**
  111667. * Default Inputs manager for the ArcRotateCamera.
  111668. * It groups all the default supported inputs for ease of use.
  111669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111670. */
  111671. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111672. /**
  111673. * Instantiates a new ArcRotateCameraInputsManager.
  111674. * @param camera Defines the camera the inputs belong to
  111675. */
  111676. constructor(camera: ArcRotateCamera);
  111677. /**
  111678. * Add mouse wheel input support to the input manager.
  111679. * @returns the current input manager
  111680. */
  111681. addMouseWheel(): ArcRotateCameraInputsManager;
  111682. /**
  111683. * Add pointers input support to the input manager.
  111684. * @returns the current input manager
  111685. */
  111686. addPointers(): ArcRotateCameraInputsManager;
  111687. /**
  111688. * Add keyboard input support to the input manager.
  111689. * @returns the current input manager
  111690. */
  111691. addKeyboard(): ArcRotateCameraInputsManager;
  111692. }
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * This represents an orbital type of camera.
  111697. *
  111698. * 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.
  111699. * 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.
  111700. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111701. */
  111702. export class ArcRotateCamera extends TargetCamera {
  111703. /**
  111704. * Defines the rotation angle of the camera along the longitudinal axis.
  111705. */
  111706. alpha: number;
  111707. /**
  111708. * Defines the rotation angle of the camera along the latitudinal axis.
  111709. */
  111710. beta: number;
  111711. /**
  111712. * Defines the radius of the camera from it s target point.
  111713. */
  111714. radius: number;
  111715. protected _target: Vector3;
  111716. protected _targetHost: Nullable<AbstractMesh>;
  111717. /**
  111718. * Defines the target point of the camera.
  111719. * The camera looks towards it form the radius distance.
  111720. */
  111721. get target(): Vector3;
  111722. set target(value: Vector3);
  111723. /**
  111724. * Define the current local position of the camera in the scene
  111725. */
  111726. get position(): Vector3;
  111727. set position(newPosition: Vector3);
  111728. protected _upVector: Vector3;
  111729. protected _upToYMatrix: Matrix;
  111730. protected _YToUpMatrix: Matrix;
  111731. /**
  111732. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111733. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111734. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111735. */
  111736. set upVector(vec: Vector3);
  111737. get upVector(): Vector3;
  111738. /**
  111739. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111740. */
  111741. setMatUp(): void;
  111742. /**
  111743. * Current inertia value on the longitudinal axis.
  111744. * The bigger this number the longer it will take for the camera to stop.
  111745. */
  111746. inertialAlphaOffset: number;
  111747. /**
  111748. * Current inertia value on the latitudinal axis.
  111749. * The bigger this number the longer it will take for the camera to stop.
  111750. */
  111751. inertialBetaOffset: number;
  111752. /**
  111753. * Current inertia value on the radius axis.
  111754. * The bigger this number the longer it will take for the camera to stop.
  111755. */
  111756. inertialRadiusOffset: number;
  111757. /**
  111758. * Minimum allowed angle on the longitudinal axis.
  111759. * This can help limiting how the Camera is able to move in the scene.
  111760. */
  111761. lowerAlphaLimit: Nullable<number>;
  111762. /**
  111763. * Maximum allowed angle on the longitudinal axis.
  111764. * This can help limiting how the Camera is able to move in the scene.
  111765. */
  111766. upperAlphaLimit: Nullable<number>;
  111767. /**
  111768. * Minimum allowed angle on the latitudinal axis.
  111769. * This can help limiting how the Camera is able to move in the scene.
  111770. */
  111771. lowerBetaLimit: number;
  111772. /**
  111773. * Maximum allowed angle on the latitudinal axis.
  111774. * This can help limiting how the Camera is able to move in the scene.
  111775. */
  111776. upperBetaLimit: number;
  111777. /**
  111778. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111779. * This can help limiting how the Camera is able to move in the scene.
  111780. */
  111781. lowerRadiusLimit: Nullable<number>;
  111782. /**
  111783. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111784. * This can help limiting how the Camera is able to move in the scene.
  111785. */
  111786. upperRadiusLimit: Nullable<number>;
  111787. /**
  111788. * Defines the current inertia value used during panning of the camera along the X axis.
  111789. */
  111790. inertialPanningX: number;
  111791. /**
  111792. * Defines the current inertia value used during panning of the camera along the Y axis.
  111793. */
  111794. inertialPanningY: number;
  111795. /**
  111796. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111797. * Basically if your fingers moves away from more than this distance you will be considered
  111798. * in pinch mode.
  111799. */
  111800. pinchToPanMaxDistance: number;
  111801. /**
  111802. * Defines the maximum distance the camera can pan.
  111803. * This could help keeping the cammera always in your scene.
  111804. */
  111805. panningDistanceLimit: Nullable<number>;
  111806. /**
  111807. * Defines the target of the camera before paning.
  111808. */
  111809. panningOriginTarget: Vector3;
  111810. /**
  111811. * Defines the value of the inertia used during panning.
  111812. * 0 would mean stop inertia and one would mean no decelleration at all.
  111813. */
  111814. panningInertia: number;
  111815. /**
  111816. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111817. */
  111818. get angularSensibilityX(): number;
  111819. set angularSensibilityX(value: number);
  111820. /**
  111821. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111822. */
  111823. get angularSensibilityY(): number;
  111824. set angularSensibilityY(value: number);
  111825. /**
  111826. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111827. */
  111828. get pinchPrecision(): number;
  111829. set pinchPrecision(value: number);
  111830. /**
  111831. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111832. * It will be used instead of pinchDeltaPrecision if different from 0.
  111833. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111834. */
  111835. get pinchDeltaPercentage(): number;
  111836. set pinchDeltaPercentage(value: number);
  111837. /**
  111838. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111839. * and pinch delta percentage.
  111840. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111841. * that any object in the plane at the camera's target point will scale
  111842. * perfectly with finger motion.
  111843. */
  111844. get useNaturalPinchZoom(): boolean;
  111845. set useNaturalPinchZoom(value: boolean);
  111846. /**
  111847. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111848. */
  111849. get panningSensibility(): number;
  111850. set panningSensibility(value: number);
  111851. /**
  111852. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111853. */
  111854. get keysUp(): number[];
  111855. set keysUp(value: number[]);
  111856. /**
  111857. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111858. */
  111859. get keysDown(): number[];
  111860. set keysDown(value: number[]);
  111861. /**
  111862. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111863. */
  111864. get keysLeft(): number[];
  111865. set keysLeft(value: number[]);
  111866. /**
  111867. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111868. */
  111869. get keysRight(): number[];
  111870. set keysRight(value: number[]);
  111871. /**
  111872. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111873. */
  111874. get wheelPrecision(): number;
  111875. set wheelPrecision(value: number);
  111876. /**
  111877. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111878. * It will be used instead of pinchDeltaPrecision if different from 0.
  111879. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111880. */
  111881. get wheelDeltaPercentage(): number;
  111882. set wheelDeltaPercentage(value: number);
  111883. /**
  111884. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111885. */
  111886. zoomOnFactor: number;
  111887. /**
  111888. * Defines a screen offset for the camera position.
  111889. */
  111890. targetScreenOffset: Vector2;
  111891. /**
  111892. * Allows the camera to be completely reversed.
  111893. * If false the camera can not arrive upside down.
  111894. */
  111895. allowUpsideDown: boolean;
  111896. /**
  111897. * Define if double tap/click is used to restore the previously saved state of the camera.
  111898. */
  111899. useInputToRestoreState: boolean;
  111900. /** @hidden */
  111901. _viewMatrix: Matrix;
  111902. /** @hidden */
  111903. _useCtrlForPanning: boolean;
  111904. /** @hidden */
  111905. _panningMouseButton: number;
  111906. /**
  111907. * Defines the input associated to the camera.
  111908. */
  111909. inputs: ArcRotateCameraInputsManager;
  111910. /** @hidden */
  111911. _reset: () => void;
  111912. /**
  111913. * Defines the allowed panning axis.
  111914. */
  111915. panningAxis: Vector3;
  111916. protected _localDirection: Vector3;
  111917. protected _transformedDirection: Vector3;
  111918. private _bouncingBehavior;
  111919. /**
  111920. * Gets the bouncing behavior of the camera if it has been enabled.
  111921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111922. */
  111923. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111924. /**
  111925. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111927. */
  111928. get useBouncingBehavior(): boolean;
  111929. set useBouncingBehavior(value: boolean);
  111930. private _framingBehavior;
  111931. /**
  111932. * Gets the framing behavior of the camera if it has been enabled.
  111933. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111934. */
  111935. get framingBehavior(): Nullable<FramingBehavior>;
  111936. /**
  111937. * Defines if the framing behavior of the camera is enabled on the camera.
  111938. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111939. */
  111940. get useFramingBehavior(): boolean;
  111941. set useFramingBehavior(value: boolean);
  111942. private _autoRotationBehavior;
  111943. /**
  111944. * Gets the auto rotation behavior of the camera if it has been enabled.
  111945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111946. */
  111947. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111948. /**
  111949. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111951. */
  111952. get useAutoRotationBehavior(): boolean;
  111953. set useAutoRotationBehavior(value: boolean);
  111954. /**
  111955. * Observable triggered when the mesh target has been changed on the camera.
  111956. */
  111957. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111958. /**
  111959. * Event raised when the camera is colliding with a mesh.
  111960. */
  111961. onCollide: (collidedMesh: AbstractMesh) => void;
  111962. /**
  111963. * Defines whether the camera should check collision with the objects oh the scene.
  111964. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111965. */
  111966. checkCollisions: boolean;
  111967. /**
  111968. * Defines the collision radius of the camera.
  111969. * This simulates a sphere around the camera.
  111970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111971. */
  111972. collisionRadius: Vector3;
  111973. protected _collider: Collider;
  111974. protected _previousPosition: Vector3;
  111975. protected _collisionVelocity: Vector3;
  111976. protected _newPosition: Vector3;
  111977. protected _previousAlpha: number;
  111978. protected _previousBeta: number;
  111979. protected _previousRadius: number;
  111980. protected _collisionTriggered: boolean;
  111981. protected _targetBoundingCenter: Nullable<Vector3>;
  111982. private _computationVector;
  111983. /**
  111984. * Instantiates a new ArcRotateCamera in a given scene
  111985. * @param name Defines the name of the camera
  111986. * @param alpha Defines the camera rotation along the logitudinal axis
  111987. * @param beta Defines the camera rotation along the latitudinal axis
  111988. * @param radius Defines the camera distance from its target
  111989. * @param target Defines the camera target
  111990. * @param scene Defines the scene the camera belongs to
  111991. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111992. */
  111993. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111994. /** @hidden */
  111995. _initCache(): void;
  111996. /** @hidden */
  111997. _updateCache(ignoreParentClass?: boolean): void;
  111998. protected _getTargetPosition(): Vector3;
  111999. private _storedAlpha;
  112000. private _storedBeta;
  112001. private _storedRadius;
  112002. private _storedTarget;
  112003. private _storedTargetScreenOffset;
  112004. /**
  112005. * Stores the current state of the camera (alpha, beta, radius and target)
  112006. * @returns the camera itself
  112007. */
  112008. storeState(): Camera;
  112009. /**
  112010. * @hidden
  112011. * Restored camera state. You must call storeState() first
  112012. */
  112013. _restoreStateValues(): boolean;
  112014. /** @hidden */
  112015. _isSynchronizedViewMatrix(): boolean;
  112016. /**
  112017. * Attached controls to the current camera.
  112018. * @param element Defines the element the controls should be listened from
  112019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112020. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112021. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112022. */
  112023. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112024. /**
  112025. * Detach the current controls from the camera.
  112026. * The camera will stop reacting to inputs.
  112027. * @param element Defines the element to stop listening the inputs from
  112028. */
  112029. detachControl(element: HTMLElement): void;
  112030. /** @hidden */
  112031. _checkInputs(): void;
  112032. protected _checkLimits(): void;
  112033. /**
  112034. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112035. */
  112036. rebuildAnglesAndRadius(): void;
  112037. /**
  112038. * Use a position to define the current camera related information like alpha, beta and radius
  112039. * @param position Defines the position to set the camera at
  112040. */
  112041. setPosition(position: Vector3): void;
  112042. /**
  112043. * Defines the target the camera should look at.
  112044. * This will automatically adapt alpha beta and radius to fit within the new target.
  112045. * @param target Defines the new target as a Vector or a mesh
  112046. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112047. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112048. */
  112049. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112050. /** @hidden */
  112051. _getViewMatrix(): Matrix;
  112052. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112053. /**
  112054. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112055. * @param meshes Defines the mesh to zoom on
  112056. * @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)
  112057. */
  112058. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112059. /**
  112060. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112061. * The target will be changed but the radius
  112062. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112063. * @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)
  112064. */
  112065. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112066. min: Vector3;
  112067. max: Vector3;
  112068. distance: number;
  112069. }, doNotUpdateMaxZ?: boolean): void;
  112070. /**
  112071. * @override
  112072. * Override Camera.createRigCamera
  112073. */
  112074. createRigCamera(name: string, cameraIndex: number): Camera;
  112075. /**
  112076. * @hidden
  112077. * @override
  112078. * Override Camera._updateRigCameras
  112079. */
  112080. _updateRigCameras(): void;
  112081. /**
  112082. * Destroy the camera and release the current resources hold by it.
  112083. */
  112084. dispose(): void;
  112085. /**
  112086. * Gets the current object class name.
  112087. * @return the class name
  112088. */
  112089. getClassName(): string;
  112090. }
  112091. }
  112092. declare module BABYLON {
  112093. /**
  112094. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112096. */
  112097. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112098. /**
  112099. * Gets the name of the behavior.
  112100. */
  112101. get name(): string;
  112102. private _zoomStopsAnimation;
  112103. private _idleRotationSpeed;
  112104. private _idleRotationWaitTime;
  112105. private _idleRotationSpinupTime;
  112106. /**
  112107. * Sets the flag that indicates if user zooming should stop animation.
  112108. */
  112109. set zoomStopsAnimation(flag: boolean);
  112110. /**
  112111. * Gets the flag that indicates if user zooming should stop animation.
  112112. */
  112113. get zoomStopsAnimation(): boolean;
  112114. /**
  112115. * Sets the default speed at which the camera rotates around the model.
  112116. */
  112117. set idleRotationSpeed(speed: number);
  112118. /**
  112119. * Gets the default speed at which the camera rotates around the model.
  112120. */
  112121. get idleRotationSpeed(): number;
  112122. /**
  112123. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112124. */
  112125. set idleRotationWaitTime(time: number);
  112126. /**
  112127. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112128. */
  112129. get idleRotationWaitTime(): number;
  112130. /**
  112131. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112132. */
  112133. set idleRotationSpinupTime(time: number);
  112134. /**
  112135. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112136. */
  112137. get idleRotationSpinupTime(): number;
  112138. /**
  112139. * Gets a value indicating if the camera is currently rotating because of this behavior
  112140. */
  112141. get rotationInProgress(): boolean;
  112142. private _onPrePointerObservableObserver;
  112143. private _onAfterCheckInputsObserver;
  112144. private _attachedCamera;
  112145. private _isPointerDown;
  112146. private _lastFrameTime;
  112147. private _lastInteractionTime;
  112148. private _cameraRotationSpeed;
  112149. /**
  112150. * Initializes the behavior.
  112151. */
  112152. init(): void;
  112153. /**
  112154. * Attaches the behavior to its arc rotate camera.
  112155. * @param camera Defines the camera to attach the behavior to
  112156. */
  112157. attach(camera: ArcRotateCamera): void;
  112158. /**
  112159. * Detaches the behavior from its current arc rotate camera.
  112160. */
  112161. detach(): void;
  112162. /**
  112163. * Returns true if user is scrolling.
  112164. * @return true if user is scrolling.
  112165. */
  112166. private _userIsZooming;
  112167. private _lastFrameRadius;
  112168. private _shouldAnimationStopForInteraction;
  112169. /**
  112170. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112171. */
  112172. private _applyUserInteraction;
  112173. private _userIsMoving;
  112174. }
  112175. }
  112176. declare module BABYLON {
  112177. /**
  112178. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112179. */
  112180. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112181. private ui;
  112182. /**
  112183. * The name of the behavior
  112184. */
  112185. name: string;
  112186. /**
  112187. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112188. */
  112189. distanceAwayFromFace: number;
  112190. /**
  112191. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112192. */
  112193. distanceAwayFromBottomOfFace: number;
  112194. private _faceVectors;
  112195. private _target;
  112196. private _scene;
  112197. private _onRenderObserver;
  112198. private _tmpMatrix;
  112199. private _tmpVector;
  112200. /**
  112201. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112202. * @param ui The transform node that should be attched to the mesh
  112203. */
  112204. constructor(ui: TransformNode);
  112205. /**
  112206. * Initializes the behavior
  112207. */
  112208. init(): void;
  112209. private _closestFace;
  112210. private _zeroVector;
  112211. private _lookAtTmpMatrix;
  112212. private _lookAtToRef;
  112213. /**
  112214. * Attaches the AttachToBoxBehavior to the passed in mesh
  112215. * @param target The mesh that the specified node will be attached to
  112216. */
  112217. attach(target: Mesh): void;
  112218. /**
  112219. * Detaches the behavior from the mesh
  112220. */
  112221. detach(): void;
  112222. }
  112223. }
  112224. declare module BABYLON {
  112225. /**
  112226. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112227. */
  112228. export class FadeInOutBehavior implements Behavior<Mesh> {
  112229. /**
  112230. * Time in milliseconds to delay before fading in (Default: 0)
  112231. */
  112232. delay: number;
  112233. /**
  112234. * Time in milliseconds for the mesh to fade in (Default: 300)
  112235. */
  112236. fadeInTime: number;
  112237. private _millisecondsPerFrame;
  112238. private _hovered;
  112239. private _hoverValue;
  112240. private _ownerNode;
  112241. /**
  112242. * Instatiates the FadeInOutBehavior
  112243. */
  112244. constructor();
  112245. /**
  112246. * The name of the behavior
  112247. */
  112248. get name(): string;
  112249. /**
  112250. * Initializes the behavior
  112251. */
  112252. init(): void;
  112253. /**
  112254. * Attaches the fade behavior on the passed in mesh
  112255. * @param ownerNode The mesh that will be faded in/out once attached
  112256. */
  112257. attach(ownerNode: Mesh): void;
  112258. /**
  112259. * Detaches the behavior from the mesh
  112260. */
  112261. detach(): void;
  112262. /**
  112263. * Triggers the mesh to begin fading in or out
  112264. * @param value if the object should fade in or out (true to fade in)
  112265. */
  112266. fadeIn(value: boolean): void;
  112267. private _update;
  112268. private _setAllVisibility;
  112269. }
  112270. }
  112271. declare module BABYLON {
  112272. /**
  112273. * Class containing a set of static utilities functions for managing Pivots
  112274. * @hidden
  112275. */
  112276. export class PivotTools {
  112277. private static _PivotCached;
  112278. private static _OldPivotPoint;
  112279. private static _PivotTranslation;
  112280. private static _PivotTmpVector;
  112281. /** @hidden */
  112282. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112283. /** @hidden */
  112284. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112285. }
  112286. }
  112287. declare module BABYLON {
  112288. /**
  112289. * Class containing static functions to help procedurally build meshes
  112290. */
  112291. export class PlaneBuilder {
  112292. /**
  112293. * Creates a plane mesh
  112294. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112295. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112296. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112300. * @param name defines the name of the mesh
  112301. * @param options defines the options used to create the mesh
  112302. * @param scene defines the hosting scene
  112303. * @returns the plane mesh
  112304. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112305. */
  112306. static CreatePlane(name: string, options: {
  112307. size?: number;
  112308. width?: number;
  112309. height?: number;
  112310. sideOrientation?: number;
  112311. frontUVs?: Vector4;
  112312. backUVs?: Vector4;
  112313. updatable?: boolean;
  112314. sourcePlane?: Plane;
  112315. }, scene?: Nullable<Scene>): Mesh;
  112316. }
  112317. }
  112318. declare module BABYLON {
  112319. /**
  112320. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112321. */
  112322. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112323. private static _AnyMouseID;
  112324. /**
  112325. * Abstract mesh the behavior is set on
  112326. */
  112327. attachedNode: AbstractMesh;
  112328. private _dragPlane;
  112329. private _scene;
  112330. private _pointerObserver;
  112331. private _beforeRenderObserver;
  112332. private static _planeScene;
  112333. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112334. /**
  112335. * 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)
  112336. */
  112337. maxDragAngle: number;
  112338. /**
  112339. * @hidden
  112340. */
  112341. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112342. /**
  112343. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112344. */
  112345. currentDraggingPointerID: number;
  112346. /**
  112347. * The last position where the pointer hit the drag plane in world space
  112348. */
  112349. lastDragPosition: Vector3;
  112350. /**
  112351. * If the behavior is currently in a dragging state
  112352. */
  112353. dragging: boolean;
  112354. /**
  112355. * 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)
  112356. */
  112357. dragDeltaRatio: number;
  112358. /**
  112359. * If the drag plane orientation should be updated during the dragging (Default: true)
  112360. */
  112361. updateDragPlane: boolean;
  112362. private _debugMode;
  112363. private _moving;
  112364. /**
  112365. * Fires each time the attached mesh is dragged with the pointer
  112366. * * delta between last drag position and current drag position in world space
  112367. * * dragDistance along the drag axis
  112368. * * dragPlaneNormal normal of the current drag plane used during the drag
  112369. * * dragPlanePoint in world space where the drag intersects the drag plane
  112370. */
  112371. onDragObservable: Observable<{
  112372. delta: Vector3;
  112373. dragPlanePoint: Vector3;
  112374. dragPlaneNormal: Vector3;
  112375. dragDistance: number;
  112376. pointerId: number;
  112377. }>;
  112378. /**
  112379. * Fires each time a drag begins (eg. mouse down on mesh)
  112380. */
  112381. onDragStartObservable: Observable<{
  112382. dragPlanePoint: Vector3;
  112383. pointerId: number;
  112384. }>;
  112385. /**
  112386. * Fires each time a drag ends (eg. mouse release after drag)
  112387. */
  112388. onDragEndObservable: Observable<{
  112389. dragPlanePoint: Vector3;
  112390. pointerId: number;
  112391. }>;
  112392. /**
  112393. * If the attached mesh should be moved when dragged
  112394. */
  112395. moveAttached: boolean;
  112396. /**
  112397. * If the drag behavior will react to drag events (Default: true)
  112398. */
  112399. enabled: boolean;
  112400. /**
  112401. * If pointer events should start and release the drag (Default: true)
  112402. */
  112403. startAndReleaseDragOnPointerEvents: boolean;
  112404. /**
  112405. * If camera controls should be detached during the drag
  112406. */
  112407. detachCameraControls: boolean;
  112408. /**
  112409. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112410. */
  112411. useObjectOrientationForDragging: boolean;
  112412. private _options;
  112413. /**
  112414. * Gets the options used by the behavior
  112415. */
  112416. get options(): {
  112417. dragAxis?: Vector3;
  112418. dragPlaneNormal?: Vector3;
  112419. };
  112420. /**
  112421. * Sets the options used by the behavior
  112422. */
  112423. set options(options: {
  112424. dragAxis?: Vector3;
  112425. dragPlaneNormal?: Vector3;
  112426. });
  112427. /**
  112428. * Creates a pointer drag behavior that can be attached to a mesh
  112429. * @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)
  112430. */
  112431. constructor(options?: {
  112432. dragAxis?: Vector3;
  112433. dragPlaneNormal?: Vector3;
  112434. });
  112435. /**
  112436. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112437. */
  112438. validateDrag: (targetPosition: Vector3) => boolean;
  112439. /**
  112440. * The name of the behavior
  112441. */
  112442. get name(): string;
  112443. /**
  112444. * Initializes the behavior
  112445. */
  112446. init(): void;
  112447. private _tmpVector;
  112448. private _alternatePickedPoint;
  112449. private _worldDragAxis;
  112450. private _targetPosition;
  112451. private _attachedElement;
  112452. /**
  112453. * Attaches the drag behavior the passed in mesh
  112454. * @param ownerNode The mesh that will be dragged around once attached
  112455. * @param predicate Predicate to use for pick filtering
  112456. */
  112457. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112458. /**
  112459. * Force relase the drag action by code.
  112460. */
  112461. releaseDrag(): void;
  112462. private _startDragRay;
  112463. private _lastPointerRay;
  112464. /**
  112465. * Simulates the start of a pointer drag event on the behavior
  112466. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112467. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112468. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112469. */
  112470. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112471. private _startDrag;
  112472. private _dragDelta;
  112473. private _moveDrag;
  112474. private _pickWithRayOnDragPlane;
  112475. private _pointA;
  112476. private _pointB;
  112477. private _pointC;
  112478. private _lineA;
  112479. private _lineB;
  112480. private _localAxis;
  112481. private _lookAt;
  112482. private _updateDragPlanePosition;
  112483. /**
  112484. * Detaches the behavior from the mesh
  112485. */
  112486. detach(): void;
  112487. }
  112488. }
  112489. declare module BABYLON {
  112490. /**
  112491. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112492. */
  112493. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112494. private _dragBehaviorA;
  112495. private _dragBehaviorB;
  112496. private _startDistance;
  112497. private _initialScale;
  112498. private _targetScale;
  112499. private _ownerNode;
  112500. private _sceneRenderObserver;
  112501. /**
  112502. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112503. */
  112504. constructor();
  112505. /**
  112506. * The name of the behavior
  112507. */
  112508. get name(): string;
  112509. /**
  112510. * Initializes the behavior
  112511. */
  112512. init(): void;
  112513. private _getCurrentDistance;
  112514. /**
  112515. * Attaches the scale behavior the passed in mesh
  112516. * @param ownerNode The mesh that will be scaled around once attached
  112517. */
  112518. attach(ownerNode: Mesh): void;
  112519. /**
  112520. * Detaches the behavior from the mesh
  112521. */
  112522. detach(): void;
  112523. }
  112524. }
  112525. declare module BABYLON {
  112526. /**
  112527. * 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
  112528. */
  112529. export class SixDofDragBehavior implements Behavior<Mesh> {
  112530. private static _virtualScene;
  112531. private _ownerNode;
  112532. private _sceneRenderObserver;
  112533. private _scene;
  112534. private _targetPosition;
  112535. private _virtualOriginMesh;
  112536. private _virtualDragMesh;
  112537. private _pointerObserver;
  112538. private _moving;
  112539. private _startingOrientation;
  112540. /**
  112541. * 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)
  112542. */
  112543. private zDragFactor;
  112544. /**
  112545. * If the object should rotate to face the drag origin
  112546. */
  112547. rotateDraggedObject: boolean;
  112548. /**
  112549. * If the behavior is currently in a dragging state
  112550. */
  112551. dragging: boolean;
  112552. /**
  112553. * 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)
  112554. */
  112555. dragDeltaRatio: number;
  112556. /**
  112557. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112558. */
  112559. currentDraggingPointerID: number;
  112560. /**
  112561. * If camera controls should be detached during the drag
  112562. */
  112563. detachCameraControls: boolean;
  112564. /**
  112565. * Fires each time a drag starts
  112566. */
  112567. onDragStartObservable: Observable<{}>;
  112568. /**
  112569. * Fires each time a drag ends (eg. mouse release after drag)
  112570. */
  112571. onDragEndObservable: Observable<{}>;
  112572. /**
  112573. * 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
  112574. */
  112575. constructor();
  112576. /**
  112577. * The name of the behavior
  112578. */
  112579. get name(): string;
  112580. /**
  112581. * Initializes the behavior
  112582. */
  112583. init(): void;
  112584. /**
  112585. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112586. */
  112587. private get _pointerCamera();
  112588. /**
  112589. * Attaches the scale behavior the passed in mesh
  112590. * @param ownerNode The mesh that will be scaled around once attached
  112591. */
  112592. attach(ownerNode: Mesh): void;
  112593. /**
  112594. * Detaches the behavior from the mesh
  112595. */
  112596. detach(): void;
  112597. }
  112598. }
  112599. declare module BABYLON {
  112600. /**
  112601. * Class used to apply inverse kinematics to bones
  112602. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112603. */
  112604. export class BoneIKController {
  112605. private static _tmpVecs;
  112606. private static _tmpQuat;
  112607. private static _tmpMats;
  112608. /**
  112609. * Gets or sets the target mesh
  112610. */
  112611. targetMesh: AbstractMesh;
  112612. /** Gets or sets the mesh used as pole */
  112613. poleTargetMesh: AbstractMesh;
  112614. /**
  112615. * Gets or sets the bone used as pole
  112616. */
  112617. poleTargetBone: Nullable<Bone>;
  112618. /**
  112619. * Gets or sets the target position
  112620. */
  112621. targetPosition: Vector3;
  112622. /**
  112623. * Gets or sets the pole target position
  112624. */
  112625. poleTargetPosition: Vector3;
  112626. /**
  112627. * Gets or sets the pole target local offset
  112628. */
  112629. poleTargetLocalOffset: Vector3;
  112630. /**
  112631. * Gets or sets the pole angle
  112632. */
  112633. poleAngle: number;
  112634. /**
  112635. * Gets or sets the mesh associated with the controller
  112636. */
  112637. mesh: AbstractMesh;
  112638. /**
  112639. * 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)
  112640. */
  112641. slerpAmount: number;
  112642. private _bone1Quat;
  112643. private _bone1Mat;
  112644. private _bone2Ang;
  112645. private _bone1;
  112646. private _bone2;
  112647. private _bone1Length;
  112648. private _bone2Length;
  112649. private _maxAngle;
  112650. private _maxReach;
  112651. private _rightHandedSystem;
  112652. private _bendAxis;
  112653. private _slerping;
  112654. private _adjustRoll;
  112655. /**
  112656. * Gets or sets maximum allowed angle
  112657. */
  112658. get maxAngle(): number;
  112659. set maxAngle(value: number);
  112660. /**
  112661. * Creates a new BoneIKController
  112662. * @param mesh defines the mesh to control
  112663. * @param bone defines the bone to control
  112664. * @param options defines options to set up the controller
  112665. */
  112666. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112667. targetMesh?: AbstractMesh;
  112668. poleTargetMesh?: AbstractMesh;
  112669. poleTargetBone?: Bone;
  112670. poleTargetLocalOffset?: Vector3;
  112671. poleAngle?: number;
  112672. bendAxis?: Vector3;
  112673. maxAngle?: number;
  112674. slerpAmount?: number;
  112675. });
  112676. private _setMaxAngle;
  112677. /**
  112678. * Force the controller to update the bones
  112679. */
  112680. update(): void;
  112681. }
  112682. }
  112683. declare module BABYLON {
  112684. /**
  112685. * Class used to make a bone look toward a point in space
  112686. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112687. */
  112688. export class BoneLookController {
  112689. private static _tmpVecs;
  112690. private static _tmpQuat;
  112691. private static _tmpMats;
  112692. /**
  112693. * The target Vector3 that the bone will look at
  112694. */
  112695. target: Vector3;
  112696. /**
  112697. * The mesh that the bone is attached to
  112698. */
  112699. mesh: AbstractMesh;
  112700. /**
  112701. * The bone that will be looking to the target
  112702. */
  112703. bone: Bone;
  112704. /**
  112705. * The up axis of the coordinate system that is used when the bone is rotated
  112706. */
  112707. upAxis: Vector3;
  112708. /**
  112709. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112710. */
  112711. upAxisSpace: Space;
  112712. /**
  112713. * Used to make an adjustment to the yaw of the bone
  112714. */
  112715. adjustYaw: number;
  112716. /**
  112717. * Used to make an adjustment to the pitch of the bone
  112718. */
  112719. adjustPitch: number;
  112720. /**
  112721. * Used to make an adjustment to the roll of the bone
  112722. */
  112723. adjustRoll: number;
  112724. /**
  112725. * 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)
  112726. */
  112727. slerpAmount: number;
  112728. private _minYaw;
  112729. private _maxYaw;
  112730. private _minPitch;
  112731. private _maxPitch;
  112732. private _minYawSin;
  112733. private _minYawCos;
  112734. private _maxYawSin;
  112735. private _maxYawCos;
  112736. private _midYawConstraint;
  112737. private _minPitchTan;
  112738. private _maxPitchTan;
  112739. private _boneQuat;
  112740. private _slerping;
  112741. private _transformYawPitch;
  112742. private _transformYawPitchInv;
  112743. private _firstFrameSkipped;
  112744. private _yawRange;
  112745. private _fowardAxis;
  112746. /**
  112747. * Gets or sets the minimum yaw angle that the bone can look to
  112748. */
  112749. get minYaw(): number;
  112750. set minYaw(value: number);
  112751. /**
  112752. * Gets or sets the maximum yaw angle that the bone can look to
  112753. */
  112754. get maxYaw(): number;
  112755. set maxYaw(value: number);
  112756. /**
  112757. * Gets or sets the minimum pitch angle that the bone can look to
  112758. */
  112759. get minPitch(): number;
  112760. set minPitch(value: number);
  112761. /**
  112762. * Gets or sets the maximum pitch angle that the bone can look to
  112763. */
  112764. get maxPitch(): number;
  112765. set maxPitch(value: number);
  112766. /**
  112767. * Create a BoneLookController
  112768. * @param mesh the mesh that the bone belongs to
  112769. * @param bone the bone that will be looking to the target
  112770. * @param target the target Vector3 to look at
  112771. * @param options optional settings:
  112772. * * maxYaw: the maximum angle the bone will yaw to
  112773. * * minYaw: the minimum angle the bone will yaw to
  112774. * * maxPitch: the maximum angle the bone will pitch to
  112775. * * minPitch: the minimum angle the bone will yaw to
  112776. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112777. * * upAxis: the up axis of the coordinate system
  112778. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112779. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112780. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112781. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112782. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112783. * * adjustRoll: used to make an adjustment to the roll of the bone
  112784. **/
  112785. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112786. maxYaw?: number;
  112787. minYaw?: number;
  112788. maxPitch?: number;
  112789. minPitch?: number;
  112790. slerpAmount?: number;
  112791. upAxis?: Vector3;
  112792. upAxisSpace?: Space;
  112793. yawAxis?: Vector3;
  112794. pitchAxis?: Vector3;
  112795. adjustYaw?: number;
  112796. adjustPitch?: number;
  112797. adjustRoll?: number;
  112798. });
  112799. /**
  112800. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112801. */
  112802. update(): void;
  112803. private _getAngleDiff;
  112804. private _getAngleBetween;
  112805. private _isAngleBetween;
  112806. }
  112807. }
  112808. declare module BABYLON {
  112809. /**
  112810. * Manage the gamepad inputs to control an arc rotate camera.
  112811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112812. */
  112813. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112814. /**
  112815. * Defines the camera the input is attached to.
  112816. */
  112817. camera: ArcRotateCamera;
  112818. /**
  112819. * Defines the gamepad the input is gathering event from.
  112820. */
  112821. gamepad: Nullable<Gamepad>;
  112822. /**
  112823. * Defines the gamepad rotation sensiblity.
  112824. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112825. */
  112826. gamepadRotationSensibility: number;
  112827. /**
  112828. * Defines the gamepad move sensiblity.
  112829. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112830. */
  112831. gamepadMoveSensibility: number;
  112832. private _yAxisScale;
  112833. /**
  112834. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112835. */
  112836. get invertYAxis(): boolean;
  112837. set invertYAxis(value: boolean);
  112838. private _onGamepadConnectedObserver;
  112839. private _onGamepadDisconnectedObserver;
  112840. /**
  112841. * Attach the input controls to a specific dom element to get the input from.
  112842. * @param element Defines the element the controls should be listened from
  112843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112844. */
  112845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112846. /**
  112847. * Detach the current controls from the specified dom element.
  112848. * @param element Defines the element to stop listening the inputs from
  112849. */
  112850. detachControl(element: Nullable<HTMLElement>): void;
  112851. /**
  112852. * Update the current camera state depending on the inputs that have been used this frame.
  112853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112854. */
  112855. checkInputs(): void;
  112856. /**
  112857. * Gets the class name of the current intput.
  112858. * @returns the class name
  112859. */
  112860. getClassName(): string;
  112861. /**
  112862. * Get the friendly name associated with the input class.
  112863. * @returns the input friendly name
  112864. */
  112865. getSimpleName(): string;
  112866. }
  112867. }
  112868. declare module BABYLON {
  112869. interface ArcRotateCameraInputsManager {
  112870. /**
  112871. * Add orientation input support to the input manager.
  112872. * @returns the current input manager
  112873. */
  112874. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112875. }
  112876. /**
  112877. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112879. */
  112880. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112881. /**
  112882. * Defines the camera the input is attached to.
  112883. */
  112884. camera: ArcRotateCamera;
  112885. /**
  112886. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112887. */
  112888. alphaCorrection: number;
  112889. /**
  112890. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112891. */
  112892. gammaCorrection: number;
  112893. private _alpha;
  112894. private _gamma;
  112895. private _dirty;
  112896. private _deviceOrientationHandler;
  112897. /**
  112898. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112899. */
  112900. constructor();
  112901. /**
  112902. * Attach the input controls to a specific dom element to get the input from.
  112903. * @param element Defines the element the controls should be listened from
  112904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112905. */
  112906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112907. /** @hidden */
  112908. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112909. /**
  112910. * Update the current camera state depending on the inputs that have been used this frame.
  112911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112912. */
  112913. checkInputs(): void;
  112914. /**
  112915. * Detach the current controls from the specified dom element.
  112916. * @param element Defines the element to stop listening the inputs from
  112917. */
  112918. detachControl(element: Nullable<HTMLElement>): void;
  112919. /**
  112920. * Gets the class name of the current intput.
  112921. * @returns the class name
  112922. */
  112923. getClassName(): string;
  112924. /**
  112925. * Get the friendly name associated with the input class.
  112926. * @returns the input friendly name
  112927. */
  112928. getSimpleName(): string;
  112929. }
  112930. }
  112931. declare module BABYLON {
  112932. /**
  112933. * Listen to mouse events to control the camera.
  112934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112935. */
  112936. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112937. /**
  112938. * Defines the camera the input is attached to.
  112939. */
  112940. camera: FlyCamera;
  112941. /**
  112942. * Defines if touch is enabled. (Default is true.)
  112943. */
  112944. touchEnabled: boolean;
  112945. /**
  112946. * Defines the buttons associated with the input to handle camera rotation.
  112947. */
  112948. buttons: number[];
  112949. /**
  112950. * Assign buttons for Yaw control.
  112951. */
  112952. buttonsYaw: number[];
  112953. /**
  112954. * Assign buttons for Pitch control.
  112955. */
  112956. buttonsPitch: number[];
  112957. /**
  112958. * Assign buttons for Roll control.
  112959. */
  112960. buttonsRoll: number[];
  112961. /**
  112962. * Detect if any button is being pressed while mouse is moved.
  112963. * -1 = Mouse locked.
  112964. * 0 = Left button.
  112965. * 1 = Middle Button.
  112966. * 2 = Right Button.
  112967. */
  112968. activeButton: number;
  112969. /**
  112970. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112971. * Higher values reduce its sensitivity.
  112972. */
  112973. angularSensibility: number;
  112974. private _mousemoveCallback;
  112975. private _observer;
  112976. private _rollObserver;
  112977. private previousPosition;
  112978. private noPreventDefault;
  112979. private element;
  112980. /**
  112981. * Listen to mouse events to control the camera.
  112982. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112984. */
  112985. constructor(touchEnabled?: boolean);
  112986. /**
  112987. * Attach the mouse control to the HTML DOM element.
  112988. * @param element Defines the element that listens to the input events.
  112989. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112990. */
  112991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112992. /**
  112993. * Detach the current controls from the specified dom element.
  112994. * @param element Defines the element to stop listening the inputs from
  112995. */
  112996. detachControl(element: Nullable<HTMLElement>): void;
  112997. /**
  112998. * Gets the class name of the current input.
  112999. * @returns the class name.
  113000. */
  113001. getClassName(): string;
  113002. /**
  113003. * Get the friendly name associated with the input class.
  113004. * @returns the input's friendly name.
  113005. */
  113006. getSimpleName(): string;
  113007. private _pointerInput;
  113008. private _onMouseMove;
  113009. /**
  113010. * Rotate camera by mouse offset.
  113011. */
  113012. private rotateCamera;
  113013. }
  113014. }
  113015. declare module BABYLON {
  113016. /**
  113017. * Default Inputs manager for the FlyCamera.
  113018. * It groups all the default supported inputs for ease of use.
  113019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113020. */
  113021. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113022. /**
  113023. * Instantiates a new FlyCameraInputsManager.
  113024. * @param camera Defines the camera the inputs belong to.
  113025. */
  113026. constructor(camera: FlyCamera);
  113027. /**
  113028. * Add keyboard input support to the input manager.
  113029. * @returns the new FlyCameraKeyboardMoveInput().
  113030. */
  113031. addKeyboard(): FlyCameraInputsManager;
  113032. /**
  113033. * Add mouse input support to the input manager.
  113034. * @param touchEnabled Enable touch screen support.
  113035. * @returns the new FlyCameraMouseInput().
  113036. */
  113037. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113038. }
  113039. }
  113040. declare module BABYLON {
  113041. /**
  113042. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113043. * such as in a 3D Space Shooter or a Flight Simulator.
  113044. */
  113045. export class FlyCamera extends TargetCamera {
  113046. /**
  113047. * Define the collision ellipsoid of the camera.
  113048. * This is helpful for simulating a camera body, like a player's body.
  113049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113050. */
  113051. ellipsoid: Vector3;
  113052. /**
  113053. * Define an offset for the position of the ellipsoid around the camera.
  113054. * This can be helpful if the camera is attached away from the player's body center,
  113055. * such as at its head.
  113056. */
  113057. ellipsoidOffset: Vector3;
  113058. /**
  113059. * Enable or disable collisions of the camera with the rest of the scene objects.
  113060. */
  113061. checkCollisions: boolean;
  113062. /**
  113063. * Enable or disable gravity on the camera.
  113064. */
  113065. applyGravity: boolean;
  113066. /**
  113067. * Define the current direction the camera is moving to.
  113068. */
  113069. cameraDirection: Vector3;
  113070. /**
  113071. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113072. * This overrides and empties cameraRotation.
  113073. */
  113074. rotationQuaternion: Quaternion;
  113075. /**
  113076. * Track Roll to maintain the wanted Rolling when looking around.
  113077. */
  113078. _trackRoll: number;
  113079. /**
  113080. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113081. */
  113082. rollCorrect: number;
  113083. /**
  113084. * Mimic a banked turn, Rolling the camera when Yawing.
  113085. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113086. */
  113087. bankedTurn: boolean;
  113088. /**
  113089. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113090. */
  113091. bankedTurnLimit: number;
  113092. /**
  113093. * Value of 0 disables the banked Roll.
  113094. * Value of 1 is equal to the Yaw angle in radians.
  113095. */
  113096. bankedTurnMultiplier: number;
  113097. /**
  113098. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113099. */
  113100. inputs: FlyCameraInputsManager;
  113101. /**
  113102. * Gets the input sensibility for mouse input.
  113103. * Higher values reduce sensitivity.
  113104. */
  113105. get angularSensibility(): number;
  113106. /**
  113107. * Sets the input sensibility for a mouse input.
  113108. * Higher values reduce sensitivity.
  113109. */
  113110. set angularSensibility(value: number);
  113111. /**
  113112. * Get the keys for camera movement forward.
  113113. */
  113114. get keysForward(): number[];
  113115. /**
  113116. * Set the keys for camera movement forward.
  113117. */
  113118. set keysForward(value: number[]);
  113119. /**
  113120. * Get the keys for camera movement backward.
  113121. */
  113122. get keysBackward(): number[];
  113123. set keysBackward(value: number[]);
  113124. /**
  113125. * Get the keys for camera movement up.
  113126. */
  113127. get keysUp(): number[];
  113128. /**
  113129. * Set the keys for camera movement up.
  113130. */
  113131. set keysUp(value: number[]);
  113132. /**
  113133. * Get the keys for camera movement down.
  113134. */
  113135. get keysDown(): number[];
  113136. /**
  113137. * Set the keys for camera movement down.
  113138. */
  113139. set keysDown(value: number[]);
  113140. /**
  113141. * Get the keys for camera movement left.
  113142. */
  113143. get keysLeft(): number[];
  113144. /**
  113145. * Set the keys for camera movement left.
  113146. */
  113147. set keysLeft(value: number[]);
  113148. /**
  113149. * Set the keys for camera movement right.
  113150. */
  113151. get keysRight(): number[];
  113152. /**
  113153. * Set the keys for camera movement right.
  113154. */
  113155. set keysRight(value: number[]);
  113156. /**
  113157. * Event raised when the camera collides with a mesh in the scene.
  113158. */
  113159. onCollide: (collidedMesh: AbstractMesh) => void;
  113160. private _collider;
  113161. private _needMoveForGravity;
  113162. private _oldPosition;
  113163. private _diffPosition;
  113164. private _newPosition;
  113165. /** @hidden */
  113166. _localDirection: Vector3;
  113167. /** @hidden */
  113168. _transformedDirection: Vector3;
  113169. /**
  113170. * Instantiates a FlyCamera.
  113171. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113172. * such as in a 3D Space Shooter or a Flight Simulator.
  113173. * @param name Define the name of the camera in the scene.
  113174. * @param position Define the starting position of the camera in the scene.
  113175. * @param scene Define the scene the camera belongs to.
  113176. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113177. */
  113178. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113179. /**
  113180. * Attach a control to the HTML DOM element.
  113181. * @param element Defines the element that listens to the input events.
  113182. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113183. */
  113184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113185. /**
  113186. * Detach a control from the HTML DOM element.
  113187. * The camera will stop reacting to that input.
  113188. * @param element Defines the element that listens to the input events.
  113189. */
  113190. detachControl(element: HTMLElement): void;
  113191. private _collisionMask;
  113192. /**
  113193. * Get the mask that the camera ignores in collision events.
  113194. */
  113195. get collisionMask(): number;
  113196. /**
  113197. * Set the mask that the camera ignores in collision events.
  113198. */
  113199. set collisionMask(mask: number);
  113200. /** @hidden */
  113201. _collideWithWorld(displacement: Vector3): void;
  113202. /** @hidden */
  113203. private _onCollisionPositionChange;
  113204. /** @hidden */
  113205. _checkInputs(): void;
  113206. /** @hidden */
  113207. _decideIfNeedsToMove(): boolean;
  113208. /** @hidden */
  113209. _updatePosition(): void;
  113210. /**
  113211. * Restore the Roll to its target value at the rate specified.
  113212. * @param rate - Higher means slower restoring.
  113213. * @hidden
  113214. */
  113215. restoreRoll(rate: number): void;
  113216. /**
  113217. * Destroy the camera and release the current resources held by it.
  113218. */
  113219. dispose(): void;
  113220. /**
  113221. * Get the current object class name.
  113222. * @returns the class name.
  113223. */
  113224. getClassName(): string;
  113225. }
  113226. }
  113227. declare module BABYLON {
  113228. /**
  113229. * Listen to keyboard events to control the camera.
  113230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113231. */
  113232. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113233. /**
  113234. * Defines the camera the input is attached to.
  113235. */
  113236. camera: FlyCamera;
  113237. /**
  113238. * The list of keyboard keys used to control the forward move of the camera.
  113239. */
  113240. keysForward: number[];
  113241. /**
  113242. * The list of keyboard keys used to control the backward move of the camera.
  113243. */
  113244. keysBackward: number[];
  113245. /**
  113246. * The list of keyboard keys used to control the forward move of the camera.
  113247. */
  113248. keysUp: number[];
  113249. /**
  113250. * The list of keyboard keys used to control the backward move of the camera.
  113251. */
  113252. keysDown: number[];
  113253. /**
  113254. * The list of keyboard keys used to control the right strafe move of the camera.
  113255. */
  113256. keysRight: number[];
  113257. /**
  113258. * The list of keyboard keys used to control the left strafe move of the camera.
  113259. */
  113260. keysLeft: number[];
  113261. private _keys;
  113262. private _onCanvasBlurObserver;
  113263. private _onKeyboardObserver;
  113264. private _engine;
  113265. private _scene;
  113266. /**
  113267. * Attach the input controls to a specific dom element to get the input from.
  113268. * @param element Defines the element the controls should be listened from
  113269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113270. */
  113271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113272. /**
  113273. * Detach the current controls from the specified dom element.
  113274. * @param element Defines the element to stop listening the inputs from
  113275. */
  113276. detachControl(element: Nullable<HTMLElement>): void;
  113277. /**
  113278. * Gets the class name of the current intput.
  113279. * @returns the class name
  113280. */
  113281. getClassName(): string;
  113282. /** @hidden */
  113283. _onLostFocus(e: FocusEvent): void;
  113284. /**
  113285. * Get the friendly name associated with the input class.
  113286. * @returns the input friendly name
  113287. */
  113288. getSimpleName(): string;
  113289. /**
  113290. * Update the current camera state depending on the inputs that have been used this frame.
  113291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113292. */
  113293. checkInputs(): void;
  113294. }
  113295. }
  113296. declare module BABYLON {
  113297. /**
  113298. * Manage the mouse wheel inputs to control a follow camera.
  113299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113300. */
  113301. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113302. /**
  113303. * Defines the camera the input is attached to.
  113304. */
  113305. camera: FollowCamera;
  113306. /**
  113307. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113308. */
  113309. axisControlRadius: boolean;
  113310. /**
  113311. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113312. */
  113313. axisControlHeight: boolean;
  113314. /**
  113315. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113316. */
  113317. axisControlRotation: boolean;
  113318. /**
  113319. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113320. * relation to mouseWheel events.
  113321. */
  113322. wheelPrecision: number;
  113323. /**
  113324. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113325. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113326. */
  113327. wheelDeltaPercentage: number;
  113328. private _wheel;
  113329. private _observer;
  113330. /**
  113331. * Attach the input controls to a specific dom element to get the input from.
  113332. * @param element Defines the element the controls should be listened from
  113333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113334. */
  113335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113336. /**
  113337. * Detach the current controls from the specified dom element.
  113338. * @param element Defines the element to stop listening the inputs from
  113339. */
  113340. detachControl(element: Nullable<HTMLElement>): void;
  113341. /**
  113342. * Gets the class name of the current intput.
  113343. * @returns the class name
  113344. */
  113345. getClassName(): string;
  113346. /**
  113347. * Get the friendly name associated with the input class.
  113348. * @returns the input friendly name
  113349. */
  113350. getSimpleName(): string;
  113351. }
  113352. }
  113353. declare module BABYLON {
  113354. /**
  113355. * Manage the pointers inputs to control an follow camera.
  113356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113357. */
  113358. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113359. /**
  113360. * Defines the camera the input is attached to.
  113361. */
  113362. camera: FollowCamera;
  113363. /**
  113364. * Gets the class name of the current input.
  113365. * @returns the class name
  113366. */
  113367. getClassName(): string;
  113368. /**
  113369. * Defines the pointer angular sensibility along the X axis or how fast is
  113370. * the camera rotating.
  113371. * A negative number will reverse the axis direction.
  113372. */
  113373. angularSensibilityX: number;
  113374. /**
  113375. * Defines the pointer angular sensibility along the Y axis or how fast is
  113376. * the camera rotating.
  113377. * A negative number will reverse the axis direction.
  113378. */
  113379. angularSensibilityY: number;
  113380. /**
  113381. * Defines the pointer pinch precision or how fast is the camera zooming.
  113382. * A negative number will reverse the axis direction.
  113383. */
  113384. pinchPrecision: number;
  113385. /**
  113386. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113387. * from 0.
  113388. * It defines the percentage of current camera.radius to use as delta when
  113389. * pinch zoom is used.
  113390. */
  113391. pinchDeltaPercentage: number;
  113392. /**
  113393. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113394. */
  113395. axisXControlRadius: boolean;
  113396. /**
  113397. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113398. */
  113399. axisXControlHeight: boolean;
  113400. /**
  113401. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113402. */
  113403. axisXControlRotation: boolean;
  113404. /**
  113405. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113406. */
  113407. axisYControlRadius: boolean;
  113408. /**
  113409. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113410. */
  113411. axisYControlHeight: boolean;
  113412. /**
  113413. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113414. */
  113415. axisYControlRotation: boolean;
  113416. /**
  113417. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113418. */
  113419. axisPinchControlRadius: boolean;
  113420. /**
  113421. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113422. */
  113423. axisPinchControlHeight: boolean;
  113424. /**
  113425. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113426. */
  113427. axisPinchControlRotation: boolean;
  113428. /**
  113429. * Log error messages if basic misconfiguration has occurred.
  113430. */
  113431. warningEnable: boolean;
  113432. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113433. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113434. private _warningCounter;
  113435. private _warning;
  113436. }
  113437. }
  113438. declare module BABYLON {
  113439. /**
  113440. * Default Inputs manager for the FollowCamera.
  113441. * It groups all the default supported inputs for ease of use.
  113442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113443. */
  113444. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113445. /**
  113446. * Instantiates a new FollowCameraInputsManager.
  113447. * @param camera Defines the camera the inputs belong to
  113448. */
  113449. constructor(camera: FollowCamera);
  113450. /**
  113451. * Add keyboard input support to the input manager.
  113452. * @returns the current input manager
  113453. */
  113454. addKeyboard(): FollowCameraInputsManager;
  113455. /**
  113456. * Add mouse wheel input support to the input manager.
  113457. * @returns the current input manager
  113458. */
  113459. addMouseWheel(): FollowCameraInputsManager;
  113460. /**
  113461. * Add pointers input support to the input manager.
  113462. * @returns the current input manager
  113463. */
  113464. addPointers(): FollowCameraInputsManager;
  113465. /**
  113466. * Add orientation input support to the input manager.
  113467. * @returns the current input manager
  113468. */
  113469. addVRDeviceOrientation(): FollowCameraInputsManager;
  113470. }
  113471. }
  113472. declare module BABYLON {
  113473. /**
  113474. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113475. * an arc rotate version arcFollowCamera are available.
  113476. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113477. */
  113478. export class FollowCamera extends TargetCamera {
  113479. /**
  113480. * Distance the follow camera should follow an object at
  113481. */
  113482. radius: number;
  113483. /**
  113484. * Minimum allowed distance of the camera to the axis of rotation
  113485. * (The camera can not get closer).
  113486. * This can help limiting how the Camera is able to move in the scene.
  113487. */
  113488. lowerRadiusLimit: Nullable<number>;
  113489. /**
  113490. * Maximum allowed distance of the camera to the axis of rotation
  113491. * (The camera can not get further).
  113492. * This can help limiting how the Camera is able to move in the scene.
  113493. */
  113494. upperRadiusLimit: Nullable<number>;
  113495. /**
  113496. * Define a rotation offset between the camera and the object it follows
  113497. */
  113498. rotationOffset: number;
  113499. /**
  113500. * Minimum allowed angle to camera position relative to target object.
  113501. * This can help limiting how the Camera is able to move in the scene.
  113502. */
  113503. lowerRotationOffsetLimit: Nullable<number>;
  113504. /**
  113505. * Maximum allowed angle to camera position relative to target object.
  113506. * This can help limiting how the Camera is able to move in the scene.
  113507. */
  113508. upperRotationOffsetLimit: Nullable<number>;
  113509. /**
  113510. * Define a height offset between the camera and the object it follows.
  113511. * It can help following an object from the top (like a car chaing a plane)
  113512. */
  113513. heightOffset: number;
  113514. /**
  113515. * Minimum allowed height of camera position relative to target object.
  113516. * This can help limiting how the Camera is able to move in the scene.
  113517. */
  113518. lowerHeightOffsetLimit: Nullable<number>;
  113519. /**
  113520. * Maximum allowed height of camera position relative to target object.
  113521. * This can help limiting how the Camera is able to move in the scene.
  113522. */
  113523. upperHeightOffsetLimit: Nullable<number>;
  113524. /**
  113525. * Define how fast the camera can accelerate to follow it s target.
  113526. */
  113527. cameraAcceleration: number;
  113528. /**
  113529. * Define the speed limit of the camera following an object.
  113530. */
  113531. maxCameraSpeed: number;
  113532. /**
  113533. * Define the target of the camera.
  113534. */
  113535. lockedTarget: Nullable<AbstractMesh>;
  113536. /**
  113537. * Defines the input associated with the camera.
  113538. */
  113539. inputs: FollowCameraInputsManager;
  113540. /**
  113541. * Instantiates the follow camera.
  113542. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113543. * @param name Define the name of the camera in the scene
  113544. * @param position Define the position of the camera
  113545. * @param scene Define the scene the camera belong to
  113546. * @param lockedTarget Define the target of the camera
  113547. */
  113548. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113549. private _follow;
  113550. /**
  113551. * Attached controls to the current camera.
  113552. * @param element Defines the element the controls should be listened from
  113553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113554. */
  113555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113556. /**
  113557. * Detach the current controls from the camera.
  113558. * The camera will stop reacting to inputs.
  113559. * @param element Defines the element to stop listening the inputs from
  113560. */
  113561. detachControl(element: HTMLElement): void;
  113562. /** @hidden */
  113563. _checkInputs(): void;
  113564. private _checkLimits;
  113565. /**
  113566. * Gets the camera class name.
  113567. * @returns the class name
  113568. */
  113569. getClassName(): string;
  113570. }
  113571. /**
  113572. * Arc Rotate version of the follow camera.
  113573. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113574. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113575. */
  113576. export class ArcFollowCamera extends TargetCamera {
  113577. /** The longitudinal angle of the camera */
  113578. alpha: number;
  113579. /** The latitudinal angle of the camera */
  113580. beta: number;
  113581. /** The radius of the camera from its target */
  113582. radius: number;
  113583. /** Define the camera target (the messh it should follow) */
  113584. target: Nullable<AbstractMesh>;
  113585. private _cartesianCoordinates;
  113586. /**
  113587. * Instantiates a new ArcFollowCamera
  113588. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113589. * @param name Define the name of the camera
  113590. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113591. * @param beta Define the rotation angle of the camera around the elevation axis
  113592. * @param radius Define the radius of the camera from its target point
  113593. * @param target Define the target of the camera
  113594. * @param scene Define the scene the camera belongs to
  113595. */
  113596. constructor(name: string,
  113597. /** The longitudinal angle of the camera */
  113598. alpha: number,
  113599. /** The latitudinal angle of the camera */
  113600. beta: number,
  113601. /** The radius of the camera from its target */
  113602. radius: number,
  113603. /** Define the camera target (the messh it should follow) */
  113604. target: Nullable<AbstractMesh>, scene: Scene);
  113605. private _follow;
  113606. /** @hidden */
  113607. _checkInputs(): void;
  113608. /**
  113609. * Returns the class name of the object.
  113610. * It is mostly used internally for serialization purposes.
  113611. */
  113612. getClassName(): string;
  113613. }
  113614. }
  113615. declare module BABYLON {
  113616. /**
  113617. * Manage the keyboard inputs to control the movement of a follow camera.
  113618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113619. */
  113620. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113621. /**
  113622. * Defines the camera the input is attached to.
  113623. */
  113624. camera: FollowCamera;
  113625. /**
  113626. * Defines the list of key codes associated with the up action (increase heightOffset)
  113627. */
  113628. keysHeightOffsetIncr: number[];
  113629. /**
  113630. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113631. */
  113632. keysHeightOffsetDecr: number[];
  113633. /**
  113634. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113635. */
  113636. keysHeightOffsetModifierAlt: boolean;
  113637. /**
  113638. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113639. */
  113640. keysHeightOffsetModifierCtrl: boolean;
  113641. /**
  113642. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113643. */
  113644. keysHeightOffsetModifierShift: boolean;
  113645. /**
  113646. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113647. */
  113648. keysRotationOffsetIncr: number[];
  113649. /**
  113650. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113651. */
  113652. keysRotationOffsetDecr: number[];
  113653. /**
  113654. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113655. */
  113656. keysRotationOffsetModifierAlt: boolean;
  113657. /**
  113658. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113659. */
  113660. keysRotationOffsetModifierCtrl: boolean;
  113661. /**
  113662. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113663. */
  113664. keysRotationOffsetModifierShift: boolean;
  113665. /**
  113666. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113667. */
  113668. keysRadiusIncr: number[];
  113669. /**
  113670. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113671. */
  113672. keysRadiusDecr: number[];
  113673. /**
  113674. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113675. */
  113676. keysRadiusModifierAlt: boolean;
  113677. /**
  113678. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113679. */
  113680. keysRadiusModifierCtrl: boolean;
  113681. /**
  113682. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113683. */
  113684. keysRadiusModifierShift: boolean;
  113685. /**
  113686. * Defines the rate of change of heightOffset.
  113687. */
  113688. heightSensibility: number;
  113689. /**
  113690. * Defines the rate of change of rotationOffset.
  113691. */
  113692. rotationSensibility: number;
  113693. /**
  113694. * Defines the rate of change of radius.
  113695. */
  113696. radiusSensibility: number;
  113697. private _keys;
  113698. private _ctrlPressed;
  113699. private _altPressed;
  113700. private _shiftPressed;
  113701. private _onCanvasBlurObserver;
  113702. private _onKeyboardObserver;
  113703. private _engine;
  113704. private _scene;
  113705. /**
  113706. * Attach the input controls to a specific dom element to get the input from.
  113707. * @param element Defines the element the controls should be listened from
  113708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113709. */
  113710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113711. /**
  113712. * Detach the current controls from the specified dom element.
  113713. * @param element Defines the element to stop listening the inputs from
  113714. */
  113715. detachControl(element: Nullable<HTMLElement>): void;
  113716. /**
  113717. * Update the current camera state depending on the inputs that have been used this frame.
  113718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113719. */
  113720. checkInputs(): void;
  113721. /**
  113722. * Gets the class name of the current input.
  113723. * @returns the class name
  113724. */
  113725. getClassName(): string;
  113726. /**
  113727. * Get the friendly name associated with the input class.
  113728. * @returns the input friendly name
  113729. */
  113730. getSimpleName(): string;
  113731. /**
  113732. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113733. * allow modification of the heightOffset value.
  113734. */
  113735. private _modifierHeightOffset;
  113736. /**
  113737. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113738. * allow modification of the rotationOffset value.
  113739. */
  113740. private _modifierRotationOffset;
  113741. /**
  113742. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113743. * allow modification of the radius value.
  113744. */
  113745. private _modifierRadius;
  113746. }
  113747. }
  113748. declare module BABYLON {
  113749. interface FreeCameraInputsManager {
  113750. /**
  113751. * @hidden
  113752. */
  113753. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113754. /**
  113755. * Add orientation input support to the input manager.
  113756. * @returns the current input manager
  113757. */
  113758. addDeviceOrientation(): FreeCameraInputsManager;
  113759. }
  113760. /**
  113761. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113762. * Screen rotation is taken into account.
  113763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113764. */
  113765. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113766. private _camera;
  113767. private _screenOrientationAngle;
  113768. private _constantTranform;
  113769. private _screenQuaternion;
  113770. private _alpha;
  113771. private _beta;
  113772. private _gamma;
  113773. /**
  113774. * Can be used to detect if a device orientation sensor is available on a device
  113775. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113776. * @returns a promise that will resolve on orientation change
  113777. */
  113778. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113779. /**
  113780. * @hidden
  113781. */
  113782. _onDeviceOrientationChangedObservable: Observable<void>;
  113783. /**
  113784. * Instantiates a new input
  113785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113786. */
  113787. constructor();
  113788. /**
  113789. * Define the camera controlled by the input.
  113790. */
  113791. get camera(): FreeCamera;
  113792. set camera(camera: FreeCamera);
  113793. /**
  113794. * Attach the input controls to a specific dom element to get the input from.
  113795. * @param element Defines the element the controls should be listened from
  113796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113797. */
  113798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113799. private _orientationChanged;
  113800. private _deviceOrientation;
  113801. /**
  113802. * Detach the current controls from the specified dom element.
  113803. * @param element Defines the element to stop listening the inputs from
  113804. */
  113805. detachControl(element: Nullable<HTMLElement>): void;
  113806. /**
  113807. * Update the current camera state depending on the inputs that have been used this frame.
  113808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113809. */
  113810. checkInputs(): void;
  113811. /**
  113812. * Gets the class name of the current intput.
  113813. * @returns the class name
  113814. */
  113815. getClassName(): string;
  113816. /**
  113817. * Get the friendly name associated with the input class.
  113818. * @returns the input friendly name
  113819. */
  113820. getSimpleName(): string;
  113821. }
  113822. }
  113823. declare module BABYLON {
  113824. /**
  113825. * Manage the gamepad inputs to control a free camera.
  113826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113827. */
  113828. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113829. /**
  113830. * Define the camera the input is attached to.
  113831. */
  113832. camera: FreeCamera;
  113833. /**
  113834. * Define the Gamepad controlling the input
  113835. */
  113836. gamepad: Nullable<Gamepad>;
  113837. /**
  113838. * Defines the gamepad rotation sensiblity.
  113839. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113840. */
  113841. gamepadAngularSensibility: number;
  113842. /**
  113843. * Defines the gamepad move sensiblity.
  113844. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113845. */
  113846. gamepadMoveSensibility: number;
  113847. private _yAxisScale;
  113848. /**
  113849. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113850. */
  113851. get invertYAxis(): boolean;
  113852. set invertYAxis(value: boolean);
  113853. private _onGamepadConnectedObserver;
  113854. private _onGamepadDisconnectedObserver;
  113855. private _cameraTransform;
  113856. private _deltaTransform;
  113857. private _vector3;
  113858. private _vector2;
  113859. /**
  113860. * Attach the input controls to a specific dom element to get the input from.
  113861. * @param element Defines the element the controls should be listened from
  113862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113863. */
  113864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113865. /**
  113866. * Detach the current controls from the specified dom element.
  113867. * @param element Defines the element to stop listening the inputs from
  113868. */
  113869. detachControl(element: Nullable<HTMLElement>): void;
  113870. /**
  113871. * Update the current camera state depending on the inputs that have been used this frame.
  113872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113873. */
  113874. checkInputs(): void;
  113875. /**
  113876. * Gets the class name of the current intput.
  113877. * @returns the class name
  113878. */
  113879. getClassName(): string;
  113880. /**
  113881. * Get the friendly name associated with the input class.
  113882. * @returns the input friendly name
  113883. */
  113884. getSimpleName(): string;
  113885. }
  113886. }
  113887. declare module BABYLON {
  113888. /**
  113889. * Defines the potential axis of a Joystick
  113890. */
  113891. export enum JoystickAxis {
  113892. /** X axis */
  113893. X = 0,
  113894. /** Y axis */
  113895. Y = 1,
  113896. /** Z axis */
  113897. Z = 2
  113898. }
  113899. /**
  113900. * Class used to define virtual joystick (used in touch mode)
  113901. */
  113902. export class VirtualJoystick {
  113903. /**
  113904. * Gets or sets a boolean indicating that left and right values must be inverted
  113905. */
  113906. reverseLeftRight: boolean;
  113907. /**
  113908. * Gets or sets a boolean indicating that up and down values must be inverted
  113909. */
  113910. reverseUpDown: boolean;
  113911. /**
  113912. * Gets the offset value for the position (ie. the change of the position value)
  113913. */
  113914. deltaPosition: Vector3;
  113915. /**
  113916. * Gets a boolean indicating if the virtual joystick was pressed
  113917. */
  113918. pressed: boolean;
  113919. /**
  113920. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113921. */
  113922. static Canvas: Nullable<HTMLCanvasElement>;
  113923. private static _globalJoystickIndex;
  113924. private static vjCanvasContext;
  113925. private static vjCanvasWidth;
  113926. private static vjCanvasHeight;
  113927. private static halfWidth;
  113928. private _action;
  113929. private _axisTargetedByLeftAndRight;
  113930. private _axisTargetedByUpAndDown;
  113931. private _joystickSensibility;
  113932. private _inversedSensibility;
  113933. private _joystickPointerID;
  113934. private _joystickColor;
  113935. private _joystickPointerPos;
  113936. private _joystickPreviousPointerPos;
  113937. private _joystickPointerStartPos;
  113938. private _deltaJoystickVector;
  113939. private _leftJoystick;
  113940. private _touches;
  113941. private _onPointerDownHandlerRef;
  113942. private _onPointerMoveHandlerRef;
  113943. private _onPointerUpHandlerRef;
  113944. private _onResize;
  113945. /**
  113946. * Creates a new virtual joystick
  113947. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113948. */
  113949. constructor(leftJoystick?: boolean);
  113950. /**
  113951. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113952. * @param newJoystickSensibility defines the new sensibility
  113953. */
  113954. setJoystickSensibility(newJoystickSensibility: number): void;
  113955. private _onPointerDown;
  113956. private _onPointerMove;
  113957. private _onPointerUp;
  113958. /**
  113959. * Change the color of the virtual joystick
  113960. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113961. */
  113962. setJoystickColor(newColor: string): void;
  113963. /**
  113964. * Defines a callback to call when the joystick is touched
  113965. * @param action defines the callback
  113966. */
  113967. setActionOnTouch(action: () => any): void;
  113968. /**
  113969. * Defines which axis you'd like to control for left & right
  113970. * @param axis defines the axis to use
  113971. */
  113972. setAxisForLeftRight(axis: JoystickAxis): void;
  113973. /**
  113974. * Defines which axis you'd like to control for up & down
  113975. * @param axis defines the axis to use
  113976. */
  113977. setAxisForUpDown(axis: JoystickAxis): void;
  113978. private _drawVirtualJoystick;
  113979. /**
  113980. * Release internal HTML canvas
  113981. */
  113982. releaseCanvas(): void;
  113983. }
  113984. }
  113985. declare module BABYLON {
  113986. interface FreeCameraInputsManager {
  113987. /**
  113988. * Add virtual joystick input support to the input manager.
  113989. * @returns the current input manager
  113990. */
  113991. addVirtualJoystick(): FreeCameraInputsManager;
  113992. }
  113993. /**
  113994. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113996. */
  113997. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113998. /**
  113999. * Defines the camera the input is attached to.
  114000. */
  114001. camera: FreeCamera;
  114002. private _leftjoystick;
  114003. private _rightjoystick;
  114004. /**
  114005. * Gets the left stick of the virtual joystick.
  114006. * @returns The virtual Joystick
  114007. */
  114008. getLeftJoystick(): VirtualJoystick;
  114009. /**
  114010. * Gets the right stick of the virtual joystick.
  114011. * @returns The virtual Joystick
  114012. */
  114013. getRightJoystick(): VirtualJoystick;
  114014. /**
  114015. * Update the current camera state depending on the inputs that have been used this frame.
  114016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114017. */
  114018. checkInputs(): void;
  114019. /**
  114020. * Attach the input controls to a specific dom element to get the input from.
  114021. * @param element Defines the element the controls should be listened from
  114022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114023. */
  114024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114025. /**
  114026. * Detach the current controls from the specified dom element.
  114027. * @param element Defines the element to stop listening the inputs from
  114028. */
  114029. detachControl(element: Nullable<HTMLElement>): void;
  114030. /**
  114031. * Gets the class name of the current intput.
  114032. * @returns the class name
  114033. */
  114034. getClassName(): string;
  114035. /**
  114036. * Get the friendly name associated with the input class.
  114037. * @returns the input friendly name
  114038. */
  114039. getSimpleName(): string;
  114040. }
  114041. }
  114042. declare module BABYLON {
  114043. /**
  114044. * This represents a FPS type of camera controlled by touch.
  114045. * This is like a universal camera minus the Gamepad controls.
  114046. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114047. */
  114048. export class TouchCamera extends FreeCamera {
  114049. /**
  114050. * Defines the touch sensibility for rotation.
  114051. * The higher the faster.
  114052. */
  114053. get touchAngularSensibility(): number;
  114054. set touchAngularSensibility(value: number);
  114055. /**
  114056. * Defines the touch sensibility for move.
  114057. * The higher the faster.
  114058. */
  114059. get touchMoveSensibility(): number;
  114060. set touchMoveSensibility(value: number);
  114061. /**
  114062. * Instantiates a new touch camera.
  114063. * This represents a FPS type of camera controlled by touch.
  114064. * This is like a universal camera minus the Gamepad controls.
  114065. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114066. * @param name Define the name of the camera in the scene
  114067. * @param position Define the start position of the camera in the scene
  114068. * @param scene Define the scene the camera belongs to
  114069. */
  114070. constructor(name: string, position: Vector3, scene: Scene);
  114071. /**
  114072. * Gets the current object class name.
  114073. * @return the class name
  114074. */
  114075. getClassName(): string;
  114076. /** @hidden */
  114077. _setupInputs(): void;
  114078. }
  114079. }
  114080. declare module BABYLON {
  114081. /**
  114082. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114083. * being tilted forward or back and left or right.
  114084. */
  114085. export class DeviceOrientationCamera extends FreeCamera {
  114086. private _initialQuaternion;
  114087. private _quaternionCache;
  114088. private _tmpDragQuaternion;
  114089. private _disablePointerInputWhenUsingDeviceOrientation;
  114090. /**
  114091. * Creates a new device orientation camera
  114092. * @param name The name of the camera
  114093. * @param position The start position camera
  114094. * @param scene The scene the camera belongs to
  114095. */
  114096. constructor(name: string, position: Vector3, scene: Scene);
  114097. /**
  114098. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114099. */
  114100. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114101. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114102. private _dragFactor;
  114103. /**
  114104. * Enabled turning on the y axis when the orientation sensor is active
  114105. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114106. */
  114107. enableHorizontalDragging(dragFactor?: number): void;
  114108. /**
  114109. * Gets the current instance class name ("DeviceOrientationCamera").
  114110. * This helps avoiding instanceof at run time.
  114111. * @returns the class name
  114112. */
  114113. getClassName(): string;
  114114. /**
  114115. * @hidden
  114116. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114117. */
  114118. _checkInputs(): void;
  114119. /**
  114120. * Reset the camera to its default orientation on the specified axis only.
  114121. * @param axis The axis to reset
  114122. */
  114123. resetToCurrentRotation(axis?: Axis): void;
  114124. }
  114125. }
  114126. declare module BABYLON {
  114127. /**
  114128. * Defines supported buttons for XBox360 compatible gamepads
  114129. */
  114130. export enum Xbox360Button {
  114131. /** A */
  114132. A = 0,
  114133. /** B */
  114134. B = 1,
  114135. /** X */
  114136. X = 2,
  114137. /** Y */
  114138. Y = 3,
  114139. /** Start */
  114140. Start = 4,
  114141. /** Back */
  114142. Back = 5,
  114143. /** Left button */
  114144. LB = 6,
  114145. /** Right button */
  114146. RB = 7,
  114147. /** Left stick */
  114148. LeftStick = 8,
  114149. /** Right stick */
  114150. RightStick = 9
  114151. }
  114152. /** Defines values for XBox360 DPad */
  114153. export enum Xbox360Dpad {
  114154. /** Up */
  114155. Up = 0,
  114156. /** Down */
  114157. Down = 1,
  114158. /** Left */
  114159. Left = 2,
  114160. /** Right */
  114161. Right = 3
  114162. }
  114163. /**
  114164. * Defines a XBox360 gamepad
  114165. */
  114166. export class Xbox360Pad extends Gamepad {
  114167. private _leftTrigger;
  114168. private _rightTrigger;
  114169. private _onlefttriggerchanged;
  114170. private _onrighttriggerchanged;
  114171. private _onbuttondown;
  114172. private _onbuttonup;
  114173. private _ondpaddown;
  114174. private _ondpadup;
  114175. /** Observable raised when a button is pressed */
  114176. onButtonDownObservable: Observable<Xbox360Button>;
  114177. /** Observable raised when a button is released */
  114178. onButtonUpObservable: Observable<Xbox360Button>;
  114179. /** Observable raised when a pad is pressed */
  114180. onPadDownObservable: Observable<Xbox360Dpad>;
  114181. /** Observable raised when a pad is released */
  114182. onPadUpObservable: Observable<Xbox360Dpad>;
  114183. private _buttonA;
  114184. private _buttonB;
  114185. private _buttonX;
  114186. private _buttonY;
  114187. private _buttonBack;
  114188. private _buttonStart;
  114189. private _buttonLB;
  114190. private _buttonRB;
  114191. private _buttonLeftStick;
  114192. private _buttonRightStick;
  114193. private _dPadUp;
  114194. private _dPadDown;
  114195. private _dPadLeft;
  114196. private _dPadRight;
  114197. private _isXboxOnePad;
  114198. /**
  114199. * Creates a new XBox360 gamepad object
  114200. * @param id defines the id of this gamepad
  114201. * @param index defines its index
  114202. * @param gamepad defines the internal HTML gamepad object
  114203. * @param xboxOne defines if it is a XBox One gamepad
  114204. */
  114205. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114206. /**
  114207. * Defines the callback to call when left trigger is pressed
  114208. * @param callback defines the callback to use
  114209. */
  114210. onlefttriggerchanged(callback: (value: number) => void): void;
  114211. /**
  114212. * Defines the callback to call when right trigger is pressed
  114213. * @param callback defines the callback to use
  114214. */
  114215. onrighttriggerchanged(callback: (value: number) => void): void;
  114216. /**
  114217. * Gets the left trigger value
  114218. */
  114219. get leftTrigger(): number;
  114220. /**
  114221. * Sets the left trigger value
  114222. */
  114223. set leftTrigger(newValue: number);
  114224. /**
  114225. * Gets the right trigger value
  114226. */
  114227. get rightTrigger(): number;
  114228. /**
  114229. * Sets the right trigger value
  114230. */
  114231. set rightTrigger(newValue: number);
  114232. /**
  114233. * Defines the callback to call when a button is pressed
  114234. * @param callback defines the callback to use
  114235. */
  114236. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114237. /**
  114238. * Defines the callback to call when a button is released
  114239. * @param callback defines the callback to use
  114240. */
  114241. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114242. /**
  114243. * Defines the callback to call when a pad is pressed
  114244. * @param callback defines the callback to use
  114245. */
  114246. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114247. /**
  114248. * Defines the callback to call when a pad is released
  114249. * @param callback defines the callback to use
  114250. */
  114251. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114252. private _setButtonValue;
  114253. private _setDPadValue;
  114254. /**
  114255. * Gets the value of the `A` button
  114256. */
  114257. get buttonA(): number;
  114258. /**
  114259. * Sets the value of the `A` button
  114260. */
  114261. set buttonA(value: number);
  114262. /**
  114263. * Gets the value of the `B` button
  114264. */
  114265. get buttonB(): number;
  114266. /**
  114267. * Sets the value of the `B` button
  114268. */
  114269. set buttonB(value: number);
  114270. /**
  114271. * Gets the value of the `X` button
  114272. */
  114273. get buttonX(): number;
  114274. /**
  114275. * Sets the value of the `X` button
  114276. */
  114277. set buttonX(value: number);
  114278. /**
  114279. * Gets the value of the `Y` button
  114280. */
  114281. get buttonY(): number;
  114282. /**
  114283. * Sets the value of the `Y` button
  114284. */
  114285. set buttonY(value: number);
  114286. /**
  114287. * Gets the value of the `Start` button
  114288. */
  114289. get buttonStart(): number;
  114290. /**
  114291. * Sets the value of the `Start` button
  114292. */
  114293. set buttonStart(value: number);
  114294. /**
  114295. * Gets the value of the `Back` button
  114296. */
  114297. get buttonBack(): number;
  114298. /**
  114299. * Sets the value of the `Back` button
  114300. */
  114301. set buttonBack(value: number);
  114302. /**
  114303. * Gets the value of the `Left` button
  114304. */
  114305. get buttonLB(): number;
  114306. /**
  114307. * Sets the value of the `Left` button
  114308. */
  114309. set buttonLB(value: number);
  114310. /**
  114311. * Gets the value of the `Right` button
  114312. */
  114313. get buttonRB(): number;
  114314. /**
  114315. * Sets the value of the `Right` button
  114316. */
  114317. set buttonRB(value: number);
  114318. /**
  114319. * Gets the value of the Left joystick
  114320. */
  114321. get buttonLeftStick(): number;
  114322. /**
  114323. * Sets the value of the Left joystick
  114324. */
  114325. set buttonLeftStick(value: number);
  114326. /**
  114327. * Gets the value of the Right joystick
  114328. */
  114329. get buttonRightStick(): number;
  114330. /**
  114331. * Sets the value of the Right joystick
  114332. */
  114333. set buttonRightStick(value: number);
  114334. /**
  114335. * Gets the value of D-pad up
  114336. */
  114337. get dPadUp(): number;
  114338. /**
  114339. * Sets the value of D-pad up
  114340. */
  114341. set dPadUp(value: number);
  114342. /**
  114343. * Gets the value of D-pad down
  114344. */
  114345. get dPadDown(): number;
  114346. /**
  114347. * Sets the value of D-pad down
  114348. */
  114349. set dPadDown(value: number);
  114350. /**
  114351. * Gets the value of D-pad left
  114352. */
  114353. get dPadLeft(): number;
  114354. /**
  114355. * Sets the value of D-pad left
  114356. */
  114357. set dPadLeft(value: number);
  114358. /**
  114359. * Gets the value of D-pad right
  114360. */
  114361. get dPadRight(): number;
  114362. /**
  114363. * Sets the value of D-pad right
  114364. */
  114365. set dPadRight(value: number);
  114366. /**
  114367. * Force the gamepad to synchronize with device values
  114368. */
  114369. update(): void;
  114370. /**
  114371. * Disposes the gamepad
  114372. */
  114373. dispose(): void;
  114374. }
  114375. }
  114376. declare module BABYLON {
  114377. /**
  114378. * Defines supported buttons for DualShock compatible gamepads
  114379. */
  114380. export enum DualShockButton {
  114381. /** Cross */
  114382. Cross = 0,
  114383. /** Circle */
  114384. Circle = 1,
  114385. /** Square */
  114386. Square = 2,
  114387. /** Triangle */
  114388. Triangle = 3,
  114389. /** Options */
  114390. Options = 4,
  114391. /** Share */
  114392. Share = 5,
  114393. /** L1 */
  114394. L1 = 6,
  114395. /** R1 */
  114396. R1 = 7,
  114397. /** Left stick */
  114398. LeftStick = 8,
  114399. /** Right stick */
  114400. RightStick = 9
  114401. }
  114402. /** Defines values for DualShock DPad */
  114403. export enum DualShockDpad {
  114404. /** Up */
  114405. Up = 0,
  114406. /** Down */
  114407. Down = 1,
  114408. /** Left */
  114409. Left = 2,
  114410. /** Right */
  114411. Right = 3
  114412. }
  114413. /**
  114414. * Defines a DualShock gamepad
  114415. */
  114416. export class DualShockPad extends Gamepad {
  114417. private _leftTrigger;
  114418. private _rightTrigger;
  114419. private _onlefttriggerchanged;
  114420. private _onrighttriggerchanged;
  114421. private _onbuttondown;
  114422. private _onbuttonup;
  114423. private _ondpaddown;
  114424. private _ondpadup;
  114425. /** Observable raised when a button is pressed */
  114426. onButtonDownObservable: Observable<DualShockButton>;
  114427. /** Observable raised when a button is released */
  114428. onButtonUpObservable: Observable<DualShockButton>;
  114429. /** Observable raised when a pad is pressed */
  114430. onPadDownObservable: Observable<DualShockDpad>;
  114431. /** Observable raised when a pad is released */
  114432. onPadUpObservable: Observable<DualShockDpad>;
  114433. private _buttonCross;
  114434. private _buttonCircle;
  114435. private _buttonSquare;
  114436. private _buttonTriangle;
  114437. private _buttonShare;
  114438. private _buttonOptions;
  114439. private _buttonL1;
  114440. private _buttonR1;
  114441. private _buttonLeftStick;
  114442. private _buttonRightStick;
  114443. private _dPadUp;
  114444. private _dPadDown;
  114445. private _dPadLeft;
  114446. private _dPadRight;
  114447. /**
  114448. * Creates a new DualShock gamepad object
  114449. * @param id defines the id of this gamepad
  114450. * @param index defines its index
  114451. * @param gamepad defines the internal HTML gamepad object
  114452. */
  114453. constructor(id: string, index: number, gamepad: any);
  114454. /**
  114455. * Defines the callback to call when left trigger is pressed
  114456. * @param callback defines the callback to use
  114457. */
  114458. onlefttriggerchanged(callback: (value: number) => void): void;
  114459. /**
  114460. * Defines the callback to call when right trigger is pressed
  114461. * @param callback defines the callback to use
  114462. */
  114463. onrighttriggerchanged(callback: (value: number) => void): void;
  114464. /**
  114465. * Gets the left trigger value
  114466. */
  114467. get leftTrigger(): number;
  114468. /**
  114469. * Sets the left trigger value
  114470. */
  114471. set leftTrigger(newValue: number);
  114472. /**
  114473. * Gets the right trigger value
  114474. */
  114475. get rightTrigger(): number;
  114476. /**
  114477. * Sets the right trigger value
  114478. */
  114479. set rightTrigger(newValue: number);
  114480. /**
  114481. * Defines the callback to call when a button is pressed
  114482. * @param callback defines the callback to use
  114483. */
  114484. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114485. /**
  114486. * Defines the callback to call when a button is released
  114487. * @param callback defines the callback to use
  114488. */
  114489. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114490. /**
  114491. * Defines the callback to call when a pad is pressed
  114492. * @param callback defines the callback to use
  114493. */
  114494. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114495. /**
  114496. * Defines the callback to call when a pad is released
  114497. * @param callback defines the callback to use
  114498. */
  114499. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114500. private _setButtonValue;
  114501. private _setDPadValue;
  114502. /**
  114503. * Gets the value of the `Cross` button
  114504. */
  114505. get buttonCross(): number;
  114506. /**
  114507. * Sets the value of the `Cross` button
  114508. */
  114509. set buttonCross(value: number);
  114510. /**
  114511. * Gets the value of the `Circle` button
  114512. */
  114513. get buttonCircle(): number;
  114514. /**
  114515. * Sets the value of the `Circle` button
  114516. */
  114517. set buttonCircle(value: number);
  114518. /**
  114519. * Gets the value of the `Square` button
  114520. */
  114521. get buttonSquare(): number;
  114522. /**
  114523. * Sets the value of the `Square` button
  114524. */
  114525. set buttonSquare(value: number);
  114526. /**
  114527. * Gets the value of the `Triangle` button
  114528. */
  114529. get buttonTriangle(): number;
  114530. /**
  114531. * Sets the value of the `Triangle` button
  114532. */
  114533. set buttonTriangle(value: number);
  114534. /**
  114535. * Gets the value of the `Options` button
  114536. */
  114537. get buttonOptions(): number;
  114538. /**
  114539. * Sets the value of the `Options` button
  114540. */
  114541. set buttonOptions(value: number);
  114542. /**
  114543. * Gets the value of the `Share` button
  114544. */
  114545. get buttonShare(): number;
  114546. /**
  114547. * Sets the value of the `Share` button
  114548. */
  114549. set buttonShare(value: number);
  114550. /**
  114551. * Gets the value of the `L1` button
  114552. */
  114553. get buttonL1(): number;
  114554. /**
  114555. * Sets the value of the `L1` button
  114556. */
  114557. set buttonL1(value: number);
  114558. /**
  114559. * Gets the value of the `R1` button
  114560. */
  114561. get buttonR1(): number;
  114562. /**
  114563. * Sets the value of the `R1` button
  114564. */
  114565. set buttonR1(value: number);
  114566. /**
  114567. * Gets the value of the Left joystick
  114568. */
  114569. get buttonLeftStick(): number;
  114570. /**
  114571. * Sets the value of the Left joystick
  114572. */
  114573. set buttonLeftStick(value: number);
  114574. /**
  114575. * Gets the value of the Right joystick
  114576. */
  114577. get buttonRightStick(): number;
  114578. /**
  114579. * Sets the value of the Right joystick
  114580. */
  114581. set buttonRightStick(value: number);
  114582. /**
  114583. * Gets the value of D-pad up
  114584. */
  114585. get dPadUp(): number;
  114586. /**
  114587. * Sets the value of D-pad up
  114588. */
  114589. set dPadUp(value: number);
  114590. /**
  114591. * Gets the value of D-pad down
  114592. */
  114593. get dPadDown(): number;
  114594. /**
  114595. * Sets the value of D-pad down
  114596. */
  114597. set dPadDown(value: number);
  114598. /**
  114599. * Gets the value of D-pad left
  114600. */
  114601. get dPadLeft(): number;
  114602. /**
  114603. * Sets the value of D-pad left
  114604. */
  114605. set dPadLeft(value: number);
  114606. /**
  114607. * Gets the value of D-pad right
  114608. */
  114609. get dPadRight(): number;
  114610. /**
  114611. * Sets the value of D-pad right
  114612. */
  114613. set dPadRight(value: number);
  114614. /**
  114615. * Force the gamepad to synchronize with device values
  114616. */
  114617. update(): void;
  114618. /**
  114619. * Disposes the gamepad
  114620. */
  114621. dispose(): void;
  114622. }
  114623. }
  114624. declare module BABYLON {
  114625. /**
  114626. * Manager for handling gamepads
  114627. */
  114628. export class GamepadManager {
  114629. private _scene?;
  114630. private _babylonGamepads;
  114631. private _oneGamepadConnected;
  114632. /** @hidden */
  114633. _isMonitoring: boolean;
  114634. private _gamepadEventSupported;
  114635. private _gamepadSupport?;
  114636. /**
  114637. * observable to be triggered when the gamepad controller has been connected
  114638. */
  114639. onGamepadConnectedObservable: Observable<Gamepad>;
  114640. /**
  114641. * observable to be triggered when the gamepad controller has been disconnected
  114642. */
  114643. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114644. private _onGamepadConnectedEvent;
  114645. private _onGamepadDisconnectedEvent;
  114646. /**
  114647. * Initializes the gamepad manager
  114648. * @param _scene BabylonJS scene
  114649. */
  114650. constructor(_scene?: Scene | undefined);
  114651. /**
  114652. * The gamepads in the game pad manager
  114653. */
  114654. get gamepads(): Gamepad[];
  114655. /**
  114656. * Get the gamepad controllers based on type
  114657. * @param type The type of gamepad controller
  114658. * @returns Nullable gamepad
  114659. */
  114660. getGamepadByType(type?: number): Nullable<Gamepad>;
  114661. /**
  114662. * Disposes the gamepad manager
  114663. */
  114664. dispose(): void;
  114665. private _addNewGamepad;
  114666. private _startMonitoringGamepads;
  114667. private _stopMonitoringGamepads;
  114668. /** @hidden */
  114669. _checkGamepadsStatus(): void;
  114670. private _updateGamepadObjects;
  114671. }
  114672. }
  114673. declare module BABYLON {
  114674. interface Scene {
  114675. /** @hidden */
  114676. _gamepadManager: Nullable<GamepadManager>;
  114677. /**
  114678. * Gets the gamepad manager associated with the scene
  114679. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114680. */
  114681. gamepadManager: GamepadManager;
  114682. }
  114683. /**
  114684. * Interface representing a free camera inputs manager
  114685. */
  114686. interface FreeCameraInputsManager {
  114687. /**
  114688. * Adds gamepad input support to the FreeCameraInputsManager.
  114689. * @returns the FreeCameraInputsManager
  114690. */
  114691. addGamepad(): FreeCameraInputsManager;
  114692. }
  114693. /**
  114694. * Interface representing an arc rotate camera inputs manager
  114695. */
  114696. interface ArcRotateCameraInputsManager {
  114697. /**
  114698. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114699. * @returns the camera inputs manager
  114700. */
  114701. addGamepad(): ArcRotateCameraInputsManager;
  114702. }
  114703. /**
  114704. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114705. */
  114706. export class GamepadSystemSceneComponent implements ISceneComponent {
  114707. /**
  114708. * The component name helpfull to identify the component in the list of scene components.
  114709. */
  114710. readonly name: string;
  114711. /**
  114712. * The scene the component belongs to.
  114713. */
  114714. scene: Scene;
  114715. /**
  114716. * Creates a new instance of the component for the given scene
  114717. * @param scene Defines the scene to register the component in
  114718. */
  114719. constructor(scene: Scene);
  114720. /**
  114721. * Registers the component in a given scene
  114722. */
  114723. register(): void;
  114724. /**
  114725. * Rebuilds the elements related to this component in case of
  114726. * context lost for instance.
  114727. */
  114728. rebuild(): void;
  114729. /**
  114730. * Disposes the component and the associated ressources
  114731. */
  114732. dispose(): void;
  114733. private _beforeCameraUpdate;
  114734. }
  114735. }
  114736. declare module BABYLON {
  114737. /**
  114738. * 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,
  114739. * which still works and will still be found in many Playgrounds.
  114740. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114741. */
  114742. export class UniversalCamera extends TouchCamera {
  114743. /**
  114744. * Defines the gamepad rotation sensiblity.
  114745. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114746. */
  114747. get gamepadAngularSensibility(): number;
  114748. set gamepadAngularSensibility(value: number);
  114749. /**
  114750. * Defines the gamepad move sensiblity.
  114751. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114752. */
  114753. get gamepadMoveSensibility(): number;
  114754. set gamepadMoveSensibility(value: number);
  114755. /**
  114756. * 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,
  114757. * which still works and will still be found in many Playgrounds.
  114758. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114759. * @param name Define the name of the camera in the scene
  114760. * @param position Define the start position of the camera in the scene
  114761. * @param scene Define the scene the camera belongs to
  114762. */
  114763. constructor(name: string, position: Vector3, scene: Scene);
  114764. /**
  114765. * Gets the current object class name.
  114766. * @return the class name
  114767. */
  114768. getClassName(): string;
  114769. }
  114770. }
  114771. declare module BABYLON {
  114772. /**
  114773. * This represents a FPS type of camera. This is only here for back compat purpose.
  114774. * Please use the UniversalCamera instead as both are identical.
  114775. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114776. */
  114777. export class GamepadCamera extends UniversalCamera {
  114778. /**
  114779. * Instantiates a new Gamepad Camera
  114780. * This represents a FPS type of camera. This is only here for back compat purpose.
  114781. * Please use the UniversalCamera instead as both are identical.
  114782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114783. * @param name Define the name of the camera in the scene
  114784. * @param position Define the start position of the camera in the scene
  114785. * @param scene Define the scene the camera belongs to
  114786. */
  114787. constructor(name: string, position: Vector3, scene: Scene);
  114788. /**
  114789. * Gets the current object class name.
  114790. * @return the class name
  114791. */
  114792. getClassName(): string;
  114793. }
  114794. }
  114795. declare module BABYLON {
  114796. /** @hidden */
  114797. export var passPixelShader: {
  114798. name: string;
  114799. shader: string;
  114800. };
  114801. }
  114802. declare module BABYLON {
  114803. /** @hidden */
  114804. export var passCubePixelShader: {
  114805. name: string;
  114806. shader: string;
  114807. };
  114808. }
  114809. declare module BABYLON {
  114810. /**
  114811. * PassPostProcess which produces an output the same as it's input
  114812. */
  114813. export class PassPostProcess extends PostProcess {
  114814. /**
  114815. * Creates the PassPostProcess
  114816. * @param name The name of the effect.
  114817. * @param options The required width/height ratio to downsize to before computing the render pass.
  114818. * @param camera The camera to apply the render pass to.
  114819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114820. * @param engine The engine which the post process will be applied. (default: current engine)
  114821. * @param reusable If the post process can be reused on the same frame. (default: false)
  114822. * @param textureType The type of texture to be used when performing the post processing.
  114823. * @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)
  114824. */
  114825. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114826. }
  114827. /**
  114828. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114829. */
  114830. export class PassCubePostProcess extends PostProcess {
  114831. private _face;
  114832. /**
  114833. * Gets or sets the cube face to display.
  114834. * * 0 is +X
  114835. * * 1 is -X
  114836. * * 2 is +Y
  114837. * * 3 is -Y
  114838. * * 4 is +Z
  114839. * * 5 is -Z
  114840. */
  114841. get face(): number;
  114842. set face(value: number);
  114843. /**
  114844. * Creates the PassCubePostProcess
  114845. * @param name The name of the effect.
  114846. * @param options The required width/height ratio to downsize to before computing the render pass.
  114847. * @param camera The camera to apply the render pass to.
  114848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114849. * @param engine The engine which the post process will be applied. (default: current engine)
  114850. * @param reusable If the post process can be reused on the same frame. (default: false)
  114851. * @param textureType The type of texture to be used when performing the post processing.
  114852. * @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)
  114853. */
  114854. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114855. }
  114856. }
  114857. declare module BABYLON {
  114858. /** @hidden */
  114859. export var anaglyphPixelShader: {
  114860. name: string;
  114861. shader: string;
  114862. };
  114863. }
  114864. declare module BABYLON {
  114865. /**
  114866. * Postprocess used to generate anaglyphic rendering
  114867. */
  114868. export class AnaglyphPostProcess extends PostProcess {
  114869. private _passedProcess;
  114870. /**
  114871. * Creates a new AnaglyphPostProcess
  114872. * @param name defines postprocess name
  114873. * @param options defines creation options or target ratio scale
  114874. * @param rigCameras defines cameras using this postprocess
  114875. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114876. * @param engine defines hosting engine
  114877. * @param reusable defines if the postprocess will be reused multiple times per frame
  114878. */
  114879. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114880. }
  114881. }
  114882. declare module BABYLON {
  114883. /**
  114884. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114885. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114886. */
  114887. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114888. /**
  114889. * Creates a new AnaglyphArcRotateCamera
  114890. * @param name defines camera name
  114891. * @param alpha defines alpha angle (in radians)
  114892. * @param beta defines beta angle (in radians)
  114893. * @param radius defines radius
  114894. * @param target defines camera target
  114895. * @param interaxialDistance defines distance between each color axis
  114896. * @param scene defines the hosting scene
  114897. */
  114898. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114899. /**
  114900. * Gets camera class name
  114901. * @returns AnaglyphArcRotateCamera
  114902. */
  114903. getClassName(): string;
  114904. }
  114905. }
  114906. declare module BABYLON {
  114907. /**
  114908. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114909. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114910. */
  114911. export class AnaglyphFreeCamera extends FreeCamera {
  114912. /**
  114913. * Creates a new AnaglyphFreeCamera
  114914. * @param name defines camera name
  114915. * @param position defines initial position
  114916. * @param interaxialDistance defines distance between each color axis
  114917. * @param scene defines the hosting scene
  114918. */
  114919. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114920. /**
  114921. * Gets camera class name
  114922. * @returns AnaglyphFreeCamera
  114923. */
  114924. getClassName(): string;
  114925. }
  114926. }
  114927. declare module BABYLON {
  114928. /**
  114929. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114930. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114931. */
  114932. export class AnaglyphGamepadCamera extends GamepadCamera {
  114933. /**
  114934. * Creates a new AnaglyphGamepadCamera
  114935. * @param name defines camera name
  114936. * @param position defines initial position
  114937. * @param interaxialDistance defines distance between each color axis
  114938. * @param scene defines the hosting scene
  114939. */
  114940. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114941. /**
  114942. * Gets camera class name
  114943. * @returns AnaglyphGamepadCamera
  114944. */
  114945. getClassName(): string;
  114946. }
  114947. }
  114948. declare module BABYLON {
  114949. /**
  114950. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114951. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114952. */
  114953. export class AnaglyphUniversalCamera extends UniversalCamera {
  114954. /**
  114955. * Creates a new AnaglyphUniversalCamera
  114956. * @param name defines camera name
  114957. * @param position defines initial position
  114958. * @param interaxialDistance defines distance between each color axis
  114959. * @param scene defines the hosting scene
  114960. */
  114961. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114962. /**
  114963. * Gets camera class name
  114964. * @returns AnaglyphUniversalCamera
  114965. */
  114966. getClassName(): string;
  114967. }
  114968. }
  114969. declare module BABYLON {
  114970. /** @hidden */
  114971. export var stereoscopicInterlacePixelShader: {
  114972. name: string;
  114973. shader: string;
  114974. };
  114975. }
  114976. declare module BABYLON {
  114977. /**
  114978. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114979. */
  114980. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114981. private _stepSize;
  114982. private _passedProcess;
  114983. /**
  114984. * Initializes a StereoscopicInterlacePostProcessI
  114985. * @param name The name of the effect.
  114986. * @param rigCameras The rig cameras to be appled to the post process
  114987. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114988. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114990. * @param engine The engine which the post process will be applied. (default: current engine)
  114991. * @param reusable If the post process can be reused on the same frame. (default: false)
  114992. */
  114993. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114994. }
  114995. /**
  114996. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114997. */
  114998. export class StereoscopicInterlacePostProcess extends PostProcess {
  114999. private _stepSize;
  115000. private _passedProcess;
  115001. /**
  115002. * Initializes a StereoscopicInterlacePostProcess
  115003. * @param name The name of the effect.
  115004. * @param rigCameras The rig cameras to be appled to the post process
  115005. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115007. * @param engine The engine which the post process will be applied. (default: current engine)
  115008. * @param reusable If the post process can be reused on the same frame. (default: false)
  115009. */
  115010. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115011. }
  115012. }
  115013. declare module BABYLON {
  115014. /**
  115015. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115016. * @see http://doc.babylonjs.com/features/cameras
  115017. */
  115018. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115019. /**
  115020. * Creates a new StereoscopicArcRotateCamera
  115021. * @param name defines camera name
  115022. * @param alpha defines alpha angle (in radians)
  115023. * @param beta defines beta angle (in radians)
  115024. * @param radius defines radius
  115025. * @param target defines camera target
  115026. * @param interaxialDistance defines distance between each color axis
  115027. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115028. * @param scene defines the hosting scene
  115029. */
  115030. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115031. /**
  115032. * Gets camera class name
  115033. * @returns StereoscopicArcRotateCamera
  115034. */
  115035. getClassName(): string;
  115036. }
  115037. }
  115038. declare module BABYLON {
  115039. /**
  115040. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115041. * @see http://doc.babylonjs.com/features/cameras
  115042. */
  115043. export class StereoscopicFreeCamera extends FreeCamera {
  115044. /**
  115045. * Creates a new StereoscopicFreeCamera
  115046. * @param name defines camera name
  115047. * @param position defines initial position
  115048. * @param interaxialDistance defines distance between each color axis
  115049. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115050. * @param scene defines the hosting scene
  115051. */
  115052. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115053. /**
  115054. * Gets camera class name
  115055. * @returns StereoscopicFreeCamera
  115056. */
  115057. getClassName(): string;
  115058. }
  115059. }
  115060. declare module BABYLON {
  115061. /**
  115062. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115063. * @see http://doc.babylonjs.com/features/cameras
  115064. */
  115065. export class StereoscopicGamepadCamera extends GamepadCamera {
  115066. /**
  115067. * Creates a new StereoscopicGamepadCamera
  115068. * @param name defines camera name
  115069. * @param position defines initial position
  115070. * @param interaxialDistance defines distance between each color axis
  115071. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115072. * @param scene defines the hosting scene
  115073. */
  115074. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115075. /**
  115076. * Gets camera class name
  115077. * @returns StereoscopicGamepadCamera
  115078. */
  115079. getClassName(): string;
  115080. }
  115081. }
  115082. declare module BABYLON {
  115083. /**
  115084. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115085. * @see http://doc.babylonjs.com/features/cameras
  115086. */
  115087. export class StereoscopicUniversalCamera extends UniversalCamera {
  115088. /**
  115089. * Creates a new StereoscopicUniversalCamera
  115090. * @param name defines camera name
  115091. * @param position defines initial position
  115092. * @param interaxialDistance defines distance between each color axis
  115093. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115094. * @param scene defines the hosting scene
  115095. */
  115096. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115097. /**
  115098. * Gets camera class name
  115099. * @returns StereoscopicUniversalCamera
  115100. */
  115101. getClassName(): string;
  115102. }
  115103. }
  115104. declare module BABYLON {
  115105. /**
  115106. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115107. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115108. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115109. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115110. */
  115111. export class VirtualJoysticksCamera extends FreeCamera {
  115112. /**
  115113. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115114. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115115. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115116. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115117. * @param name Define the name of the camera in the scene
  115118. * @param position Define the start position of the camera in the scene
  115119. * @param scene Define the scene the camera belongs to
  115120. */
  115121. constructor(name: string, position: Vector3, scene: Scene);
  115122. /**
  115123. * Gets the current object class name.
  115124. * @return the class name
  115125. */
  115126. getClassName(): string;
  115127. }
  115128. }
  115129. declare module BABYLON {
  115130. /**
  115131. * This represents all the required metrics to create a VR camera.
  115132. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115133. */
  115134. export class VRCameraMetrics {
  115135. /**
  115136. * Define the horizontal resolution off the screen.
  115137. */
  115138. hResolution: number;
  115139. /**
  115140. * Define the vertical resolution off the screen.
  115141. */
  115142. vResolution: number;
  115143. /**
  115144. * Define the horizontal screen size.
  115145. */
  115146. hScreenSize: number;
  115147. /**
  115148. * Define the vertical screen size.
  115149. */
  115150. vScreenSize: number;
  115151. /**
  115152. * Define the vertical screen center position.
  115153. */
  115154. vScreenCenter: number;
  115155. /**
  115156. * Define the distance of the eyes to the screen.
  115157. */
  115158. eyeToScreenDistance: number;
  115159. /**
  115160. * Define the distance between both lenses
  115161. */
  115162. lensSeparationDistance: number;
  115163. /**
  115164. * Define the distance between both viewer's eyes.
  115165. */
  115166. interpupillaryDistance: number;
  115167. /**
  115168. * Define the distortion factor of the VR postprocess.
  115169. * Please, touch with care.
  115170. */
  115171. distortionK: number[];
  115172. /**
  115173. * Define the chromatic aberration correction factors for the VR post process.
  115174. */
  115175. chromaAbCorrection: number[];
  115176. /**
  115177. * Define the scale factor of the post process.
  115178. * The smaller the better but the slower.
  115179. */
  115180. postProcessScaleFactor: number;
  115181. /**
  115182. * Define an offset for the lens center.
  115183. */
  115184. lensCenterOffset: number;
  115185. /**
  115186. * Define if the current vr camera should compensate the distortion of the lense or not.
  115187. */
  115188. compensateDistortion: boolean;
  115189. /**
  115190. * Defines if multiview should be enabled when rendering (Default: false)
  115191. */
  115192. multiviewEnabled: boolean;
  115193. /**
  115194. * Gets the rendering aspect ratio based on the provided resolutions.
  115195. */
  115196. get aspectRatio(): number;
  115197. /**
  115198. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115199. */
  115200. get aspectRatioFov(): number;
  115201. /**
  115202. * @hidden
  115203. */
  115204. get leftHMatrix(): Matrix;
  115205. /**
  115206. * @hidden
  115207. */
  115208. get rightHMatrix(): Matrix;
  115209. /**
  115210. * @hidden
  115211. */
  115212. get leftPreViewMatrix(): Matrix;
  115213. /**
  115214. * @hidden
  115215. */
  115216. get rightPreViewMatrix(): Matrix;
  115217. /**
  115218. * Get the default VRMetrics based on the most generic setup.
  115219. * @returns the default vr metrics
  115220. */
  115221. static GetDefault(): VRCameraMetrics;
  115222. }
  115223. }
  115224. declare module BABYLON {
  115225. /** @hidden */
  115226. export var vrDistortionCorrectionPixelShader: {
  115227. name: string;
  115228. shader: string;
  115229. };
  115230. }
  115231. declare module BABYLON {
  115232. /**
  115233. * VRDistortionCorrectionPostProcess used for mobile VR
  115234. */
  115235. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115236. private _isRightEye;
  115237. private _distortionFactors;
  115238. private _postProcessScaleFactor;
  115239. private _lensCenterOffset;
  115240. private _scaleIn;
  115241. private _scaleFactor;
  115242. private _lensCenter;
  115243. /**
  115244. * Initializes the VRDistortionCorrectionPostProcess
  115245. * @param name The name of the effect.
  115246. * @param camera The camera to apply the render pass to.
  115247. * @param isRightEye If this is for the right eye distortion
  115248. * @param vrMetrics All the required metrics for the VR camera
  115249. */
  115250. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115251. }
  115252. }
  115253. declare module BABYLON {
  115254. /**
  115255. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115256. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115257. */
  115258. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115259. /**
  115260. * Creates a new VRDeviceOrientationArcRotateCamera
  115261. * @param name defines camera name
  115262. * @param alpha defines the camera rotation along the logitudinal axis
  115263. * @param beta defines the camera rotation along the latitudinal axis
  115264. * @param radius defines the camera distance from its target
  115265. * @param target defines the camera target
  115266. * @param scene defines the scene the camera belongs to
  115267. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115268. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115269. */
  115270. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115271. /**
  115272. * Gets camera class name
  115273. * @returns VRDeviceOrientationArcRotateCamera
  115274. */
  115275. getClassName(): string;
  115276. }
  115277. }
  115278. declare module BABYLON {
  115279. /**
  115280. * Camera used to simulate VR rendering (based on FreeCamera)
  115281. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115282. */
  115283. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115284. /**
  115285. * Creates a new VRDeviceOrientationFreeCamera
  115286. * @param name defines camera name
  115287. * @param position defines the start position of the camera
  115288. * @param scene defines the scene the camera belongs to
  115289. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115290. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115291. */
  115292. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115293. /**
  115294. * Gets camera class name
  115295. * @returns VRDeviceOrientationFreeCamera
  115296. */
  115297. getClassName(): string;
  115298. }
  115299. }
  115300. declare module BABYLON {
  115301. /**
  115302. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115303. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115304. */
  115305. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115306. /**
  115307. * Creates a new VRDeviceOrientationGamepadCamera
  115308. * @param name defines camera name
  115309. * @param position defines the start position of the camera
  115310. * @param scene defines the scene the camera belongs to
  115311. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115312. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115313. */
  115314. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115315. /**
  115316. * Gets camera class name
  115317. * @returns VRDeviceOrientationGamepadCamera
  115318. */
  115319. getClassName(): string;
  115320. }
  115321. }
  115322. declare module BABYLON {
  115323. /** @hidden */
  115324. export var imageProcessingPixelShader: {
  115325. name: string;
  115326. shader: string;
  115327. };
  115328. }
  115329. declare module BABYLON {
  115330. /**
  115331. * ImageProcessingPostProcess
  115332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115333. */
  115334. export class ImageProcessingPostProcess extends PostProcess {
  115335. /**
  115336. * Default configuration related to image processing available in the PBR Material.
  115337. */
  115338. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115339. /**
  115340. * Gets the image processing configuration used either in this material.
  115341. */
  115342. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115343. /**
  115344. * Sets the Default image processing configuration used either in the this material.
  115345. *
  115346. * If sets to null, the scene one is in use.
  115347. */
  115348. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115349. /**
  115350. * Keep track of the image processing observer to allow dispose and replace.
  115351. */
  115352. private _imageProcessingObserver;
  115353. /**
  115354. * Attaches a new image processing configuration to the PBR Material.
  115355. * @param configuration
  115356. */
  115357. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115358. /**
  115359. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115360. */
  115361. get colorCurves(): Nullable<ColorCurves>;
  115362. /**
  115363. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115364. */
  115365. set colorCurves(value: Nullable<ColorCurves>);
  115366. /**
  115367. * Gets wether the color curves effect is enabled.
  115368. */
  115369. get colorCurvesEnabled(): boolean;
  115370. /**
  115371. * Sets wether the color curves effect is enabled.
  115372. */
  115373. set colorCurvesEnabled(value: boolean);
  115374. /**
  115375. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115376. */
  115377. get colorGradingTexture(): Nullable<BaseTexture>;
  115378. /**
  115379. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115380. */
  115381. set colorGradingTexture(value: Nullable<BaseTexture>);
  115382. /**
  115383. * Gets wether the color grading effect is enabled.
  115384. */
  115385. get colorGradingEnabled(): boolean;
  115386. /**
  115387. * Gets wether the color grading effect is enabled.
  115388. */
  115389. set colorGradingEnabled(value: boolean);
  115390. /**
  115391. * Gets exposure used in the effect.
  115392. */
  115393. get exposure(): number;
  115394. /**
  115395. * Sets exposure used in the effect.
  115396. */
  115397. set exposure(value: number);
  115398. /**
  115399. * Gets wether tonemapping is enabled or not.
  115400. */
  115401. get toneMappingEnabled(): boolean;
  115402. /**
  115403. * Sets wether tonemapping is enabled or not
  115404. */
  115405. set toneMappingEnabled(value: boolean);
  115406. /**
  115407. * Gets the type of tone mapping effect.
  115408. */
  115409. get toneMappingType(): number;
  115410. /**
  115411. * Sets the type of tone mapping effect.
  115412. */
  115413. set toneMappingType(value: number);
  115414. /**
  115415. * Gets contrast used in the effect.
  115416. */
  115417. get contrast(): number;
  115418. /**
  115419. * Sets contrast used in the effect.
  115420. */
  115421. set contrast(value: number);
  115422. /**
  115423. * Gets Vignette stretch size.
  115424. */
  115425. get vignetteStretch(): number;
  115426. /**
  115427. * Sets Vignette stretch size.
  115428. */
  115429. set vignetteStretch(value: number);
  115430. /**
  115431. * Gets Vignette centre X Offset.
  115432. */
  115433. get vignetteCentreX(): number;
  115434. /**
  115435. * Sets Vignette centre X Offset.
  115436. */
  115437. set vignetteCentreX(value: number);
  115438. /**
  115439. * Gets Vignette centre Y Offset.
  115440. */
  115441. get vignetteCentreY(): number;
  115442. /**
  115443. * Sets Vignette centre Y Offset.
  115444. */
  115445. set vignetteCentreY(value: number);
  115446. /**
  115447. * Gets Vignette weight or intensity of the vignette effect.
  115448. */
  115449. get vignetteWeight(): number;
  115450. /**
  115451. * Sets Vignette weight or intensity of the vignette effect.
  115452. */
  115453. set vignetteWeight(value: number);
  115454. /**
  115455. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115456. * if vignetteEnabled is set to true.
  115457. */
  115458. get vignetteColor(): Color4;
  115459. /**
  115460. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115461. * if vignetteEnabled is set to true.
  115462. */
  115463. set vignetteColor(value: Color4);
  115464. /**
  115465. * Gets Camera field of view used by the Vignette effect.
  115466. */
  115467. get vignetteCameraFov(): number;
  115468. /**
  115469. * Sets Camera field of view used by the Vignette effect.
  115470. */
  115471. set vignetteCameraFov(value: number);
  115472. /**
  115473. * Gets the vignette blend mode allowing different kind of effect.
  115474. */
  115475. get vignetteBlendMode(): number;
  115476. /**
  115477. * Sets the vignette blend mode allowing different kind of effect.
  115478. */
  115479. set vignetteBlendMode(value: number);
  115480. /**
  115481. * Gets wether the vignette effect is enabled.
  115482. */
  115483. get vignetteEnabled(): boolean;
  115484. /**
  115485. * Sets wether the vignette effect is enabled.
  115486. */
  115487. set vignetteEnabled(value: boolean);
  115488. private _fromLinearSpace;
  115489. /**
  115490. * Gets wether the input of the processing is in Gamma or Linear Space.
  115491. */
  115492. get fromLinearSpace(): boolean;
  115493. /**
  115494. * Sets wether the input of the processing is in Gamma or Linear Space.
  115495. */
  115496. set fromLinearSpace(value: boolean);
  115497. /**
  115498. * Defines cache preventing GC.
  115499. */
  115500. private _defines;
  115501. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115502. /**
  115503. * "ImageProcessingPostProcess"
  115504. * @returns "ImageProcessingPostProcess"
  115505. */
  115506. getClassName(): string;
  115507. protected _updateParameters(): void;
  115508. dispose(camera?: Camera): void;
  115509. }
  115510. }
  115511. declare module BABYLON {
  115512. /**
  115513. * Class containing static functions to help procedurally build meshes
  115514. */
  115515. export class GroundBuilder {
  115516. /**
  115517. * Creates a ground mesh
  115518. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115519. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115521. * @param name defines the name of the mesh
  115522. * @param options defines the options used to create the mesh
  115523. * @param scene defines the hosting scene
  115524. * @returns the ground mesh
  115525. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115526. */
  115527. static CreateGround(name: string, options: {
  115528. width?: number;
  115529. height?: number;
  115530. subdivisions?: number;
  115531. subdivisionsX?: number;
  115532. subdivisionsY?: number;
  115533. updatable?: boolean;
  115534. }, scene: any): Mesh;
  115535. /**
  115536. * Creates a tiled ground mesh
  115537. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115538. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115539. * * 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
  115540. * * 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
  115541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115542. * @param name defines the name of the mesh
  115543. * @param options defines the options used to create the mesh
  115544. * @param scene defines the hosting scene
  115545. * @returns the tiled ground mesh
  115546. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115547. */
  115548. static CreateTiledGround(name: string, options: {
  115549. xmin: number;
  115550. zmin: number;
  115551. xmax: number;
  115552. zmax: number;
  115553. subdivisions?: {
  115554. w: number;
  115555. h: number;
  115556. };
  115557. precision?: {
  115558. w: number;
  115559. h: number;
  115560. };
  115561. updatable?: boolean;
  115562. }, scene?: Nullable<Scene>): Mesh;
  115563. /**
  115564. * Creates a ground mesh from a height map
  115565. * * The parameter `url` sets the URL of the height map image resource.
  115566. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115567. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115568. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115569. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115570. * * 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.
  115571. * * 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).
  115572. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115574. * @param name defines the name of the mesh
  115575. * @param url defines the url to the height map
  115576. * @param options defines the options used to create the mesh
  115577. * @param scene defines the hosting scene
  115578. * @returns the ground mesh
  115579. * @see https://doc.babylonjs.com/babylon101/height_map
  115580. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115581. */
  115582. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115583. width?: number;
  115584. height?: number;
  115585. subdivisions?: number;
  115586. minHeight?: number;
  115587. maxHeight?: number;
  115588. colorFilter?: Color3;
  115589. alphaFilter?: number;
  115590. updatable?: boolean;
  115591. onReady?: (mesh: GroundMesh) => void;
  115592. }, scene?: Nullable<Scene>): GroundMesh;
  115593. }
  115594. }
  115595. declare module BABYLON {
  115596. /**
  115597. * Class containing static functions to help procedurally build meshes
  115598. */
  115599. export class TorusBuilder {
  115600. /**
  115601. * Creates a torus mesh
  115602. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115603. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115604. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115608. * @param name defines the name of the mesh
  115609. * @param options defines the options used to create the mesh
  115610. * @param scene defines the hosting scene
  115611. * @returns the torus mesh
  115612. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115613. */
  115614. static CreateTorus(name: string, options: {
  115615. diameter?: number;
  115616. thickness?: number;
  115617. tessellation?: number;
  115618. updatable?: boolean;
  115619. sideOrientation?: number;
  115620. frontUVs?: Vector4;
  115621. backUVs?: Vector4;
  115622. }, scene: any): Mesh;
  115623. }
  115624. }
  115625. declare module BABYLON {
  115626. /**
  115627. * Class containing static functions to help procedurally build meshes
  115628. */
  115629. export class CylinderBuilder {
  115630. /**
  115631. * Creates a cylinder or a cone mesh
  115632. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115633. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115634. * * 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.
  115635. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115636. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115637. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115638. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115639. * * 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).
  115640. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115641. * * 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).
  115642. * * 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
  115643. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115644. * * 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
  115645. * * 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.
  115646. * * If `enclose` is false, a ring surface is one element.
  115647. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115648. * * 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
  115649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115652. * @param name defines the name of the mesh
  115653. * @param options defines the options used to create the mesh
  115654. * @param scene defines the hosting scene
  115655. * @returns the cylinder mesh
  115656. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115657. */
  115658. static CreateCylinder(name: string, options: {
  115659. height?: number;
  115660. diameterTop?: number;
  115661. diameterBottom?: number;
  115662. diameter?: number;
  115663. tessellation?: number;
  115664. subdivisions?: number;
  115665. arc?: number;
  115666. faceColors?: Color4[];
  115667. faceUV?: Vector4[];
  115668. updatable?: boolean;
  115669. hasRings?: boolean;
  115670. enclose?: boolean;
  115671. cap?: number;
  115672. sideOrientation?: number;
  115673. frontUVs?: Vector4;
  115674. backUVs?: Vector4;
  115675. }, scene: any): Mesh;
  115676. }
  115677. }
  115678. declare module BABYLON {
  115679. /**
  115680. * States of the webXR experience
  115681. */
  115682. export enum WebXRState {
  115683. /**
  115684. * Transitioning to being in XR mode
  115685. */
  115686. ENTERING_XR = 0,
  115687. /**
  115688. * Transitioning to non XR mode
  115689. */
  115690. EXITING_XR = 1,
  115691. /**
  115692. * In XR mode and presenting
  115693. */
  115694. IN_XR = 2,
  115695. /**
  115696. * Not entered XR mode
  115697. */
  115698. NOT_IN_XR = 3
  115699. }
  115700. /**
  115701. * Abstraction of the XR render target
  115702. */
  115703. export interface WebXRRenderTarget extends IDisposable {
  115704. /**
  115705. * xrpresent context of the canvas which can be used to display/mirror xr content
  115706. */
  115707. canvasContext: WebGLRenderingContext;
  115708. /**
  115709. * xr layer for the canvas
  115710. */
  115711. xrLayer: Nullable<XRWebGLLayer>;
  115712. /**
  115713. * Initializes the xr layer for the session
  115714. * @param xrSession xr session
  115715. * @returns a promise that will resolve once the XR Layer has been created
  115716. */
  115717. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115718. }
  115719. }
  115720. declare module BABYLON {
  115721. /**
  115722. * COnfiguration object for WebXR output canvas
  115723. */
  115724. export class WebXRManagedOutputCanvasOptions {
  115725. /**
  115726. * An optional canvas in case you wish to create it yourself and provide it here.
  115727. * If not provided, a new canvas will be created
  115728. */
  115729. canvasElement?: HTMLCanvasElement;
  115730. /**
  115731. * Options for this XR Layer output
  115732. */
  115733. canvasOptions?: XRWebGLLayerOptions;
  115734. /**
  115735. * CSS styling for a newly created canvas (if not provided)
  115736. */
  115737. newCanvasCssStyle?: string;
  115738. /**
  115739. * Get the default values of the configuration object
  115740. * @returns default values of this configuration object
  115741. */
  115742. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115743. }
  115744. /**
  115745. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115746. */
  115747. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115748. private _options;
  115749. private _canvas;
  115750. private _engine;
  115751. /**
  115752. * Rendering context of the canvas which can be used to display/mirror xr content
  115753. */
  115754. canvasContext: WebGLRenderingContext;
  115755. /**
  115756. * xr layer for the canvas
  115757. */
  115758. xrLayer: Nullable<XRWebGLLayer>;
  115759. /**
  115760. * Initializes the canvas to be added/removed upon entering/exiting xr
  115761. * @param _xrSessionManager The XR Session manager
  115762. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115763. */
  115764. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115765. /**
  115766. * Disposes of the object
  115767. */
  115768. dispose(): void;
  115769. /**
  115770. * Initializes the xr layer for the session
  115771. * @param xrSession xr session
  115772. * @returns a promise that will resolve once the XR Layer has been created
  115773. */
  115774. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115775. private _addCanvas;
  115776. private _removeCanvas;
  115777. private _setManagedOutputCanvas;
  115778. }
  115779. }
  115780. declare module BABYLON {
  115781. /**
  115782. * Manages an XRSession to work with Babylon's engine
  115783. * @see https://doc.babylonjs.com/how_to/webxr
  115784. */
  115785. export class WebXRSessionManager implements IDisposable {
  115786. /** The scene which the session should be created for */
  115787. scene: Scene;
  115788. private _referenceSpace;
  115789. private _rttProvider;
  115790. private _sessionEnded;
  115791. private _xrNavigator;
  115792. private baseLayer;
  115793. /**
  115794. * The base reference space from which the session started. good if you want to reset your
  115795. * reference space
  115796. */
  115797. baseReferenceSpace: XRReferenceSpace;
  115798. /**
  115799. * Current XR frame
  115800. */
  115801. currentFrame: Nullable<XRFrame>;
  115802. /** WebXR timestamp updated every frame */
  115803. currentTimestamp: number;
  115804. /**
  115805. * Used just in case of a failure to initialize an immersive session.
  115806. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115807. */
  115808. defaultHeightCompensation: number;
  115809. /**
  115810. * Fires every time a new xrFrame arrives which can be used to update the camera
  115811. */
  115812. onXRFrameObservable: Observable<XRFrame>;
  115813. /**
  115814. * Fires when the reference space changed
  115815. */
  115816. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115817. /**
  115818. * Fires when the xr session is ended either by the device or manually done
  115819. */
  115820. onXRSessionEnded: Observable<any>;
  115821. /**
  115822. * Fires when the xr session is ended either by the device or manually done
  115823. */
  115824. onXRSessionInit: Observable<XRSession>;
  115825. /**
  115826. * Underlying xr session
  115827. */
  115828. session: XRSession;
  115829. /**
  115830. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115831. * or get the offset the player is currently at.
  115832. */
  115833. viewerReferenceSpace: XRReferenceSpace;
  115834. /**
  115835. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115836. * @param scene The scene which the session should be created for
  115837. */
  115838. constructor(
  115839. /** The scene which the session should be created for */
  115840. scene: Scene);
  115841. /**
  115842. * The current reference space used in this session. This reference space can constantly change!
  115843. * It is mainly used to offset the camera's position.
  115844. */
  115845. get referenceSpace(): XRReferenceSpace;
  115846. /**
  115847. * Set a new reference space and triggers the observable
  115848. */
  115849. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115850. /**
  115851. * Disposes of the session manager
  115852. */
  115853. dispose(): void;
  115854. /**
  115855. * Stops the xrSession and restores the render loop
  115856. * @returns Promise which resolves after it exits XR
  115857. */
  115858. exitXRAsync(): Promise<void>;
  115859. /**
  115860. * Gets the correct render target texture to be rendered this frame for this eye
  115861. * @param eye the eye for which to get the render target
  115862. * @returns the render target for the specified eye
  115863. */
  115864. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115865. /**
  115866. * Creates a WebXRRenderTarget object for the XR session
  115867. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115868. * @param options optional options to provide when creating a new render target
  115869. * @returns a WebXR render target to which the session can render
  115870. */
  115871. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115872. /**
  115873. * Initializes the manager
  115874. * After initialization enterXR can be called to start an XR session
  115875. * @returns Promise which resolves after it is initialized
  115876. */
  115877. initializeAsync(): Promise<void>;
  115878. /**
  115879. * Initializes an xr session
  115880. * @param xrSessionMode mode to initialize
  115881. * @param xrSessionInit defines optional and required values to pass to the session builder
  115882. * @returns a promise which will resolve once the session has been initialized
  115883. */
  115884. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115885. /**
  115886. * Checks if a session would be supported for the creation options specified
  115887. * @param sessionMode session mode to check if supported eg. immersive-vr
  115888. * @returns A Promise that resolves to true if supported and false if not
  115889. */
  115890. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115891. /**
  115892. * Resets the reference space to the one started the session
  115893. */
  115894. resetReferenceSpace(): void;
  115895. /**
  115896. * Starts rendering to the xr layer
  115897. */
  115898. runXRRenderLoop(): void;
  115899. /**
  115900. * Sets the reference space on the xr session
  115901. * @param referenceSpaceType space to set
  115902. * @returns a promise that will resolve once the reference space has been set
  115903. */
  115904. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115905. /**
  115906. * Updates the render state of the session
  115907. * @param state state to set
  115908. * @returns a promise that resolves once the render state has been updated
  115909. */
  115910. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115911. /**
  115912. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115913. * @param sessionMode defines the session to test
  115914. * @returns a promise with boolean as final value
  115915. */
  115916. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115917. private _createRenderTargetTexture;
  115918. }
  115919. }
  115920. declare module BABYLON {
  115921. /**
  115922. * WebXR Camera which holds the views for the xrSession
  115923. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115924. */
  115925. export class WebXRCamera extends FreeCamera {
  115926. private _xrSessionManager;
  115927. private _firstFrame;
  115928. private _referenceQuaternion;
  115929. private _referencedPosition;
  115930. private _xrInvPositionCache;
  115931. private _xrInvQuaternionCache;
  115932. /**
  115933. * Should position compensation execute on first frame.
  115934. * This is used when copying the position from a native (non XR) camera
  115935. */
  115936. compensateOnFirstFrame: boolean;
  115937. /**
  115938. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115939. * @param name the name of the camera
  115940. * @param scene the scene to add the camera to
  115941. * @param _xrSessionManager a constructed xr session manager
  115942. */
  115943. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115944. /**
  115945. * Return the user's height, unrelated to the current ground.
  115946. * This will be the y position of this camera, when ground level is 0.
  115947. */
  115948. get realWorldHeight(): number;
  115949. /** @hidden */
  115950. _updateForDualEyeDebugging(): void;
  115951. /**
  115952. * Sets this camera's transformation based on a non-vr camera
  115953. * @param otherCamera the non-vr camera to copy the transformation from
  115954. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115955. */
  115956. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115957. private _updateFromXRSession;
  115958. private _updateNumberOfRigCameras;
  115959. private _updateReferenceSpace;
  115960. private _updateReferenceSpaceOffset;
  115961. }
  115962. }
  115963. declare module BABYLON {
  115964. /**
  115965. * Defining the interface required for a (webxr) feature
  115966. */
  115967. export interface IWebXRFeature extends IDisposable {
  115968. /**
  115969. * Is this feature attached
  115970. */
  115971. attached: boolean;
  115972. /**
  115973. * Should auto-attach be disabled?
  115974. */
  115975. disableAutoAttach: boolean;
  115976. /**
  115977. * Attach the feature to the session
  115978. * Will usually be called by the features manager
  115979. *
  115980. * @param force should attachment be forced (even when already attached)
  115981. * @returns true if successful.
  115982. */
  115983. attach(force?: boolean): boolean;
  115984. /**
  115985. * Detach the feature from the session
  115986. * Will usually be called by the features manager
  115987. *
  115988. * @returns true if successful.
  115989. */
  115990. detach(): boolean;
  115991. }
  115992. /**
  115993. * A list of the currently available features without referencing them
  115994. */
  115995. export class WebXRFeatureName {
  115996. /**
  115997. * The name of the anchor system feature
  115998. */
  115999. static ANCHOR_SYSTEM: string;
  116000. /**
  116001. * The name of the background remover feature
  116002. */
  116003. static BACKGROUND_REMOVER: string;
  116004. /**
  116005. * The name of the hit test feature
  116006. */
  116007. static HIT_TEST: string;
  116008. /**
  116009. * physics impostors for xr controllers feature
  116010. */
  116011. static PHYSICS_CONTROLLERS: string;
  116012. /**
  116013. * The name of the plane detection feature
  116014. */
  116015. static PLANE_DETECTION: string;
  116016. /**
  116017. * The name of the pointer selection feature
  116018. */
  116019. static POINTER_SELECTION: string;
  116020. /**
  116021. * The name of the teleportation feature
  116022. */
  116023. static TELEPORTATION: string;
  116024. }
  116025. /**
  116026. * Defining the constructor of a feature. Used to register the modules.
  116027. */
  116028. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116029. /**
  116030. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116031. * It is mainly used in AR sessions.
  116032. *
  116033. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116034. */
  116035. export class WebXRFeaturesManager implements IDisposable {
  116036. private _xrSessionManager;
  116037. private static readonly _AvailableFeatures;
  116038. private _features;
  116039. /**
  116040. * constructs a new features manages.
  116041. *
  116042. * @param _xrSessionManager an instance of WebXRSessionManager
  116043. */
  116044. constructor(_xrSessionManager: WebXRSessionManager);
  116045. /**
  116046. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116047. * Mainly used internally.
  116048. *
  116049. * @param featureName the name of the feature to register
  116050. * @param constructorFunction the function used to construct the module
  116051. * @param version the (babylon) version of the module
  116052. * @param stable is that a stable version of this module
  116053. */
  116054. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116055. /**
  116056. * Returns a constructor of a specific feature.
  116057. *
  116058. * @param featureName the name of the feature to construct
  116059. * @param version the version of the feature to load
  116060. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116061. * @param options optional options provided to the module.
  116062. * @returns a function that, when called, will return a new instance of this feature
  116063. */
  116064. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116065. /**
  116066. * Can be used to return the list of features currently registered
  116067. *
  116068. * @returns an Array of available features
  116069. */
  116070. static GetAvailableFeatures(): string[];
  116071. /**
  116072. * Gets the versions available for a specific feature
  116073. * @param featureName the name of the feature
  116074. * @returns an array with the available versions
  116075. */
  116076. static GetAvailableVersions(featureName: string): string[];
  116077. /**
  116078. * Return the latest unstable version of this feature
  116079. * @param featureName the name of the feature to search
  116080. * @returns the version number. if not found will return -1
  116081. */
  116082. static GetLatestVersionOfFeature(featureName: string): number;
  116083. /**
  116084. * Return the latest stable version of this feature
  116085. * @param featureName the name of the feature to search
  116086. * @returns the version number. if not found will return -1
  116087. */
  116088. static GetStableVersionOfFeature(featureName: string): number;
  116089. /**
  116090. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116091. * Can be used during a session to start a feature
  116092. * @param featureName the name of feature to attach
  116093. */
  116094. attachFeature(featureName: string): void;
  116095. /**
  116096. * Can be used inside a session or when the session ends to detach a specific feature
  116097. * @param featureName the name of the feature to detach
  116098. */
  116099. detachFeature(featureName: string): void;
  116100. /**
  116101. * Used to disable an already-enabled feature
  116102. * The feature will be disposed and will be recreated once enabled.
  116103. * @param featureName the feature to disable
  116104. * @returns true if disable was successful
  116105. */
  116106. disableFeature(featureName: string | {
  116107. Name: string;
  116108. }): boolean;
  116109. /**
  116110. * dispose this features manager
  116111. */
  116112. dispose(): void;
  116113. /**
  116114. * 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.
  116115. * 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.
  116116. *
  116117. * @param featureName the name of the feature to load or the class of the feature
  116118. * @param version optional version to load. if not provided the latest version will be enabled
  116119. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116120. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116121. * @returns a new constructed feature or throws an error if feature not found.
  116122. */
  116123. enableFeature(featureName: string | {
  116124. Name: string;
  116125. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116126. /**
  116127. * get the implementation of an enabled feature.
  116128. * @param featureName the name of the feature to load
  116129. * @returns the feature class, if found
  116130. */
  116131. getEnabledFeature(featureName: string): IWebXRFeature;
  116132. /**
  116133. * Get the list of enabled features
  116134. * @returns an array of enabled features
  116135. */
  116136. getEnabledFeatures(): string[];
  116137. }
  116138. }
  116139. declare module BABYLON {
  116140. /**
  116141. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116142. * @see https://doc.babylonjs.com/how_to/webxr
  116143. */
  116144. export class WebXRExperienceHelper implements IDisposable {
  116145. private scene;
  116146. private _nonVRCamera;
  116147. private _originalSceneAutoClear;
  116148. private _supported;
  116149. /**
  116150. * Camera used to render xr content
  116151. */
  116152. camera: WebXRCamera;
  116153. /** A features manager for this xr session */
  116154. featuresManager: WebXRFeaturesManager;
  116155. /**
  116156. * Observers registered here will be triggered after the camera's initial transformation is set
  116157. * This can be used to set a different ground level or an extra rotation.
  116158. *
  116159. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116160. * to the position set after this observable is done executing.
  116161. */
  116162. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116163. /**
  116164. * Fires when the state of the experience helper has changed
  116165. */
  116166. onStateChangedObservable: Observable<WebXRState>;
  116167. /** Session manager used to keep track of xr session */
  116168. sessionManager: WebXRSessionManager;
  116169. /**
  116170. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116171. */
  116172. state: WebXRState;
  116173. /**
  116174. * Creates a WebXRExperienceHelper
  116175. * @param scene The scene the helper should be created in
  116176. */
  116177. private constructor();
  116178. /**
  116179. * Creates the experience helper
  116180. * @param scene the scene to attach the experience helper to
  116181. * @returns a promise for the experience helper
  116182. */
  116183. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116184. /**
  116185. * Disposes of the experience helper
  116186. */
  116187. dispose(): void;
  116188. /**
  116189. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116190. * @param sessionMode options for the XR session
  116191. * @param referenceSpaceType frame of reference of the XR session
  116192. * @param renderTarget the output canvas that will be used to enter XR mode
  116193. * @returns promise that resolves after xr mode has entered
  116194. */
  116195. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116196. /**
  116197. * Exits XR mode and returns the scene to its original state
  116198. * @returns promise that resolves after xr mode has exited
  116199. */
  116200. exitXRAsync(): Promise<void>;
  116201. private _nonXRToXRCamera;
  116202. private _setState;
  116203. }
  116204. }
  116205. declare module BABYLON {
  116206. /**
  116207. * X-Y values for axes in WebXR
  116208. */
  116209. export interface IWebXRMotionControllerAxesValue {
  116210. /**
  116211. * The value of the x axis
  116212. */
  116213. x: number;
  116214. /**
  116215. * The value of the y-axis
  116216. */
  116217. y: number;
  116218. }
  116219. /**
  116220. * changed / previous values for the values of this component
  116221. */
  116222. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116223. /**
  116224. * current (this frame) value
  116225. */
  116226. current: T;
  116227. /**
  116228. * previous (last change) value
  116229. */
  116230. previous: T;
  116231. }
  116232. /**
  116233. * Represents changes in the component between current frame and last values recorded
  116234. */
  116235. export interface IWebXRMotionControllerComponentChanges {
  116236. /**
  116237. * will be populated with previous and current values if axes changed
  116238. */
  116239. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116240. /**
  116241. * will be populated with previous and current values if pressed changed
  116242. */
  116243. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116244. /**
  116245. * will be populated with previous and current values if touched changed
  116246. */
  116247. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116248. /**
  116249. * will be populated with previous and current values if value changed
  116250. */
  116251. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116252. }
  116253. /**
  116254. * This class represents a single component (for example button or thumbstick) of a motion controller
  116255. */
  116256. export class WebXRControllerComponent implements IDisposable {
  116257. /**
  116258. * the id of this component
  116259. */
  116260. id: string;
  116261. /**
  116262. * the type of the component
  116263. */
  116264. type: MotionControllerComponentType;
  116265. private _buttonIndex;
  116266. private _axesIndices;
  116267. private _axes;
  116268. private _changes;
  116269. private _currentValue;
  116270. private _hasChanges;
  116271. private _pressed;
  116272. private _touched;
  116273. /**
  116274. * button component type
  116275. */
  116276. static BUTTON_TYPE: MotionControllerComponentType;
  116277. /**
  116278. * squeeze component type
  116279. */
  116280. static SQUEEZE_TYPE: MotionControllerComponentType;
  116281. /**
  116282. * Thumbstick component type
  116283. */
  116284. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116285. /**
  116286. * Touchpad component type
  116287. */
  116288. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116289. /**
  116290. * trigger component type
  116291. */
  116292. static TRIGGER_TYPE: MotionControllerComponentType;
  116293. /**
  116294. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116295. * the axes data changes
  116296. */
  116297. onAxisValueChangedObservable: Observable<{
  116298. x: number;
  116299. y: number;
  116300. }>;
  116301. /**
  116302. * Observers registered here will be triggered when the state of a button changes
  116303. * State change is either pressed / touched / value
  116304. */
  116305. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116306. /**
  116307. * Creates a new component for a motion controller.
  116308. * It is created by the motion controller itself
  116309. *
  116310. * @param id the id of this component
  116311. * @param type the type of the component
  116312. * @param _buttonIndex index in the buttons array of the gamepad
  116313. * @param _axesIndices indices of the values in the axes array of the gamepad
  116314. */
  116315. constructor(
  116316. /**
  116317. * the id of this component
  116318. */
  116319. id: string,
  116320. /**
  116321. * the type of the component
  116322. */
  116323. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116324. /**
  116325. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116326. */
  116327. get axes(): IWebXRMotionControllerAxesValue;
  116328. /**
  116329. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116330. */
  116331. get changes(): IWebXRMotionControllerComponentChanges;
  116332. /**
  116333. * Return whether or not the component changed the last frame
  116334. */
  116335. get hasChanges(): boolean;
  116336. /**
  116337. * is the button currently pressed
  116338. */
  116339. get pressed(): boolean;
  116340. /**
  116341. * is the button currently touched
  116342. */
  116343. get touched(): boolean;
  116344. /**
  116345. * Get the current value of this component
  116346. */
  116347. get value(): number;
  116348. /**
  116349. * Dispose this component
  116350. */
  116351. dispose(): void;
  116352. /**
  116353. * Are there axes correlating to this component
  116354. * @return true is axes data is available
  116355. */
  116356. isAxes(): boolean;
  116357. /**
  116358. * Is this component a button (hence - pressable)
  116359. * @returns true if can be pressed
  116360. */
  116361. isButton(): boolean;
  116362. /**
  116363. * update this component using the gamepad object it is in. Called on every frame
  116364. * @param nativeController the native gamepad controller object
  116365. */
  116366. update(nativeController: IMinimalMotionControllerObject): void;
  116367. }
  116368. }
  116369. declare module BABYLON {
  116370. /**
  116371. * Class used to represent data loading progression
  116372. */
  116373. export class SceneLoaderProgressEvent {
  116374. /** defines if data length to load can be evaluated */
  116375. readonly lengthComputable: boolean;
  116376. /** defines the loaded data length */
  116377. readonly loaded: number;
  116378. /** defines the data length to load */
  116379. readonly total: number;
  116380. /**
  116381. * Create a new progress event
  116382. * @param lengthComputable defines if data length to load can be evaluated
  116383. * @param loaded defines the loaded data length
  116384. * @param total defines the data length to load
  116385. */
  116386. constructor(
  116387. /** defines if data length to load can be evaluated */
  116388. lengthComputable: boolean,
  116389. /** defines the loaded data length */
  116390. loaded: number,
  116391. /** defines the data length to load */
  116392. total: number);
  116393. /**
  116394. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116395. * @param event defines the source event
  116396. * @returns a new SceneLoaderProgressEvent
  116397. */
  116398. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116399. }
  116400. /**
  116401. * Interface used by SceneLoader plugins to define supported file extensions
  116402. */
  116403. export interface ISceneLoaderPluginExtensions {
  116404. /**
  116405. * Defines the list of supported extensions
  116406. */
  116407. [extension: string]: {
  116408. isBinary: boolean;
  116409. };
  116410. }
  116411. /**
  116412. * Interface used by SceneLoader plugin factory
  116413. */
  116414. export interface ISceneLoaderPluginFactory {
  116415. /**
  116416. * Defines the name of the factory
  116417. */
  116418. name: string;
  116419. /**
  116420. * Function called to create a new plugin
  116421. * @return the new plugin
  116422. */
  116423. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116424. /**
  116425. * The callback that returns true if the data can be directly loaded.
  116426. * @param data string containing the file data
  116427. * @returns if the data can be loaded directly
  116428. */
  116429. canDirectLoad?(data: string): boolean;
  116430. }
  116431. /**
  116432. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116433. */
  116434. export interface ISceneLoaderPluginBase {
  116435. /**
  116436. * The friendly name of this plugin.
  116437. */
  116438. name: string;
  116439. /**
  116440. * The file extensions supported by this plugin.
  116441. */
  116442. extensions: string | ISceneLoaderPluginExtensions;
  116443. /**
  116444. * The callback called when loading from a url.
  116445. * @param scene scene loading this url
  116446. * @param url url to load
  116447. * @param onSuccess callback called when the file successfully loads
  116448. * @param onProgress callback called while file is loading (if the server supports this mode)
  116449. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116450. * @param onError callback called when the file fails to load
  116451. * @returns a file request object
  116452. */
  116453. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116454. /**
  116455. * The callback called when loading from a file object.
  116456. * @param scene scene loading this file
  116457. * @param file defines the file to load
  116458. * @param onSuccess defines the callback to call when data is loaded
  116459. * @param onProgress defines the callback to call during loading process
  116460. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116461. * @param onError defines the callback to call when an error occurs
  116462. * @returns a file request object
  116463. */
  116464. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116465. /**
  116466. * The callback that returns true if the data can be directly loaded.
  116467. * @param data string containing the file data
  116468. * @returns if the data can be loaded directly
  116469. */
  116470. canDirectLoad?(data: string): boolean;
  116471. /**
  116472. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116473. * @param scene scene loading this data
  116474. * @param data string containing the data
  116475. * @returns data to pass to the plugin
  116476. */
  116477. directLoad?(scene: Scene, data: string): any;
  116478. /**
  116479. * The callback that allows custom handling of the root url based on the response url.
  116480. * @param rootUrl the original root url
  116481. * @param responseURL the response url if available
  116482. * @returns the new root url
  116483. */
  116484. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116485. }
  116486. /**
  116487. * Interface used to define a SceneLoader plugin
  116488. */
  116489. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116490. /**
  116491. * Import meshes into a scene.
  116492. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116493. * @param scene The scene to import into
  116494. * @param data The data to import
  116495. * @param rootUrl The root url for scene and resources
  116496. * @param meshes The meshes array to import into
  116497. * @param particleSystems The particle systems array to import into
  116498. * @param skeletons The skeletons array to import into
  116499. * @param onError The callback when import fails
  116500. * @returns True if successful or false otherwise
  116501. */
  116502. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116503. /**
  116504. * Load into a scene.
  116505. * @param scene The scene to load into
  116506. * @param data The data to import
  116507. * @param rootUrl The root url for scene and resources
  116508. * @param onError The callback when import fails
  116509. * @returns True if successful or false otherwise
  116510. */
  116511. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116512. /**
  116513. * Load into an asset container.
  116514. * @param scene The scene to load into
  116515. * @param data The data to import
  116516. * @param rootUrl The root url for scene and resources
  116517. * @param onError The callback when import fails
  116518. * @returns The loaded asset container
  116519. */
  116520. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116521. }
  116522. /**
  116523. * Interface used to define an async SceneLoader plugin
  116524. */
  116525. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116526. /**
  116527. * Import meshes into a scene.
  116528. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116529. * @param scene The scene to import into
  116530. * @param data The data to import
  116531. * @param rootUrl The root url for scene and resources
  116532. * @param onProgress The callback when the load progresses
  116533. * @param fileName Defines the name of the file to load
  116534. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116535. */
  116536. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116537. meshes: AbstractMesh[];
  116538. particleSystems: IParticleSystem[];
  116539. skeletons: Skeleton[];
  116540. animationGroups: AnimationGroup[];
  116541. }>;
  116542. /**
  116543. * Load into a scene.
  116544. * @param scene The scene to load into
  116545. * @param data The data to import
  116546. * @param rootUrl The root url for scene and resources
  116547. * @param onProgress The callback when the load progresses
  116548. * @param fileName Defines the name of the file to load
  116549. * @returns Nothing
  116550. */
  116551. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116552. /**
  116553. * Load into an asset container.
  116554. * @param scene The scene to load into
  116555. * @param data The data to import
  116556. * @param rootUrl The root url for scene and resources
  116557. * @param onProgress The callback when the load progresses
  116558. * @param fileName Defines the name of the file to load
  116559. * @returns The loaded asset container
  116560. */
  116561. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116562. }
  116563. /**
  116564. * Mode that determines how to handle old animation groups before loading new ones.
  116565. */
  116566. export enum SceneLoaderAnimationGroupLoadingMode {
  116567. /**
  116568. * Reset all old animations to initial state then dispose them.
  116569. */
  116570. Clean = 0,
  116571. /**
  116572. * Stop all old animations.
  116573. */
  116574. Stop = 1,
  116575. /**
  116576. * Restart old animations from first frame.
  116577. */
  116578. Sync = 2,
  116579. /**
  116580. * Old animations remains untouched.
  116581. */
  116582. NoSync = 3
  116583. }
  116584. /**
  116585. * Class used to load scene from various file formats using registered plugins
  116586. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116587. */
  116588. export class SceneLoader {
  116589. /**
  116590. * No logging while loading
  116591. */
  116592. static readonly NO_LOGGING: number;
  116593. /**
  116594. * Minimal logging while loading
  116595. */
  116596. static readonly MINIMAL_LOGGING: number;
  116597. /**
  116598. * Summary logging while loading
  116599. */
  116600. static readonly SUMMARY_LOGGING: number;
  116601. /**
  116602. * Detailled logging while loading
  116603. */
  116604. static readonly DETAILED_LOGGING: number;
  116605. /**
  116606. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116607. */
  116608. static get ForceFullSceneLoadingForIncremental(): boolean;
  116609. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116610. /**
  116611. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116612. */
  116613. static get ShowLoadingScreen(): boolean;
  116614. static set ShowLoadingScreen(value: boolean);
  116615. /**
  116616. * Defines the current logging level (while loading the scene)
  116617. * @ignorenaming
  116618. */
  116619. static get loggingLevel(): number;
  116620. static set loggingLevel(value: number);
  116621. /**
  116622. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116623. */
  116624. static get CleanBoneMatrixWeights(): boolean;
  116625. static set CleanBoneMatrixWeights(value: boolean);
  116626. /**
  116627. * Event raised when a plugin is used to load a scene
  116628. */
  116629. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116630. private static _registeredPlugins;
  116631. private static _getDefaultPlugin;
  116632. private static _getPluginForExtension;
  116633. private static _getPluginForDirectLoad;
  116634. private static _getPluginForFilename;
  116635. private static _getDirectLoad;
  116636. private static _loadData;
  116637. private static _getFileInfo;
  116638. /**
  116639. * Gets a plugin that can load the given extension
  116640. * @param extension defines the extension to load
  116641. * @returns a plugin or null if none works
  116642. */
  116643. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116644. /**
  116645. * Gets a boolean indicating that the given extension can be loaded
  116646. * @param extension defines the extension to load
  116647. * @returns true if the extension is supported
  116648. */
  116649. static IsPluginForExtensionAvailable(extension: string): boolean;
  116650. /**
  116651. * Adds a new plugin to the list of registered plugins
  116652. * @param plugin defines the plugin to add
  116653. */
  116654. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116655. /**
  116656. * Import meshes into a scene
  116657. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116658. * @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)
  116659. * @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)
  116660. * @param scene the instance of BABYLON.Scene to append to
  116661. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116662. * @param onProgress a callback with a progress event for each file being loaded
  116663. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116664. * @param pluginExtension the extension used to determine the plugin
  116665. * @returns The loaded plugin
  116666. */
  116667. 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>;
  116668. /**
  116669. * Import meshes into a scene
  116670. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116671. * @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)
  116672. * @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)
  116673. * @param scene the instance of BABYLON.Scene to append to
  116674. * @param onProgress a callback with a progress event for each file being loaded
  116675. * @param pluginExtension the extension used to determine the plugin
  116676. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116677. */
  116678. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116679. meshes: AbstractMesh[];
  116680. particleSystems: IParticleSystem[];
  116681. skeletons: Skeleton[];
  116682. animationGroups: AnimationGroup[];
  116683. }>;
  116684. /**
  116685. * Load a scene
  116686. * @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)
  116687. * @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)
  116688. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116689. * @param onSuccess a callback with the scene when import succeeds
  116690. * @param onProgress a callback with a progress event for each file being loaded
  116691. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116692. * @param pluginExtension the extension used to determine the plugin
  116693. * @returns The loaded plugin
  116694. */
  116695. 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>;
  116696. /**
  116697. * Load a scene
  116698. * @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)
  116699. * @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)
  116700. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116701. * @param onProgress a callback with a progress event for each file being loaded
  116702. * @param pluginExtension the extension used to determine the plugin
  116703. * @returns The loaded scene
  116704. */
  116705. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116706. /**
  116707. * Append a scene
  116708. * @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)
  116709. * @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)
  116710. * @param scene is the instance of BABYLON.Scene to append to
  116711. * @param onSuccess a callback with the scene when import succeeds
  116712. * @param onProgress a callback with a progress event for each file being loaded
  116713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116714. * @param pluginExtension the extension used to determine the plugin
  116715. * @returns The loaded plugin
  116716. */
  116717. 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>;
  116718. /**
  116719. * Append a scene
  116720. * @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)
  116721. * @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)
  116722. * @param scene is the instance of BABYLON.Scene to append to
  116723. * @param onProgress a callback with a progress event for each file being loaded
  116724. * @param pluginExtension the extension used to determine the plugin
  116725. * @returns The given scene
  116726. */
  116727. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116728. /**
  116729. * Load a scene into an asset container
  116730. * @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)
  116731. * @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)
  116732. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116733. * @param onSuccess a callback with the scene when import succeeds
  116734. * @param onProgress a callback with a progress event for each file being loaded
  116735. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116736. * @param pluginExtension the extension used to determine the plugin
  116737. * @returns The loaded plugin
  116738. */
  116739. 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>;
  116740. /**
  116741. * Load a scene into an asset container
  116742. * @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)
  116743. * @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)
  116744. * @param scene is the instance of Scene to append to
  116745. * @param onProgress a callback with a progress event for each file being loaded
  116746. * @param pluginExtension the extension used to determine the plugin
  116747. * @returns The loaded asset container
  116748. */
  116749. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116750. /**
  116751. * Import animations from a file into a scene
  116752. * @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)
  116753. * @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)
  116754. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116755. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116756. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116757. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116758. * @param onSuccess a callback with the scene when import succeeds
  116759. * @param onProgress a callback with a progress event for each file being loaded
  116760. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116761. */
  116762. 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;
  116763. /**
  116764. * Import animations from a file into a scene
  116765. * @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)
  116766. * @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)
  116767. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116768. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116769. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116770. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116771. * @param onSuccess a callback with the scene when import succeeds
  116772. * @param onProgress a callback with a progress event for each file being loaded
  116773. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116774. * @returns the updated scene with imported animations
  116775. */
  116776. 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>;
  116777. }
  116778. }
  116779. declare module BABYLON {
  116780. /**
  116781. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116782. */
  116783. export type MotionControllerHandness = "none" | "left" | "right";
  116784. /**
  116785. * The type of components available in motion controllers.
  116786. * This is not the name of the component.
  116787. */
  116788. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116789. /**
  116790. * The state of a controller component
  116791. */
  116792. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116793. /**
  116794. * The schema of motion controller layout.
  116795. * No object will be initialized using this interface
  116796. * This is used just to define the profile.
  116797. */
  116798. export interface IMotionControllerLayout {
  116799. /**
  116800. * Path to load the assets. Usually relative to the base path
  116801. */
  116802. assetPath: string;
  116803. /**
  116804. * Available components (unsorted)
  116805. */
  116806. components: {
  116807. /**
  116808. * A map of component Ids
  116809. */
  116810. [componentId: string]: {
  116811. /**
  116812. * The type of input the component outputs
  116813. */
  116814. type: MotionControllerComponentType;
  116815. /**
  116816. * The indices of this component in the gamepad object
  116817. */
  116818. gamepadIndices: {
  116819. /**
  116820. * Index of button
  116821. */
  116822. button?: number;
  116823. /**
  116824. * If available, index of x-axis
  116825. */
  116826. xAxis?: number;
  116827. /**
  116828. * If available, index of y-axis
  116829. */
  116830. yAxis?: number;
  116831. };
  116832. /**
  116833. * The mesh's root node name
  116834. */
  116835. rootNodeName: string;
  116836. /**
  116837. * Animation definitions for this model
  116838. */
  116839. visualResponses: {
  116840. [stateKey: string]: {
  116841. /**
  116842. * What property will be animated
  116843. */
  116844. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116845. /**
  116846. * What states influence this visual response
  116847. */
  116848. states: MotionControllerComponentStateType[];
  116849. /**
  116850. * Type of animation - movement or visibility
  116851. */
  116852. valueNodeProperty: "transform" | "visibility";
  116853. /**
  116854. * Base node name to move. Its position will be calculated according to the min and max nodes
  116855. */
  116856. valueNodeName?: string;
  116857. /**
  116858. * Minimum movement node
  116859. */
  116860. minNodeName?: string;
  116861. /**
  116862. * Max movement node
  116863. */
  116864. maxNodeName?: string;
  116865. };
  116866. };
  116867. /**
  116868. * If touch enabled, what is the name of node to display user feedback
  116869. */
  116870. touchPointNodeName?: string;
  116871. };
  116872. };
  116873. /**
  116874. * Is it xr standard mapping or not
  116875. */
  116876. gamepadMapping: "" | "xr-standard";
  116877. /**
  116878. * Base root node of this entire model
  116879. */
  116880. rootNodeName: string;
  116881. /**
  116882. * Defines the main button component id
  116883. */
  116884. selectComponentId: string;
  116885. }
  116886. /**
  116887. * A definition for the layout map in the input profile
  116888. */
  116889. export interface IMotionControllerLayoutMap {
  116890. /**
  116891. * Layouts with handness type as a key
  116892. */
  116893. [handness: string]: IMotionControllerLayout;
  116894. }
  116895. /**
  116896. * The XR Input profile schema
  116897. * Profiles can be found here:
  116898. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116899. */
  116900. export interface IMotionControllerProfile {
  116901. /**
  116902. * fallback profiles for this profileId
  116903. */
  116904. fallbackProfileIds: string[];
  116905. /**
  116906. * The layout map, with handness as key
  116907. */
  116908. layouts: IMotionControllerLayoutMap;
  116909. /**
  116910. * The id of this profile
  116911. * correlates to the profile(s) in the xrInput.profiles array
  116912. */
  116913. profileId: string;
  116914. }
  116915. /**
  116916. * A helper-interface for the 3 meshes needed for controller button animation
  116917. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116918. */
  116919. export interface IMotionControllerButtonMeshMap {
  116920. /**
  116921. * the mesh that defines the pressed value mesh position.
  116922. * This is used to find the max-position of this button
  116923. */
  116924. pressedMesh: AbstractMesh;
  116925. /**
  116926. * the mesh that defines the unpressed value mesh position.
  116927. * This is used to find the min (or initial) position of this button
  116928. */
  116929. unpressedMesh: AbstractMesh;
  116930. /**
  116931. * The mesh that will be changed when value changes
  116932. */
  116933. valueMesh: AbstractMesh;
  116934. }
  116935. /**
  116936. * A helper-interface for the 3 meshes needed for controller axis animation.
  116937. * This will be expanded when touchpad animations are fully supported
  116938. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116939. */
  116940. export interface IMotionControllerMeshMap {
  116941. /**
  116942. * the mesh that defines the maximum value mesh position.
  116943. */
  116944. maxMesh?: AbstractMesh;
  116945. /**
  116946. * the mesh that defines the minimum value mesh position.
  116947. */
  116948. minMesh?: AbstractMesh;
  116949. /**
  116950. * The mesh that will be changed when axis value changes
  116951. */
  116952. valueMesh: AbstractMesh;
  116953. }
  116954. /**
  116955. * The elements needed for change-detection of the gamepad objects in motion controllers
  116956. */
  116957. export interface IMinimalMotionControllerObject {
  116958. /**
  116959. * Available axes of this controller
  116960. */
  116961. axes: number[];
  116962. /**
  116963. * An array of available buttons
  116964. */
  116965. buttons: Array<{
  116966. /**
  116967. * Value of the button/trigger
  116968. */
  116969. value: number;
  116970. /**
  116971. * If the button/trigger is currently touched
  116972. */
  116973. touched: boolean;
  116974. /**
  116975. * If the button/trigger is currently pressed
  116976. */
  116977. pressed: boolean;
  116978. }>;
  116979. }
  116980. /**
  116981. * An Abstract Motion controller
  116982. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116983. * Each component has an observable to check for changes in value and state
  116984. */
  116985. export abstract class WebXRAbstractMotionController implements IDisposable {
  116986. protected scene: Scene;
  116987. protected layout: IMotionControllerLayout;
  116988. /**
  116989. * The gamepad object correlating to this controller
  116990. */
  116991. gamepadObject: IMinimalMotionControllerObject;
  116992. /**
  116993. * handness (left/right/none) of this controller
  116994. */
  116995. handness: MotionControllerHandness;
  116996. private _initComponent;
  116997. private _modelReady;
  116998. /**
  116999. * A map of components (WebXRControllerComponent) in this motion controller
  117000. * Components have a ComponentType and can also have both button and axis definitions
  117001. */
  117002. readonly components: {
  117003. [id: string]: WebXRControllerComponent;
  117004. };
  117005. /**
  117006. * Disable the model's animation. Can be set at any time.
  117007. */
  117008. disableAnimation: boolean;
  117009. /**
  117010. * Observers registered here will be triggered when the model of this controller is done loading
  117011. */
  117012. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117013. /**
  117014. * The profile id of this motion controller
  117015. */
  117016. abstract profileId: string;
  117017. /**
  117018. * The root mesh of the model. It is null if the model was not yet initialized
  117019. */
  117020. rootMesh: Nullable<AbstractMesh>;
  117021. /**
  117022. * constructs a new abstract motion controller
  117023. * @param scene the scene to which the model of the controller will be added
  117024. * @param layout The profile layout to load
  117025. * @param gamepadObject The gamepad object correlating to this controller
  117026. * @param handness handness (left/right/none) of this controller
  117027. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117028. */
  117029. constructor(scene: Scene, layout: IMotionControllerLayout,
  117030. /**
  117031. * The gamepad object correlating to this controller
  117032. */
  117033. gamepadObject: IMinimalMotionControllerObject,
  117034. /**
  117035. * handness (left/right/none) of this controller
  117036. */
  117037. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117038. /**
  117039. * Dispose this controller, the model mesh and all its components
  117040. */
  117041. dispose(): void;
  117042. /**
  117043. * Returns all components of specific type
  117044. * @param type the type to search for
  117045. * @return an array of components with this type
  117046. */
  117047. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117048. /**
  117049. * get a component based an its component id as defined in layout.components
  117050. * @param id the id of the component
  117051. * @returns the component correlates to the id or undefined if not found
  117052. */
  117053. getComponent(id: string): WebXRControllerComponent;
  117054. /**
  117055. * Get the list of components available in this motion controller
  117056. * @returns an array of strings correlating to available components
  117057. */
  117058. getComponentIds(): string[];
  117059. /**
  117060. * Get the first component of specific type
  117061. * @param type type of component to find
  117062. * @return a controller component or null if not found
  117063. */
  117064. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117065. /**
  117066. * Get the main (Select) component of this controller as defined in the layout
  117067. * @returns the main component of this controller
  117068. */
  117069. getMainComponent(): WebXRControllerComponent;
  117070. /**
  117071. * Loads the model correlating to this controller
  117072. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117073. * @returns A promise fulfilled with the result of the model loading
  117074. */
  117075. loadModel(): Promise<boolean>;
  117076. /**
  117077. * Update this model using the current XRFrame
  117078. * @param xrFrame the current xr frame to use and update the model
  117079. */
  117080. updateFromXRFrame(xrFrame: XRFrame): void;
  117081. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117082. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117083. /**
  117084. * Moves the axis on the controller mesh based on its current state
  117085. * @param axis the index of the axis
  117086. * @param axisValue the value of the axis which determines the meshes new position
  117087. * @hidden
  117088. */
  117089. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117090. /**
  117091. * Update the model itself with the current frame data
  117092. * @param xrFrame the frame to use for updating the model mesh
  117093. */
  117094. protected updateModel(xrFrame: XRFrame): void;
  117095. /**
  117096. * Get the filename and path for this controller's model
  117097. * @returns a map of filename and path
  117098. */
  117099. protected abstract _getFilenameAndPath(): {
  117100. filename: string;
  117101. path: string;
  117102. };
  117103. /**
  117104. * This function is called before the mesh is loaded. It checks for loading constraints.
  117105. * For example, this function can check if the GLB loader is available
  117106. * If this function returns false, the generic controller will be loaded instead
  117107. * @returns Is the client ready to load the mesh
  117108. */
  117109. protected abstract _getModelLoadingConstraints(): boolean;
  117110. /**
  117111. * This function will be called after the model was successfully loaded and can be used
  117112. * for mesh transformations before it is available for the user
  117113. * @param meshes the loaded meshes
  117114. */
  117115. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117116. /**
  117117. * Set the root mesh for this controller. Important for the WebXR controller class
  117118. * @param meshes the loaded meshes
  117119. */
  117120. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117121. /**
  117122. * A function executed each frame that updates the mesh (if needed)
  117123. * @param xrFrame the current xrFrame
  117124. */
  117125. protected abstract _updateModel(xrFrame: XRFrame): void;
  117126. private _getGenericFilenameAndPath;
  117127. private _getGenericParentMesh;
  117128. }
  117129. }
  117130. declare module BABYLON {
  117131. /**
  117132. * A generic trigger-only motion controller for WebXR
  117133. */
  117134. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117135. /**
  117136. * Static version of the profile id of this controller
  117137. */
  117138. static ProfileId: string;
  117139. profileId: string;
  117140. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117141. protected _getFilenameAndPath(): {
  117142. filename: string;
  117143. path: string;
  117144. };
  117145. protected _getModelLoadingConstraints(): boolean;
  117146. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117147. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117148. protected _updateModel(): void;
  117149. }
  117150. }
  117151. declare module BABYLON {
  117152. /**
  117153. * Class containing static functions to help procedurally build meshes
  117154. */
  117155. export class SphereBuilder {
  117156. /**
  117157. * Creates a sphere mesh
  117158. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117159. * * 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`)
  117160. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117161. * * 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
  117162. * * 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)
  117163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117166. * @param name defines the name of the mesh
  117167. * @param options defines the options used to create the mesh
  117168. * @param scene defines the hosting scene
  117169. * @returns the sphere mesh
  117170. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117171. */
  117172. static CreateSphere(name: string, options: {
  117173. segments?: number;
  117174. diameter?: number;
  117175. diameterX?: number;
  117176. diameterY?: number;
  117177. diameterZ?: number;
  117178. arc?: number;
  117179. slice?: number;
  117180. sideOrientation?: number;
  117181. frontUVs?: Vector4;
  117182. backUVs?: Vector4;
  117183. updatable?: boolean;
  117184. }, scene?: Nullable<Scene>): Mesh;
  117185. }
  117186. }
  117187. declare module BABYLON {
  117188. /**
  117189. * A profiled motion controller has its profile loaded from an online repository.
  117190. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117191. */
  117192. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117193. private _repositoryUrl;
  117194. private _buttonMeshMapping;
  117195. private _touchDots;
  117196. /**
  117197. * The profile ID of this controller. Will be populated when the controller initializes.
  117198. */
  117199. profileId: string;
  117200. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117201. dispose(): void;
  117202. protected _getFilenameAndPath(): {
  117203. filename: string;
  117204. path: string;
  117205. };
  117206. protected _getModelLoadingConstraints(): boolean;
  117207. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117208. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117209. protected _updateModel(_xrFrame: XRFrame): void;
  117210. }
  117211. }
  117212. declare module BABYLON {
  117213. /**
  117214. * A construction function type to create a new controller based on an xrInput object
  117215. */
  117216. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117217. /**
  117218. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117219. *
  117220. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117221. * it should be replaced with auto-loaded controllers.
  117222. *
  117223. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117224. */
  117225. export class WebXRMotionControllerManager {
  117226. private static _AvailableControllers;
  117227. private static _Fallbacks;
  117228. private static _ProfileLoadingPromises;
  117229. private static _ProfilesList;
  117230. /**
  117231. * The base URL of the online controller repository. Can be changed at any time.
  117232. */
  117233. static BaseRepositoryUrl: string;
  117234. /**
  117235. * Which repository gets priority - local or online
  117236. */
  117237. static PrioritizeOnlineRepository: boolean;
  117238. /**
  117239. * Use the online repository, or use only locally-defined controllers
  117240. */
  117241. static UseOnlineRepository: boolean;
  117242. /**
  117243. * Clear the cache used for profile loading and reload when requested again
  117244. */
  117245. static ClearProfilesCache(): void;
  117246. /**
  117247. * Register the default fallbacks.
  117248. * This function is called automatically when this file is imported.
  117249. */
  117250. static DefaultFallbacks(): void;
  117251. /**
  117252. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117253. * @param profileId the profile to which a fallback needs to be found
  117254. * @return an array with corresponding fallback profiles
  117255. */
  117256. static FindFallbackWithProfileId(profileId: string): string[];
  117257. /**
  117258. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117259. * The order of search:
  117260. *
  117261. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117262. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117263. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117264. * 4) return the generic trigger controller if none were found
  117265. *
  117266. * @param xrInput the xrInput to which a new controller is initialized
  117267. * @param scene the scene to which the model will be added
  117268. * @param forceProfile force a certain profile for this controller
  117269. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117270. */
  117271. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117272. /**
  117273. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117274. *
  117275. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117276. *
  117277. * @param type the profile type to register
  117278. * @param constructFunction the function to be called when loading this profile
  117279. */
  117280. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117281. /**
  117282. * Register a fallback to a specific profile.
  117283. * @param profileId the profileId that will receive the fallbacks
  117284. * @param fallbacks A list of fallback profiles
  117285. */
  117286. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117287. /**
  117288. * Will update the list of profiles available in the repository
  117289. * @return a promise that resolves to a map of profiles available online
  117290. */
  117291. static UpdateProfilesList(): Promise<{
  117292. [profile: string]: string;
  117293. }>;
  117294. private static _LoadProfileFromRepository;
  117295. private static _LoadProfilesFromAvailableControllers;
  117296. }
  117297. }
  117298. declare module BABYLON {
  117299. /**
  117300. * Configuration options for the WebXR controller creation
  117301. */
  117302. export interface IWebXRControllerOptions {
  117303. /**
  117304. * Should the controller mesh be animated when a user interacts with it
  117305. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117306. */
  117307. disableMotionControllerAnimation?: boolean;
  117308. /**
  117309. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117310. */
  117311. doNotLoadControllerMesh?: boolean;
  117312. /**
  117313. * Force a specific controller type for this controller.
  117314. * This can be used when creating your own profile or when testing different controllers
  117315. */
  117316. forceControllerProfile?: string;
  117317. }
  117318. /**
  117319. * Represents an XR controller
  117320. */
  117321. export class WebXRInputSource {
  117322. private _scene;
  117323. /** The underlying input source for the controller */
  117324. inputSource: XRInputSource;
  117325. private _options;
  117326. private _tmpQuaternion;
  117327. private _tmpVector;
  117328. private _uniqueId;
  117329. /**
  117330. * 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
  117331. */
  117332. grip?: AbstractMesh;
  117333. /**
  117334. * If available, this is the gamepad object related to this controller.
  117335. * Using this object it is possible to get click events and trackpad changes of the
  117336. * webxr controller that is currently being used.
  117337. */
  117338. motionController?: WebXRAbstractMotionController;
  117339. /**
  117340. * Event that fires when the controller is removed/disposed.
  117341. * The object provided as event data is this controller, after associated assets were disposed.
  117342. * uniqueId is still available.
  117343. */
  117344. onDisposeObservable: Observable<WebXRInputSource>;
  117345. /**
  117346. * Will be triggered when the mesh associated with the motion controller is done loading.
  117347. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117348. * A shortened version of controller -> motion controller -> on mesh loaded.
  117349. */
  117350. onMeshLoadedObservable: Observable<AbstractMesh>;
  117351. /**
  117352. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117353. */
  117354. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117355. /**
  117356. * Pointer which can be used to select objects or attach a visible laser to
  117357. */
  117358. pointer: AbstractMesh;
  117359. /**
  117360. * Creates the controller
  117361. * @see https://doc.babylonjs.com/how_to/webxr
  117362. * @param _scene the scene which the controller should be associated to
  117363. * @param inputSource the underlying input source for the controller
  117364. * @param _options options for this controller creation
  117365. */
  117366. constructor(_scene: Scene,
  117367. /** The underlying input source for the controller */
  117368. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117369. /**
  117370. * Get this controllers unique id
  117371. */
  117372. get uniqueId(): string;
  117373. /**
  117374. * Disposes of the object
  117375. */
  117376. dispose(): void;
  117377. /**
  117378. * Gets a world space ray coming from the pointer or grip
  117379. * @param result the resulting ray
  117380. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117381. */
  117382. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117383. /**
  117384. * Updates the controller pose based on the given XRFrame
  117385. * @param xrFrame xr frame to update the pose with
  117386. * @param referenceSpace reference space to use
  117387. */
  117388. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117389. }
  117390. }
  117391. declare module BABYLON {
  117392. /**
  117393. * The schema for initialization options of the XR Input class
  117394. */
  117395. export interface IWebXRInputOptions {
  117396. /**
  117397. * If set to true no model will be automatically loaded
  117398. */
  117399. doNotLoadControllerMeshes?: boolean;
  117400. /**
  117401. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117402. * If not found, the xr input profile data will be used.
  117403. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117404. */
  117405. forceInputProfile?: string;
  117406. /**
  117407. * Do not send a request to the controller repository to load the profile.
  117408. *
  117409. * Instead, use the controllers available in babylon itself.
  117410. */
  117411. disableOnlineControllerRepository?: boolean;
  117412. /**
  117413. * A custom URL for the controllers repository
  117414. */
  117415. customControllersRepositoryURL?: string;
  117416. /**
  117417. * Should the controller model's components not move according to the user input
  117418. */
  117419. disableControllerAnimation?: boolean;
  117420. }
  117421. /**
  117422. * XR input used to track XR inputs such as controllers/rays
  117423. */
  117424. export class WebXRInput implements IDisposable {
  117425. /**
  117426. * the xr session manager for this session
  117427. */
  117428. xrSessionManager: WebXRSessionManager;
  117429. /**
  117430. * the WebXR camera for this session. Mainly used for teleportation
  117431. */
  117432. xrCamera: WebXRCamera;
  117433. private readonly options;
  117434. /**
  117435. * XR controllers being tracked
  117436. */
  117437. controllers: Array<WebXRInputSource>;
  117438. private _frameObserver;
  117439. private _sessionEndedObserver;
  117440. private _sessionInitObserver;
  117441. /**
  117442. * Event when a controller has been connected/added
  117443. */
  117444. onControllerAddedObservable: Observable<WebXRInputSource>;
  117445. /**
  117446. * Event when a controller has been removed/disconnected
  117447. */
  117448. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117449. /**
  117450. * Initializes the WebXRInput
  117451. * @param xrSessionManager the xr session manager for this session
  117452. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117453. * @param options = initialization options for this xr input
  117454. */
  117455. constructor(
  117456. /**
  117457. * the xr session manager for this session
  117458. */
  117459. xrSessionManager: WebXRSessionManager,
  117460. /**
  117461. * the WebXR camera for this session. Mainly used for teleportation
  117462. */
  117463. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117464. private _onInputSourcesChange;
  117465. private _addAndRemoveControllers;
  117466. /**
  117467. * Disposes of the object
  117468. */
  117469. dispose(): void;
  117470. }
  117471. }
  117472. declare module BABYLON {
  117473. /**
  117474. * This is the base class for all WebXR features.
  117475. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117476. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117477. */
  117478. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117479. protected _xrSessionManager: WebXRSessionManager;
  117480. private _attached;
  117481. private _removeOnDetach;
  117482. /**
  117483. * Should auto-attach be disabled?
  117484. */
  117485. disableAutoAttach: boolean;
  117486. /**
  117487. * Construct a new (abstract) WebXR feature
  117488. * @param _xrSessionManager the xr session manager for this feature
  117489. */
  117490. constructor(_xrSessionManager: WebXRSessionManager);
  117491. /**
  117492. * Is this feature attached
  117493. */
  117494. get attached(): boolean;
  117495. /**
  117496. * attach this feature
  117497. *
  117498. * @param force should attachment be forced (even when already attached)
  117499. * @returns true if successful, false is failed or already attached
  117500. */
  117501. attach(force?: boolean): boolean;
  117502. /**
  117503. * detach this feature.
  117504. *
  117505. * @returns true if successful, false if failed or already detached
  117506. */
  117507. detach(): boolean;
  117508. /**
  117509. * Dispose this feature and all of the resources attached
  117510. */
  117511. dispose(): void;
  117512. /**
  117513. * This is used to register callbacks that will automatically be removed when detach is called.
  117514. * @param observable the observable to which the observer will be attached
  117515. * @param callback the callback to register
  117516. */
  117517. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117518. /**
  117519. * Code in this function will be executed on each xrFrame received from the browser.
  117520. * This function will not execute after the feature is detached.
  117521. * @param _xrFrame the current frame
  117522. */
  117523. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117524. }
  117525. }
  117526. declare module BABYLON {
  117527. /**
  117528. * Renders a layer on top of an existing scene
  117529. */
  117530. export class UtilityLayerRenderer implements IDisposable {
  117531. /** the original scene that will be rendered on top of */
  117532. originalScene: Scene;
  117533. private _pointerCaptures;
  117534. private _lastPointerEvents;
  117535. private static _DefaultUtilityLayer;
  117536. private static _DefaultKeepDepthUtilityLayer;
  117537. private _sharedGizmoLight;
  117538. private _renderCamera;
  117539. /**
  117540. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117541. * @returns the camera that is used when rendering the utility layer
  117542. */
  117543. getRenderCamera(): Camera;
  117544. /**
  117545. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117546. * @param cam the camera that should be used when rendering the utility layer
  117547. */
  117548. setRenderCamera(cam: Nullable<Camera>): void;
  117549. /**
  117550. * @hidden
  117551. * Light which used by gizmos to get light shading
  117552. */
  117553. _getSharedGizmoLight(): HemisphericLight;
  117554. /**
  117555. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117556. */
  117557. pickUtilitySceneFirst: boolean;
  117558. /**
  117559. * 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)
  117560. */
  117561. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117562. /**
  117563. * 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)
  117564. */
  117565. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117566. /**
  117567. * The scene that is rendered on top of the original scene
  117568. */
  117569. utilityLayerScene: Scene;
  117570. /**
  117571. * If the utility layer should automatically be rendered on top of existing scene
  117572. */
  117573. shouldRender: boolean;
  117574. /**
  117575. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117576. */
  117577. onlyCheckPointerDownEvents: boolean;
  117578. /**
  117579. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117580. */
  117581. processAllEvents: boolean;
  117582. /**
  117583. * Observable raised when the pointer move from the utility layer scene to the main scene
  117584. */
  117585. onPointerOutObservable: Observable<number>;
  117586. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117587. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117588. private _afterRenderObserver;
  117589. private _sceneDisposeObserver;
  117590. private _originalPointerObserver;
  117591. /**
  117592. * Instantiates a UtilityLayerRenderer
  117593. * @param originalScene the original scene that will be rendered on top of
  117594. * @param handleEvents boolean indicating if the utility layer should handle events
  117595. */
  117596. constructor(
  117597. /** the original scene that will be rendered on top of */
  117598. originalScene: Scene, handleEvents?: boolean);
  117599. private _notifyObservers;
  117600. /**
  117601. * Renders the utility layers scene on top of the original scene
  117602. */
  117603. render(): void;
  117604. /**
  117605. * Disposes of the renderer
  117606. */
  117607. dispose(): void;
  117608. private _updateCamera;
  117609. }
  117610. }
  117611. declare module BABYLON {
  117612. /**
  117613. * Options interface for the pointer selection module
  117614. */
  117615. export interface IWebXRControllerPointerSelectionOptions {
  117616. /**
  117617. * if provided, this scene will be used to render meshes.
  117618. */
  117619. customUtilityLayerScene?: Scene;
  117620. /**
  117621. * 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)
  117622. * If not disabled, the last picked point will be used to execute a pointer up event
  117623. * If disabled, pointer up event will be triggered right after the pointer down event.
  117624. * Used in screen and gaze target ray mode only
  117625. */
  117626. disablePointerUpOnTouchOut: boolean;
  117627. /**
  117628. * For gaze mode (time to select instead of press)
  117629. */
  117630. forceGazeMode: boolean;
  117631. /**
  117632. * 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
  117633. * to start a new countdown to the pointer down event.
  117634. * Defaults to 1.
  117635. */
  117636. gazeModePointerMovedFactor?: number;
  117637. /**
  117638. * Different button type to use instead of the main component
  117639. */
  117640. overrideButtonId?: string;
  117641. /**
  117642. * use this rendering group id for the meshes (optional)
  117643. */
  117644. renderingGroupId?: number;
  117645. /**
  117646. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117647. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117648. * 3000 means 3 seconds between pointing at something and selecting it
  117649. */
  117650. timeToSelect?: number;
  117651. /**
  117652. * Should meshes created here be added to a utility layer or the main scene
  117653. */
  117654. useUtilityLayer?: boolean;
  117655. /**
  117656. * the xr input to use with this pointer selection
  117657. */
  117658. xrInput: WebXRInput;
  117659. }
  117660. /**
  117661. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117662. */
  117663. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117664. private readonly _options;
  117665. private static _idCounter;
  117666. private _attachController;
  117667. private _controllers;
  117668. private _scene;
  117669. private _tmpVectorForPickCompare;
  117670. /**
  117671. * The module's name
  117672. */
  117673. static readonly Name: string;
  117674. /**
  117675. * The (Babylon) version of this module.
  117676. * This is an integer representing the implementation version.
  117677. * This number does not correspond to the WebXR specs version
  117678. */
  117679. static readonly Version: number;
  117680. /**
  117681. * Disable lighting on the laser pointer (so it will always be visible)
  117682. */
  117683. disablePointerLighting: boolean;
  117684. /**
  117685. * Disable lighting on the selection mesh (so it will always be visible)
  117686. */
  117687. disableSelectionMeshLighting: boolean;
  117688. /**
  117689. * Should the laser pointer be displayed
  117690. */
  117691. displayLaserPointer: boolean;
  117692. /**
  117693. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117694. */
  117695. displaySelectionMesh: boolean;
  117696. /**
  117697. * This color will be set to the laser pointer when selection is triggered
  117698. */
  117699. laserPointerPickedColor: Color3;
  117700. /**
  117701. * Default color of the laser pointer
  117702. */
  117703. lasterPointerDefaultColor: Color3;
  117704. /**
  117705. * default color of the selection ring
  117706. */
  117707. selectionMeshDefaultColor: Color3;
  117708. /**
  117709. * This color will be applied to the selection ring when selection is triggered
  117710. */
  117711. selectionMeshPickedColor: Color3;
  117712. /**
  117713. * constructs a new background remover module
  117714. * @param _xrSessionManager the session manager for this module
  117715. * @param _options read-only options to be used in this module
  117716. */
  117717. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117718. /**
  117719. * attach this feature
  117720. * Will usually be called by the features manager
  117721. *
  117722. * @returns true if successful.
  117723. */
  117724. attach(): boolean;
  117725. /**
  117726. * detach this feature.
  117727. * Will usually be called by the features manager
  117728. *
  117729. * @returns true if successful.
  117730. */
  117731. detach(): boolean;
  117732. /**
  117733. * Will get the mesh under a specific pointer.
  117734. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117735. * @param controllerId the controllerId to check
  117736. * @returns The mesh under pointer or null if no mesh is under the pointer
  117737. */
  117738. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117739. /**
  117740. * Get the xr controller that correlates to the pointer id in the pointer event
  117741. *
  117742. * @param id the pointer id to search for
  117743. * @returns the controller that correlates to this id or null if not found
  117744. */
  117745. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117746. protected _onXRFrame(_xrFrame: XRFrame): void;
  117747. private _attachGazeMode;
  117748. private _attachScreenRayMode;
  117749. private _attachTrackedPointerRayMode;
  117750. private _convertNormalToDirectionOfRay;
  117751. private _detachController;
  117752. private _generateNewMeshPair;
  117753. private _pickingMoved;
  117754. private _updatePointerDistance;
  117755. }
  117756. }
  117757. declare module BABYLON {
  117758. /**
  117759. * Button which can be used to enter a different mode of XR
  117760. */
  117761. export class WebXREnterExitUIButton {
  117762. /** button element */
  117763. element: HTMLElement;
  117764. /** XR initialization options for the button */
  117765. sessionMode: XRSessionMode;
  117766. /** Reference space type */
  117767. referenceSpaceType: XRReferenceSpaceType;
  117768. /**
  117769. * Creates a WebXREnterExitUIButton
  117770. * @param element button element
  117771. * @param sessionMode XR initialization session mode
  117772. * @param referenceSpaceType the type of reference space to be used
  117773. */
  117774. constructor(
  117775. /** button element */
  117776. element: HTMLElement,
  117777. /** XR initialization options for the button */
  117778. sessionMode: XRSessionMode,
  117779. /** Reference space type */
  117780. referenceSpaceType: XRReferenceSpaceType);
  117781. /**
  117782. * Extendable function which can be used to update the button's visuals when the state changes
  117783. * @param activeButton the current active button in the UI
  117784. */
  117785. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117786. }
  117787. /**
  117788. * Options to create the webXR UI
  117789. */
  117790. export class WebXREnterExitUIOptions {
  117791. /**
  117792. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117793. */
  117794. customButtons?: Array<WebXREnterExitUIButton>;
  117795. /**
  117796. * A reference space type to use when creating the default button.
  117797. * Default is local-floor
  117798. */
  117799. referenceSpaceType?: XRReferenceSpaceType;
  117800. /**
  117801. * Context to enter xr with
  117802. */
  117803. renderTarget?: Nullable<WebXRRenderTarget>;
  117804. /**
  117805. * A session mode to use when creating the default button.
  117806. * Default is immersive-vr
  117807. */
  117808. sessionMode?: XRSessionMode;
  117809. }
  117810. /**
  117811. * UI to allow the user to enter/exit XR mode
  117812. */
  117813. export class WebXREnterExitUI implements IDisposable {
  117814. private scene;
  117815. /** version of the options passed to this UI */
  117816. options: WebXREnterExitUIOptions;
  117817. private _activeButton;
  117818. private _buttons;
  117819. private _overlay;
  117820. /**
  117821. * Fired every time the active button is changed.
  117822. *
  117823. * When xr is entered via a button that launches xr that button will be the callback parameter
  117824. *
  117825. * When exiting xr the callback parameter will be null)
  117826. */
  117827. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117828. /**
  117829. *
  117830. * @param scene babylon scene object to use
  117831. * @param options (read-only) version of the options passed to this UI
  117832. */
  117833. private constructor();
  117834. /**
  117835. * Creates UI to allow the user to enter/exit XR mode
  117836. * @param scene the scene to add the ui to
  117837. * @param helper the xr experience helper to enter/exit xr with
  117838. * @param options options to configure the UI
  117839. * @returns the created ui
  117840. */
  117841. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117842. /**
  117843. * Disposes of the XR UI component
  117844. */
  117845. dispose(): void;
  117846. private _updateButtons;
  117847. }
  117848. }
  117849. declare module BABYLON {
  117850. /**
  117851. * Class containing static functions to help procedurally build meshes
  117852. */
  117853. export class LinesBuilder {
  117854. /**
  117855. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117856. * * 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
  117857. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117858. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117859. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117860. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117861. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117862. * * 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
  117863. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117866. * @param name defines the name of the new line system
  117867. * @param options defines the options used to create the line system
  117868. * @param scene defines the hosting scene
  117869. * @returns a new line system mesh
  117870. */
  117871. static CreateLineSystem(name: string, options: {
  117872. lines: Vector3[][];
  117873. updatable?: boolean;
  117874. instance?: Nullable<LinesMesh>;
  117875. colors?: Nullable<Color4[][]>;
  117876. useVertexAlpha?: boolean;
  117877. }, scene: Nullable<Scene>): LinesMesh;
  117878. /**
  117879. * Creates a line mesh
  117880. * 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
  117881. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117882. * * The parameter `points` is an array successive Vector3
  117883. * * 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
  117884. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117885. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117886. * * When updating an instance, remember that only point positions can change, not the number of points
  117887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117889. * @param name defines the name of the new line system
  117890. * @param options defines the options used to create the line system
  117891. * @param scene defines the hosting scene
  117892. * @returns a new line mesh
  117893. */
  117894. static CreateLines(name: string, options: {
  117895. points: Vector3[];
  117896. updatable?: boolean;
  117897. instance?: Nullable<LinesMesh>;
  117898. colors?: Color4[];
  117899. useVertexAlpha?: boolean;
  117900. }, scene?: Nullable<Scene>): LinesMesh;
  117901. /**
  117902. * Creates a dashed line mesh
  117903. * * 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
  117904. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117905. * * The parameter `points` is an array successive Vector3
  117906. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117907. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117908. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117909. * * 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
  117910. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117911. * * When updating an instance, remember that only point positions can change, not the number of points
  117912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117913. * @param name defines the name of the mesh
  117914. * @param options defines the options used to create the mesh
  117915. * @param scene defines the hosting scene
  117916. * @returns the dashed line mesh
  117917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117918. */
  117919. static CreateDashedLines(name: string, options: {
  117920. points: Vector3[];
  117921. dashSize?: number;
  117922. gapSize?: number;
  117923. dashNb?: number;
  117924. updatable?: boolean;
  117925. instance?: LinesMesh;
  117926. useVertexAlpha?: boolean;
  117927. }, scene?: Nullable<Scene>): LinesMesh;
  117928. }
  117929. }
  117930. declare module BABYLON {
  117931. /**
  117932. * The options container for the teleportation module
  117933. */
  117934. export interface IWebXRTeleportationOptions {
  117935. /**
  117936. * if provided, this scene will be used to render meshes.
  117937. */
  117938. customUtilityLayerScene?: Scene;
  117939. /**
  117940. * Values to configure the default target mesh
  117941. */
  117942. defaultTargetMeshOptions?: {
  117943. /**
  117944. * Fill color of the teleportation area
  117945. */
  117946. teleportationFillColor?: string;
  117947. /**
  117948. * Border color for the teleportation area
  117949. */
  117950. teleportationBorderColor?: string;
  117951. /**
  117952. * Disable the mesh's animation sequence
  117953. */
  117954. disableAnimation?: boolean;
  117955. /**
  117956. * Disable lighting on the material or the ring and arrow
  117957. */
  117958. disableLighting?: boolean;
  117959. /**
  117960. * Override the default material of the torus and arrow
  117961. */
  117962. torusArrowMaterial?: Material;
  117963. };
  117964. /**
  117965. * A list of meshes to use as floor meshes.
  117966. * Meshes can be added and removed after initializing the feature using the
  117967. * addFloorMesh and removeFloorMesh functions
  117968. * If empty, rotation will still work
  117969. */
  117970. floorMeshes?: AbstractMesh[];
  117971. /**
  117972. * use this rendering group id for the meshes (optional)
  117973. */
  117974. renderingGroupId?: number;
  117975. /**
  117976. * Should teleportation move only to snap points
  117977. */
  117978. snapPointsOnly?: boolean;
  117979. /**
  117980. * An array of points to which the teleportation will snap to.
  117981. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  117982. */
  117983. snapPositions?: Vector3[];
  117984. /**
  117985. * How close should the teleportation ray be in order to snap to position.
  117986. * Default to 0.8 units (meters)
  117987. */
  117988. snapToPositionRadius?: number;
  117989. /**
  117990. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117991. * If you want to support rotation, make sure your mesh has a direction indicator.
  117992. *
  117993. * When left untouched, the default mesh will be initialized.
  117994. */
  117995. teleportationTargetMesh?: AbstractMesh;
  117996. /**
  117997. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  117998. */
  117999. timeToTeleport?: number;
  118000. /**
  118001. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118002. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118003. */
  118004. useMainComponentOnly?: boolean;
  118005. /**
  118006. * Should meshes created here be added to a utility layer or the main scene
  118007. */
  118008. useUtilityLayer?: boolean;
  118009. /**
  118010. * Babylon XR Input class for controller
  118011. */
  118012. xrInput: WebXRInput;
  118013. }
  118014. /**
  118015. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118016. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118017. * the input of the attached controllers.
  118018. */
  118019. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118020. private _options;
  118021. private _controllers;
  118022. private _currentTeleportationControllerId;
  118023. private _floorMeshes;
  118024. private _quadraticBezierCurve;
  118025. private _selectionFeature;
  118026. private _snapToPositions;
  118027. private _snappedToPoint;
  118028. private _teleportationRingMaterial?;
  118029. private _tmpRay;
  118030. private _tmpVector;
  118031. /**
  118032. * The module's name
  118033. */
  118034. static readonly Name: string;
  118035. /**
  118036. * The (Babylon) version of this module.
  118037. * This is an integer representing the implementation version.
  118038. * This number does not correspond to the webxr specs version
  118039. */
  118040. static readonly Version: number;
  118041. /**
  118042. * Is movement backwards enabled
  118043. */
  118044. backwardsMovementEnabled: boolean;
  118045. /**
  118046. * Distance to travel when moving backwards
  118047. */
  118048. backwardsTeleportationDistance: number;
  118049. /**
  118050. * The distance from the user to the inspection point in the direction of the controller
  118051. * A higher number will allow the user to move further
  118052. * defaults to 5 (meters, in xr units)
  118053. */
  118054. parabolicCheckRadius: number;
  118055. /**
  118056. * Should the module support parabolic ray on top of direct ray
  118057. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118058. * Very helpful when moving between floors / different heights
  118059. */
  118060. parabolicRayEnabled: boolean;
  118061. /**
  118062. * How much rotation should be applied when rotating right and left
  118063. */
  118064. rotationAngle: number;
  118065. /**
  118066. * Is rotation enabled when moving forward?
  118067. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118068. */
  118069. rotationEnabled: boolean;
  118070. /**
  118071. * constructs a new anchor system
  118072. * @param _xrSessionManager an instance of WebXRSessionManager
  118073. * @param _options configuration object for this feature
  118074. */
  118075. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118076. /**
  118077. * Get the snapPointsOnly flag
  118078. */
  118079. get snapPointsOnly(): boolean;
  118080. /**
  118081. * Sets the snapPointsOnly flag
  118082. * @param snapToPoints should teleportation be exclusively to snap points
  118083. */
  118084. set snapPointsOnly(snapToPoints: boolean);
  118085. /**
  118086. * Add a new mesh to the floor meshes array
  118087. * @param mesh the mesh to use as floor mesh
  118088. */
  118089. addFloorMesh(mesh: AbstractMesh): void;
  118090. /**
  118091. * Add a new snap-to point to fix teleportation to this position
  118092. * @param newSnapPoint The new Snap-To point
  118093. */
  118094. addSnapPoint(newSnapPoint: Vector3): void;
  118095. attach(): boolean;
  118096. detach(): boolean;
  118097. dispose(): void;
  118098. /**
  118099. * Remove a mesh from the floor meshes array
  118100. * @param mesh the mesh to remove
  118101. */
  118102. removeFloorMesh(mesh: AbstractMesh): void;
  118103. /**
  118104. * Remove a mesh from the floor meshes array using its name
  118105. * @param name the mesh name to remove
  118106. */
  118107. removeFloorMeshByName(name: string): void;
  118108. /**
  118109. * 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
  118110. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118111. * @returns was the point found and removed or not
  118112. */
  118113. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118114. /**
  118115. * This function sets a selection feature that will be disabled when
  118116. * the forward ray is shown and will be reattached when hidden.
  118117. * This is used to remove the selection rays when moving.
  118118. * @param selectionFeature the feature to disable when forward movement is enabled
  118119. */
  118120. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118121. protected _onXRFrame(_xrFrame: XRFrame): void;
  118122. private _attachController;
  118123. private _createDefaultTargetMesh;
  118124. private _detachController;
  118125. private _findClosestSnapPointWithRadius;
  118126. private _setTargetMeshPosition;
  118127. private _setTargetMeshVisibility;
  118128. private _showParabolicPath;
  118129. private _teleportForward;
  118130. }
  118131. }
  118132. declare module BABYLON {
  118133. /**
  118134. * Options for the default xr helper
  118135. */
  118136. export class WebXRDefaultExperienceOptions {
  118137. /**
  118138. * Enable or disable default UI to enter XR
  118139. */
  118140. disableDefaultUI?: boolean;
  118141. /**
  118142. * Should teleportation not initialize. defaults to false.
  118143. */
  118144. disableTeleportation?: boolean;
  118145. /**
  118146. * Floor meshes that will be used for teleport
  118147. */
  118148. floorMeshes?: Array<AbstractMesh>;
  118149. /**
  118150. * If set to true, the first frame will not be used to reset position
  118151. * The first frame is mainly used when copying transformation from the old camera
  118152. * Mainly used in AR
  118153. */
  118154. ignoreNativeCameraTransformation?: boolean;
  118155. /**
  118156. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118157. */
  118158. inputOptions?: IWebXRInputOptions;
  118159. /**
  118160. * optional configuration for the output canvas
  118161. */
  118162. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118163. /**
  118164. * optional UI options. This can be used among other to change session mode and reference space type
  118165. */
  118166. uiOptions?: WebXREnterExitUIOptions;
  118167. /**
  118168. * When loading teleportation and pointer select, use stable versions instead of latest.
  118169. */
  118170. useStablePlugins?: boolean;
  118171. }
  118172. /**
  118173. * Default experience which provides a similar setup to the previous webVRExperience
  118174. */
  118175. export class WebXRDefaultExperience {
  118176. /**
  118177. * Base experience
  118178. */
  118179. baseExperience: WebXRExperienceHelper;
  118180. /**
  118181. * Enables ui for entering/exiting xr
  118182. */
  118183. enterExitUI: WebXREnterExitUI;
  118184. /**
  118185. * Input experience extension
  118186. */
  118187. input: WebXRInput;
  118188. /**
  118189. * Enables laser pointer and selection
  118190. */
  118191. pointerSelection: WebXRControllerPointerSelection;
  118192. /**
  118193. * Default target xr should render to
  118194. */
  118195. renderTarget: WebXRRenderTarget;
  118196. /**
  118197. * Enables teleportation
  118198. */
  118199. teleportation: WebXRMotionControllerTeleportation;
  118200. private constructor();
  118201. /**
  118202. * Creates the default xr experience
  118203. * @param scene scene
  118204. * @param options options for basic configuration
  118205. * @returns resulting WebXRDefaultExperience
  118206. */
  118207. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118208. /**
  118209. * DIsposes of the experience helper
  118210. */
  118211. dispose(): void;
  118212. }
  118213. }
  118214. declare module BABYLON {
  118215. /**
  118216. * Options to modify the vr teleportation behavior.
  118217. */
  118218. export interface VRTeleportationOptions {
  118219. /**
  118220. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118221. */
  118222. floorMeshName?: string;
  118223. /**
  118224. * A list of meshes to be used as the teleportation floor. (default: empty)
  118225. */
  118226. floorMeshes?: Mesh[];
  118227. /**
  118228. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118229. */
  118230. teleportationMode?: number;
  118231. /**
  118232. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118233. */
  118234. teleportationTime?: number;
  118235. /**
  118236. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118237. */
  118238. teleportationSpeed?: number;
  118239. /**
  118240. * The easing function used in the animation or null for Linear. (default CircleEase)
  118241. */
  118242. easingFunction?: EasingFunction;
  118243. }
  118244. /**
  118245. * Options to modify the vr experience helper's behavior.
  118246. */
  118247. export interface VRExperienceHelperOptions extends WebVROptions {
  118248. /**
  118249. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118250. */
  118251. createDeviceOrientationCamera?: boolean;
  118252. /**
  118253. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118254. */
  118255. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118256. /**
  118257. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118258. */
  118259. laserToggle?: boolean;
  118260. /**
  118261. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118262. */
  118263. floorMeshes?: Mesh[];
  118264. /**
  118265. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118266. */
  118267. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118268. /**
  118269. * Defines if WebXR should be used instead of WebVR (if available)
  118270. */
  118271. useXR?: boolean;
  118272. }
  118273. /**
  118274. * Event containing information after VR has been entered
  118275. */
  118276. export class OnAfterEnteringVRObservableEvent {
  118277. /**
  118278. * If entering vr was successful
  118279. */
  118280. success: boolean;
  118281. }
  118282. /**
  118283. * Helps to quickly add VR support to an existing scene.
  118284. * See http://doc.babylonjs.com/how_to/webvr_helper
  118285. */
  118286. export class VRExperienceHelper {
  118287. /** Options to modify the vr experience helper's behavior. */
  118288. webVROptions: VRExperienceHelperOptions;
  118289. private _scene;
  118290. private _position;
  118291. private _btnVR;
  118292. private _btnVRDisplayed;
  118293. private _webVRsupported;
  118294. private _webVRready;
  118295. private _webVRrequesting;
  118296. private _webVRpresenting;
  118297. private _hasEnteredVR;
  118298. private _fullscreenVRpresenting;
  118299. private _inputElement;
  118300. private _webVRCamera;
  118301. private _vrDeviceOrientationCamera;
  118302. private _deviceOrientationCamera;
  118303. private _existingCamera;
  118304. private _onKeyDown;
  118305. private _onVrDisplayPresentChange;
  118306. private _onVRDisplayChanged;
  118307. private _onVRRequestPresentStart;
  118308. private _onVRRequestPresentComplete;
  118309. /**
  118310. * 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)
  118311. */
  118312. enableGazeEvenWhenNoPointerLock: boolean;
  118313. /**
  118314. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118315. */
  118316. exitVROnDoubleTap: boolean;
  118317. /**
  118318. * Observable raised right before entering VR.
  118319. */
  118320. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118321. /**
  118322. * Observable raised when entering VR has completed.
  118323. */
  118324. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118325. /**
  118326. * Observable raised when exiting VR.
  118327. */
  118328. onExitingVRObservable: Observable<VRExperienceHelper>;
  118329. /**
  118330. * Observable raised when controller mesh is loaded.
  118331. */
  118332. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118333. /** Return this.onEnteringVRObservable
  118334. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118335. */
  118336. get onEnteringVR(): Observable<VRExperienceHelper>;
  118337. /** Return this.onExitingVRObservable
  118338. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118339. */
  118340. get onExitingVR(): Observable<VRExperienceHelper>;
  118341. /** Return this.onControllerMeshLoadedObservable
  118342. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118343. */
  118344. get onControllerMeshLoaded(): Observable<WebVRController>;
  118345. private _rayLength;
  118346. private _useCustomVRButton;
  118347. private _teleportationRequested;
  118348. private _teleportActive;
  118349. private _floorMeshName;
  118350. private _floorMeshesCollection;
  118351. private _teleportationMode;
  118352. private _teleportationTime;
  118353. private _teleportationSpeed;
  118354. private _teleportationEasing;
  118355. private _rotationAllowed;
  118356. private _teleportBackwardsVector;
  118357. private _teleportationTarget;
  118358. private _isDefaultTeleportationTarget;
  118359. private _postProcessMove;
  118360. private _teleportationFillColor;
  118361. private _teleportationBorderColor;
  118362. private _rotationAngle;
  118363. private _haloCenter;
  118364. private _cameraGazer;
  118365. private _padSensibilityUp;
  118366. private _padSensibilityDown;
  118367. private _leftController;
  118368. private _rightController;
  118369. private _gazeColor;
  118370. private _laserColor;
  118371. private _pickedLaserColor;
  118372. private _pickedGazeColor;
  118373. /**
  118374. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118375. */
  118376. onNewMeshSelected: Observable<AbstractMesh>;
  118377. /**
  118378. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118379. * This observable will provide the mesh and the controller used to select the mesh
  118380. */
  118381. onMeshSelectedWithController: Observable<{
  118382. mesh: AbstractMesh;
  118383. controller: WebVRController;
  118384. }>;
  118385. /**
  118386. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118387. */
  118388. onNewMeshPicked: Observable<PickingInfo>;
  118389. private _circleEase;
  118390. /**
  118391. * Observable raised before camera teleportation
  118392. */
  118393. onBeforeCameraTeleport: Observable<Vector3>;
  118394. /**
  118395. * Observable raised after camera teleportation
  118396. */
  118397. onAfterCameraTeleport: Observable<Vector3>;
  118398. /**
  118399. * Observable raised when current selected mesh gets unselected
  118400. */
  118401. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118402. private _raySelectionPredicate;
  118403. /**
  118404. * To be optionaly changed by user to define custom ray selection
  118405. */
  118406. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118407. /**
  118408. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118409. */
  118410. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118411. /**
  118412. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118413. */
  118414. teleportationEnabled: boolean;
  118415. private _defaultHeight;
  118416. private _teleportationInitialized;
  118417. private _interactionsEnabled;
  118418. private _interactionsRequested;
  118419. private _displayGaze;
  118420. private _displayLaserPointer;
  118421. /**
  118422. * The mesh used to display where the user is going to teleport.
  118423. */
  118424. get teleportationTarget(): Mesh;
  118425. /**
  118426. * Sets the mesh to be used to display where the user is going to teleport.
  118427. */
  118428. set teleportationTarget(value: Mesh);
  118429. /**
  118430. * 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
  118431. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118432. * See http://doc.babylonjs.com/resources/baking_transformations
  118433. */
  118434. get gazeTrackerMesh(): Mesh;
  118435. set gazeTrackerMesh(value: Mesh);
  118436. /**
  118437. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118438. */
  118439. updateGazeTrackerScale: boolean;
  118440. /**
  118441. * If the gaze trackers color should be updated when selecting meshes
  118442. */
  118443. updateGazeTrackerColor: boolean;
  118444. /**
  118445. * If the controller laser color should be updated when selecting meshes
  118446. */
  118447. updateControllerLaserColor: boolean;
  118448. /**
  118449. * The gaze tracking mesh corresponding to the left controller
  118450. */
  118451. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118452. /**
  118453. * The gaze tracking mesh corresponding to the right controller
  118454. */
  118455. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118456. /**
  118457. * If the ray of the gaze should be displayed.
  118458. */
  118459. get displayGaze(): boolean;
  118460. /**
  118461. * Sets if the ray of the gaze should be displayed.
  118462. */
  118463. set displayGaze(value: boolean);
  118464. /**
  118465. * If the ray of the LaserPointer should be displayed.
  118466. */
  118467. get displayLaserPointer(): boolean;
  118468. /**
  118469. * Sets if the ray of the LaserPointer should be displayed.
  118470. */
  118471. set displayLaserPointer(value: boolean);
  118472. /**
  118473. * The deviceOrientationCamera used as the camera when not in VR.
  118474. */
  118475. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118476. /**
  118477. * Based on the current WebVR support, returns the current VR camera used.
  118478. */
  118479. get currentVRCamera(): Nullable<Camera>;
  118480. /**
  118481. * The webVRCamera which is used when in VR.
  118482. */
  118483. get webVRCamera(): WebVRFreeCamera;
  118484. /**
  118485. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118486. */
  118487. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118488. /**
  118489. * The html button that is used to trigger entering into VR.
  118490. */
  118491. get vrButton(): Nullable<HTMLButtonElement>;
  118492. private get _teleportationRequestInitiated();
  118493. /**
  118494. * Defines whether or not Pointer lock should be requested when switching to
  118495. * full screen.
  118496. */
  118497. requestPointerLockOnFullScreen: boolean;
  118498. /**
  118499. * If asking to force XR, this will be populated with the default xr experience
  118500. */
  118501. xr: WebXRDefaultExperience;
  118502. /**
  118503. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118504. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118505. */
  118506. xrTestDone: boolean;
  118507. /**
  118508. * Instantiates a VRExperienceHelper.
  118509. * Helps to quickly add VR support to an existing scene.
  118510. * @param scene The scene the VRExperienceHelper belongs to.
  118511. * @param webVROptions Options to modify the vr experience helper's behavior.
  118512. */
  118513. constructor(scene: Scene,
  118514. /** Options to modify the vr experience helper's behavior. */
  118515. webVROptions?: VRExperienceHelperOptions);
  118516. private completeVRInit;
  118517. private _onDefaultMeshLoaded;
  118518. private _onResize;
  118519. private _onFullscreenChange;
  118520. /**
  118521. * Gets a value indicating if we are currently in VR mode.
  118522. */
  118523. get isInVRMode(): boolean;
  118524. private onVrDisplayPresentChange;
  118525. private onVRDisplayChanged;
  118526. private moveButtonToBottomRight;
  118527. private displayVRButton;
  118528. private updateButtonVisibility;
  118529. private _cachedAngularSensibility;
  118530. /**
  118531. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118532. * Otherwise, will use the fullscreen API.
  118533. */
  118534. enterVR(): void;
  118535. /**
  118536. * Attempt to exit VR, or fullscreen.
  118537. */
  118538. exitVR(): void;
  118539. /**
  118540. * The position of the vr experience helper.
  118541. */
  118542. get position(): Vector3;
  118543. /**
  118544. * Sets the position of the vr experience helper.
  118545. */
  118546. set position(value: Vector3);
  118547. /**
  118548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118549. */
  118550. enableInteractions(): void;
  118551. private get _noControllerIsActive();
  118552. private beforeRender;
  118553. private _isTeleportationFloor;
  118554. /**
  118555. * Adds a floor mesh to be used for teleportation.
  118556. * @param floorMesh the mesh to be used for teleportation.
  118557. */
  118558. addFloorMesh(floorMesh: Mesh): void;
  118559. /**
  118560. * Removes a floor mesh from being used for teleportation.
  118561. * @param floorMesh the mesh to be removed.
  118562. */
  118563. removeFloorMesh(floorMesh: Mesh): void;
  118564. /**
  118565. * Enables interactions and teleportation using the VR controllers and gaze.
  118566. * @param vrTeleportationOptions options to modify teleportation behavior.
  118567. */
  118568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118569. private _onNewGamepadConnected;
  118570. private _tryEnableInteractionOnController;
  118571. private _onNewGamepadDisconnected;
  118572. private _enableInteractionOnController;
  118573. private _checkTeleportWithRay;
  118574. private _checkRotate;
  118575. private _checkTeleportBackwards;
  118576. private _enableTeleportationOnController;
  118577. private _createTeleportationCircles;
  118578. private _displayTeleportationTarget;
  118579. private _hideTeleportationTarget;
  118580. private _rotateCamera;
  118581. private _moveTeleportationSelectorTo;
  118582. private _workingVector;
  118583. private _workingQuaternion;
  118584. private _workingMatrix;
  118585. /**
  118586. * Time Constant Teleportation Mode
  118587. */
  118588. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118589. /**
  118590. * Speed Constant Teleportation Mode
  118591. */
  118592. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118593. /**
  118594. * Teleports the users feet to the desired location
  118595. * @param location The location where the user's feet should be placed
  118596. */
  118597. teleportCamera(location: Vector3): void;
  118598. private _convertNormalToDirectionOfRay;
  118599. private _castRayAndSelectObject;
  118600. private _notifySelectedMeshUnselected;
  118601. /**
  118602. * Permanently set new colors for the laser pointer
  118603. * @param color the new laser color
  118604. * @param pickedColor the new laser color when picked mesh detected
  118605. */
  118606. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118607. /**
  118608. * Set lighting enabled / disabled on the laser pointer of both controllers
  118609. * @param enabled should the lighting be enabled on the laser pointer
  118610. */
  118611. setLaserLightingState(enabled?: boolean): void;
  118612. /**
  118613. * Permanently set new colors for the gaze pointer
  118614. * @param color the new gaze color
  118615. * @param pickedColor the new gaze color when picked mesh detected
  118616. */
  118617. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118618. /**
  118619. * Sets the color of the laser ray from the vr controllers.
  118620. * @param color new color for the ray.
  118621. */
  118622. changeLaserColor(color: Color3): void;
  118623. /**
  118624. * Sets the color of the ray from the vr headsets gaze.
  118625. * @param color new color for the ray.
  118626. */
  118627. changeGazeColor(color: Color3): void;
  118628. /**
  118629. * Exits VR and disposes of the vr experience helper
  118630. */
  118631. dispose(): void;
  118632. /**
  118633. * Gets the name of the VRExperienceHelper class
  118634. * @returns "VRExperienceHelper"
  118635. */
  118636. getClassName(): string;
  118637. }
  118638. }
  118639. declare module BABYLON {
  118640. /**
  118641. * Contains an array of blocks representing the octree
  118642. */
  118643. export interface IOctreeContainer<T> {
  118644. /**
  118645. * Blocks within the octree
  118646. */
  118647. blocks: Array<OctreeBlock<T>>;
  118648. }
  118649. /**
  118650. * Class used to store a cell in an octree
  118651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118652. */
  118653. export class OctreeBlock<T> {
  118654. /**
  118655. * Gets the content of the current block
  118656. */
  118657. entries: T[];
  118658. /**
  118659. * Gets the list of block children
  118660. */
  118661. blocks: Array<OctreeBlock<T>>;
  118662. private _depth;
  118663. private _maxDepth;
  118664. private _capacity;
  118665. private _minPoint;
  118666. private _maxPoint;
  118667. private _boundingVectors;
  118668. private _creationFunc;
  118669. /**
  118670. * Creates a new block
  118671. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118672. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118673. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118674. * @param depth defines the current depth of this block in the octree
  118675. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118676. * @param creationFunc defines a callback to call when an element is added to the block
  118677. */
  118678. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118679. /**
  118680. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118681. */
  118682. get capacity(): number;
  118683. /**
  118684. * Gets the minimum vector (in world space) of the block's bounding box
  118685. */
  118686. get minPoint(): Vector3;
  118687. /**
  118688. * Gets the maximum vector (in world space) of the block's bounding box
  118689. */
  118690. get maxPoint(): Vector3;
  118691. /**
  118692. * Add a new element to this block
  118693. * @param entry defines the element to add
  118694. */
  118695. addEntry(entry: T): void;
  118696. /**
  118697. * Remove an element from this block
  118698. * @param entry defines the element to remove
  118699. */
  118700. removeEntry(entry: T): void;
  118701. /**
  118702. * Add an array of elements to this block
  118703. * @param entries defines the array of elements to add
  118704. */
  118705. addEntries(entries: T[]): void;
  118706. /**
  118707. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118708. * @param frustumPlanes defines the frustum planes to test
  118709. * @param selection defines the array to store current content if selection is positive
  118710. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118711. */
  118712. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118713. /**
  118714. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118715. * @param sphereCenter defines the bounding sphere center
  118716. * @param sphereRadius defines the bounding sphere radius
  118717. * @param selection defines the array to store current content if selection is positive
  118718. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118719. */
  118720. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118721. /**
  118722. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118723. * @param ray defines the ray to test with
  118724. * @param selection defines the array to store current content if selection is positive
  118725. */
  118726. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118727. /**
  118728. * Subdivide the content into child blocks (this block will then be empty)
  118729. */
  118730. createInnerBlocks(): void;
  118731. /**
  118732. * @hidden
  118733. */
  118734. 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;
  118735. }
  118736. }
  118737. declare module BABYLON {
  118738. /**
  118739. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118740. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118741. */
  118742. export class Octree<T> {
  118743. /** 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.) */
  118744. maxDepth: number;
  118745. /**
  118746. * Blocks within the octree containing objects
  118747. */
  118748. blocks: Array<OctreeBlock<T>>;
  118749. /**
  118750. * Content stored in the octree
  118751. */
  118752. dynamicContent: T[];
  118753. private _maxBlockCapacity;
  118754. private _selectionContent;
  118755. private _creationFunc;
  118756. /**
  118757. * Creates a octree
  118758. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118759. * @param creationFunc function to be used to instatiate the octree
  118760. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118761. * @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.)
  118762. */
  118763. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118764. /** 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.) */
  118765. maxDepth?: number);
  118766. /**
  118767. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118768. * @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);
  118769. * @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);
  118770. * @param entries meshes to be added to the octree blocks
  118771. */
  118772. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118773. /**
  118774. * Adds a mesh to the octree
  118775. * @param entry Mesh to add to the octree
  118776. */
  118777. addMesh(entry: T): void;
  118778. /**
  118779. * Remove an element from the octree
  118780. * @param entry defines the element to remove
  118781. */
  118782. removeMesh(entry: T): void;
  118783. /**
  118784. * Selects an array of meshes within the frustum
  118785. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118786. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118787. * @returns array of meshes within the frustum
  118788. */
  118789. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118790. /**
  118791. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118792. * @param sphereCenter defines the bounding sphere center
  118793. * @param sphereRadius defines the bounding sphere radius
  118794. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118795. * @returns an array of objects that intersect the sphere
  118796. */
  118797. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118798. /**
  118799. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118800. * @param ray defines the ray to test with
  118801. * @returns array of intersected objects
  118802. */
  118803. intersectsRay(ray: Ray): SmartArray<T>;
  118804. /**
  118805. * Adds a mesh into the octree block if it intersects the block
  118806. */
  118807. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118808. /**
  118809. * Adds a submesh into the octree block if it intersects the block
  118810. */
  118811. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118812. }
  118813. }
  118814. declare module BABYLON {
  118815. interface Scene {
  118816. /**
  118817. * @hidden
  118818. * Backing Filed
  118819. */
  118820. _selectionOctree: Octree<AbstractMesh>;
  118821. /**
  118822. * Gets the octree used to boost mesh selection (picking)
  118823. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118824. */
  118825. selectionOctree: Octree<AbstractMesh>;
  118826. /**
  118827. * Creates or updates the octree used to boost selection (picking)
  118828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118829. * @param maxCapacity defines the maximum capacity per leaf
  118830. * @param maxDepth defines the maximum depth of the octree
  118831. * @returns an octree of AbstractMesh
  118832. */
  118833. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118834. }
  118835. interface AbstractMesh {
  118836. /**
  118837. * @hidden
  118838. * Backing Field
  118839. */
  118840. _submeshesOctree: Octree<SubMesh>;
  118841. /**
  118842. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118843. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118844. * @param maxCapacity defines the maximum size of each block (64 by default)
  118845. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118846. * @returns the new octree
  118847. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118848. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118849. */
  118850. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118851. }
  118852. /**
  118853. * Defines the octree scene component responsible to manage any octrees
  118854. * in a given scene.
  118855. */
  118856. export class OctreeSceneComponent {
  118857. /**
  118858. * The component name help to identify the component in the list of scene components.
  118859. */
  118860. readonly name: string;
  118861. /**
  118862. * The scene the component belongs to.
  118863. */
  118864. scene: Scene;
  118865. /**
  118866. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118867. */
  118868. readonly checksIsEnabled: boolean;
  118869. /**
  118870. * Creates a new instance of the component for the given scene
  118871. * @param scene Defines the scene to register the component in
  118872. */
  118873. constructor(scene: Scene);
  118874. /**
  118875. * Registers the component in a given scene
  118876. */
  118877. register(): void;
  118878. /**
  118879. * Return the list of active meshes
  118880. * @returns the list of active meshes
  118881. */
  118882. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118883. /**
  118884. * Return the list of active sub meshes
  118885. * @param mesh The mesh to get the candidates sub meshes from
  118886. * @returns the list of active sub meshes
  118887. */
  118888. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118889. private _tempRay;
  118890. /**
  118891. * Return the list of sub meshes intersecting with a given local ray
  118892. * @param mesh defines the mesh to find the submesh for
  118893. * @param localRay defines the ray in local space
  118894. * @returns the list of intersecting sub meshes
  118895. */
  118896. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118897. /**
  118898. * Return the list of sub meshes colliding with a collider
  118899. * @param mesh defines the mesh to find the submesh for
  118900. * @param collider defines the collider to evaluate the collision against
  118901. * @returns the list of colliding sub meshes
  118902. */
  118903. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118904. /**
  118905. * Rebuilds the elements related to this component in case of
  118906. * context lost for instance.
  118907. */
  118908. rebuild(): void;
  118909. /**
  118910. * Disposes the component and the associated ressources.
  118911. */
  118912. dispose(): void;
  118913. }
  118914. }
  118915. declare module BABYLON {
  118916. /**
  118917. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118918. */
  118919. export class Gizmo implements IDisposable {
  118920. /** The utility layer the gizmo will be added to */
  118921. gizmoLayer: UtilityLayerRenderer;
  118922. /**
  118923. * The root mesh of the gizmo
  118924. */
  118925. _rootMesh: Mesh;
  118926. private _attachedMesh;
  118927. /**
  118928. * Ratio for the scale of the gizmo (Default: 1)
  118929. */
  118930. scaleRatio: number;
  118931. /**
  118932. * If a custom mesh has been set (Default: false)
  118933. */
  118934. protected _customMeshSet: boolean;
  118935. /**
  118936. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118937. * * When set, interactions will be enabled
  118938. */
  118939. get attachedMesh(): Nullable<AbstractMesh>;
  118940. set attachedMesh(value: Nullable<AbstractMesh>);
  118941. /**
  118942. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118943. * @param mesh The mesh to replace the default mesh of the gizmo
  118944. */
  118945. setCustomMesh(mesh: Mesh): void;
  118946. /**
  118947. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118948. */
  118949. updateGizmoRotationToMatchAttachedMesh: boolean;
  118950. /**
  118951. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118952. */
  118953. updateGizmoPositionToMatchAttachedMesh: boolean;
  118954. /**
  118955. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118956. */
  118957. updateScale: boolean;
  118958. protected _interactionsEnabled: boolean;
  118959. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118960. private _beforeRenderObserver;
  118961. private _tempVector;
  118962. /**
  118963. * Creates a gizmo
  118964. * @param gizmoLayer The utility layer the gizmo will be added to
  118965. */
  118966. constructor(
  118967. /** The utility layer the gizmo will be added to */
  118968. gizmoLayer?: UtilityLayerRenderer);
  118969. /**
  118970. * Updates the gizmo to match the attached mesh's position/rotation
  118971. */
  118972. protected _update(): void;
  118973. /**
  118974. * Disposes of the gizmo
  118975. */
  118976. dispose(): void;
  118977. }
  118978. }
  118979. declare module BABYLON {
  118980. /**
  118981. * Single plane drag gizmo
  118982. */
  118983. export class PlaneDragGizmo extends Gizmo {
  118984. /**
  118985. * Drag behavior responsible for the gizmos dragging interactions
  118986. */
  118987. dragBehavior: PointerDragBehavior;
  118988. private _pointerObserver;
  118989. /**
  118990. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118991. */
  118992. snapDistance: number;
  118993. /**
  118994. * Event that fires each time the gizmo snaps to a new location.
  118995. * * snapDistance is the the change in distance
  118996. */
  118997. onSnapObservable: Observable<{
  118998. snapDistance: number;
  118999. }>;
  119000. private _plane;
  119001. private _coloredMaterial;
  119002. private _hoverMaterial;
  119003. private _isEnabled;
  119004. private _parent;
  119005. /** @hidden */
  119006. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119007. /** @hidden */
  119008. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119009. /**
  119010. * Creates a PlaneDragGizmo
  119011. * @param gizmoLayer The utility layer the gizmo will be added to
  119012. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119013. * @param color The color of the gizmo
  119014. */
  119015. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119016. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119017. /**
  119018. * If the gizmo is enabled
  119019. */
  119020. set isEnabled(value: boolean);
  119021. get isEnabled(): boolean;
  119022. /**
  119023. * Disposes of the gizmo
  119024. */
  119025. dispose(): void;
  119026. }
  119027. }
  119028. declare module BABYLON {
  119029. /**
  119030. * Gizmo that enables dragging a mesh along 3 axis
  119031. */
  119032. export class PositionGizmo extends Gizmo {
  119033. /**
  119034. * Internal gizmo used for interactions on the x axis
  119035. */
  119036. xGizmo: AxisDragGizmo;
  119037. /**
  119038. * Internal gizmo used for interactions on the y axis
  119039. */
  119040. yGizmo: AxisDragGizmo;
  119041. /**
  119042. * Internal gizmo used for interactions on the z axis
  119043. */
  119044. zGizmo: AxisDragGizmo;
  119045. /**
  119046. * Internal gizmo used for interactions on the yz plane
  119047. */
  119048. xPlaneGizmo: PlaneDragGizmo;
  119049. /**
  119050. * Internal gizmo used for interactions on the xz plane
  119051. */
  119052. yPlaneGizmo: PlaneDragGizmo;
  119053. /**
  119054. * Internal gizmo used for interactions on the xy plane
  119055. */
  119056. zPlaneGizmo: PlaneDragGizmo;
  119057. /**
  119058. * private variables
  119059. */
  119060. private _meshAttached;
  119061. private _updateGizmoRotationToMatchAttachedMesh;
  119062. private _snapDistance;
  119063. private _scaleRatio;
  119064. /** Fires an event when any of it's sub gizmos are dragged */
  119065. onDragStartObservable: Observable<unknown>;
  119066. /** Fires an event when any of it's sub gizmos are released from dragging */
  119067. onDragEndObservable: Observable<unknown>;
  119068. /**
  119069. * If set to true, planar drag is enabled
  119070. */
  119071. private _planarGizmoEnabled;
  119072. get attachedMesh(): Nullable<AbstractMesh>;
  119073. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119074. /**
  119075. * Creates a PositionGizmo
  119076. * @param gizmoLayer The utility layer the gizmo will be added to
  119077. */
  119078. constructor(gizmoLayer?: UtilityLayerRenderer);
  119079. /**
  119080. * If the planar drag gizmo is enabled
  119081. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119082. */
  119083. set planarGizmoEnabled(value: boolean);
  119084. get planarGizmoEnabled(): boolean;
  119085. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119086. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119087. /**
  119088. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119089. */
  119090. set snapDistance(value: number);
  119091. get snapDistance(): number;
  119092. /**
  119093. * Ratio for the scale of the gizmo (Default: 1)
  119094. */
  119095. set scaleRatio(value: number);
  119096. get scaleRatio(): number;
  119097. /**
  119098. * Disposes of the gizmo
  119099. */
  119100. dispose(): void;
  119101. /**
  119102. * CustomMeshes are not supported by this gizmo
  119103. * @param mesh The mesh to replace the default mesh of the gizmo
  119104. */
  119105. setCustomMesh(mesh: Mesh): void;
  119106. }
  119107. }
  119108. declare module BABYLON {
  119109. /**
  119110. * Single axis drag gizmo
  119111. */
  119112. export class AxisDragGizmo extends Gizmo {
  119113. /**
  119114. * Drag behavior responsible for the gizmos dragging interactions
  119115. */
  119116. dragBehavior: PointerDragBehavior;
  119117. private _pointerObserver;
  119118. /**
  119119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119120. */
  119121. snapDistance: number;
  119122. /**
  119123. * Event that fires each time the gizmo snaps to a new location.
  119124. * * snapDistance is the the change in distance
  119125. */
  119126. onSnapObservable: Observable<{
  119127. snapDistance: number;
  119128. }>;
  119129. private _isEnabled;
  119130. private _parent;
  119131. private _arrow;
  119132. private _coloredMaterial;
  119133. private _hoverMaterial;
  119134. /** @hidden */
  119135. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119136. /** @hidden */
  119137. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119138. /**
  119139. * Creates an AxisDragGizmo
  119140. * @param gizmoLayer The utility layer the gizmo will be added to
  119141. * @param dragAxis The axis which the gizmo will be able to drag on
  119142. * @param color The color of the gizmo
  119143. */
  119144. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119145. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119146. /**
  119147. * If the gizmo is enabled
  119148. */
  119149. set isEnabled(value: boolean);
  119150. get isEnabled(): boolean;
  119151. /**
  119152. * Disposes of the gizmo
  119153. */
  119154. dispose(): void;
  119155. }
  119156. }
  119157. declare module BABYLON.Debug {
  119158. /**
  119159. * The Axes viewer will show 3 axes in a specific point in space
  119160. */
  119161. export class AxesViewer {
  119162. private _xAxis;
  119163. private _yAxis;
  119164. private _zAxis;
  119165. private _scaleLinesFactor;
  119166. private _instanced;
  119167. /**
  119168. * Gets the hosting scene
  119169. */
  119170. scene: Scene;
  119171. /**
  119172. * Gets or sets a number used to scale line length
  119173. */
  119174. scaleLines: number;
  119175. /** Gets the node hierarchy used to render x-axis */
  119176. get xAxis(): TransformNode;
  119177. /** Gets the node hierarchy used to render y-axis */
  119178. get yAxis(): TransformNode;
  119179. /** Gets the node hierarchy used to render z-axis */
  119180. get zAxis(): TransformNode;
  119181. /**
  119182. * Creates a new AxesViewer
  119183. * @param scene defines the hosting scene
  119184. * @param scaleLines defines a number used to scale line length (1 by default)
  119185. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119186. * @param xAxis defines the node hierarchy used to render the x-axis
  119187. * @param yAxis defines the node hierarchy used to render the y-axis
  119188. * @param zAxis defines the node hierarchy used to render the z-axis
  119189. */
  119190. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119191. /**
  119192. * Force the viewer to update
  119193. * @param position defines the position of the viewer
  119194. * @param xaxis defines the x axis of the viewer
  119195. * @param yaxis defines the y axis of the viewer
  119196. * @param zaxis defines the z axis of the viewer
  119197. */
  119198. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119199. /**
  119200. * Creates an instance of this axes viewer.
  119201. * @returns a new axes viewer with instanced meshes
  119202. */
  119203. createInstance(): AxesViewer;
  119204. /** Releases resources */
  119205. dispose(): void;
  119206. private static _SetRenderingGroupId;
  119207. }
  119208. }
  119209. declare module BABYLON.Debug {
  119210. /**
  119211. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119212. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119213. */
  119214. export class BoneAxesViewer extends AxesViewer {
  119215. /**
  119216. * Gets or sets the target mesh where to display the axes viewer
  119217. */
  119218. mesh: Nullable<Mesh>;
  119219. /**
  119220. * Gets or sets the target bone where to display the axes viewer
  119221. */
  119222. bone: Nullable<Bone>;
  119223. /** Gets current position */
  119224. pos: Vector3;
  119225. /** Gets direction of X axis */
  119226. xaxis: Vector3;
  119227. /** Gets direction of Y axis */
  119228. yaxis: Vector3;
  119229. /** Gets direction of Z axis */
  119230. zaxis: Vector3;
  119231. /**
  119232. * Creates a new BoneAxesViewer
  119233. * @param scene defines the hosting scene
  119234. * @param bone defines the target bone
  119235. * @param mesh defines the target mesh
  119236. * @param scaleLines defines a scaling factor for line length (1 by default)
  119237. */
  119238. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119239. /**
  119240. * Force the viewer to update
  119241. */
  119242. update(): void;
  119243. /** Releases resources */
  119244. dispose(): void;
  119245. }
  119246. }
  119247. declare module BABYLON {
  119248. /**
  119249. * Interface used to define scene explorer extensibility option
  119250. */
  119251. export interface IExplorerExtensibilityOption {
  119252. /**
  119253. * Define the option label
  119254. */
  119255. label: string;
  119256. /**
  119257. * Defines the action to execute on click
  119258. */
  119259. action: (entity: any) => void;
  119260. }
  119261. /**
  119262. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119263. */
  119264. export interface IExplorerExtensibilityGroup {
  119265. /**
  119266. * Defines a predicate to test if a given type mut be extended
  119267. */
  119268. predicate: (entity: any) => boolean;
  119269. /**
  119270. * Gets the list of options added to a type
  119271. */
  119272. entries: IExplorerExtensibilityOption[];
  119273. }
  119274. /**
  119275. * Interface used to define the options to use to create the Inspector
  119276. */
  119277. export interface IInspectorOptions {
  119278. /**
  119279. * Display in overlay mode (default: false)
  119280. */
  119281. overlay?: boolean;
  119282. /**
  119283. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119284. */
  119285. globalRoot?: HTMLElement;
  119286. /**
  119287. * Display the Scene explorer
  119288. */
  119289. showExplorer?: boolean;
  119290. /**
  119291. * Display the property inspector
  119292. */
  119293. showInspector?: boolean;
  119294. /**
  119295. * Display in embed mode (both panes on the right)
  119296. */
  119297. embedMode?: boolean;
  119298. /**
  119299. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119300. */
  119301. handleResize?: boolean;
  119302. /**
  119303. * Allow the panes to popup (default: true)
  119304. */
  119305. enablePopup?: boolean;
  119306. /**
  119307. * Allow the panes to be closed by users (default: true)
  119308. */
  119309. enableClose?: boolean;
  119310. /**
  119311. * Optional list of extensibility entries
  119312. */
  119313. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119314. /**
  119315. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119316. */
  119317. inspectorURL?: string;
  119318. /**
  119319. * Optional initial tab (default to DebugLayerTab.Properties)
  119320. */
  119321. initialTab?: DebugLayerTab;
  119322. }
  119323. interface Scene {
  119324. /**
  119325. * @hidden
  119326. * Backing field
  119327. */
  119328. _debugLayer: DebugLayer;
  119329. /**
  119330. * Gets the debug layer (aka Inspector) associated with the scene
  119331. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119332. */
  119333. debugLayer: DebugLayer;
  119334. }
  119335. /**
  119336. * Enum of inspector action tab
  119337. */
  119338. export enum DebugLayerTab {
  119339. /**
  119340. * Properties tag (default)
  119341. */
  119342. Properties = 0,
  119343. /**
  119344. * Debug tab
  119345. */
  119346. Debug = 1,
  119347. /**
  119348. * Statistics tab
  119349. */
  119350. Statistics = 2,
  119351. /**
  119352. * Tools tab
  119353. */
  119354. Tools = 3,
  119355. /**
  119356. * Settings tab
  119357. */
  119358. Settings = 4
  119359. }
  119360. /**
  119361. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119362. * what is happening in your scene
  119363. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119364. */
  119365. export class DebugLayer {
  119366. /**
  119367. * Define the url to get the inspector script from.
  119368. * By default it uses the babylonjs CDN.
  119369. * @ignoreNaming
  119370. */
  119371. static InspectorURL: string;
  119372. private _scene;
  119373. private BJSINSPECTOR;
  119374. private _onPropertyChangedObservable?;
  119375. /**
  119376. * Observable triggered when a property is changed through the inspector.
  119377. */
  119378. get onPropertyChangedObservable(): any;
  119379. /**
  119380. * Instantiates a new debug layer.
  119381. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119382. * what is happening in your scene
  119383. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119384. * @param scene Defines the scene to inspect
  119385. */
  119386. constructor(scene: Scene);
  119387. /** Creates the inspector window. */
  119388. private _createInspector;
  119389. /**
  119390. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119391. * @param entity defines the entity to select
  119392. * @param lineContainerTitle defines the specific block to highlight
  119393. */
  119394. select(entity: any, lineContainerTitle?: string): void;
  119395. /** Get the inspector from bundle or global */
  119396. private _getGlobalInspector;
  119397. /**
  119398. * Get if the inspector is visible or not.
  119399. * @returns true if visible otherwise, false
  119400. */
  119401. isVisible(): boolean;
  119402. /**
  119403. * Hide the inspector and close its window.
  119404. */
  119405. hide(): void;
  119406. /**
  119407. * Launch the debugLayer.
  119408. * @param config Define the configuration of the inspector
  119409. * @return a promise fulfilled when the debug layer is visible
  119410. */
  119411. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119412. }
  119413. }
  119414. declare module BABYLON {
  119415. /**
  119416. * Class containing static functions to help procedurally build meshes
  119417. */
  119418. export class BoxBuilder {
  119419. /**
  119420. * Creates a box mesh
  119421. * * The parameter `size` sets the size (float) of each box side (default 1)
  119422. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119423. * * 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)
  119424. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119428. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119429. * @param name defines the name of the mesh
  119430. * @param options defines the options used to create the mesh
  119431. * @param scene defines the hosting scene
  119432. * @returns the box mesh
  119433. */
  119434. static CreateBox(name: string, options: {
  119435. size?: number;
  119436. width?: number;
  119437. height?: number;
  119438. depth?: number;
  119439. faceUV?: Vector4[];
  119440. faceColors?: Color4[];
  119441. sideOrientation?: number;
  119442. frontUVs?: Vector4;
  119443. backUVs?: Vector4;
  119444. wrap?: boolean;
  119445. topBaseAt?: number;
  119446. bottomBaseAt?: number;
  119447. updatable?: boolean;
  119448. }, scene?: Nullable<Scene>): Mesh;
  119449. }
  119450. }
  119451. declare module BABYLON.Debug {
  119452. /**
  119453. * Used to show the physics impostor around the specific mesh
  119454. */
  119455. export class PhysicsViewer {
  119456. /** @hidden */
  119457. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119458. /** @hidden */
  119459. protected _meshes: Array<Nullable<AbstractMesh>>;
  119460. /** @hidden */
  119461. protected _scene: Nullable<Scene>;
  119462. /** @hidden */
  119463. protected _numMeshes: number;
  119464. /** @hidden */
  119465. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119466. private _renderFunction;
  119467. private _utilityLayer;
  119468. private _debugBoxMesh;
  119469. private _debugSphereMesh;
  119470. private _debugCylinderMesh;
  119471. private _debugMaterial;
  119472. private _debugMeshMeshes;
  119473. /**
  119474. * Creates a new PhysicsViewer
  119475. * @param scene defines the hosting scene
  119476. */
  119477. constructor(scene: Scene);
  119478. /** @hidden */
  119479. protected _updateDebugMeshes(): void;
  119480. /**
  119481. * Renders a specified physic impostor
  119482. * @param impostor defines the impostor to render
  119483. * @param targetMesh defines the mesh represented by the impostor
  119484. * @returns the new debug mesh used to render the impostor
  119485. */
  119486. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119487. /**
  119488. * Hides a specified physic impostor
  119489. * @param impostor defines the impostor to hide
  119490. */
  119491. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119492. private _getDebugMaterial;
  119493. private _getDebugBoxMesh;
  119494. private _getDebugSphereMesh;
  119495. private _getDebugCylinderMesh;
  119496. private _getDebugMeshMesh;
  119497. private _getDebugMesh;
  119498. /** Releases all resources */
  119499. dispose(): void;
  119500. }
  119501. }
  119502. declare module BABYLON {
  119503. /**
  119504. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119505. * in order to better appreciate the issue one might have.
  119506. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119507. */
  119508. export class RayHelper {
  119509. /**
  119510. * Defines the ray we are currently tryin to visualize.
  119511. */
  119512. ray: Nullable<Ray>;
  119513. private _renderPoints;
  119514. private _renderLine;
  119515. private _renderFunction;
  119516. private _scene;
  119517. private _updateToMeshFunction;
  119518. private _attachedToMesh;
  119519. private _meshSpaceDirection;
  119520. private _meshSpaceOrigin;
  119521. /**
  119522. * Helper function to create a colored helper in a scene in one line.
  119523. * @param ray Defines the ray we are currently tryin to visualize
  119524. * @param scene Defines the scene the ray is used in
  119525. * @param color Defines the color we want to see the ray in
  119526. * @returns The newly created ray helper.
  119527. */
  119528. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119529. /**
  119530. * Instantiate a new ray helper.
  119531. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119532. * in order to better appreciate the issue one might have.
  119533. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119534. * @param ray Defines the ray we are currently tryin to visualize
  119535. */
  119536. constructor(ray: Ray);
  119537. /**
  119538. * Shows the ray we are willing to debug.
  119539. * @param scene Defines the scene the ray needs to be rendered in
  119540. * @param color Defines the color the ray needs to be rendered in
  119541. */
  119542. show(scene: Scene, color?: Color3): void;
  119543. /**
  119544. * Hides the ray we are debugging.
  119545. */
  119546. hide(): void;
  119547. private _render;
  119548. /**
  119549. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119550. * @param mesh Defines the mesh we want the helper attached to
  119551. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119552. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119553. * @param length Defines the length of the ray
  119554. */
  119555. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119556. /**
  119557. * Detach the ray helper from the mesh it has previously been attached to.
  119558. */
  119559. detachFromMesh(): void;
  119560. private _updateToMesh;
  119561. /**
  119562. * Dispose the helper and release its associated resources.
  119563. */
  119564. dispose(): void;
  119565. }
  119566. }
  119567. declare module BABYLON.Debug {
  119568. /**
  119569. * Class used to render a debug view of a given skeleton
  119570. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119571. */
  119572. export class SkeletonViewer {
  119573. /** defines the skeleton to render */
  119574. skeleton: Skeleton;
  119575. /** defines the mesh attached to the skeleton */
  119576. mesh: AbstractMesh;
  119577. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119578. autoUpdateBonesMatrices: boolean;
  119579. /** defines the rendering group id to use with the viewer */
  119580. renderingGroupId: number;
  119581. /** Gets or sets the color used to render the skeleton */
  119582. color: Color3;
  119583. private _scene;
  119584. private _debugLines;
  119585. private _debugMesh;
  119586. private _isEnabled;
  119587. private _renderFunction;
  119588. private _utilityLayer;
  119589. /**
  119590. * Returns the mesh used to render the bones
  119591. */
  119592. get debugMesh(): Nullable<LinesMesh>;
  119593. /**
  119594. * Creates a new SkeletonViewer
  119595. * @param skeleton defines the skeleton to render
  119596. * @param mesh defines the mesh attached to the skeleton
  119597. * @param scene defines the hosting scene
  119598. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119599. * @param renderingGroupId defines the rendering group id to use with the viewer
  119600. */
  119601. constructor(
  119602. /** defines the skeleton to render */
  119603. skeleton: Skeleton,
  119604. /** defines the mesh attached to the skeleton */
  119605. mesh: AbstractMesh, scene: Scene,
  119606. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119607. autoUpdateBonesMatrices?: boolean,
  119608. /** defines the rendering group id to use with the viewer */
  119609. renderingGroupId?: number);
  119610. /** Gets or sets a boolean indicating if the viewer is enabled */
  119611. set isEnabled(value: boolean);
  119612. get isEnabled(): boolean;
  119613. private _getBonePosition;
  119614. private _getLinesForBonesWithLength;
  119615. private _getLinesForBonesNoLength;
  119616. /** Update the viewer to sync with current skeleton state */
  119617. update(): void;
  119618. /** Release associated resources */
  119619. dispose(): void;
  119620. }
  119621. }
  119622. declare module BABYLON {
  119623. /**
  119624. * Options to create the null engine
  119625. */
  119626. export class NullEngineOptions {
  119627. /**
  119628. * Render width (Default: 512)
  119629. */
  119630. renderWidth: number;
  119631. /**
  119632. * Render height (Default: 256)
  119633. */
  119634. renderHeight: number;
  119635. /**
  119636. * Texture size (Default: 512)
  119637. */
  119638. textureSize: number;
  119639. /**
  119640. * If delta time between frames should be constant
  119641. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119642. */
  119643. deterministicLockstep: boolean;
  119644. /**
  119645. * Maximum about of steps between frames (Default: 4)
  119646. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119647. */
  119648. lockstepMaxSteps: number;
  119649. }
  119650. /**
  119651. * The null engine class provides support for headless version of babylon.js.
  119652. * This can be used in server side scenario or for testing purposes
  119653. */
  119654. export class NullEngine extends Engine {
  119655. private _options;
  119656. /**
  119657. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119659. * @returns true if engine is in deterministic lock step mode
  119660. */
  119661. isDeterministicLockStep(): boolean;
  119662. /**
  119663. * Gets the max steps when engine is running in deterministic lock step
  119664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119665. * @returns the max steps
  119666. */
  119667. getLockstepMaxSteps(): number;
  119668. /**
  119669. * Gets the current hardware scaling level.
  119670. * By default the hardware scaling level is computed from the window device ratio.
  119671. * 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.
  119672. * @returns a number indicating the current hardware scaling level
  119673. */
  119674. getHardwareScalingLevel(): number;
  119675. constructor(options?: NullEngineOptions);
  119676. /**
  119677. * Creates a vertex buffer
  119678. * @param vertices the data for the vertex buffer
  119679. * @returns the new WebGL static buffer
  119680. */
  119681. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119682. /**
  119683. * Creates a new index buffer
  119684. * @param indices defines the content of the index buffer
  119685. * @param updatable defines if the index buffer must be updatable
  119686. * @returns a new webGL buffer
  119687. */
  119688. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119689. /**
  119690. * Clear the current render buffer or the current render target (if any is set up)
  119691. * @param color defines the color to use
  119692. * @param backBuffer defines if the back buffer must be cleared
  119693. * @param depth defines if the depth buffer must be cleared
  119694. * @param stencil defines if the stencil buffer must be cleared
  119695. */
  119696. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119697. /**
  119698. * Gets the current render width
  119699. * @param useScreen defines if screen size must be used (or the current render target if any)
  119700. * @returns a number defining the current render width
  119701. */
  119702. getRenderWidth(useScreen?: boolean): number;
  119703. /**
  119704. * Gets the current render height
  119705. * @param useScreen defines if screen size must be used (or the current render target if any)
  119706. * @returns a number defining the current render height
  119707. */
  119708. getRenderHeight(useScreen?: boolean): number;
  119709. /**
  119710. * Set the WebGL's viewport
  119711. * @param viewport defines the viewport element to be used
  119712. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119713. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119714. */
  119715. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119717. /**
  119718. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119719. * @param pipelineContext defines the pipeline context to use
  119720. * @param uniformsNames defines the list of uniform names
  119721. * @returns an array of webGL uniform locations
  119722. */
  119723. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119724. /**
  119725. * Gets the lsit of active attributes for a given webGL program
  119726. * @param pipelineContext defines the pipeline context to use
  119727. * @param attributesNames defines the list of attribute names to get
  119728. * @returns an array of indices indicating the offset of each attribute
  119729. */
  119730. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119731. /**
  119732. * Binds an effect to the webGL context
  119733. * @param effect defines the effect to bind
  119734. */
  119735. bindSamplers(effect: Effect): void;
  119736. /**
  119737. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119738. * @param effect defines the effect to activate
  119739. */
  119740. enableEffect(effect: Effect): void;
  119741. /**
  119742. * Set various states to the webGL context
  119743. * @param culling defines backface culling state
  119744. * @param zOffset defines the value to apply to zOffset (0 by default)
  119745. * @param force defines if states must be applied even if cache is up to date
  119746. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119747. */
  119748. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119749. /**
  119750. * Set the value of an uniform to an array of int32
  119751. * @param uniform defines the webGL uniform location where to store the value
  119752. * @param array defines the array of int32 to store
  119753. */
  119754. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119755. /**
  119756. * Set the value of an uniform to an array of int32 (stored as vec2)
  119757. * @param uniform defines the webGL uniform location where to store the value
  119758. * @param array defines the array of int32 to store
  119759. */
  119760. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119761. /**
  119762. * Set the value of an uniform to an array of int32 (stored as vec3)
  119763. * @param uniform defines the webGL uniform location where to store the value
  119764. * @param array defines the array of int32 to store
  119765. */
  119766. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119767. /**
  119768. * Set the value of an uniform to an array of int32 (stored as vec4)
  119769. * @param uniform defines the webGL uniform location where to store the value
  119770. * @param array defines the array of int32 to store
  119771. */
  119772. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119773. /**
  119774. * Set the value of an uniform to an array of float32
  119775. * @param uniform defines the webGL uniform location where to store the value
  119776. * @param array defines the array of float32 to store
  119777. */
  119778. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119779. /**
  119780. * Set the value of an uniform to an array of float32 (stored as vec2)
  119781. * @param uniform defines the webGL uniform location where to store the value
  119782. * @param array defines the array of float32 to store
  119783. */
  119784. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119785. /**
  119786. * Set the value of an uniform to an array of float32 (stored as vec3)
  119787. * @param uniform defines the webGL uniform location where to store the value
  119788. * @param array defines the array of float32 to store
  119789. */
  119790. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119791. /**
  119792. * Set the value of an uniform to an array of float32 (stored as vec4)
  119793. * @param uniform defines the webGL uniform location where to store the value
  119794. * @param array defines the array of float32 to store
  119795. */
  119796. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119797. /**
  119798. * Set the value of an uniform to an array of number
  119799. * @param uniform defines the webGL uniform location where to store the value
  119800. * @param array defines the array of number to store
  119801. */
  119802. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119803. /**
  119804. * Set the value of an uniform to an array of number (stored as vec2)
  119805. * @param uniform defines the webGL uniform location where to store the value
  119806. * @param array defines the array of number to store
  119807. */
  119808. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119809. /**
  119810. * Set the value of an uniform to an array of number (stored as vec3)
  119811. * @param uniform defines the webGL uniform location where to store the value
  119812. * @param array defines the array of number to store
  119813. */
  119814. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119815. /**
  119816. * Set the value of an uniform to an array of number (stored as vec4)
  119817. * @param uniform defines the webGL uniform location where to store the value
  119818. * @param array defines the array of number to store
  119819. */
  119820. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119821. /**
  119822. * Set the value of an uniform to an array of float32 (stored as matrices)
  119823. * @param uniform defines the webGL uniform location where to store the value
  119824. * @param matrices defines the array of float32 to store
  119825. */
  119826. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119827. /**
  119828. * Set the value of an uniform to a matrix (3x3)
  119829. * @param uniform defines the webGL uniform location where to store the value
  119830. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119831. */
  119832. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119833. /**
  119834. * Set the value of an uniform to a matrix (2x2)
  119835. * @param uniform defines the webGL uniform location where to store the value
  119836. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119837. */
  119838. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119839. /**
  119840. * Set the value of an uniform to a number (float)
  119841. * @param uniform defines the webGL uniform location where to store the value
  119842. * @param value defines the float number to store
  119843. */
  119844. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119845. /**
  119846. * Set the value of an uniform to a vec2
  119847. * @param uniform defines the webGL uniform location where to store the value
  119848. * @param x defines the 1st component of the value
  119849. * @param y defines the 2nd component of the value
  119850. */
  119851. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119852. /**
  119853. * Set the value of an uniform to a vec3
  119854. * @param uniform defines the webGL uniform location where to store the value
  119855. * @param x defines the 1st component of the value
  119856. * @param y defines the 2nd component of the value
  119857. * @param z defines the 3rd component of the value
  119858. */
  119859. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119860. /**
  119861. * Set the value of an uniform to a boolean
  119862. * @param uniform defines the webGL uniform location where to store the value
  119863. * @param bool defines the boolean to store
  119864. */
  119865. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119866. /**
  119867. * Set the value of an uniform to a vec4
  119868. * @param uniform defines the webGL uniform location where to store the value
  119869. * @param x defines the 1st component of the value
  119870. * @param y defines the 2nd component of the value
  119871. * @param z defines the 3rd component of the value
  119872. * @param w defines the 4th component of the value
  119873. */
  119874. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119875. /**
  119876. * Sets the current alpha mode
  119877. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119878. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119879. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119880. */
  119881. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119882. /**
  119883. * Bind webGl buffers directly to the webGL context
  119884. * @param vertexBuffers defines the vertex buffer to bind
  119885. * @param indexBuffer defines the index buffer to bind
  119886. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119887. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119888. * @param effect defines the effect associated with the vertex buffer
  119889. */
  119890. bindBuffers(vertexBuffers: {
  119891. [key: string]: VertexBuffer;
  119892. }, indexBuffer: DataBuffer, effect: Effect): void;
  119893. /**
  119894. * Force the entire cache to be cleared
  119895. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119896. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119897. */
  119898. wipeCaches(bruteForce?: boolean): void;
  119899. /**
  119900. * Send a draw order
  119901. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119902. * @param indexStart defines the starting index
  119903. * @param indexCount defines the number of index to draw
  119904. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119905. */
  119906. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119907. /**
  119908. * Draw a list of indexed primitives
  119909. * @param fillMode defines the primitive to use
  119910. * @param indexStart defines the starting index
  119911. * @param indexCount defines the number of index to draw
  119912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119913. */
  119914. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119915. /**
  119916. * Draw a list of unindexed primitives
  119917. * @param fillMode defines the primitive to use
  119918. * @param verticesStart defines the index of first vertex to draw
  119919. * @param verticesCount defines the count of vertices to draw
  119920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119921. */
  119922. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119923. /** @hidden */
  119924. _createTexture(): WebGLTexture;
  119925. /** @hidden */
  119926. _releaseTexture(texture: InternalTexture): void;
  119927. /**
  119928. * Usually called from Texture.ts.
  119929. * Passed information to create a WebGLTexture
  119930. * @param urlArg defines a value which contains one of the following:
  119931. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119932. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119933. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119934. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119935. * @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)
  119936. * @param scene needed for loading to the correct scene
  119937. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119938. * @param onLoad optional callback to be called upon successful completion
  119939. * @param onError optional callback to be called upon failure
  119940. * @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
  119941. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119942. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119943. * @param forcedExtension defines the extension to use to pick the right loader
  119944. * @param mimeType defines an optional mime type
  119945. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119946. */
  119947. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  119948. /**
  119949. * Creates a new render target texture
  119950. * @param size defines the size of the texture
  119951. * @param options defines the options used to create the texture
  119952. * @returns a new render target texture stored in an InternalTexture
  119953. */
  119954. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119955. /**
  119956. * Update the sampling mode of a given texture
  119957. * @param samplingMode defines the required sampling mode
  119958. * @param texture defines the texture to update
  119959. */
  119960. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119961. /**
  119962. * Binds the frame buffer to the specified texture.
  119963. * @param texture The texture to render to or null for the default canvas
  119964. * @param faceIndex The face of the texture to render to in case of cube texture
  119965. * @param requiredWidth The width of the target to render to
  119966. * @param requiredHeight The height of the target to render to
  119967. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119968. * @param lodLevel defines le lod level to bind to the frame buffer
  119969. */
  119970. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119971. /**
  119972. * Unbind the current render target texture from the webGL context
  119973. * @param texture defines the render target texture to unbind
  119974. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119975. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119976. */
  119977. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119978. /**
  119979. * Creates a dynamic vertex buffer
  119980. * @param vertices the data for the dynamic vertex buffer
  119981. * @returns the new WebGL dynamic buffer
  119982. */
  119983. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119984. /**
  119985. * Update the content of a dynamic texture
  119986. * @param texture defines the texture to update
  119987. * @param canvas defines the canvas containing the source
  119988. * @param invertY defines if data must be stored with Y axis inverted
  119989. * @param premulAlpha defines if alpha is stored as premultiplied
  119990. * @param format defines the format of the data
  119991. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119992. */
  119993. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119994. /**
  119995. * Gets a boolean indicating if all created effects are ready
  119996. * @returns true if all effects are ready
  119997. */
  119998. areAllEffectsReady(): boolean;
  119999. /**
  120000. * @hidden
  120001. * Get the current error code of the webGL context
  120002. * @returns the error code
  120003. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120004. */
  120005. getError(): number;
  120006. /** @hidden */
  120007. _getUnpackAlignement(): number;
  120008. /** @hidden */
  120009. _unpackFlipY(value: boolean): void;
  120010. /**
  120011. * Update a dynamic index buffer
  120012. * @param indexBuffer defines the target index buffer
  120013. * @param indices defines the data to update
  120014. * @param offset defines the offset in the target index buffer where update should start
  120015. */
  120016. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120017. /**
  120018. * Updates a dynamic vertex buffer.
  120019. * @param vertexBuffer the vertex buffer to update
  120020. * @param vertices the data used to update the vertex buffer
  120021. * @param byteOffset the byte offset of the data (optional)
  120022. * @param byteLength the byte length of the data (optional)
  120023. */
  120024. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120025. /** @hidden */
  120026. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120027. /** @hidden */
  120028. _bindTexture(channel: number, texture: InternalTexture): void;
  120029. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120030. /**
  120031. * 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
  120032. */
  120033. releaseEffects(): void;
  120034. displayLoadingUI(): void;
  120035. hideLoadingUI(): void;
  120036. /** @hidden */
  120037. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120038. /** @hidden */
  120039. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120040. /** @hidden */
  120041. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120042. /** @hidden */
  120043. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120044. }
  120045. }
  120046. declare module BABYLON {
  120047. /**
  120048. * @hidden
  120049. **/
  120050. export class _TimeToken {
  120051. _startTimeQuery: Nullable<WebGLQuery>;
  120052. _endTimeQuery: Nullable<WebGLQuery>;
  120053. _timeElapsedQuery: Nullable<WebGLQuery>;
  120054. _timeElapsedQueryEnded: boolean;
  120055. }
  120056. }
  120057. declare module BABYLON {
  120058. /** @hidden */
  120059. export class _OcclusionDataStorage {
  120060. /** @hidden */
  120061. occlusionInternalRetryCounter: number;
  120062. /** @hidden */
  120063. isOcclusionQueryInProgress: boolean;
  120064. /** @hidden */
  120065. isOccluded: boolean;
  120066. /** @hidden */
  120067. occlusionRetryCount: number;
  120068. /** @hidden */
  120069. occlusionType: number;
  120070. /** @hidden */
  120071. occlusionQueryAlgorithmType: number;
  120072. }
  120073. interface Engine {
  120074. /**
  120075. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120076. * @return the new query
  120077. */
  120078. createQuery(): WebGLQuery;
  120079. /**
  120080. * Delete and release a webGL query
  120081. * @param query defines the query to delete
  120082. * @return the current engine
  120083. */
  120084. deleteQuery(query: WebGLQuery): Engine;
  120085. /**
  120086. * Check if a given query has resolved and got its value
  120087. * @param query defines the query to check
  120088. * @returns true if the query got its value
  120089. */
  120090. isQueryResultAvailable(query: WebGLQuery): boolean;
  120091. /**
  120092. * Gets the value of a given query
  120093. * @param query defines the query to check
  120094. * @returns the value of the query
  120095. */
  120096. getQueryResult(query: WebGLQuery): number;
  120097. /**
  120098. * Initiates an occlusion query
  120099. * @param algorithmType defines the algorithm to use
  120100. * @param query defines the query to use
  120101. * @returns the current engine
  120102. * @see http://doc.babylonjs.com/features/occlusionquery
  120103. */
  120104. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120105. /**
  120106. * Ends an occlusion query
  120107. * @see http://doc.babylonjs.com/features/occlusionquery
  120108. * @param algorithmType defines the algorithm to use
  120109. * @returns the current engine
  120110. */
  120111. endOcclusionQuery(algorithmType: number): Engine;
  120112. /**
  120113. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120114. * Please note that only one query can be issued at a time
  120115. * @returns a time token used to track the time span
  120116. */
  120117. startTimeQuery(): Nullable<_TimeToken>;
  120118. /**
  120119. * Ends a time query
  120120. * @param token defines the token used to measure the time span
  120121. * @returns the time spent (in ns)
  120122. */
  120123. endTimeQuery(token: _TimeToken): int;
  120124. /** @hidden */
  120125. _currentNonTimestampToken: Nullable<_TimeToken>;
  120126. /** @hidden */
  120127. _createTimeQuery(): WebGLQuery;
  120128. /** @hidden */
  120129. _deleteTimeQuery(query: WebGLQuery): void;
  120130. /** @hidden */
  120131. _getGlAlgorithmType(algorithmType: number): number;
  120132. /** @hidden */
  120133. _getTimeQueryResult(query: WebGLQuery): any;
  120134. /** @hidden */
  120135. _getTimeQueryAvailability(query: WebGLQuery): any;
  120136. }
  120137. interface AbstractMesh {
  120138. /**
  120139. * Backing filed
  120140. * @hidden
  120141. */
  120142. __occlusionDataStorage: _OcclusionDataStorage;
  120143. /**
  120144. * Access property
  120145. * @hidden
  120146. */
  120147. _occlusionDataStorage: _OcclusionDataStorage;
  120148. /**
  120149. * 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.
  120150. * The default value is -1 which means don't break the query and wait till the result
  120151. * @see http://doc.babylonjs.com/features/occlusionquery
  120152. */
  120153. occlusionRetryCount: number;
  120154. /**
  120155. * 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:
  120156. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120157. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120158. * * 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.
  120159. * @see http://doc.babylonjs.com/features/occlusionquery
  120160. */
  120161. occlusionType: number;
  120162. /**
  120163. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120164. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120165. * * 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.
  120166. * @see http://doc.babylonjs.com/features/occlusionquery
  120167. */
  120168. occlusionQueryAlgorithmType: number;
  120169. /**
  120170. * 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
  120171. * @see http://doc.babylonjs.com/features/occlusionquery
  120172. */
  120173. isOccluded: boolean;
  120174. /**
  120175. * Flag to check the progress status of the query
  120176. * @see http://doc.babylonjs.com/features/occlusionquery
  120177. */
  120178. isOcclusionQueryInProgress: boolean;
  120179. }
  120180. }
  120181. declare module BABYLON {
  120182. /** @hidden */
  120183. export var _forceTransformFeedbackToBundle: boolean;
  120184. interface Engine {
  120185. /**
  120186. * Creates a webGL transform feedback object
  120187. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120188. * @returns the webGL transform feedback object
  120189. */
  120190. createTransformFeedback(): WebGLTransformFeedback;
  120191. /**
  120192. * Delete a webGL transform feedback object
  120193. * @param value defines the webGL transform feedback object to delete
  120194. */
  120195. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120196. /**
  120197. * Bind a webGL transform feedback object to the webgl context
  120198. * @param value defines the webGL transform feedback object to bind
  120199. */
  120200. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120201. /**
  120202. * Begins a transform feedback operation
  120203. * @param usePoints defines if points or triangles must be used
  120204. */
  120205. beginTransformFeedback(usePoints: boolean): void;
  120206. /**
  120207. * Ends a transform feedback operation
  120208. */
  120209. endTransformFeedback(): void;
  120210. /**
  120211. * Specify the varyings to use with transform feedback
  120212. * @param program defines the associated webGL program
  120213. * @param value defines the list of strings representing the varying names
  120214. */
  120215. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120216. /**
  120217. * Bind a webGL buffer for a transform feedback operation
  120218. * @param value defines the webGL buffer to bind
  120219. */
  120220. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120221. }
  120222. }
  120223. declare module BABYLON {
  120224. /**
  120225. * Creation options of the multi render target texture.
  120226. */
  120227. export interface IMultiRenderTargetOptions {
  120228. /**
  120229. * Define if the texture needs to create mip maps after render.
  120230. */
  120231. generateMipMaps?: boolean;
  120232. /**
  120233. * Define the types of all the draw buffers we want to create
  120234. */
  120235. types?: number[];
  120236. /**
  120237. * Define the sampling modes of all the draw buffers we want to create
  120238. */
  120239. samplingModes?: number[];
  120240. /**
  120241. * Define if a depth buffer is required
  120242. */
  120243. generateDepthBuffer?: boolean;
  120244. /**
  120245. * Define if a stencil buffer is required
  120246. */
  120247. generateStencilBuffer?: boolean;
  120248. /**
  120249. * Define if a depth texture is required instead of a depth buffer
  120250. */
  120251. generateDepthTexture?: boolean;
  120252. /**
  120253. * Define the number of desired draw buffers
  120254. */
  120255. textureCount?: number;
  120256. /**
  120257. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120258. */
  120259. doNotChangeAspectRatio?: boolean;
  120260. /**
  120261. * Define the default type of the buffers we are creating
  120262. */
  120263. defaultType?: number;
  120264. }
  120265. /**
  120266. * A multi render target, like a render target provides the ability to render to a texture.
  120267. * Unlike the render target, it can render to several draw buffers in one draw.
  120268. * This is specially interesting in deferred rendering or for any effects requiring more than
  120269. * just one color from a single pass.
  120270. */
  120271. export class MultiRenderTarget extends RenderTargetTexture {
  120272. private _internalTextures;
  120273. private _textures;
  120274. private _multiRenderTargetOptions;
  120275. /**
  120276. * Get if draw buffers are currently supported by the used hardware and browser.
  120277. */
  120278. get isSupported(): boolean;
  120279. /**
  120280. * Get the list of textures generated by the multi render target.
  120281. */
  120282. get textures(): Texture[];
  120283. /**
  120284. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120285. */
  120286. get depthTexture(): Texture;
  120287. /**
  120288. * Set the wrapping mode on U of all the textures we are rendering to.
  120289. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120290. */
  120291. set wrapU(wrap: number);
  120292. /**
  120293. * Set the wrapping mode on V of all the textures we are rendering to.
  120294. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120295. */
  120296. set wrapV(wrap: number);
  120297. /**
  120298. * Instantiate a new multi render target texture.
  120299. * A multi render target, like a render target provides the ability to render to a texture.
  120300. * Unlike the render target, it can render to several draw buffers in one draw.
  120301. * This is specially interesting in deferred rendering or for any effects requiring more than
  120302. * just one color from a single pass.
  120303. * @param name Define the name of the texture
  120304. * @param size Define the size of the buffers to render to
  120305. * @param count Define the number of target we are rendering into
  120306. * @param scene Define the scene the texture belongs to
  120307. * @param options Define the options used to create the multi render target
  120308. */
  120309. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120310. /** @hidden */
  120311. _rebuild(): void;
  120312. private _createInternalTextures;
  120313. private _createTextures;
  120314. /**
  120315. * Define the number of samples used if MSAA is enabled.
  120316. */
  120317. get samples(): number;
  120318. set samples(value: number);
  120319. /**
  120320. * Resize all the textures in the multi render target.
  120321. * Be carrefull as it will recreate all the data in the new texture.
  120322. * @param size Define the new size
  120323. */
  120324. resize(size: any): void;
  120325. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120326. /**
  120327. * Dispose the render targets and their associated resources
  120328. */
  120329. dispose(): void;
  120330. /**
  120331. * Release all the underlying texture used as draw buffers.
  120332. */
  120333. releaseInternalTextures(): void;
  120334. }
  120335. }
  120336. declare module BABYLON {
  120337. interface ThinEngine {
  120338. /**
  120339. * Unbind a list of render target textures from the webGL context
  120340. * This is used only when drawBuffer extension or webGL2 are active
  120341. * @param textures defines the render target textures to unbind
  120342. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120343. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120344. */
  120345. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120346. /**
  120347. * Create a multi render target texture
  120348. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120349. * @param size defines the size of the texture
  120350. * @param options defines the creation options
  120351. * @returns the cube texture as an InternalTexture
  120352. */
  120353. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120354. /**
  120355. * Update the sample count for a given multiple render target texture
  120356. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120357. * @param textures defines the textures to update
  120358. * @param samples defines the sample count to set
  120359. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120360. */
  120361. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120362. }
  120363. }
  120364. declare module BABYLON {
  120365. /**
  120366. * Class used to define an additional view for the engine
  120367. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120368. */
  120369. export class EngineView {
  120370. /** Defines the canvas where to render the view */
  120371. target: HTMLCanvasElement;
  120372. /** Defines an optional camera used to render the view (will use active camera else) */
  120373. camera?: Camera;
  120374. }
  120375. interface Engine {
  120376. /**
  120377. * Gets or sets the HTML element to use for attaching events
  120378. */
  120379. inputElement: Nullable<HTMLElement>;
  120380. /**
  120381. * Gets the current engine view
  120382. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120383. */
  120384. activeView: Nullable<EngineView>;
  120385. /** Gets or sets the list of views */
  120386. views: EngineView[];
  120387. /**
  120388. * Register a new child canvas
  120389. * @param canvas defines the canvas to register
  120390. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120391. * @returns the associated view
  120392. */
  120393. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120394. /**
  120395. * Remove a registered child canvas
  120396. * @param canvas defines the canvas to remove
  120397. * @returns the current engine
  120398. */
  120399. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120400. }
  120401. }
  120402. declare module BABYLON {
  120403. /**
  120404. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120405. */
  120406. export interface CubeMapInfo {
  120407. /**
  120408. * The pixel array for the front face.
  120409. * This is stored in format, left to right, up to down format.
  120410. */
  120411. front: Nullable<ArrayBufferView>;
  120412. /**
  120413. * The pixel array for the back face.
  120414. * This is stored in format, left to right, up to down format.
  120415. */
  120416. back: Nullable<ArrayBufferView>;
  120417. /**
  120418. * The pixel array for the left face.
  120419. * This is stored in format, left to right, up to down format.
  120420. */
  120421. left: Nullable<ArrayBufferView>;
  120422. /**
  120423. * The pixel array for the right face.
  120424. * This is stored in format, left to right, up to down format.
  120425. */
  120426. right: Nullable<ArrayBufferView>;
  120427. /**
  120428. * The pixel array for the up face.
  120429. * This is stored in format, left to right, up to down format.
  120430. */
  120431. up: Nullable<ArrayBufferView>;
  120432. /**
  120433. * The pixel array for the down face.
  120434. * This is stored in format, left to right, up to down format.
  120435. */
  120436. down: Nullable<ArrayBufferView>;
  120437. /**
  120438. * The size of the cubemap stored.
  120439. *
  120440. * Each faces will be size * size pixels.
  120441. */
  120442. size: number;
  120443. /**
  120444. * The format of the texture.
  120445. *
  120446. * RGBA, RGB.
  120447. */
  120448. format: number;
  120449. /**
  120450. * The type of the texture data.
  120451. *
  120452. * UNSIGNED_INT, FLOAT.
  120453. */
  120454. type: number;
  120455. /**
  120456. * Specifies whether the texture is in gamma space.
  120457. */
  120458. gammaSpace: boolean;
  120459. }
  120460. /**
  120461. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120462. */
  120463. export class PanoramaToCubeMapTools {
  120464. private static FACE_FRONT;
  120465. private static FACE_BACK;
  120466. private static FACE_RIGHT;
  120467. private static FACE_LEFT;
  120468. private static FACE_DOWN;
  120469. private static FACE_UP;
  120470. /**
  120471. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120472. *
  120473. * @param float32Array The source data.
  120474. * @param inputWidth The width of the input panorama.
  120475. * @param inputHeight The height of the input panorama.
  120476. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120477. * @return The cubemap data
  120478. */
  120479. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120480. private static CreateCubemapTexture;
  120481. private static CalcProjectionSpherical;
  120482. }
  120483. }
  120484. declare module BABYLON {
  120485. /**
  120486. * Helper class dealing with the extraction of spherical polynomial dataArray
  120487. * from a cube map.
  120488. */
  120489. export class CubeMapToSphericalPolynomialTools {
  120490. private static FileFaces;
  120491. /**
  120492. * Converts a texture to the according Spherical Polynomial data.
  120493. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120494. *
  120495. * @param texture The texture to extract the information from.
  120496. * @return The Spherical Polynomial data.
  120497. */
  120498. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120499. /**
  120500. * Converts a cubemap to the according Spherical Polynomial data.
  120501. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120502. *
  120503. * @param cubeInfo The Cube map to extract the information from.
  120504. * @return The Spherical Polynomial data.
  120505. */
  120506. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120507. }
  120508. }
  120509. declare module BABYLON {
  120510. interface BaseTexture {
  120511. /**
  120512. * Get the polynomial representation of the texture data.
  120513. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120514. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120515. */
  120516. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120517. }
  120518. }
  120519. declare module BABYLON {
  120520. /** @hidden */
  120521. export var rgbdEncodePixelShader: {
  120522. name: string;
  120523. shader: string;
  120524. };
  120525. }
  120526. declare module BABYLON {
  120527. /** @hidden */
  120528. export var rgbdDecodePixelShader: {
  120529. name: string;
  120530. shader: string;
  120531. };
  120532. }
  120533. declare module BABYLON {
  120534. /**
  120535. * Raw texture data and descriptor sufficient for WebGL texture upload
  120536. */
  120537. export interface EnvironmentTextureInfo {
  120538. /**
  120539. * Version of the environment map
  120540. */
  120541. version: number;
  120542. /**
  120543. * Width of image
  120544. */
  120545. width: number;
  120546. /**
  120547. * Irradiance information stored in the file.
  120548. */
  120549. irradiance: any;
  120550. /**
  120551. * Specular information stored in the file.
  120552. */
  120553. specular: any;
  120554. }
  120555. /**
  120556. * Defines One Image in the file. It requires only the position in the file
  120557. * as well as the length.
  120558. */
  120559. interface BufferImageData {
  120560. /**
  120561. * Length of the image data.
  120562. */
  120563. length: number;
  120564. /**
  120565. * Position of the data from the null terminator delimiting the end of the JSON.
  120566. */
  120567. position: number;
  120568. }
  120569. /**
  120570. * Defines the specular data enclosed in the file.
  120571. * This corresponds to the version 1 of the data.
  120572. */
  120573. export interface EnvironmentTextureSpecularInfoV1 {
  120574. /**
  120575. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120576. */
  120577. specularDataPosition?: number;
  120578. /**
  120579. * This contains all the images data needed to reconstruct the cubemap.
  120580. */
  120581. mipmaps: Array<BufferImageData>;
  120582. /**
  120583. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120584. */
  120585. lodGenerationScale: number;
  120586. }
  120587. /**
  120588. * Sets of helpers addressing the serialization and deserialization of environment texture
  120589. * stored in a BabylonJS env file.
  120590. * Those files are usually stored as .env files.
  120591. */
  120592. export class EnvironmentTextureTools {
  120593. /**
  120594. * Magic number identifying the env file.
  120595. */
  120596. private static _MagicBytes;
  120597. /**
  120598. * Gets the environment info from an env file.
  120599. * @param data The array buffer containing the .env bytes.
  120600. * @returns the environment file info (the json header) if successfully parsed.
  120601. */
  120602. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120603. /**
  120604. * Creates an environment texture from a loaded cube texture.
  120605. * @param texture defines the cube texture to convert in env file
  120606. * @return a promise containing the environment data if succesfull.
  120607. */
  120608. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120609. /**
  120610. * Creates a JSON representation of the spherical data.
  120611. * @param texture defines the texture containing the polynomials
  120612. * @return the JSON representation of the spherical info
  120613. */
  120614. private static _CreateEnvTextureIrradiance;
  120615. /**
  120616. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120617. * @param data the image data
  120618. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120619. * @return the views described by info providing access to the underlying buffer
  120620. */
  120621. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120622. /**
  120623. * Uploads the texture info contained in the env file to the GPU.
  120624. * @param texture defines the internal texture to upload to
  120625. * @param data defines the data to load
  120626. * @param info defines the texture info retrieved through the GetEnvInfo method
  120627. * @returns a promise
  120628. */
  120629. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120630. private static _OnImageReadyAsync;
  120631. /**
  120632. * Uploads the levels of image data to the GPU.
  120633. * @param texture defines the internal texture to upload to
  120634. * @param imageData defines the array buffer views of image data [mipmap][face]
  120635. * @returns a promise
  120636. */
  120637. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120638. /**
  120639. * Uploads spherical polynomials information to the texture.
  120640. * @param texture defines the texture we are trying to upload the information to
  120641. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120642. */
  120643. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120644. /** @hidden */
  120645. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120646. }
  120647. }
  120648. declare module BABYLON {
  120649. /**
  120650. * Contains position and normal vectors for a vertex
  120651. */
  120652. export class PositionNormalVertex {
  120653. /** the position of the vertex (defaut: 0,0,0) */
  120654. position: Vector3;
  120655. /** the normal of the vertex (defaut: 0,1,0) */
  120656. normal: Vector3;
  120657. /**
  120658. * Creates a PositionNormalVertex
  120659. * @param position the position of the vertex (defaut: 0,0,0)
  120660. * @param normal the normal of the vertex (defaut: 0,1,0)
  120661. */
  120662. constructor(
  120663. /** the position of the vertex (defaut: 0,0,0) */
  120664. position?: Vector3,
  120665. /** the normal of the vertex (defaut: 0,1,0) */
  120666. normal?: Vector3);
  120667. /**
  120668. * Clones the PositionNormalVertex
  120669. * @returns the cloned PositionNormalVertex
  120670. */
  120671. clone(): PositionNormalVertex;
  120672. }
  120673. /**
  120674. * Contains position, normal and uv vectors for a vertex
  120675. */
  120676. export class PositionNormalTextureVertex {
  120677. /** the position of the vertex (defaut: 0,0,0) */
  120678. position: Vector3;
  120679. /** the normal of the vertex (defaut: 0,1,0) */
  120680. normal: Vector3;
  120681. /** the uv of the vertex (default: 0,0) */
  120682. uv: Vector2;
  120683. /**
  120684. * Creates a PositionNormalTextureVertex
  120685. * @param position the position of the vertex (defaut: 0,0,0)
  120686. * @param normal the normal of the vertex (defaut: 0,1,0)
  120687. * @param uv the uv of the vertex (default: 0,0)
  120688. */
  120689. constructor(
  120690. /** the position of the vertex (defaut: 0,0,0) */
  120691. position?: Vector3,
  120692. /** the normal of the vertex (defaut: 0,1,0) */
  120693. normal?: Vector3,
  120694. /** the uv of the vertex (default: 0,0) */
  120695. uv?: Vector2);
  120696. /**
  120697. * Clones the PositionNormalTextureVertex
  120698. * @returns the cloned PositionNormalTextureVertex
  120699. */
  120700. clone(): PositionNormalTextureVertex;
  120701. }
  120702. }
  120703. declare module BABYLON {
  120704. /** @hidden */
  120705. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120706. private _genericAttributeLocation;
  120707. private _varyingLocationCount;
  120708. private _varyingLocationMap;
  120709. private _replacements;
  120710. private _textureCount;
  120711. private _uniforms;
  120712. lineProcessor(line: string): string;
  120713. attributeProcessor(attribute: string): string;
  120714. varyingProcessor(varying: string, isFragment: boolean): string;
  120715. uniformProcessor(uniform: string): string;
  120716. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120717. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120718. }
  120719. }
  120720. declare module BABYLON {
  120721. /**
  120722. * Container for accessors for natively-stored mesh data buffers.
  120723. */
  120724. class NativeDataBuffer extends DataBuffer {
  120725. /**
  120726. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120727. */
  120728. nativeIndexBuffer?: any;
  120729. /**
  120730. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120731. */
  120732. nativeVertexBuffer?: any;
  120733. }
  120734. /** @hidden */
  120735. class NativeTexture extends InternalTexture {
  120736. getInternalTexture(): InternalTexture;
  120737. getViewCount(): number;
  120738. }
  120739. /** @hidden */
  120740. export class NativeEngine extends Engine {
  120741. private readonly _native;
  120742. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120743. private readonly INVALID_HANDLE;
  120744. getHardwareScalingLevel(): number;
  120745. constructor();
  120746. /**
  120747. * Can be used to override the current requestAnimationFrame requester.
  120748. * @hidden
  120749. */
  120750. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120751. /**
  120752. * Override default engine behavior.
  120753. * @param color
  120754. * @param backBuffer
  120755. * @param depth
  120756. * @param stencil
  120757. */
  120758. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120759. /**
  120760. * Gets host document
  120761. * @returns the host document object
  120762. */
  120763. getHostDocument(): Nullable<Document>;
  120764. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120765. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120766. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120767. recordVertexArrayObject(vertexBuffers: {
  120768. [key: string]: VertexBuffer;
  120769. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120770. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120771. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120772. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120773. /**
  120774. * Draw a list of indexed primitives
  120775. * @param fillMode defines the primitive to use
  120776. * @param indexStart defines the starting index
  120777. * @param indexCount defines the number of index to draw
  120778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120779. */
  120780. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120781. /**
  120782. * Draw a list of unindexed primitives
  120783. * @param fillMode defines the primitive to use
  120784. * @param verticesStart defines the index of first vertex to draw
  120785. * @param verticesCount defines the count of vertices to draw
  120786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120787. */
  120788. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120789. createPipelineContext(): IPipelineContext;
  120790. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120791. /** @hidden */
  120792. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120793. /** @hidden */
  120794. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120795. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120796. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120797. protected _setProgram(program: WebGLProgram): void;
  120798. _releaseEffect(effect: Effect): void;
  120799. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120800. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120801. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120802. bindSamplers(effect: Effect): void;
  120803. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120804. getRenderWidth(useScreen?: boolean): number;
  120805. getRenderHeight(useScreen?: boolean): number;
  120806. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120807. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120808. /**
  120809. * Set the z offset to apply to current rendering
  120810. * @param value defines the offset to apply
  120811. */
  120812. setZOffset(value: number): void;
  120813. /**
  120814. * Gets the current value of the zOffset
  120815. * @returns the current zOffset state
  120816. */
  120817. getZOffset(): number;
  120818. /**
  120819. * Enable or disable depth buffering
  120820. * @param enable defines the state to set
  120821. */
  120822. setDepthBuffer(enable: boolean): void;
  120823. /**
  120824. * Gets a boolean indicating if depth writing is enabled
  120825. * @returns the current depth writing state
  120826. */
  120827. getDepthWrite(): boolean;
  120828. /**
  120829. * Enable or disable depth writing
  120830. * @param enable defines the state to set
  120831. */
  120832. setDepthWrite(enable: boolean): void;
  120833. /**
  120834. * Enable or disable color writing
  120835. * @param enable defines the state to set
  120836. */
  120837. setColorWrite(enable: boolean): void;
  120838. /**
  120839. * Gets a boolean indicating if color writing is enabled
  120840. * @returns the current color writing state
  120841. */
  120842. getColorWrite(): boolean;
  120843. /**
  120844. * Sets alpha constants used by some alpha blending modes
  120845. * @param r defines the red component
  120846. * @param g defines the green component
  120847. * @param b defines the blue component
  120848. * @param a defines the alpha component
  120849. */
  120850. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120851. /**
  120852. * Sets the current alpha mode
  120853. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120854. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120855. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120856. */
  120857. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120858. /**
  120859. * Gets the current alpha mode
  120860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120861. * @returns the current alpha mode
  120862. */
  120863. getAlphaMode(): number;
  120864. setInt(uniform: WebGLUniformLocation, int: number): void;
  120865. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120866. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120867. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120868. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120869. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120870. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120871. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120872. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120873. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120874. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120875. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120876. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120877. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120878. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120879. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120880. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120881. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120882. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120883. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120884. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120885. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120886. wipeCaches(bruteForce?: boolean): void;
  120887. _createTexture(): WebGLTexture;
  120888. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120889. /**
  120890. * Usually called from Texture.ts.
  120891. * Passed information to create a WebGLTexture
  120892. * @param urlArg defines a value which contains one of the following:
  120893. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120894. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120895. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120897. * @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)
  120898. * @param scene needed for loading to the correct scene
  120899. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120900. * @param onLoad optional callback to be called upon successful completion
  120901. * @param onError optional callback to be called upon failure
  120902. * @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
  120903. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120904. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120905. * @param forcedExtension defines the extension to use to pick the right loader
  120906. * @param mimeType defines an optional mime type
  120907. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120908. */
  120909. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  120910. /**
  120911. * Creates a cube texture
  120912. * @param rootUrl defines the url where the files to load is located
  120913. * @param scene defines the current scene
  120914. * @param files defines the list of files to load (1 per face)
  120915. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120916. * @param onLoad defines an optional callback raised when the texture is loaded
  120917. * @param onError defines an optional callback raised if there is an issue to load the texture
  120918. * @param format defines the format of the data
  120919. * @param forcedExtension defines the extension to use to pick the right loader
  120920. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120921. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120922. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120923. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120924. * @returns the cube texture as an InternalTexture
  120925. */
  120926. 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;
  120927. private _getSamplingFilter;
  120928. private static _GetNativeTextureFormat;
  120929. createRenderTargetTexture(size: number | {
  120930. width: number;
  120931. height: number;
  120932. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120933. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120934. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120935. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120936. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120937. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120938. /**
  120939. * Updates a dynamic vertex buffer.
  120940. * @param vertexBuffer the vertex buffer to update
  120941. * @param data the data used to update the vertex buffer
  120942. * @param byteOffset the byte offset of the data (optional)
  120943. * @param byteLength the byte length of the data (optional)
  120944. */
  120945. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120946. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120947. private _updateAnisotropicLevel;
  120948. private _getAddressMode;
  120949. /** @hidden */
  120950. _bindTexture(channel: number, texture: InternalTexture): void;
  120951. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120952. releaseEffects(): void;
  120953. /** @hidden */
  120954. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120955. /** @hidden */
  120956. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120957. /** @hidden */
  120958. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120959. /** @hidden */
  120960. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120961. }
  120962. }
  120963. declare module BABYLON {
  120964. /**
  120965. * Gather the list of clipboard event types as constants.
  120966. */
  120967. export class ClipboardEventTypes {
  120968. /**
  120969. * The clipboard event is fired when a copy command is active (pressed).
  120970. */
  120971. static readonly COPY: number;
  120972. /**
  120973. * The clipboard event is fired when a cut command is active (pressed).
  120974. */
  120975. static readonly CUT: number;
  120976. /**
  120977. * The clipboard event is fired when a paste command is active (pressed).
  120978. */
  120979. static readonly PASTE: number;
  120980. }
  120981. /**
  120982. * This class is used to store clipboard related info for the onClipboardObservable event.
  120983. */
  120984. export class ClipboardInfo {
  120985. /**
  120986. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120987. */
  120988. type: number;
  120989. /**
  120990. * Defines the related dom event
  120991. */
  120992. event: ClipboardEvent;
  120993. /**
  120994. *Creates an instance of ClipboardInfo.
  120995. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120996. * @param event Defines the related dom event
  120997. */
  120998. constructor(
  120999. /**
  121000. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121001. */
  121002. type: number,
  121003. /**
  121004. * Defines the related dom event
  121005. */
  121006. event: ClipboardEvent);
  121007. /**
  121008. * Get the clipboard event's type from the keycode.
  121009. * @param keyCode Defines the keyCode for the current keyboard event.
  121010. * @return {number}
  121011. */
  121012. static GetTypeFromCharacter(keyCode: number): number;
  121013. }
  121014. }
  121015. declare module BABYLON {
  121016. /**
  121017. * Google Daydream controller
  121018. */
  121019. export class DaydreamController extends WebVRController {
  121020. /**
  121021. * Base Url for the controller model.
  121022. */
  121023. static MODEL_BASE_URL: string;
  121024. /**
  121025. * File name for the controller model.
  121026. */
  121027. static MODEL_FILENAME: string;
  121028. /**
  121029. * Gamepad Id prefix used to identify Daydream Controller.
  121030. */
  121031. static readonly GAMEPAD_ID_PREFIX: string;
  121032. /**
  121033. * Creates a new DaydreamController from a gamepad
  121034. * @param vrGamepad the gamepad that the controller should be created from
  121035. */
  121036. constructor(vrGamepad: any);
  121037. /**
  121038. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121039. * @param scene scene in which to add meshes
  121040. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121041. */
  121042. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121043. /**
  121044. * Called once for each button that changed state since the last frame
  121045. * @param buttonIdx Which button index changed
  121046. * @param state New state of the button
  121047. * @param changes Which properties on the state changed since last frame
  121048. */
  121049. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121050. }
  121051. }
  121052. declare module BABYLON {
  121053. /**
  121054. * Gear VR Controller
  121055. */
  121056. export class GearVRController extends WebVRController {
  121057. /**
  121058. * Base Url for the controller model.
  121059. */
  121060. static MODEL_BASE_URL: string;
  121061. /**
  121062. * File name for the controller model.
  121063. */
  121064. static MODEL_FILENAME: string;
  121065. /**
  121066. * Gamepad Id prefix used to identify this controller.
  121067. */
  121068. static readonly GAMEPAD_ID_PREFIX: string;
  121069. private readonly _buttonIndexToObservableNameMap;
  121070. /**
  121071. * Creates a new GearVRController from a gamepad
  121072. * @param vrGamepad the gamepad that the controller should be created from
  121073. */
  121074. constructor(vrGamepad: any);
  121075. /**
  121076. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121077. * @param scene scene in which to add meshes
  121078. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121079. */
  121080. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121081. /**
  121082. * Called once for each button that changed state since the last frame
  121083. * @param buttonIdx Which button index changed
  121084. * @param state New state of the button
  121085. * @param changes Which properties on the state changed since last frame
  121086. */
  121087. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121088. }
  121089. }
  121090. declare module BABYLON {
  121091. /**
  121092. * Generic Controller
  121093. */
  121094. export class GenericController extends WebVRController {
  121095. /**
  121096. * Base Url for the controller model.
  121097. */
  121098. static readonly MODEL_BASE_URL: string;
  121099. /**
  121100. * File name for the controller model.
  121101. */
  121102. static readonly MODEL_FILENAME: string;
  121103. /**
  121104. * Creates a new GenericController from a gamepad
  121105. * @param vrGamepad the gamepad that the controller should be created from
  121106. */
  121107. constructor(vrGamepad: any);
  121108. /**
  121109. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121110. * @param scene scene in which to add meshes
  121111. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121112. */
  121113. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121114. /**
  121115. * Called once for each button that changed state since the last frame
  121116. * @param buttonIdx Which button index changed
  121117. * @param state New state of the button
  121118. * @param changes Which properties on the state changed since last frame
  121119. */
  121120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121121. }
  121122. }
  121123. declare module BABYLON {
  121124. /**
  121125. * Oculus Touch Controller
  121126. */
  121127. export class OculusTouchController extends WebVRController {
  121128. /**
  121129. * Base Url for the controller model.
  121130. */
  121131. static MODEL_BASE_URL: string;
  121132. /**
  121133. * File name for the left controller model.
  121134. */
  121135. static MODEL_LEFT_FILENAME: string;
  121136. /**
  121137. * File name for the right controller model.
  121138. */
  121139. static MODEL_RIGHT_FILENAME: string;
  121140. /**
  121141. * Base Url for the Quest controller model.
  121142. */
  121143. static QUEST_MODEL_BASE_URL: string;
  121144. /**
  121145. * @hidden
  121146. * If the controllers are running on a device that needs the updated Quest controller models
  121147. */
  121148. static _IsQuest: boolean;
  121149. /**
  121150. * Fired when the secondary trigger on this controller is modified
  121151. */
  121152. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121153. /**
  121154. * Fired when the thumb rest on this controller is modified
  121155. */
  121156. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121157. /**
  121158. * Creates a new OculusTouchController from a gamepad
  121159. * @param vrGamepad the gamepad that the controller should be created from
  121160. */
  121161. constructor(vrGamepad: any);
  121162. /**
  121163. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121164. * @param scene scene in which to add meshes
  121165. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121166. */
  121167. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121168. /**
  121169. * Fired when the A button on this controller is modified
  121170. */
  121171. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121172. /**
  121173. * Fired when the B button on this controller is modified
  121174. */
  121175. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121176. /**
  121177. * Fired when the X button on this controller is modified
  121178. */
  121179. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121180. /**
  121181. * Fired when the Y button on this controller is modified
  121182. */
  121183. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121184. /**
  121185. * Called once for each button that changed state since the last frame
  121186. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121187. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121188. * 2) secondary trigger (same)
  121189. * 3) A (right) X (left), touch, pressed = value
  121190. * 4) B / Y
  121191. * 5) thumb rest
  121192. * @param buttonIdx Which button index changed
  121193. * @param state New state of the button
  121194. * @param changes Which properties on the state changed since last frame
  121195. */
  121196. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121197. }
  121198. }
  121199. declare module BABYLON {
  121200. /**
  121201. * Vive Controller
  121202. */
  121203. export class ViveController extends WebVRController {
  121204. /**
  121205. * Base Url for the controller model.
  121206. */
  121207. static MODEL_BASE_URL: string;
  121208. /**
  121209. * File name for the controller model.
  121210. */
  121211. static MODEL_FILENAME: string;
  121212. /**
  121213. * Creates a new ViveController from a gamepad
  121214. * @param vrGamepad the gamepad that the controller should be created from
  121215. */
  121216. constructor(vrGamepad: any);
  121217. /**
  121218. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121219. * @param scene scene in which to add meshes
  121220. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121221. */
  121222. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121223. /**
  121224. * Fired when the left button on this controller is modified
  121225. */
  121226. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121227. /**
  121228. * Fired when the right button on this controller is modified
  121229. */
  121230. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121231. /**
  121232. * Fired when the menu button on this controller is modified
  121233. */
  121234. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121235. /**
  121236. * Called once for each button that changed state since the last frame
  121237. * Vive mapping:
  121238. * 0: touchpad
  121239. * 1: trigger
  121240. * 2: left AND right buttons
  121241. * 3: menu button
  121242. * @param buttonIdx Which button index changed
  121243. * @param state New state of the button
  121244. * @param changes Which properties on the state changed since last frame
  121245. */
  121246. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121247. }
  121248. }
  121249. declare module BABYLON {
  121250. /**
  121251. * Defines the WindowsMotionController object that the state of the windows motion controller
  121252. */
  121253. export class WindowsMotionController extends WebVRController {
  121254. /**
  121255. * The base url used to load the left and right controller models
  121256. */
  121257. static MODEL_BASE_URL: string;
  121258. /**
  121259. * The name of the left controller model file
  121260. */
  121261. static MODEL_LEFT_FILENAME: string;
  121262. /**
  121263. * The name of the right controller model file
  121264. */
  121265. static MODEL_RIGHT_FILENAME: string;
  121266. /**
  121267. * The controller name prefix for this controller type
  121268. */
  121269. static readonly GAMEPAD_ID_PREFIX: string;
  121270. /**
  121271. * The controller id pattern for this controller type
  121272. */
  121273. private static readonly GAMEPAD_ID_PATTERN;
  121274. private _loadedMeshInfo;
  121275. protected readonly _mapping: {
  121276. buttons: string[];
  121277. buttonMeshNames: {
  121278. 'trigger': string;
  121279. 'menu': string;
  121280. 'grip': string;
  121281. 'thumbstick': string;
  121282. 'trackpad': string;
  121283. };
  121284. buttonObservableNames: {
  121285. 'trigger': string;
  121286. 'menu': string;
  121287. 'grip': string;
  121288. 'thumbstick': string;
  121289. 'trackpad': string;
  121290. };
  121291. axisMeshNames: string[];
  121292. pointingPoseMeshName: string;
  121293. };
  121294. /**
  121295. * Fired when the trackpad on this controller is clicked
  121296. */
  121297. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121298. /**
  121299. * Fired when the trackpad on this controller is modified
  121300. */
  121301. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121302. /**
  121303. * The current x and y values of this controller's trackpad
  121304. */
  121305. trackpad: StickValues;
  121306. /**
  121307. * Creates a new WindowsMotionController from a gamepad
  121308. * @param vrGamepad the gamepad that the controller should be created from
  121309. */
  121310. constructor(vrGamepad: any);
  121311. /**
  121312. * Fired when the trigger on this controller is modified
  121313. */
  121314. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121315. /**
  121316. * Fired when the menu button on this controller is modified
  121317. */
  121318. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121319. /**
  121320. * Fired when the grip button on this controller is modified
  121321. */
  121322. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121323. /**
  121324. * Fired when the thumbstick button on this controller is modified
  121325. */
  121326. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121327. /**
  121328. * Fired when the touchpad button on this controller is modified
  121329. */
  121330. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121331. /**
  121332. * Fired when the touchpad values on this controller are modified
  121333. */
  121334. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121335. protected _updateTrackpad(): void;
  121336. /**
  121337. * Called once per frame by the engine.
  121338. */
  121339. update(): void;
  121340. /**
  121341. * Called once for each button that changed state since the last frame
  121342. * @param buttonIdx Which button index changed
  121343. * @param state New state of the button
  121344. * @param changes Which properties on the state changed since last frame
  121345. */
  121346. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121347. /**
  121348. * Moves the buttons on the controller mesh based on their current state
  121349. * @param buttonName the name of the button to move
  121350. * @param buttonValue the value of the button which determines the buttons new position
  121351. */
  121352. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121353. /**
  121354. * Moves the axis on the controller mesh based on its current state
  121355. * @param axis the index of the axis
  121356. * @param axisValue the value of the axis which determines the meshes new position
  121357. * @hidden
  121358. */
  121359. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121360. /**
  121361. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121362. * @param scene scene in which to add meshes
  121363. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121364. */
  121365. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121366. /**
  121367. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121368. * can be transformed by button presses and axes values, based on this._mapping.
  121369. *
  121370. * @param scene scene in which the meshes exist
  121371. * @param meshes list of meshes that make up the controller model to process
  121372. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121373. */
  121374. private processModel;
  121375. private createMeshInfo;
  121376. /**
  121377. * Gets the ray of the controller in the direction the controller is pointing
  121378. * @param length the length the resulting ray should be
  121379. * @returns a ray in the direction the controller is pointing
  121380. */
  121381. getForwardRay(length?: number): Ray;
  121382. /**
  121383. * Disposes of the controller
  121384. */
  121385. dispose(): void;
  121386. }
  121387. /**
  121388. * This class represents a new windows motion controller in XR.
  121389. */
  121390. export class XRWindowsMotionController extends WindowsMotionController {
  121391. /**
  121392. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121393. */
  121394. protected readonly _mapping: {
  121395. buttons: string[];
  121396. buttonMeshNames: {
  121397. 'trigger': string;
  121398. 'menu': string;
  121399. 'grip': string;
  121400. 'thumbstick': string;
  121401. 'trackpad': string;
  121402. };
  121403. buttonObservableNames: {
  121404. 'trigger': string;
  121405. 'menu': string;
  121406. 'grip': string;
  121407. 'thumbstick': string;
  121408. 'trackpad': string;
  121409. };
  121410. axisMeshNames: string[];
  121411. pointingPoseMeshName: string;
  121412. };
  121413. /**
  121414. * Construct a new XR-Based windows motion controller
  121415. *
  121416. * @param gamepadInfo the gamepad object from the browser
  121417. */
  121418. constructor(gamepadInfo: any);
  121419. /**
  121420. * holds the thumbstick values (X,Y)
  121421. */
  121422. thumbstickValues: StickValues;
  121423. /**
  121424. * Fired when the thumbstick on this controller is clicked
  121425. */
  121426. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121427. /**
  121428. * Fired when the thumbstick on this controller is modified
  121429. */
  121430. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121431. /**
  121432. * Fired when the touchpad button on this controller is modified
  121433. */
  121434. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121435. /**
  121436. * Fired when the touchpad values on this controller are modified
  121437. */
  121438. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121439. /**
  121440. * Fired when the thumbstick button on this controller is modified
  121441. * here to prevent breaking changes
  121442. */
  121443. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121444. /**
  121445. * updating the thumbstick(!) and not the trackpad.
  121446. * This is named this way due to the difference between WebVR and XR and to avoid
  121447. * changing the parent class.
  121448. */
  121449. protected _updateTrackpad(): void;
  121450. /**
  121451. * Disposes the class with joy
  121452. */
  121453. dispose(): void;
  121454. }
  121455. }
  121456. declare module BABYLON {
  121457. /**
  121458. * Class containing static functions to help procedurally build meshes
  121459. */
  121460. export class PolyhedronBuilder {
  121461. /**
  121462. * Creates a polyhedron mesh
  121463. * * 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
  121464. * * The parameter `size` (positive float, default 1) sets the polygon size
  121465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121466. * * 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`
  121467. * * 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
  121468. * * 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)`)
  121469. * * 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
  121470. * * 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
  121471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121474. * @param name defines the name of the mesh
  121475. * @param options defines the options used to create the mesh
  121476. * @param scene defines the hosting scene
  121477. * @returns the polyhedron mesh
  121478. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121479. */
  121480. static CreatePolyhedron(name: string, options: {
  121481. type?: number;
  121482. size?: number;
  121483. sizeX?: number;
  121484. sizeY?: number;
  121485. sizeZ?: number;
  121486. custom?: any;
  121487. faceUV?: Vector4[];
  121488. faceColors?: Color4[];
  121489. flat?: boolean;
  121490. updatable?: boolean;
  121491. sideOrientation?: number;
  121492. frontUVs?: Vector4;
  121493. backUVs?: Vector4;
  121494. }, scene?: Nullable<Scene>): Mesh;
  121495. }
  121496. }
  121497. declare module BABYLON {
  121498. /**
  121499. * Gizmo that enables scaling a mesh along 3 axis
  121500. */
  121501. export class ScaleGizmo extends Gizmo {
  121502. /**
  121503. * Internal gizmo used for interactions on the x axis
  121504. */
  121505. xGizmo: AxisScaleGizmo;
  121506. /**
  121507. * Internal gizmo used for interactions on the y axis
  121508. */
  121509. yGizmo: AxisScaleGizmo;
  121510. /**
  121511. * Internal gizmo used for interactions on the z axis
  121512. */
  121513. zGizmo: AxisScaleGizmo;
  121514. /**
  121515. * Internal gizmo used to scale all axis equally
  121516. */
  121517. uniformScaleGizmo: AxisScaleGizmo;
  121518. private _meshAttached;
  121519. private _updateGizmoRotationToMatchAttachedMesh;
  121520. private _snapDistance;
  121521. private _scaleRatio;
  121522. private _uniformScalingMesh;
  121523. private _octahedron;
  121524. private _sensitivity;
  121525. /** Fires an event when any of it's sub gizmos are dragged */
  121526. onDragStartObservable: Observable<unknown>;
  121527. /** Fires an event when any of it's sub gizmos are released from dragging */
  121528. onDragEndObservable: Observable<unknown>;
  121529. get attachedMesh(): Nullable<AbstractMesh>;
  121530. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121531. /**
  121532. * Creates a ScaleGizmo
  121533. * @param gizmoLayer The utility layer the gizmo will be added to
  121534. */
  121535. constructor(gizmoLayer?: UtilityLayerRenderer);
  121536. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121537. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121538. /**
  121539. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121540. */
  121541. set snapDistance(value: number);
  121542. get snapDistance(): number;
  121543. /**
  121544. * Ratio for the scale of the gizmo (Default: 1)
  121545. */
  121546. set scaleRatio(value: number);
  121547. get scaleRatio(): number;
  121548. /**
  121549. * Sensitivity factor for dragging (Default: 1)
  121550. */
  121551. set sensitivity(value: number);
  121552. get sensitivity(): number;
  121553. /**
  121554. * Disposes of the gizmo
  121555. */
  121556. dispose(): void;
  121557. }
  121558. }
  121559. declare module BABYLON {
  121560. /**
  121561. * Single axis scale gizmo
  121562. */
  121563. export class AxisScaleGizmo extends Gizmo {
  121564. /**
  121565. * Drag behavior responsible for the gizmos dragging interactions
  121566. */
  121567. dragBehavior: PointerDragBehavior;
  121568. private _pointerObserver;
  121569. /**
  121570. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121571. */
  121572. snapDistance: number;
  121573. /**
  121574. * Event that fires each time the gizmo snaps to a new location.
  121575. * * snapDistance is the the change in distance
  121576. */
  121577. onSnapObservable: Observable<{
  121578. snapDistance: number;
  121579. }>;
  121580. /**
  121581. * If the scaling operation should be done on all axis (default: false)
  121582. */
  121583. uniformScaling: boolean;
  121584. /**
  121585. * Custom sensitivity value for the drag strength
  121586. */
  121587. sensitivity: number;
  121588. private _isEnabled;
  121589. private _parent;
  121590. private _arrow;
  121591. private _coloredMaterial;
  121592. private _hoverMaterial;
  121593. /**
  121594. * Creates an AxisScaleGizmo
  121595. * @param gizmoLayer The utility layer the gizmo will be added to
  121596. * @param dragAxis The axis which the gizmo will be able to scale on
  121597. * @param color The color of the gizmo
  121598. */
  121599. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121600. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121601. /**
  121602. * If the gizmo is enabled
  121603. */
  121604. set isEnabled(value: boolean);
  121605. get isEnabled(): boolean;
  121606. /**
  121607. * Disposes of the gizmo
  121608. */
  121609. dispose(): void;
  121610. /**
  121611. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121612. * @param mesh The mesh to replace the default mesh of the gizmo
  121613. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121614. */
  121615. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121616. }
  121617. }
  121618. declare module BABYLON {
  121619. /**
  121620. * Bounding box gizmo
  121621. */
  121622. export class BoundingBoxGizmo extends Gizmo {
  121623. private _lineBoundingBox;
  121624. private _rotateSpheresParent;
  121625. private _scaleBoxesParent;
  121626. private _boundingDimensions;
  121627. private _renderObserver;
  121628. private _pointerObserver;
  121629. private _scaleDragSpeed;
  121630. private _tmpQuaternion;
  121631. private _tmpVector;
  121632. private _tmpRotationMatrix;
  121633. /**
  121634. * 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)
  121635. */
  121636. ignoreChildren: boolean;
  121637. /**
  121638. * 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)
  121639. */
  121640. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121641. /**
  121642. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121643. */
  121644. rotationSphereSize: number;
  121645. /**
  121646. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121647. */
  121648. scaleBoxSize: number;
  121649. /**
  121650. * 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)
  121651. */
  121652. fixedDragMeshScreenSize: boolean;
  121653. /**
  121654. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121655. */
  121656. fixedDragMeshScreenSizeDistanceFactor: number;
  121657. /**
  121658. * Fired when a rotation sphere or scale box is dragged
  121659. */
  121660. onDragStartObservable: Observable<{}>;
  121661. /**
  121662. * Fired when a scale box is dragged
  121663. */
  121664. onScaleBoxDragObservable: Observable<{}>;
  121665. /**
  121666. * Fired when a scale box drag is ended
  121667. */
  121668. onScaleBoxDragEndObservable: Observable<{}>;
  121669. /**
  121670. * Fired when a rotation sphere is dragged
  121671. */
  121672. onRotationSphereDragObservable: Observable<{}>;
  121673. /**
  121674. * Fired when a rotation sphere drag is ended
  121675. */
  121676. onRotationSphereDragEndObservable: Observable<{}>;
  121677. /**
  121678. * 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)
  121679. */
  121680. scalePivot: Nullable<Vector3>;
  121681. /**
  121682. * Mesh used as a pivot to rotate the attached mesh
  121683. */
  121684. private _anchorMesh;
  121685. private _existingMeshScale;
  121686. private _dragMesh;
  121687. private pointerDragBehavior;
  121688. private coloredMaterial;
  121689. private hoverColoredMaterial;
  121690. /**
  121691. * Sets the color of the bounding box gizmo
  121692. * @param color the color to set
  121693. */
  121694. setColor(color: Color3): void;
  121695. /**
  121696. * Creates an BoundingBoxGizmo
  121697. * @param gizmoLayer The utility layer the gizmo will be added to
  121698. * @param color The color of the gizmo
  121699. */
  121700. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121702. private _selectNode;
  121703. /**
  121704. * Updates the bounding box information for the Gizmo
  121705. */
  121706. updateBoundingBox(): void;
  121707. private _updateRotationSpheres;
  121708. private _updateScaleBoxes;
  121709. /**
  121710. * Enables rotation on the specified axis and disables rotation on the others
  121711. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121712. */
  121713. setEnabledRotationAxis(axis: string): void;
  121714. /**
  121715. * Enables/disables scaling
  121716. * @param enable if scaling should be enabled
  121717. */
  121718. setEnabledScaling(enable: boolean): void;
  121719. private _updateDummy;
  121720. /**
  121721. * Enables a pointer drag behavior on the bounding box of the gizmo
  121722. */
  121723. enableDragBehavior(): void;
  121724. /**
  121725. * Disposes of the gizmo
  121726. */
  121727. dispose(): void;
  121728. /**
  121729. * 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)
  121730. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121731. * @returns the bounding box mesh with the passed in mesh as a child
  121732. */
  121733. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121734. /**
  121735. * CustomMeshes are not supported by this gizmo
  121736. * @param mesh The mesh to replace the default mesh of the gizmo
  121737. */
  121738. setCustomMesh(mesh: Mesh): void;
  121739. }
  121740. }
  121741. declare module BABYLON {
  121742. /**
  121743. * Single plane rotation gizmo
  121744. */
  121745. export class PlaneRotationGizmo extends Gizmo {
  121746. /**
  121747. * Drag behavior responsible for the gizmos dragging interactions
  121748. */
  121749. dragBehavior: PointerDragBehavior;
  121750. private _pointerObserver;
  121751. /**
  121752. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121753. */
  121754. snapDistance: number;
  121755. /**
  121756. * Event that fires each time the gizmo snaps to a new location.
  121757. * * snapDistance is the the change in distance
  121758. */
  121759. onSnapObservable: Observable<{
  121760. snapDistance: number;
  121761. }>;
  121762. private _isEnabled;
  121763. private _parent;
  121764. /**
  121765. * Creates a PlaneRotationGizmo
  121766. * @param gizmoLayer The utility layer the gizmo will be added to
  121767. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121768. * @param color The color of the gizmo
  121769. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121770. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121771. */
  121772. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121773. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121774. /**
  121775. * If the gizmo is enabled
  121776. */
  121777. set isEnabled(value: boolean);
  121778. get isEnabled(): boolean;
  121779. /**
  121780. * Disposes of the gizmo
  121781. */
  121782. dispose(): void;
  121783. }
  121784. }
  121785. declare module BABYLON {
  121786. /**
  121787. * Gizmo that enables rotating a mesh along 3 axis
  121788. */
  121789. export class RotationGizmo extends Gizmo {
  121790. /**
  121791. * Internal gizmo used for interactions on the x axis
  121792. */
  121793. xGizmo: PlaneRotationGizmo;
  121794. /**
  121795. * Internal gizmo used for interactions on the y axis
  121796. */
  121797. yGizmo: PlaneRotationGizmo;
  121798. /**
  121799. * Internal gizmo used for interactions on the z axis
  121800. */
  121801. zGizmo: PlaneRotationGizmo;
  121802. /** Fires an event when any of it's sub gizmos are dragged */
  121803. onDragStartObservable: Observable<unknown>;
  121804. /** Fires an event when any of it's sub gizmos are released from dragging */
  121805. onDragEndObservable: Observable<unknown>;
  121806. private _meshAttached;
  121807. get attachedMesh(): Nullable<AbstractMesh>;
  121808. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121809. /**
  121810. * Creates a RotationGizmo
  121811. * @param gizmoLayer The utility layer the gizmo will be added to
  121812. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121813. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121814. */
  121815. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121816. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121817. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121818. /**
  121819. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121820. */
  121821. set snapDistance(value: number);
  121822. get snapDistance(): number;
  121823. /**
  121824. * Ratio for the scale of the gizmo (Default: 1)
  121825. */
  121826. set scaleRatio(value: number);
  121827. get scaleRatio(): number;
  121828. /**
  121829. * Disposes of the gizmo
  121830. */
  121831. dispose(): void;
  121832. /**
  121833. * CustomMeshes are not supported by this gizmo
  121834. * @param mesh The mesh to replace the default mesh of the gizmo
  121835. */
  121836. setCustomMesh(mesh: Mesh): void;
  121837. }
  121838. }
  121839. declare module BABYLON {
  121840. /**
  121841. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121842. */
  121843. export class GizmoManager implements IDisposable {
  121844. private scene;
  121845. /**
  121846. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121847. */
  121848. gizmos: {
  121849. positionGizmo: Nullable<PositionGizmo>;
  121850. rotationGizmo: Nullable<RotationGizmo>;
  121851. scaleGizmo: Nullable<ScaleGizmo>;
  121852. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121853. };
  121854. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121855. clearGizmoOnEmptyPointerEvent: boolean;
  121856. /** Fires an event when the manager is attached to a mesh */
  121857. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121858. private _gizmosEnabled;
  121859. private _pointerObserver;
  121860. private _attachedMesh;
  121861. private _boundingBoxColor;
  121862. private _defaultUtilityLayer;
  121863. private _defaultKeepDepthUtilityLayer;
  121864. /**
  121865. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121866. */
  121867. boundingBoxDragBehavior: SixDofDragBehavior;
  121868. /**
  121869. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121870. */
  121871. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121872. /**
  121873. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121874. */
  121875. usePointerToAttachGizmos: boolean;
  121876. /**
  121877. * Utility layer that the bounding box gizmo belongs to
  121878. */
  121879. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121880. /**
  121881. * Utility layer that all gizmos besides bounding box belong to
  121882. */
  121883. get utilityLayer(): UtilityLayerRenderer;
  121884. /**
  121885. * Instatiates a gizmo manager
  121886. * @param scene the scene to overlay the gizmos on top of
  121887. */
  121888. constructor(scene: Scene);
  121889. /**
  121890. * Attaches a set of gizmos to the specified mesh
  121891. * @param mesh The mesh the gizmo's should be attached to
  121892. */
  121893. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121894. /**
  121895. * If the position gizmo is enabled
  121896. */
  121897. set positionGizmoEnabled(value: boolean);
  121898. get positionGizmoEnabled(): boolean;
  121899. /**
  121900. * If the rotation gizmo is enabled
  121901. */
  121902. set rotationGizmoEnabled(value: boolean);
  121903. get rotationGizmoEnabled(): boolean;
  121904. /**
  121905. * If the scale gizmo is enabled
  121906. */
  121907. set scaleGizmoEnabled(value: boolean);
  121908. get scaleGizmoEnabled(): boolean;
  121909. /**
  121910. * If the boundingBox gizmo is enabled
  121911. */
  121912. set boundingBoxGizmoEnabled(value: boolean);
  121913. get boundingBoxGizmoEnabled(): boolean;
  121914. /**
  121915. * Disposes of the gizmo manager
  121916. */
  121917. dispose(): void;
  121918. }
  121919. }
  121920. declare module BABYLON {
  121921. /**
  121922. * A directional light is defined by a direction (what a surprise!).
  121923. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121924. * 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.
  121925. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121926. */
  121927. export class DirectionalLight extends ShadowLight {
  121928. private _shadowFrustumSize;
  121929. /**
  121930. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121931. */
  121932. get shadowFrustumSize(): number;
  121933. /**
  121934. * Specifies a fix frustum size for the shadow generation.
  121935. */
  121936. set shadowFrustumSize(value: number);
  121937. private _shadowOrthoScale;
  121938. /**
  121939. * Gets the shadow projection scale against the optimal computed one.
  121940. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121941. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121942. */
  121943. get shadowOrthoScale(): number;
  121944. /**
  121945. * Sets the shadow projection scale against the optimal computed one.
  121946. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121947. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121948. */
  121949. set shadowOrthoScale(value: number);
  121950. /**
  121951. * Automatically compute the projection matrix to best fit (including all the casters)
  121952. * on each frame.
  121953. */
  121954. autoUpdateExtends: boolean;
  121955. /**
  121956. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121957. * on each frame. autoUpdateExtends must be set to true for this to work
  121958. */
  121959. autoCalcShadowZBounds: boolean;
  121960. private _orthoLeft;
  121961. private _orthoRight;
  121962. private _orthoTop;
  121963. private _orthoBottom;
  121964. /**
  121965. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121966. * The directional light is emitted from everywhere in the given direction.
  121967. * It can cast shadows.
  121968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121969. * @param name The friendly name of the light
  121970. * @param direction The direction of the light
  121971. * @param scene The scene the light belongs to
  121972. */
  121973. constructor(name: string, direction: Vector3, scene: Scene);
  121974. /**
  121975. * Returns the string "DirectionalLight".
  121976. * @return The class name
  121977. */
  121978. getClassName(): string;
  121979. /**
  121980. * Returns the integer 1.
  121981. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121982. */
  121983. getTypeID(): number;
  121984. /**
  121985. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121986. * Returns the DirectionalLight Shadow projection matrix.
  121987. */
  121988. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121989. /**
  121990. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121991. * Returns the DirectionalLight Shadow projection matrix.
  121992. */
  121993. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121994. /**
  121995. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121996. * Returns the DirectionalLight Shadow projection matrix.
  121997. */
  121998. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121999. protected _buildUniformLayout(): void;
  122000. /**
  122001. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122002. * @param effect The effect to update
  122003. * @param lightIndex The index of the light in the effect to update
  122004. * @returns The directional light
  122005. */
  122006. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122007. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122008. /**
  122009. * Gets the minZ used for shadow according to both the scene and the light.
  122010. *
  122011. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122012. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122013. * @param activeCamera The camera we are returning the min for
  122014. * @returns the depth min z
  122015. */
  122016. getDepthMinZ(activeCamera: Camera): number;
  122017. /**
  122018. * Gets the maxZ used for shadow according to both the scene and the light.
  122019. *
  122020. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122021. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122022. * @param activeCamera The camera we are returning the max for
  122023. * @returns the depth max z
  122024. */
  122025. getDepthMaxZ(activeCamera: Camera): number;
  122026. /**
  122027. * Prepares the list of defines specific to the light type.
  122028. * @param defines the list of defines
  122029. * @param lightIndex defines the index of the light for the effect
  122030. */
  122031. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122032. }
  122033. }
  122034. declare module BABYLON {
  122035. /**
  122036. * Class containing static functions to help procedurally build meshes
  122037. */
  122038. export class HemisphereBuilder {
  122039. /**
  122040. * Creates a hemisphere mesh
  122041. * @param name defines the name of the mesh
  122042. * @param options defines the options used to create the mesh
  122043. * @param scene defines the hosting scene
  122044. * @returns the hemisphere mesh
  122045. */
  122046. static CreateHemisphere(name: string, options: {
  122047. segments?: number;
  122048. diameter?: number;
  122049. sideOrientation?: number;
  122050. }, scene: any): Mesh;
  122051. }
  122052. }
  122053. declare module BABYLON {
  122054. /**
  122055. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122056. * These values define a cone of light starting from the position, emitting toward the direction.
  122057. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122058. * and the exponent defines the speed of the decay of the light with distance (reach).
  122059. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122060. */
  122061. export class SpotLight extends ShadowLight {
  122062. private _angle;
  122063. private _innerAngle;
  122064. private _cosHalfAngle;
  122065. private _lightAngleScale;
  122066. private _lightAngleOffset;
  122067. /**
  122068. * Gets the cone angle of the spot light in Radians.
  122069. */
  122070. get angle(): number;
  122071. /**
  122072. * Sets the cone angle of the spot light in Radians.
  122073. */
  122074. set angle(value: number);
  122075. /**
  122076. * Only used in gltf falloff mode, this defines the angle where
  122077. * the directional falloff will start before cutting at angle which could be seen
  122078. * as outer angle.
  122079. */
  122080. get innerAngle(): number;
  122081. /**
  122082. * Only used in gltf falloff mode, this defines the angle where
  122083. * the directional falloff will start before cutting at angle which could be seen
  122084. * as outer angle.
  122085. */
  122086. set innerAngle(value: number);
  122087. private _shadowAngleScale;
  122088. /**
  122089. * Allows scaling the angle of the light for shadow generation only.
  122090. */
  122091. get shadowAngleScale(): number;
  122092. /**
  122093. * Allows scaling the angle of the light for shadow generation only.
  122094. */
  122095. set shadowAngleScale(value: number);
  122096. /**
  122097. * The light decay speed with the distance from the emission spot.
  122098. */
  122099. exponent: number;
  122100. private _projectionTextureMatrix;
  122101. /**
  122102. * Allows reading the projecton texture
  122103. */
  122104. get projectionTextureMatrix(): Matrix;
  122105. protected _projectionTextureLightNear: number;
  122106. /**
  122107. * Gets the near clip of the Spotlight for texture projection.
  122108. */
  122109. get projectionTextureLightNear(): number;
  122110. /**
  122111. * Sets the near clip of the Spotlight for texture projection.
  122112. */
  122113. set projectionTextureLightNear(value: number);
  122114. protected _projectionTextureLightFar: number;
  122115. /**
  122116. * Gets the far clip of the Spotlight for texture projection.
  122117. */
  122118. get projectionTextureLightFar(): number;
  122119. /**
  122120. * Sets the far clip of the Spotlight for texture projection.
  122121. */
  122122. set projectionTextureLightFar(value: number);
  122123. protected _projectionTextureUpDirection: Vector3;
  122124. /**
  122125. * Gets the Up vector of the Spotlight for texture projection.
  122126. */
  122127. get projectionTextureUpDirection(): Vector3;
  122128. /**
  122129. * Sets the Up vector of the Spotlight for texture projection.
  122130. */
  122131. set projectionTextureUpDirection(value: Vector3);
  122132. private _projectionTexture;
  122133. /**
  122134. * Gets the projection texture of the light.
  122135. */
  122136. get projectionTexture(): Nullable<BaseTexture>;
  122137. /**
  122138. * Sets the projection texture of the light.
  122139. */
  122140. set projectionTexture(value: Nullable<BaseTexture>);
  122141. private _projectionTextureViewLightDirty;
  122142. private _projectionTextureProjectionLightDirty;
  122143. private _projectionTextureDirty;
  122144. private _projectionTextureViewTargetVector;
  122145. private _projectionTextureViewLightMatrix;
  122146. private _projectionTextureProjectionLightMatrix;
  122147. private _projectionTextureScalingMatrix;
  122148. /**
  122149. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122150. * It can cast shadows.
  122151. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122152. * @param name The light friendly name
  122153. * @param position The position of the spot light in the scene
  122154. * @param direction The direction of the light in the scene
  122155. * @param angle The cone angle of the light in Radians
  122156. * @param exponent The light decay speed with the distance from the emission spot
  122157. * @param scene The scene the lights belongs to
  122158. */
  122159. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122160. /**
  122161. * Returns the string "SpotLight".
  122162. * @returns the class name
  122163. */
  122164. getClassName(): string;
  122165. /**
  122166. * Returns the integer 2.
  122167. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122168. */
  122169. getTypeID(): number;
  122170. /**
  122171. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122172. */
  122173. protected _setDirection(value: Vector3): void;
  122174. /**
  122175. * Overrides the position setter to recompute the projection texture view light Matrix.
  122176. */
  122177. protected _setPosition(value: Vector3): void;
  122178. /**
  122179. * 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.
  122180. * Returns the SpotLight.
  122181. */
  122182. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122183. protected _computeProjectionTextureViewLightMatrix(): void;
  122184. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122185. /**
  122186. * Main function for light texture projection matrix computing.
  122187. */
  122188. protected _computeProjectionTextureMatrix(): void;
  122189. protected _buildUniformLayout(): void;
  122190. private _computeAngleValues;
  122191. /**
  122192. * Sets the passed Effect "effect" with the Light textures.
  122193. * @param effect The effect to update
  122194. * @param lightIndex The index of the light in the effect to update
  122195. * @returns The light
  122196. */
  122197. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122198. /**
  122199. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122200. * @param effect The effect to update
  122201. * @param lightIndex The index of the light in the effect to update
  122202. * @returns The spot light
  122203. */
  122204. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122205. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122206. /**
  122207. * Disposes the light and the associated resources.
  122208. */
  122209. dispose(): void;
  122210. /**
  122211. * Prepares the list of defines specific to the light type.
  122212. * @param defines the list of defines
  122213. * @param lightIndex defines the index of the light for the effect
  122214. */
  122215. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122216. }
  122217. }
  122218. declare module BABYLON {
  122219. /**
  122220. * Gizmo that enables viewing a light
  122221. */
  122222. export class LightGizmo extends Gizmo {
  122223. private _lightMesh;
  122224. private _material;
  122225. private _cachedPosition;
  122226. private _cachedForward;
  122227. private _attachedMeshParent;
  122228. /**
  122229. * Creates a LightGizmo
  122230. * @param gizmoLayer The utility layer the gizmo will be added to
  122231. */
  122232. constructor(gizmoLayer?: UtilityLayerRenderer);
  122233. private _light;
  122234. /**
  122235. * The light that the gizmo is attached to
  122236. */
  122237. set light(light: Nullable<Light>);
  122238. get light(): Nullable<Light>;
  122239. /**
  122240. * Gets the material used to render the light gizmo
  122241. */
  122242. get material(): StandardMaterial;
  122243. /**
  122244. * @hidden
  122245. * Updates the gizmo to match the attached mesh's position/rotation
  122246. */
  122247. protected _update(): void;
  122248. private static _Scale;
  122249. /**
  122250. * Creates the lines for a light mesh
  122251. */
  122252. private static _CreateLightLines;
  122253. /**
  122254. * Disposes of the light gizmo
  122255. */
  122256. dispose(): void;
  122257. private static _CreateHemisphericLightMesh;
  122258. private static _CreatePointLightMesh;
  122259. private static _CreateSpotLightMesh;
  122260. private static _CreateDirectionalLightMesh;
  122261. }
  122262. }
  122263. declare module BABYLON {
  122264. /** @hidden */
  122265. export var backgroundFragmentDeclaration: {
  122266. name: string;
  122267. shader: string;
  122268. };
  122269. }
  122270. declare module BABYLON {
  122271. /** @hidden */
  122272. export var backgroundUboDeclaration: {
  122273. name: string;
  122274. shader: string;
  122275. };
  122276. }
  122277. declare module BABYLON {
  122278. /** @hidden */
  122279. export var backgroundPixelShader: {
  122280. name: string;
  122281. shader: string;
  122282. };
  122283. }
  122284. declare module BABYLON {
  122285. /** @hidden */
  122286. export var backgroundVertexDeclaration: {
  122287. name: string;
  122288. shader: string;
  122289. };
  122290. }
  122291. declare module BABYLON {
  122292. /** @hidden */
  122293. export var backgroundVertexShader: {
  122294. name: string;
  122295. shader: string;
  122296. };
  122297. }
  122298. declare module BABYLON {
  122299. /**
  122300. * Background material used to create an efficient environement around your scene.
  122301. */
  122302. export class BackgroundMaterial extends PushMaterial {
  122303. /**
  122304. * Standard reflectance value at parallel view angle.
  122305. */
  122306. static StandardReflectance0: number;
  122307. /**
  122308. * Standard reflectance value at grazing angle.
  122309. */
  122310. static StandardReflectance90: number;
  122311. protected _primaryColor: Color3;
  122312. /**
  122313. * Key light Color (multiply against the environement texture)
  122314. */
  122315. primaryColor: Color3;
  122316. protected __perceptualColor: Nullable<Color3>;
  122317. /**
  122318. * Experimental Internal Use Only.
  122319. *
  122320. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122321. * This acts as a helper to set the primary color to a more "human friendly" value.
  122322. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122323. * output color as close as possible from the chosen value.
  122324. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122325. * part of lighting setup.)
  122326. */
  122327. get _perceptualColor(): Nullable<Color3>;
  122328. set _perceptualColor(value: Nullable<Color3>);
  122329. protected _primaryColorShadowLevel: float;
  122330. /**
  122331. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122332. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122333. */
  122334. get primaryColorShadowLevel(): float;
  122335. set primaryColorShadowLevel(value: float);
  122336. protected _primaryColorHighlightLevel: float;
  122337. /**
  122338. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122339. * The primary color is used at the level chosen to define what the white area would look.
  122340. */
  122341. get primaryColorHighlightLevel(): float;
  122342. set primaryColorHighlightLevel(value: float);
  122343. protected _reflectionTexture: Nullable<BaseTexture>;
  122344. /**
  122345. * Reflection Texture used in the material.
  122346. * Should be author in a specific way for the best result (refer to the documentation).
  122347. */
  122348. reflectionTexture: Nullable<BaseTexture>;
  122349. protected _reflectionBlur: float;
  122350. /**
  122351. * Reflection Texture level of blur.
  122352. *
  122353. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122354. * texture twice.
  122355. */
  122356. reflectionBlur: float;
  122357. protected _diffuseTexture: Nullable<BaseTexture>;
  122358. /**
  122359. * Diffuse Texture used in the material.
  122360. * Should be author in a specific way for the best result (refer to the documentation).
  122361. */
  122362. diffuseTexture: Nullable<BaseTexture>;
  122363. protected _shadowLights: Nullable<IShadowLight[]>;
  122364. /**
  122365. * Specify the list of lights casting shadow on the material.
  122366. * All scene shadow lights will be included if null.
  122367. */
  122368. shadowLights: Nullable<IShadowLight[]>;
  122369. protected _shadowLevel: float;
  122370. /**
  122371. * Helps adjusting the shadow to a softer level if required.
  122372. * 0 means black shadows and 1 means no shadows.
  122373. */
  122374. shadowLevel: float;
  122375. protected _sceneCenter: Vector3;
  122376. /**
  122377. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122378. * It is usually zero but might be interesting to modify according to your setup.
  122379. */
  122380. sceneCenter: Vector3;
  122381. protected _opacityFresnel: boolean;
  122382. /**
  122383. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122384. * This helps ensuring a nice transition when the camera goes under the ground.
  122385. */
  122386. opacityFresnel: boolean;
  122387. protected _reflectionFresnel: boolean;
  122388. /**
  122389. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122390. * This helps adding a mirror texture on the ground.
  122391. */
  122392. reflectionFresnel: boolean;
  122393. protected _reflectionFalloffDistance: number;
  122394. /**
  122395. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122396. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122397. */
  122398. reflectionFalloffDistance: number;
  122399. protected _reflectionAmount: number;
  122400. /**
  122401. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122402. */
  122403. reflectionAmount: number;
  122404. protected _reflectionReflectance0: number;
  122405. /**
  122406. * This specifies the weight of the reflection at grazing angle.
  122407. */
  122408. reflectionReflectance0: number;
  122409. protected _reflectionReflectance90: number;
  122410. /**
  122411. * This specifies the weight of the reflection at a perpendicular point of view.
  122412. */
  122413. reflectionReflectance90: number;
  122414. /**
  122415. * Sets the reflection reflectance fresnel values according to the default standard
  122416. * empirically know to work well :-)
  122417. */
  122418. set reflectionStandardFresnelWeight(value: number);
  122419. protected _useRGBColor: boolean;
  122420. /**
  122421. * Helps to directly use the maps channels instead of their level.
  122422. */
  122423. useRGBColor: boolean;
  122424. protected _enableNoise: boolean;
  122425. /**
  122426. * This helps reducing the banding effect that could occur on the background.
  122427. */
  122428. enableNoise: boolean;
  122429. /**
  122430. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122431. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122432. * Recommended to be keep at 1.0 except for special cases.
  122433. */
  122434. get fovMultiplier(): number;
  122435. set fovMultiplier(value: number);
  122436. private _fovMultiplier;
  122437. /**
  122438. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122439. */
  122440. useEquirectangularFOV: boolean;
  122441. private _maxSimultaneousLights;
  122442. /**
  122443. * Number of Simultaneous lights allowed on the material.
  122444. */
  122445. maxSimultaneousLights: int;
  122446. /**
  122447. * Default configuration related to image processing available in the Background Material.
  122448. */
  122449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122450. /**
  122451. * Keep track of the image processing observer to allow dispose and replace.
  122452. */
  122453. private _imageProcessingObserver;
  122454. /**
  122455. * Attaches a new image processing configuration to the PBR Material.
  122456. * @param configuration (if null the scene configuration will be use)
  122457. */
  122458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122459. /**
  122460. * Gets the image processing configuration used either in this material.
  122461. */
  122462. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122463. /**
  122464. * Sets the Default image processing configuration used either in the this material.
  122465. *
  122466. * If sets to null, the scene one is in use.
  122467. */
  122468. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122469. /**
  122470. * Gets wether the color curves effect is enabled.
  122471. */
  122472. get cameraColorCurvesEnabled(): boolean;
  122473. /**
  122474. * Sets wether the color curves effect is enabled.
  122475. */
  122476. set cameraColorCurvesEnabled(value: boolean);
  122477. /**
  122478. * Gets wether the color grading effect is enabled.
  122479. */
  122480. get cameraColorGradingEnabled(): boolean;
  122481. /**
  122482. * Gets wether the color grading effect is enabled.
  122483. */
  122484. set cameraColorGradingEnabled(value: boolean);
  122485. /**
  122486. * Gets wether tonemapping is enabled or not.
  122487. */
  122488. get cameraToneMappingEnabled(): boolean;
  122489. /**
  122490. * Sets wether tonemapping is enabled or not
  122491. */
  122492. set cameraToneMappingEnabled(value: boolean);
  122493. /**
  122494. * The camera exposure used on this material.
  122495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122496. * This corresponds to a photographic exposure.
  122497. */
  122498. get cameraExposure(): float;
  122499. /**
  122500. * The camera exposure used on this material.
  122501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122502. * This corresponds to a photographic exposure.
  122503. */
  122504. set cameraExposure(value: float);
  122505. /**
  122506. * Gets The camera contrast used on this material.
  122507. */
  122508. get cameraContrast(): float;
  122509. /**
  122510. * Sets The camera contrast used on this material.
  122511. */
  122512. set cameraContrast(value: float);
  122513. /**
  122514. * Gets the Color Grading 2D Lookup Texture.
  122515. */
  122516. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122517. /**
  122518. * Sets the Color Grading 2D Lookup Texture.
  122519. */
  122520. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122521. /**
  122522. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122523. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122524. * 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;
  122525. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122526. */
  122527. get cameraColorCurves(): Nullable<ColorCurves>;
  122528. /**
  122529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122531. * 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;
  122532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122533. */
  122534. set cameraColorCurves(value: Nullable<ColorCurves>);
  122535. /**
  122536. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122537. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122538. */
  122539. switchToBGR: boolean;
  122540. private _renderTargets;
  122541. private _reflectionControls;
  122542. private _white;
  122543. private _primaryShadowColor;
  122544. private _primaryHighlightColor;
  122545. /**
  122546. * Instantiates a Background Material in the given scene
  122547. * @param name The friendly name of the material
  122548. * @param scene The scene to add the material to
  122549. */
  122550. constructor(name: string, scene: Scene);
  122551. /**
  122552. * Gets a boolean indicating that current material needs to register RTT
  122553. */
  122554. get hasRenderTargetTextures(): boolean;
  122555. /**
  122556. * The entire material has been created in order to prevent overdraw.
  122557. * @returns false
  122558. */
  122559. needAlphaTesting(): boolean;
  122560. /**
  122561. * The entire material has been created in order to prevent overdraw.
  122562. * @returns true if blending is enable
  122563. */
  122564. needAlphaBlending(): boolean;
  122565. /**
  122566. * Checks wether the material is ready to be rendered for a given mesh.
  122567. * @param mesh The mesh to render
  122568. * @param subMesh The submesh to check against
  122569. * @param useInstances Specify wether or not the material is used with instances
  122570. * @returns true if all the dependencies are ready (Textures, Effects...)
  122571. */
  122572. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122573. /**
  122574. * Compute the primary color according to the chosen perceptual color.
  122575. */
  122576. private _computePrimaryColorFromPerceptualColor;
  122577. /**
  122578. * Compute the highlights and shadow colors according to their chosen levels.
  122579. */
  122580. private _computePrimaryColors;
  122581. /**
  122582. * Build the uniform buffer used in the material.
  122583. */
  122584. buildUniformLayout(): void;
  122585. /**
  122586. * Unbind the material.
  122587. */
  122588. unbind(): void;
  122589. /**
  122590. * Bind only the world matrix to the material.
  122591. * @param world The world matrix to bind.
  122592. */
  122593. bindOnlyWorldMatrix(world: Matrix): void;
  122594. /**
  122595. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122596. * @param world The world matrix to bind.
  122597. * @param subMesh The submesh to bind for.
  122598. */
  122599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122600. /**
  122601. * Checks to see if a texture is used in the material.
  122602. * @param texture - Base texture to use.
  122603. * @returns - Boolean specifying if a texture is used in the material.
  122604. */
  122605. hasTexture(texture: BaseTexture): boolean;
  122606. /**
  122607. * Dispose the material.
  122608. * @param forceDisposeEffect Force disposal of the associated effect.
  122609. * @param forceDisposeTextures Force disposal of the associated textures.
  122610. */
  122611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122612. /**
  122613. * Clones the material.
  122614. * @param name The cloned name.
  122615. * @returns The cloned material.
  122616. */
  122617. clone(name: string): BackgroundMaterial;
  122618. /**
  122619. * Serializes the current material to its JSON representation.
  122620. * @returns The JSON representation.
  122621. */
  122622. serialize(): any;
  122623. /**
  122624. * Gets the class name of the material
  122625. * @returns "BackgroundMaterial"
  122626. */
  122627. getClassName(): string;
  122628. /**
  122629. * Parse a JSON input to create back a background material.
  122630. * @param source The JSON data to parse
  122631. * @param scene The scene to create the parsed material in
  122632. * @param rootUrl The root url of the assets the material depends upon
  122633. * @returns the instantiated BackgroundMaterial.
  122634. */
  122635. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122636. }
  122637. }
  122638. declare module BABYLON {
  122639. /**
  122640. * Represents the different options available during the creation of
  122641. * a Environment helper.
  122642. *
  122643. * This can control the default ground, skybox and image processing setup of your scene.
  122644. */
  122645. export interface IEnvironmentHelperOptions {
  122646. /**
  122647. * Specifies whether or not to create a ground.
  122648. * True by default.
  122649. */
  122650. createGround: boolean;
  122651. /**
  122652. * Specifies the ground size.
  122653. * 15 by default.
  122654. */
  122655. groundSize: number;
  122656. /**
  122657. * The texture used on the ground for the main color.
  122658. * Comes from the BabylonJS CDN by default.
  122659. *
  122660. * Remarks: Can be either a texture or a url.
  122661. */
  122662. groundTexture: string | BaseTexture;
  122663. /**
  122664. * The color mixed in the ground texture by default.
  122665. * BabylonJS clearColor by default.
  122666. */
  122667. groundColor: Color3;
  122668. /**
  122669. * Specifies the ground opacity.
  122670. * 1 by default.
  122671. */
  122672. groundOpacity: number;
  122673. /**
  122674. * Enables the ground to receive shadows.
  122675. * True by default.
  122676. */
  122677. enableGroundShadow: boolean;
  122678. /**
  122679. * Helps preventing the shadow to be fully black on the ground.
  122680. * 0.5 by default.
  122681. */
  122682. groundShadowLevel: number;
  122683. /**
  122684. * Creates a mirror texture attach to the ground.
  122685. * false by default.
  122686. */
  122687. enableGroundMirror: boolean;
  122688. /**
  122689. * Specifies the ground mirror size ratio.
  122690. * 0.3 by default as the default kernel is 64.
  122691. */
  122692. groundMirrorSizeRatio: number;
  122693. /**
  122694. * Specifies the ground mirror blur kernel size.
  122695. * 64 by default.
  122696. */
  122697. groundMirrorBlurKernel: number;
  122698. /**
  122699. * Specifies the ground mirror visibility amount.
  122700. * 1 by default
  122701. */
  122702. groundMirrorAmount: number;
  122703. /**
  122704. * Specifies the ground mirror reflectance weight.
  122705. * This uses the standard weight of the background material to setup the fresnel effect
  122706. * of the mirror.
  122707. * 1 by default.
  122708. */
  122709. groundMirrorFresnelWeight: number;
  122710. /**
  122711. * Specifies the ground mirror Falloff distance.
  122712. * This can helps reducing the size of the reflection.
  122713. * 0 by Default.
  122714. */
  122715. groundMirrorFallOffDistance: number;
  122716. /**
  122717. * Specifies the ground mirror texture type.
  122718. * Unsigned Int by Default.
  122719. */
  122720. groundMirrorTextureType: number;
  122721. /**
  122722. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122723. * the shown objects.
  122724. */
  122725. groundYBias: number;
  122726. /**
  122727. * Specifies whether or not to create a skybox.
  122728. * True by default.
  122729. */
  122730. createSkybox: boolean;
  122731. /**
  122732. * Specifies the skybox size.
  122733. * 20 by default.
  122734. */
  122735. skyboxSize: number;
  122736. /**
  122737. * The texture used on the skybox for the main color.
  122738. * Comes from the BabylonJS CDN by default.
  122739. *
  122740. * Remarks: Can be either a texture or a url.
  122741. */
  122742. skyboxTexture: string | BaseTexture;
  122743. /**
  122744. * The color mixed in the skybox texture by default.
  122745. * BabylonJS clearColor by default.
  122746. */
  122747. skyboxColor: Color3;
  122748. /**
  122749. * The background rotation around the Y axis of the scene.
  122750. * This helps aligning the key lights of your scene with the background.
  122751. * 0 by default.
  122752. */
  122753. backgroundYRotation: number;
  122754. /**
  122755. * Compute automatically the size of the elements to best fit with the scene.
  122756. */
  122757. sizeAuto: boolean;
  122758. /**
  122759. * Default position of the rootMesh if autoSize is not true.
  122760. */
  122761. rootPosition: Vector3;
  122762. /**
  122763. * Sets up the image processing in the scene.
  122764. * true by default.
  122765. */
  122766. setupImageProcessing: boolean;
  122767. /**
  122768. * The texture used as your environment texture in the scene.
  122769. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122770. *
  122771. * Remarks: Can be either a texture or a url.
  122772. */
  122773. environmentTexture: string | BaseTexture;
  122774. /**
  122775. * The value of the exposure to apply to the scene.
  122776. * 0.6 by default if setupImageProcessing is true.
  122777. */
  122778. cameraExposure: number;
  122779. /**
  122780. * The value of the contrast to apply to the scene.
  122781. * 1.6 by default if setupImageProcessing is true.
  122782. */
  122783. cameraContrast: number;
  122784. /**
  122785. * Specifies whether or not tonemapping should be enabled in the scene.
  122786. * true by default if setupImageProcessing is true.
  122787. */
  122788. toneMappingEnabled: boolean;
  122789. }
  122790. /**
  122791. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122792. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122793. * It also helps with the default setup of your imageProcessing configuration.
  122794. */
  122795. export class EnvironmentHelper {
  122796. /**
  122797. * Default ground texture URL.
  122798. */
  122799. private static _groundTextureCDNUrl;
  122800. /**
  122801. * Default skybox texture URL.
  122802. */
  122803. private static _skyboxTextureCDNUrl;
  122804. /**
  122805. * Default environment texture URL.
  122806. */
  122807. private static _environmentTextureCDNUrl;
  122808. /**
  122809. * Creates the default options for the helper.
  122810. */
  122811. private static _getDefaultOptions;
  122812. private _rootMesh;
  122813. /**
  122814. * Gets the root mesh created by the helper.
  122815. */
  122816. get rootMesh(): Mesh;
  122817. private _skybox;
  122818. /**
  122819. * Gets the skybox created by the helper.
  122820. */
  122821. get skybox(): Nullable<Mesh>;
  122822. private _skyboxTexture;
  122823. /**
  122824. * Gets the skybox texture created by the helper.
  122825. */
  122826. get skyboxTexture(): Nullable<BaseTexture>;
  122827. private _skyboxMaterial;
  122828. /**
  122829. * Gets the skybox material created by the helper.
  122830. */
  122831. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122832. private _ground;
  122833. /**
  122834. * Gets the ground mesh created by the helper.
  122835. */
  122836. get ground(): Nullable<Mesh>;
  122837. private _groundTexture;
  122838. /**
  122839. * Gets the ground texture created by the helper.
  122840. */
  122841. get groundTexture(): Nullable<BaseTexture>;
  122842. private _groundMirror;
  122843. /**
  122844. * Gets the ground mirror created by the helper.
  122845. */
  122846. get groundMirror(): Nullable<MirrorTexture>;
  122847. /**
  122848. * Gets the ground mirror render list to helps pushing the meshes
  122849. * you wish in the ground reflection.
  122850. */
  122851. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122852. private _groundMaterial;
  122853. /**
  122854. * Gets the ground material created by the helper.
  122855. */
  122856. get groundMaterial(): Nullable<BackgroundMaterial>;
  122857. /**
  122858. * Stores the creation options.
  122859. */
  122860. private readonly _scene;
  122861. private _options;
  122862. /**
  122863. * This observable will be notified with any error during the creation of the environment,
  122864. * mainly texture creation errors.
  122865. */
  122866. onErrorObservable: Observable<{
  122867. message?: string;
  122868. exception?: any;
  122869. }>;
  122870. /**
  122871. * constructor
  122872. * @param options Defines the options we want to customize the helper
  122873. * @param scene The scene to add the material to
  122874. */
  122875. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122876. /**
  122877. * Updates the background according to the new options
  122878. * @param options
  122879. */
  122880. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122881. /**
  122882. * Sets the primary color of all the available elements.
  122883. * @param color the main color to affect to the ground and the background
  122884. */
  122885. setMainColor(color: Color3): void;
  122886. /**
  122887. * Setup the image processing according to the specified options.
  122888. */
  122889. private _setupImageProcessing;
  122890. /**
  122891. * Setup the environment texture according to the specified options.
  122892. */
  122893. private _setupEnvironmentTexture;
  122894. /**
  122895. * Setup the background according to the specified options.
  122896. */
  122897. private _setupBackground;
  122898. /**
  122899. * Get the scene sizes according to the setup.
  122900. */
  122901. private _getSceneSize;
  122902. /**
  122903. * Setup the ground according to the specified options.
  122904. */
  122905. private _setupGround;
  122906. /**
  122907. * Setup the ground material according to the specified options.
  122908. */
  122909. private _setupGroundMaterial;
  122910. /**
  122911. * Setup the ground diffuse texture according to the specified options.
  122912. */
  122913. private _setupGroundDiffuseTexture;
  122914. /**
  122915. * Setup the ground mirror texture according to the specified options.
  122916. */
  122917. private _setupGroundMirrorTexture;
  122918. /**
  122919. * Setup the ground to receive the mirror texture.
  122920. */
  122921. private _setupMirrorInGroundMaterial;
  122922. /**
  122923. * Setup the skybox according to the specified options.
  122924. */
  122925. private _setupSkybox;
  122926. /**
  122927. * Setup the skybox material according to the specified options.
  122928. */
  122929. private _setupSkyboxMaterial;
  122930. /**
  122931. * Setup the skybox reflection texture according to the specified options.
  122932. */
  122933. private _setupSkyboxReflectionTexture;
  122934. private _errorHandler;
  122935. /**
  122936. * Dispose all the elements created by the Helper.
  122937. */
  122938. dispose(): void;
  122939. }
  122940. }
  122941. declare module BABYLON {
  122942. /**
  122943. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122944. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122945. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122946. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122947. */
  122948. export class PhotoDome extends TransformNode {
  122949. /**
  122950. * Define the image as a Monoscopic panoramic 360 image.
  122951. */
  122952. static readonly MODE_MONOSCOPIC: number;
  122953. /**
  122954. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122955. */
  122956. static readonly MODE_TOPBOTTOM: number;
  122957. /**
  122958. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122959. */
  122960. static readonly MODE_SIDEBYSIDE: number;
  122961. private _useDirectMapping;
  122962. /**
  122963. * The texture being displayed on the sphere
  122964. */
  122965. protected _photoTexture: Texture;
  122966. /**
  122967. * Gets or sets the texture being displayed on the sphere
  122968. */
  122969. get photoTexture(): Texture;
  122970. set photoTexture(value: Texture);
  122971. /**
  122972. * Observable raised when an error occured while loading the 360 image
  122973. */
  122974. onLoadErrorObservable: Observable<string>;
  122975. /**
  122976. * The skybox material
  122977. */
  122978. protected _material: BackgroundMaterial;
  122979. /**
  122980. * The surface used for the skybox
  122981. */
  122982. protected _mesh: Mesh;
  122983. /**
  122984. * Gets the mesh used for the skybox.
  122985. */
  122986. get mesh(): Mesh;
  122987. /**
  122988. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122989. * Also see the options.resolution property.
  122990. */
  122991. get fovMultiplier(): number;
  122992. set fovMultiplier(value: number);
  122993. private _imageMode;
  122994. /**
  122995. * Gets or set the current video mode for the video. It can be:
  122996. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122997. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122998. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122999. */
  123000. get imageMode(): number;
  123001. set imageMode(value: number);
  123002. /**
  123003. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123004. * @param name Element's name, child elements will append suffixes for their own names.
  123005. * @param urlsOfPhoto defines the url of the photo to display
  123006. * @param options defines an object containing optional or exposed sub element properties
  123007. * @param onError defines a callback called when an error occured while loading the texture
  123008. */
  123009. constructor(name: string, urlOfPhoto: string, options: {
  123010. resolution?: number;
  123011. size?: number;
  123012. useDirectMapping?: boolean;
  123013. faceForward?: boolean;
  123014. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123015. private _onBeforeCameraRenderObserver;
  123016. private _changeImageMode;
  123017. /**
  123018. * Releases resources associated with this node.
  123019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123021. */
  123022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123023. }
  123024. }
  123025. declare module BABYLON {
  123026. /**
  123027. * Class used to host RGBD texture specific utilities
  123028. */
  123029. export class RGBDTextureTools {
  123030. /**
  123031. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123032. * @param texture the texture to expand.
  123033. */
  123034. static ExpandRGBDTexture(texture: Texture): void;
  123035. }
  123036. }
  123037. declare module BABYLON {
  123038. /**
  123039. * Class used to host texture specific utilities
  123040. */
  123041. export class BRDFTextureTools {
  123042. /**
  123043. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123044. * @param scene defines the hosting scene
  123045. * @returns the environment BRDF texture
  123046. */
  123047. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123048. private static _environmentBRDFBase64Texture;
  123049. }
  123050. }
  123051. declare module BABYLON {
  123052. /**
  123053. * @hidden
  123054. */
  123055. export interface IMaterialClearCoatDefines {
  123056. CLEARCOAT: boolean;
  123057. CLEARCOAT_DEFAULTIOR: boolean;
  123058. CLEARCOAT_TEXTURE: boolean;
  123059. CLEARCOAT_TEXTUREDIRECTUV: number;
  123060. CLEARCOAT_BUMP: boolean;
  123061. CLEARCOAT_BUMPDIRECTUV: number;
  123062. CLEARCOAT_TINT: boolean;
  123063. CLEARCOAT_TINT_TEXTURE: boolean;
  123064. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123065. /** @hidden */
  123066. _areTexturesDirty: boolean;
  123067. }
  123068. /**
  123069. * Define the code related to the clear coat parameters of the pbr material.
  123070. */
  123071. export class PBRClearCoatConfiguration {
  123072. /**
  123073. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123074. * The default fits with a polyurethane material.
  123075. */
  123076. private static readonly _DefaultIndexOfRefraction;
  123077. private _isEnabled;
  123078. /**
  123079. * Defines if the clear coat is enabled in the material.
  123080. */
  123081. isEnabled: boolean;
  123082. /**
  123083. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123084. */
  123085. intensity: number;
  123086. /**
  123087. * Defines the clear coat layer roughness.
  123088. */
  123089. roughness: number;
  123090. private _indexOfRefraction;
  123091. /**
  123092. * Defines the index of refraction of the clear coat.
  123093. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123094. * The default fits with a polyurethane material.
  123095. * Changing the default value is more performance intensive.
  123096. */
  123097. indexOfRefraction: number;
  123098. private _texture;
  123099. /**
  123100. * Stores the clear coat values in a texture.
  123101. */
  123102. texture: Nullable<BaseTexture>;
  123103. private _bumpTexture;
  123104. /**
  123105. * Define the clear coat specific bump texture.
  123106. */
  123107. bumpTexture: Nullable<BaseTexture>;
  123108. private _isTintEnabled;
  123109. /**
  123110. * Defines if the clear coat tint is enabled in the material.
  123111. */
  123112. isTintEnabled: boolean;
  123113. /**
  123114. * Defines the clear coat tint of the material.
  123115. * This is only use if tint is enabled
  123116. */
  123117. tintColor: Color3;
  123118. /**
  123119. * Defines the distance at which the tint color should be found in the
  123120. * clear coat media.
  123121. * This is only use if tint is enabled
  123122. */
  123123. tintColorAtDistance: number;
  123124. /**
  123125. * Defines the clear coat layer thickness.
  123126. * This is only use if tint is enabled
  123127. */
  123128. tintThickness: number;
  123129. private _tintTexture;
  123130. /**
  123131. * Stores the clear tint values in a texture.
  123132. * rgb is tint
  123133. * a is a thickness factor
  123134. */
  123135. tintTexture: Nullable<BaseTexture>;
  123136. /** @hidden */
  123137. private _internalMarkAllSubMeshesAsTexturesDirty;
  123138. /** @hidden */
  123139. _markAllSubMeshesAsTexturesDirty(): void;
  123140. /**
  123141. * Instantiate a new istance of clear coat configuration.
  123142. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123143. */
  123144. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123145. /**
  123146. * Gets wehter the submesh is ready to be used or not.
  123147. * @param defines the list of "defines" to update.
  123148. * @param scene defines the scene the material belongs to.
  123149. * @param engine defines the engine the material belongs to.
  123150. * @param disableBumpMap defines wether the material disables bump or not.
  123151. * @returns - boolean indicating that the submesh is ready or not.
  123152. */
  123153. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123154. /**
  123155. * Checks to see if a texture is used in the material.
  123156. * @param defines the list of "defines" to update.
  123157. * @param scene defines the scene to the material belongs to.
  123158. */
  123159. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123160. /**
  123161. * Binds the material data.
  123162. * @param uniformBuffer defines the Uniform buffer to fill in.
  123163. * @param scene defines the scene the material belongs to.
  123164. * @param engine defines the engine the material belongs to.
  123165. * @param disableBumpMap defines wether the material disables bump or not.
  123166. * @param isFrozen defines wether the material is frozen or not.
  123167. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123168. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123169. */
  123170. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123171. /**
  123172. * Checks to see if a texture is used in the material.
  123173. * @param texture - Base texture to use.
  123174. * @returns - Boolean specifying if a texture is used in the material.
  123175. */
  123176. hasTexture(texture: BaseTexture): boolean;
  123177. /**
  123178. * Returns an array of the actively used textures.
  123179. * @param activeTextures Array of BaseTextures
  123180. */
  123181. getActiveTextures(activeTextures: BaseTexture[]): void;
  123182. /**
  123183. * Returns the animatable textures.
  123184. * @param animatables Array of animatable textures.
  123185. */
  123186. getAnimatables(animatables: IAnimatable[]): void;
  123187. /**
  123188. * Disposes the resources of the material.
  123189. * @param forceDisposeTextures - Forces the disposal of all textures.
  123190. */
  123191. dispose(forceDisposeTextures?: boolean): void;
  123192. /**
  123193. * Get the current class name of the texture useful for serialization or dynamic coding.
  123194. * @returns "PBRClearCoatConfiguration"
  123195. */
  123196. getClassName(): string;
  123197. /**
  123198. * Add fallbacks to the effect fallbacks list.
  123199. * @param defines defines the Base texture to use.
  123200. * @param fallbacks defines the current fallback list.
  123201. * @param currentRank defines the current fallback rank.
  123202. * @returns the new fallback rank.
  123203. */
  123204. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123205. /**
  123206. * Add the required uniforms to the current list.
  123207. * @param uniforms defines the current uniform list.
  123208. */
  123209. static AddUniforms(uniforms: string[]): void;
  123210. /**
  123211. * Add the required samplers to the current list.
  123212. * @param samplers defines the current sampler list.
  123213. */
  123214. static AddSamplers(samplers: string[]): void;
  123215. /**
  123216. * Add the required uniforms to the current buffer.
  123217. * @param uniformBuffer defines the current uniform buffer.
  123218. */
  123219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123220. /**
  123221. * Makes a duplicate of the current configuration into another one.
  123222. * @param clearCoatConfiguration define the config where to copy the info
  123223. */
  123224. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123225. /**
  123226. * Serializes this clear coat configuration.
  123227. * @returns - An object with the serialized config.
  123228. */
  123229. serialize(): any;
  123230. /**
  123231. * Parses a anisotropy Configuration from a serialized object.
  123232. * @param source - Serialized object.
  123233. * @param scene Defines the scene we are parsing for
  123234. * @param rootUrl Defines the rootUrl to load from
  123235. */
  123236. parse(source: any, scene: Scene, rootUrl: string): void;
  123237. }
  123238. }
  123239. declare module BABYLON {
  123240. /**
  123241. * @hidden
  123242. */
  123243. export interface IMaterialAnisotropicDefines {
  123244. ANISOTROPIC: boolean;
  123245. ANISOTROPIC_TEXTURE: boolean;
  123246. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123247. MAINUV1: boolean;
  123248. _areTexturesDirty: boolean;
  123249. _needUVs: boolean;
  123250. }
  123251. /**
  123252. * Define the code related to the anisotropic parameters of the pbr material.
  123253. */
  123254. export class PBRAnisotropicConfiguration {
  123255. private _isEnabled;
  123256. /**
  123257. * Defines if the anisotropy is enabled in the material.
  123258. */
  123259. isEnabled: boolean;
  123260. /**
  123261. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123262. */
  123263. intensity: number;
  123264. /**
  123265. * Defines if the effect is along the tangents, bitangents or in between.
  123266. * By default, the effect is "strectching" the highlights along the tangents.
  123267. */
  123268. direction: Vector2;
  123269. private _texture;
  123270. /**
  123271. * Stores the anisotropy values in a texture.
  123272. * rg is direction (like normal from -1 to 1)
  123273. * b is a intensity
  123274. */
  123275. texture: Nullable<BaseTexture>;
  123276. /** @hidden */
  123277. private _internalMarkAllSubMeshesAsTexturesDirty;
  123278. /** @hidden */
  123279. _markAllSubMeshesAsTexturesDirty(): void;
  123280. /**
  123281. * Instantiate a new istance of anisotropy configuration.
  123282. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123283. */
  123284. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123285. /**
  123286. * Specifies that the submesh is ready to be used.
  123287. * @param defines the list of "defines" to update.
  123288. * @param scene defines the scene the material belongs to.
  123289. * @returns - boolean indicating that the submesh is ready or not.
  123290. */
  123291. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123292. /**
  123293. * Checks to see if a texture is used in the material.
  123294. * @param defines the list of "defines" to update.
  123295. * @param mesh the mesh we are preparing the defines for.
  123296. * @param scene defines the scene the material belongs to.
  123297. */
  123298. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123299. /**
  123300. * Binds the material data.
  123301. * @param uniformBuffer defines the Uniform buffer to fill in.
  123302. * @param scene defines the scene the material belongs to.
  123303. * @param isFrozen defines wether the material is frozen or not.
  123304. */
  123305. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123306. /**
  123307. * Checks to see if a texture is used in the material.
  123308. * @param texture - Base texture to use.
  123309. * @returns - Boolean specifying if a texture is used in the material.
  123310. */
  123311. hasTexture(texture: BaseTexture): boolean;
  123312. /**
  123313. * Returns an array of the actively used textures.
  123314. * @param activeTextures Array of BaseTextures
  123315. */
  123316. getActiveTextures(activeTextures: BaseTexture[]): void;
  123317. /**
  123318. * Returns the animatable textures.
  123319. * @param animatables Array of animatable textures.
  123320. */
  123321. getAnimatables(animatables: IAnimatable[]): void;
  123322. /**
  123323. * Disposes the resources of the material.
  123324. * @param forceDisposeTextures - Forces the disposal of all textures.
  123325. */
  123326. dispose(forceDisposeTextures?: boolean): void;
  123327. /**
  123328. * Get the current class name of the texture useful for serialization or dynamic coding.
  123329. * @returns "PBRAnisotropicConfiguration"
  123330. */
  123331. getClassName(): string;
  123332. /**
  123333. * Add fallbacks to the effect fallbacks list.
  123334. * @param defines defines the Base texture to use.
  123335. * @param fallbacks defines the current fallback list.
  123336. * @param currentRank defines the current fallback rank.
  123337. * @returns the new fallback rank.
  123338. */
  123339. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123340. /**
  123341. * Add the required uniforms to the current list.
  123342. * @param uniforms defines the current uniform list.
  123343. */
  123344. static AddUniforms(uniforms: string[]): void;
  123345. /**
  123346. * Add the required uniforms to the current buffer.
  123347. * @param uniformBuffer defines the current uniform buffer.
  123348. */
  123349. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123350. /**
  123351. * Add the required samplers to the current list.
  123352. * @param samplers defines the current sampler list.
  123353. */
  123354. static AddSamplers(samplers: string[]): void;
  123355. /**
  123356. * Makes a duplicate of the current configuration into another one.
  123357. * @param anisotropicConfiguration define the config where to copy the info
  123358. */
  123359. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123360. /**
  123361. * Serializes this anisotropy configuration.
  123362. * @returns - An object with the serialized config.
  123363. */
  123364. serialize(): any;
  123365. /**
  123366. * Parses a anisotropy Configuration from a serialized object.
  123367. * @param source - Serialized object.
  123368. * @param scene Defines the scene we are parsing for
  123369. * @param rootUrl Defines the rootUrl to load from
  123370. */
  123371. parse(source: any, scene: Scene, rootUrl: string): void;
  123372. }
  123373. }
  123374. declare module BABYLON {
  123375. /**
  123376. * @hidden
  123377. */
  123378. export interface IMaterialBRDFDefines {
  123379. BRDF_V_HEIGHT_CORRELATED: boolean;
  123380. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123381. SPHERICAL_HARMONICS: boolean;
  123382. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123383. /** @hidden */
  123384. _areMiscDirty: boolean;
  123385. }
  123386. /**
  123387. * Define the code related to the BRDF parameters of the pbr material.
  123388. */
  123389. export class PBRBRDFConfiguration {
  123390. /**
  123391. * Default value used for the energy conservation.
  123392. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123393. */
  123394. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123395. /**
  123396. * Default value used for the Smith Visibility Height Correlated mode.
  123397. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123398. */
  123399. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123400. /**
  123401. * Default value used for the IBL diffuse part.
  123402. * This can help switching back to the polynomials mode globally which is a tiny bit
  123403. * less GPU intensive at the drawback of a lower quality.
  123404. */
  123405. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123406. /**
  123407. * Default value used for activating energy conservation for the specular workflow.
  123408. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123409. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123410. */
  123411. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123412. private _useEnergyConservation;
  123413. /**
  123414. * Defines if the material uses energy conservation.
  123415. */
  123416. useEnergyConservation: boolean;
  123417. private _useSmithVisibilityHeightCorrelated;
  123418. /**
  123419. * LEGACY Mode set to false
  123420. * Defines if the material uses height smith correlated visibility term.
  123421. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123422. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123423. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123424. * Not relying on height correlated will also disable energy conservation.
  123425. */
  123426. useSmithVisibilityHeightCorrelated: boolean;
  123427. private _useSphericalHarmonics;
  123428. /**
  123429. * LEGACY Mode set to false
  123430. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123431. * diffuse part of the IBL.
  123432. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123433. * to the ground truth.
  123434. */
  123435. useSphericalHarmonics: boolean;
  123436. private _useSpecularGlossinessInputEnergyConservation;
  123437. /**
  123438. * Defines if the material uses energy conservation, when the specular workflow is active.
  123439. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123440. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123441. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123442. */
  123443. useSpecularGlossinessInputEnergyConservation: boolean;
  123444. /** @hidden */
  123445. private _internalMarkAllSubMeshesAsMiscDirty;
  123446. /** @hidden */
  123447. _markAllSubMeshesAsMiscDirty(): void;
  123448. /**
  123449. * Instantiate a new istance of clear coat configuration.
  123450. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123451. */
  123452. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123453. /**
  123454. * Checks to see if a texture is used in the material.
  123455. * @param defines the list of "defines" to update.
  123456. */
  123457. prepareDefines(defines: IMaterialBRDFDefines): void;
  123458. /**
  123459. * Get the current class name of the texture useful for serialization or dynamic coding.
  123460. * @returns "PBRClearCoatConfiguration"
  123461. */
  123462. getClassName(): string;
  123463. /**
  123464. * Makes a duplicate of the current configuration into another one.
  123465. * @param brdfConfiguration define the config where to copy the info
  123466. */
  123467. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123468. /**
  123469. * Serializes this BRDF configuration.
  123470. * @returns - An object with the serialized config.
  123471. */
  123472. serialize(): any;
  123473. /**
  123474. * Parses a anisotropy Configuration from a serialized object.
  123475. * @param source - Serialized object.
  123476. * @param scene Defines the scene we are parsing for
  123477. * @param rootUrl Defines the rootUrl to load from
  123478. */
  123479. parse(source: any, scene: Scene, rootUrl: string): void;
  123480. }
  123481. }
  123482. declare module BABYLON {
  123483. /**
  123484. * @hidden
  123485. */
  123486. export interface IMaterialSheenDefines {
  123487. SHEEN: boolean;
  123488. SHEEN_TEXTURE: boolean;
  123489. SHEEN_TEXTUREDIRECTUV: number;
  123490. SHEEN_LINKWITHALBEDO: boolean;
  123491. /** @hidden */
  123492. _areTexturesDirty: boolean;
  123493. }
  123494. /**
  123495. * Define the code related to the Sheen parameters of the pbr material.
  123496. */
  123497. export class PBRSheenConfiguration {
  123498. private _isEnabled;
  123499. /**
  123500. * Defines if the material uses sheen.
  123501. */
  123502. isEnabled: boolean;
  123503. private _linkSheenWithAlbedo;
  123504. /**
  123505. * Defines if the sheen is linked to the sheen color.
  123506. */
  123507. linkSheenWithAlbedo: boolean;
  123508. /**
  123509. * Defines the sheen intensity.
  123510. */
  123511. intensity: number;
  123512. /**
  123513. * Defines the sheen color.
  123514. */
  123515. color: Color3;
  123516. private _texture;
  123517. /**
  123518. * Stores the sheen tint values in a texture.
  123519. * rgb is tint
  123520. * a is a intensity
  123521. */
  123522. texture: Nullable<BaseTexture>;
  123523. /** @hidden */
  123524. private _internalMarkAllSubMeshesAsTexturesDirty;
  123525. /** @hidden */
  123526. _markAllSubMeshesAsTexturesDirty(): void;
  123527. /**
  123528. * Instantiate a new istance of clear coat configuration.
  123529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123530. */
  123531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123532. /**
  123533. * Specifies that the submesh is ready to be used.
  123534. * @param defines the list of "defines" to update.
  123535. * @param scene defines the scene the material belongs to.
  123536. * @returns - boolean indicating that the submesh is ready or not.
  123537. */
  123538. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123539. /**
  123540. * Checks to see if a texture is used in the material.
  123541. * @param defines the list of "defines" to update.
  123542. * @param scene defines the scene the material belongs to.
  123543. */
  123544. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123545. /**
  123546. * Binds the material data.
  123547. * @param uniformBuffer defines the Uniform buffer to fill in.
  123548. * @param scene defines the scene the material belongs to.
  123549. * @param isFrozen defines wether the material is frozen or not.
  123550. */
  123551. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123552. /**
  123553. * Checks to see if a texture is used in the material.
  123554. * @param texture - Base texture to use.
  123555. * @returns - Boolean specifying if a texture is used in the material.
  123556. */
  123557. hasTexture(texture: BaseTexture): boolean;
  123558. /**
  123559. * Returns an array of the actively used textures.
  123560. * @param activeTextures Array of BaseTextures
  123561. */
  123562. getActiveTextures(activeTextures: BaseTexture[]): void;
  123563. /**
  123564. * Returns the animatable textures.
  123565. * @param animatables Array of animatable textures.
  123566. */
  123567. getAnimatables(animatables: IAnimatable[]): void;
  123568. /**
  123569. * Disposes the resources of the material.
  123570. * @param forceDisposeTextures - Forces the disposal of all textures.
  123571. */
  123572. dispose(forceDisposeTextures?: boolean): void;
  123573. /**
  123574. * Get the current class name of the texture useful for serialization or dynamic coding.
  123575. * @returns "PBRSheenConfiguration"
  123576. */
  123577. getClassName(): string;
  123578. /**
  123579. * Add fallbacks to the effect fallbacks list.
  123580. * @param defines defines the Base texture to use.
  123581. * @param fallbacks defines the current fallback list.
  123582. * @param currentRank defines the current fallback rank.
  123583. * @returns the new fallback rank.
  123584. */
  123585. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123586. /**
  123587. * Add the required uniforms to the current list.
  123588. * @param uniforms defines the current uniform list.
  123589. */
  123590. static AddUniforms(uniforms: string[]): void;
  123591. /**
  123592. * Add the required uniforms to the current buffer.
  123593. * @param uniformBuffer defines the current uniform buffer.
  123594. */
  123595. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123596. /**
  123597. * Add the required samplers to the current list.
  123598. * @param samplers defines the current sampler list.
  123599. */
  123600. static AddSamplers(samplers: string[]): void;
  123601. /**
  123602. * Makes a duplicate of the current configuration into another one.
  123603. * @param sheenConfiguration define the config where to copy the info
  123604. */
  123605. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123606. /**
  123607. * Serializes this BRDF configuration.
  123608. * @returns - An object with the serialized config.
  123609. */
  123610. serialize(): any;
  123611. /**
  123612. * Parses a anisotropy Configuration from a serialized object.
  123613. * @param source - Serialized object.
  123614. * @param scene Defines the scene we are parsing for
  123615. * @param rootUrl Defines the rootUrl to load from
  123616. */
  123617. parse(source: any, scene: Scene, rootUrl: string): void;
  123618. }
  123619. }
  123620. declare module BABYLON {
  123621. /**
  123622. * @hidden
  123623. */
  123624. export interface IMaterialSubSurfaceDefines {
  123625. SUBSURFACE: boolean;
  123626. SS_REFRACTION: boolean;
  123627. SS_TRANSLUCENCY: boolean;
  123628. SS_SCATERRING: boolean;
  123629. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123630. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123631. SS_REFRACTIONMAP_3D: boolean;
  123632. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123633. SS_LODINREFRACTIONALPHA: boolean;
  123634. SS_GAMMAREFRACTION: boolean;
  123635. SS_RGBDREFRACTION: boolean;
  123636. SS_LINEARSPECULARREFRACTION: boolean;
  123637. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123638. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123639. /** @hidden */
  123640. _areTexturesDirty: boolean;
  123641. }
  123642. /**
  123643. * Define the code related to the sub surface parameters of the pbr material.
  123644. */
  123645. export class PBRSubSurfaceConfiguration {
  123646. private _isRefractionEnabled;
  123647. /**
  123648. * Defines if the refraction is enabled in the material.
  123649. */
  123650. isRefractionEnabled: boolean;
  123651. private _isTranslucencyEnabled;
  123652. /**
  123653. * Defines if the translucency is enabled in the material.
  123654. */
  123655. isTranslucencyEnabled: boolean;
  123656. private _isScatteringEnabled;
  123657. /**
  123658. * Defines the refraction intensity of the material.
  123659. * The refraction when enabled replaces the Diffuse part of the material.
  123660. * The intensity helps transitionning between diffuse and refraction.
  123661. */
  123662. refractionIntensity: number;
  123663. /**
  123664. * Defines the translucency intensity of the material.
  123665. * When translucency has been enabled, this defines how much of the "translucency"
  123666. * is addded to the diffuse part of the material.
  123667. */
  123668. translucencyIntensity: number;
  123669. /**
  123670. * Defines the scattering intensity of the material.
  123671. * When scattering has been enabled, this defines how much of the "scattered light"
  123672. * is addded to the diffuse part of the material.
  123673. */
  123674. scatteringIntensity: number;
  123675. private _thicknessTexture;
  123676. /**
  123677. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123678. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123679. * 0 would mean minimumThickness
  123680. * 1 would mean maximumThickness
  123681. * The other channels might be use as a mask to vary the different effects intensity.
  123682. */
  123683. thicknessTexture: Nullable<BaseTexture>;
  123684. private _refractionTexture;
  123685. /**
  123686. * Defines the texture to use for refraction.
  123687. */
  123688. refractionTexture: Nullable<BaseTexture>;
  123689. private _indexOfRefraction;
  123690. /**
  123691. * Defines the index of refraction used in the material.
  123692. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123693. */
  123694. indexOfRefraction: number;
  123695. private _invertRefractionY;
  123696. /**
  123697. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123698. */
  123699. invertRefractionY: boolean;
  123700. private _linkRefractionWithTransparency;
  123701. /**
  123702. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123703. * Materials half opaque for instance using refraction could benefit from this control.
  123704. */
  123705. linkRefractionWithTransparency: boolean;
  123706. /**
  123707. * Defines the minimum thickness stored in the thickness map.
  123708. * If no thickness map is defined, this value will be used to simulate thickness.
  123709. */
  123710. minimumThickness: number;
  123711. /**
  123712. * Defines the maximum thickness stored in the thickness map.
  123713. */
  123714. maximumThickness: number;
  123715. /**
  123716. * Defines the volume tint of the material.
  123717. * This is used for both translucency and scattering.
  123718. */
  123719. tintColor: Color3;
  123720. /**
  123721. * Defines the distance at which the tint color should be found in the media.
  123722. * This is used for refraction only.
  123723. */
  123724. tintColorAtDistance: number;
  123725. /**
  123726. * Defines how far each channel transmit through the media.
  123727. * It is defined as a color to simplify it selection.
  123728. */
  123729. diffusionDistance: Color3;
  123730. private _useMaskFromThicknessTexture;
  123731. /**
  123732. * Stores the intensity of the different subsurface effects in the thickness texture.
  123733. * * the green channel is the translucency intensity.
  123734. * * the blue channel is the scattering intensity.
  123735. * * the alpha channel is the refraction intensity.
  123736. */
  123737. useMaskFromThicknessTexture: boolean;
  123738. /** @hidden */
  123739. private _internalMarkAllSubMeshesAsTexturesDirty;
  123740. /** @hidden */
  123741. _markAllSubMeshesAsTexturesDirty(): void;
  123742. /**
  123743. * Instantiate a new istance of sub surface configuration.
  123744. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123745. */
  123746. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123747. /**
  123748. * Gets wehter the submesh is ready to be used or not.
  123749. * @param defines the list of "defines" to update.
  123750. * @param scene defines the scene the material belongs to.
  123751. * @returns - boolean indicating that the submesh is ready or not.
  123752. */
  123753. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123754. /**
  123755. * Checks to see if a texture is used in the material.
  123756. * @param defines the list of "defines" to update.
  123757. * @param scene defines the scene to the material belongs to.
  123758. */
  123759. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123760. /**
  123761. * Binds the material data.
  123762. * @param uniformBuffer defines the Uniform buffer to fill in.
  123763. * @param scene defines the scene the material belongs to.
  123764. * @param engine defines the engine the material belongs to.
  123765. * @param isFrozen defines wether the material is frozen or not.
  123766. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123767. */
  123768. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123769. /**
  123770. * Unbinds the material from the mesh.
  123771. * @param activeEffect defines the effect that should be unbound from.
  123772. * @returns true if unbound, otherwise false
  123773. */
  123774. unbind(activeEffect: Effect): boolean;
  123775. /**
  123776. * Returns the texture used for refraction or null if none is used.
  123777. * @param scene defines the scene the material belongs to.
  123778. * @returns - Refraction texture if present. If no refraction texture and refraction
  123779. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123780. */
  123781. private _getRefractionTexture;
  123782. /**
  123783. * Returns true if alpha blending should be disabled.
  123784. */
  123785. get disableAlphaBlending(): boolean;
  123786. /**
  123787. * Fills the list of render target textures.
  123788. * @param renderTargets the list of render targets to update
  123789. */
  123790. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123791. /**
  123792. * Checks to see if a texture is used in the material.
  123793. * @param texture - Base texture to use.
  123794. * @returns - Boolean specifying if a texture is used in the material.
  123795. */
  123796. hasTexture(texture: BaseTexture): boolean;
  123797. /**
  123798. * Gets a boolean indicating that current material needs to register RTT
  123799. * @returns true if this uses a render target otherwise false.
  123800. */
  123801. hasRenderTargetTextures(): boolean;
  123802. /**
  123803. * Returns an array of the actively used textures.
  123804. * @param activeTextures Array of BaseTextures
  123805. */
  123806. getActiveTextures(activeTextures: BaseTexture[]): void;
  123807. /**
  123808. * Returns the animatable textures.
  123809. * @param animatables Array of animatable textures.
  123810. */
  123811. getAnimatables(animatables: IAnimatable[]): void;
  123812. /**
  123813. * Disposes the resources of the material.
  123814. * @param forceDisposeTextures - Forces the disposal of all textures.
  123815. */
  123816. dispose(forceDisposeTextures?: boolean): void;
  123817. /**
  123818. * Get the current class name of the texture useful for serialization or dynamic coding.
  123819. * @returns "PBRSubSurfaceConfiguration"
  123820. */
  123821. getClassName(): string;
  123822. /**
  123823. * Add fallbacks to the effect fallbacks list.
  123824. * @param defines defines the Base texture to use.
  123825. * @param fallbacks defines the current fallback list.
  123826. * @param currentRank defines the current fallback rank.
  123827. * @returns the new fallback rank.
  123828. */
  123829. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123830. /**
  123831. * Add the required uniforms to the current list.
  123832. * @param uniforms defines the current uniform list.
  123833. */
  123834. static AddUniforms(uniforms: string[]): void;
  123835. /**
  123836. * Add the required samplers to the current list.
  123837. * @param samplers defines the current sampler list.
  123838. */
  123839. static AddSamplers(samplers: string[]): void;
  123840. /**
  123841. * Add the required uniforms to the current buffer.
  123842. * @param uniformBuffer defines the current uniform buffer.
  123843. */
  123844. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123845. /**
  123846. * Makes a duplicate of the current configuration into another one.
  123847. * @param configuration define the config where to copy the info
  123848. */
  123849. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123850. /**
  123851. * Serializes this Sub Surface configuration.
  123852. * @returns - An object with the serialized config.
  123853. */
  123854. serialize(): any;
  123855. /**
  123856. * Parses a anisotropy Configuration from a serialized object.
  123857. * @param source - Serialized object.
  123858. * @param scene Defines the scene we are parsing for
  123859. * @param rootUrl Defines the rootUrl to load from
  123860. */
  123861. parse(source: any, scene: Scene, rootUrl: string): void;
  123862. }
  123863. }
  123864. declare module BABYLON {
  123865. /** @hidden */
  123866. export var pbrFragmentDeclaration: {
  123867. name: string;
  123868. shader: string;
  123869. };
  123870. }
  123871. declare module BABYLON {
  123872. /** @hidden */
  123873. export var pbrUboDeclaration: {
  123874. name: string;
  123875. shader: string;
  123876. };
  123877. }
  123878. declare module BABYLON {
  123879. /** @hidden */
  123880. export var pbrFragmentExtraDeclaration: {
  123881. name: string;
  123882. shader: string;
  123883. };
  123884. }
  123885. declare module BABYLON {
  123886. /** @hidden */
  123887. export var pbrFragmentSamplersDeclaration: {
  123888. name: string;
  123889. shader: string;
  123890. };
  123891. }
  123892. declare module BABYLON {
  123893. /** @hidden */
  123894. export var pbrHelperFunctions: {
  123895. name: string;
  123896. shader: string;
  123897. };
  123898. }
  123899. declare module BABYLON {
  123900. /** @hidden */
  123901. export var harmonicsFunctions: {
  123902. name: string;
  123903. shader: string;
  123904. };
  123905. }
  123906. declare module BABYLON {
  123907. /** @hidden */
  123908. export var pbrDirectLightingSetupFunctions: {
  123909. name: string;
  123910. shader: string;
  123911. };
  123912. }
  123913. declare module BABYLON {
  123914. /** @hidden */
  123915. export var pbrDirectLightingFalloffFunctions: {
  123916. name: string;
  123917. shader: string;
  123918. };
  123919. }
  123920. declare module BABYLON {
  123921. /** @hidden */
  123922. export var pbrBRDFFunctions: {
  123923. name: string;
  123924. shader: string;
  123925. };
  123926. }
  123927. declare module BABYLON {
  123928. /** @hidden */
  123929. export var pbrDirectLightingFunctions: {
  123930. name: string;
  123931. shader: string;
  123932. };
  123933. }
  123934. declare module BABYLON {
  123935. /** @hidden */
  123936. export var pbrIBLFunctions: {
  123937. name: string;
  123938. shader: string;
  123939. };
  123940. }
  123941. declare module BABYLON {
  123942. /** @hidden */
  123943. export var pbrDebug: {
  123944. name: string;
  123945. shader: string;
  123946. };
  123947. }
  123948. declare module BABYLON {
  123949. /** @hidden */
  123950. export var pbrPixelShader: {
  123951. name: string;
  123952. shader: string;
  123953. };
  123954. }
  123955. declare module BABYLON {
  123956. /** @hidden */
  123957. export var pbrVertexDeclaration: {
  123958. name: string;
  123959. shader: string;
  123960. };
  123961. }
  123962. declare module BABYLON {
  123963. /** @hidden */
  123964. export var pbrVertexShader: {
  123965. name: string;
  123966. shader: string;
  123967. };
  123968. }
  123969. declare module BABYLON {
  123970. /**
  123971. * Manages the defines for the PBR Material.
  123972. * @hidden
  123973. */
  123974. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123975. PBR: boolean;
  123976. MAINUV1: boolean;
  123977. MAINUV2: boolean;
  123978. UV1: boolean;
  123979. UV2: boolean;
  123980. ALBEDO: boolean;
  123981. GAMMAALBEDO: boolean;
  123982. ALBEDODIRECTUV: number;
  123983. VERTEXCOLOR: boolean;
  123984. AMBIENT: boolean;
  123985. AMBIENTDIRECTUV: number;
  123986. AMBIENTINGRAYSCALE: boolean;
  123987. OPACITY: boolean;
  123988. VERTEXALPHA: boolean;
  123989. OPACITYDIRECTUV: number;
  123990. OPACITYRGB: boolean;
  123991. ALPHATEST: boolean;
  123992. DEPTHPREPASS: boolean;
  123993. ALPHABLEND: boolean;
  123994. ALPHAFROMALBEDO: boolean;
  123995. ALPHATESTVALUE: string;
  123996. SPECULAROVERALPHA: boolean;
  123997. RADIANCEOVERALPHA: boolean;
  123998. ALPHAFRESNEL: boolean;
  123999. LINEARALPHAFRESNEL: boolean;
  124000. PREMULTIPLYALPHA: boolean;
  124001. EMISSIVE: boolean;
  124002. EMISSIVEDIRECTUV: number;
  124003. REFLECTIVITY: boolean;
  124004. REFLECTIVITYDIRECTUV: number;
  124005. SPECULARTERM: boolean;
  124006. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124007. MICROSURFACEAUTOMATIC: boolean;
  124008. LODBASEDMICROSFURACE: boolean;
  124009. MICROSURFACEMAP: boolean;
  124010. MICROSURFACEMAPDIRECTUV: number;
  124011. METALLICWORKFLOW: boolean;
  124012. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124013. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124014. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124015. AOSTOREINMETALMAPRED: boolean;
  124016. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124017. ENVIRONMENTBRDF: boolean;
  124018. ENVIRONMENTBRDF_RGBD: boolean;
  124019. NORMAL: boolean;
  124020. TANGENT: boolean;
  124021. BUMP: boolean;
  124022. BUMPDIRECTUV: number;
  124023. OBJECTSPACE_NORMALMAP: boolean;
  124024. PARALLAX: boolean;
  124025. PARALLAXOCCLUSION: boolean;
  124026. NORMALXYSCALE: boolean;
  124027. LIGHTMAP: boolean;
  124028. LIGHTMAPDIRECTUV: number;
  124029. USELIGHTMAPASSHADOWMAP: boolean;
  124030. GAMMALIGHTMAP: boolean;
  124031. RGBDLIGHTMAP: boolean;
  124032. REFLECTION: boolean;
  124033. REFLECTIONMAP_3D: boolean;
  124034. REFLECTIONMAP_SPHERICAL: boolean;
  124035. REFLECTIONMAP_PLANAR: boolean;
  124036. REFLECTIONMAP_CUBIC: boolean;
  124037. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124038. REFLECTIONMAP_PROJECTION: boolean;
  124039. REFLECTIONMAP_SKYBOX: boolean;
  124040. REFLECTIONMAP_EXPLICIT: boolean;
  124041. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124042. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124043. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124044. INVERTCUBICMAP: boolean;
  124045. USESPHERICALFROMREFLECTIONMAP: boolean;
  124046. USEIRRADIANCEMAP: boolean;
  124047. SPHERICAL_HARMONICS: boolean;
  124048. USESPHERICALINVERTEX: boolean;
  124049. REFLECTIONMAP_OPPOSITEZ: boolean;
  124050. LODINREFLECTIONALPHA: boolean;
  124051. GAMMAREFLECTION: boolean;
  124052. RGBDREFLECTION: boolean;
  124053. LINEARSPECULARREFLECTION: boolean;
  124054. RADIANCEOCCLUSION: boolean;
  124055. HORIZONOCCLUSION: boolean;
  124056. INSTANCES: boolean;
  124057. NUM_BONE_INFLUENCERS: number;
  124058. BonesPerMesh: number;
  124059. BONETEXTURE: boolean;
  124060. NONUNIFORMSCALING: boolean;
  124061. MORPHTARGETS: boolean;
  124062. MORPHTARGETS_NORMAL: boolean;
  124063. MORPHTARGETS_TANGENT: boolean;
  124064. MORPHTARGETS_UV: boolean;
  124065. NUM_MORPH_INFLUENCERS: number;
  124066. IMAGEPROCESSING: boolean;
  124067. VIGNETTE: boolean;
  124068. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124069. VIGNETTEBLENDMODEOPAQUE: boolean;
  124070. TONEMAPPING: boolean;
  124071. TONEMAPPING_ACES: boolean;
  124072. CONTRAST: boolean;
  124073. COLORCURVES: boolean;
  124074. COLORGRADING: boolean;
  124075. COLORGRADING3D: boolean;
  124076. SAMPLER3DGREENDEPTH: boolean;
  124077. SAMPLER3DBGRMAP: boolean;
  124078. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124079. EXPOSURE: boolean;
  124080. MULTIVIEW: boolean;
  124081. USEPHYSICALLIGHTFALLOFF: boolean;
  124082. USEGLTFLIGHTFALLOFF: boolean;
  124083. TWOSIDEDLIGHTING: boolean;
  124084. SHADOWFLOAT: boolean;
  124085. CLIPPLANE: boolean;
  124086. CLIPPLANE2: boolean;
  124087. CLIPPLANE3: boolean;
  124088. CLIPPLANE4: boolean;
  124089. CLIPPLANE5: boolean;
  124090. CLIPPLANE6: boolean;
  124091. POINTSIZE: boolean;
  124092. FOG: boolean;
  124093. LOGARITHMICDEPTH: boolean;
  124094. FORCENORMALFORWARD: boolean;
  124095. SPECULARAA: boolean;
  124096. CLEARCOAT: boolean;
  124097. CLEARCOAT_DEFAULTIOR: boolean;
  124098. CLEARCOAT_TEXTURE: boolean;
  124099. CLEARCOAT_TEXTUREDIRECTUV: number;
  124100. CLEARCOAT_BUMP: boolean;
  124101. CLEARCOAT_BUMPDIRECTUV: number;
  124102. CLEARCOAT_TINT: boolean;
  124103. CLEARCOAT_TINT_TEXTURE: boolean;
  124104. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124105. ANISOTROPIC: boolean;
  124106. ANISOTROPIC_TEXTURE: boolean;
  124107. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124108. BRDF_V_HEIGHT_CORRELATED: boolean;
  124109. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124110. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124111. SHEEN: boolean;
  124112. SHEEN_TEXTURE: boolean;
  124113. SHEEN_TEXTUREDIRECTUV: number;
  124114. SHEEN_LINKWITHALBEDO: boolean;
  124115. SUBSURFACE: boolean;
  124116. SS_REFRACTION: boolean;
  124117. SS_TRANSLUCENCY: boolean;
  124118. SS_SCATERRING: boolean;
  124119. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124120. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124121. SS_REFRACTIONMAP_3D: boolean;
  124122. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124123. SS_LODINREFRACTIONALPHA: boolean;
  124124. SS_GAMMAREFRACTION: boolean;
  124125. SS_RGBDREFRACTION: boolean;
  124126. SS_LINEARSPECULARREFRACTION: boolean;
  124127. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124128. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124129. UNLIT: boolean;
  124130. DEBUGMODE: number;
  124131. /**
  124132. * Initializes the PBR Material defines.
  124133. */
  124134. constructor();
  124135. /**
  124136. * Resets the PBR Material defines.
  124137. */
  124138. reset(): void;
  124139. }
  124140. /**
  124141. * The Physically based material base class of BJS.
  124142. *
  124143. * This offers the main features of a standard PBR material.
  124144. * For more information, please refer to the documentation :
  124145. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124146. */
  124147. export abstract class PBRBaseMaterial extends PushMaterial {
  124148. /**
  124149. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124150. */
  124151. static readonly PBRMATERIAL_OPAQUE: number;
  124152. /**
  124153. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124154. */
  124155. static readonly PBRMATERIAL_ALPHATEST: number;
  124156. /**
  124157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124158. */
  124159. static readonly PBRMATERIAL_ALPHABLEND: number;
  124160. /**
  124161. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124162. * They are also discarded below the alpha cutoff threshold to improve performances.
  124163. */
  124164. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124165. /**
  124166. * Defines the default value of how much AO map is occluding the analytical lights
  124167. * (point spot...).
  124168. */
  124169. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124170. /**
  124171. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124172. */
  124173. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124174. /**
  124175. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124176. * to enhance interoperability with other engines.
  124177. */
  124178. static readonly LIGHTFALLOFF_GLTF: number;
  124179. /**
  124180. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124181. * to enhance interoperability with other materials.
  124182. */
  124183. static readonly LIGHTFALLOFF_STANDARD: number;
  124184. /**
  124185. * Intensity of the direct lights e.g. the four lights available in your scene.
  124186. * This impacts both the direct diffuse and specular highlights.
  124187. */
  124188. protected _directIntensity: number;
  124189. /**
  124190. * Intensity of the emissive part of the material.
  124191. * This helps controlling the emissive effect without modifying the emissive color.
  124192. */
  124193. protected _emissiveIntensity: number;
  124194. /**
  124195. * Intensity of the environment e.g. how much the environment will light the object
  124196. * either through harmonics for rough material or through the refelction for shiny ones.
  124197. */
  124198. protected _environmentIntensity: number;
  124199. /**
  124200. * This is a special control allowing the reduction of the specular highlights coming from the
  124201. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124202. */
  124203. protected _specularIntensity: number;
  124204. /**
  124205. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124206. */
  124207. private _lightingInfos;
  124208. /**
  124209. * Debug Control allowing disabling the bump map on this material.
  124210. */
  124211. protected _disableBumpMap: boolean;
  124212. /**
  124213. * AKA Diffuse Texture in standard nomenclature.
  124214. */
  124215. protected _albedoTexture: Nullable<BaseTexture>;
  124216. /**
  124217. * AKA Occlusion Texture in other nomenclature.
  124218. */
  124219. protected _ambientTexture: Nullable<BaseTexture>;
  124220. /**
  124221. * AKA Occlusion Texture Intensity in other nomenclature.
  124222. */
  124223. protected _ambientTextureStrength: number;
  124224. /**
  124225. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124226. * 1 means it completely occludes it
  124227. * 0 mean it has no impact
  124228. */
  124229. protected _ambientTextureImpactOnAnalyticalLights: number;
  124230. /**
  124231. * Stores the alpha values in a texture.
  124232. */
  124233. protected _opacityTexture: Nullable<BaseTexture>;
  124234. /**
  124235. * Stores the reflection values in a texture.
  124236. */
  124237. protected _reflectionTexture: Nullable<BaseTexture>;
  124238. /**
  124239. * Stores the emissive values in a texture.
  124240. */
  124241. protected _emissiveTexture: Nullable<BaseTexture>;
  124242. /**
  124243. * AKA Specular texture in other nomenclature.
  124244. */
  124245. protected _reflectivityTexture: Nullable<BaseTexture>;
  124246. /**
  124247. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124248. */
  124249. protected _metallicTexture: Nullable<BaseTexture>;
  124250. /**
  124251. * Specifies the metallic scalar of the metallic/roughness workflow.
  124252. * Can also be used to scale the metalness values of the metallic texture.
  124253. */
  124254. protected _metallic: Nullable<number>;
  124255. /**
  124256. * Specifies the roughness scalar of the metallic/roughness workflow.
  124257. * Can also be used to scale the roughness values of the metallic texture.
  124258. */
  124259. protected _roughness: Nullable<number>;
  124260. /**
  124261. * Specifies the an F0 factor to help configuring the material F0.
  124262. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124263. * to 0.5 the previously hard coded value stays the same.
  124264. * Can also be used to scale the F0 values of the metallic texture.
  124265. */
  124266. protected _metallicF0Factor: number;
  124267. /**
  124268. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124269. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124270. * your expectation as it multiplies with the texture data.
  124271. */
  124272. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124273. /**
  124274. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124275. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124276. */
  124277. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124278. /**
  124279. * Stores surface normal data used to displace a mesh in a texture.
  124280. */
  124281. protected _bumpTexture: Nullable<BaseTexture>;
  124282. /**
  124283. * Stores the pre-calculated light information of a mesh in a texture.
  124284. */
  124285. protected _lightmapTexture: Nullable<BaseTexture>;
  124286. /**
  124287. * The color of a material in ambient lighting.
  124288. */
  124289. protected _ambientColor: Color3;
  124290. /**
  124291. * AKA Diffuse Color in other nomenclature.
  124292. */
  124293. protected _albedoColor: Color3;
  124294. /**
  124295. * AKA Specular Color in other nomenclature.
  124296. */
  124297. protected _reflectivityColor: Color3;
  124298. /**
  124299. * The color applied when light is reflected from a material.
  124300. */
  124301. protected _reflectionColor: Color3;
  124302. /**
  124303. * The color applied when light is emitted from a material.
  124304. */
  124305. protected _emissiveColor: Color3;
  124306. /**
  124307. * AKA Glossiness in other nomenclature.
  124308. */
  124309. protected _microSurface: number;
  124310. /**
  124311. * Specifies that the material will use the light map as a show map.
  124312. */
  124313. protected _useLightmapAsShadowmap: boolean;
  124314. /**
  124315. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124316. * makes the reflect vector face the model (under horizon).
  124317. */
  124318. protected _useHorizonOcclusion: boolean;
  124319. /**
  124320. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124321. * too much the area relying on ambient texture to define their ambient occlusion.
  124322. */
  124323. protected _useRadianceOcclusion: boolean;
  124324. /**
  124325. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124326. */
  124327. protected _useAlphaFromAlbedoTexture: boolean;
  124328. /**
  124329. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124330. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124331. */
  124332. protected _useSpecularOverAlpha: boolean;
  124333. /**
  124334. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124335. */
  124336. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124337. /**
  124338. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124339. */
  124340. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124341. /**
  124342. * Specifies if the metallic texture contains the roughness information in its green channel.
  124343. */
  124344. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124345. /**
  124346. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124347. */
  124348. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124349. /**
  124350. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124351. */
  124352. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124353. /**
  124354. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124355. */
  124356. protected _useAmbientInGrayScale: boolean;
  124357. /**
  124358. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124359. * The material will try to infer what glossiness each pixel should be.
  124360. */
  124361. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124362. /**
  124363. * Defines the falloff type used in this material.
  124364. * It by default is Physical.
  124365. */
  124366. protected _lightFalloff: number;
  124367. /**
  124368. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124369. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124370. */
  124371. protected _useRadianceOverAlpha: boolean;
  124372. /**
  124373. * Allows using an object space normal map (instead of tangent space).
  124374. */
  124375. protected _useObjectSpaceNormalMap: boolean;
  124376. /**
  124377. * Allows using the bump map in parallax mode.
  124378. */
  124379. protected _useParallax: boolean;
  124380. /**
  124381. * Allows using the bump map in parallax occlusion mode.
  124382. */
  124383. protected _useParallaxOcclusion: boolean;
  124384. /**
  124385. * Controls the scale bias of the parallax mode.
  124386. */
  124387. protected _parallaxScaleBias: number;
  124388. /**
  124389. * If sets to true, disables all the lights affecting the material.
  124390. */
  124391. protected _disableLighting: boolean;
  124392. /**
  124393. * Number of Simultaneous lights allowed on the material.
  124394. */
  124395. protected _maxSimultaneousLights: number;
  124396. /**
  124397. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124398. */
  124399. protected _invertNormalMapX: boolean;
  124400. /**
  124401. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124402. */
  124403. protected _invertNormalMapY: boolean;
  124404. /**
  124405. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124406. */
  124407. protected _twoSidedLighting: boolean;
  124408. /**
  124409. * Defines the alpha limits in alpha test mode.
  124410. */
  124411. protected _alphaCutOff: number;
  124412. /**
  124413. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124414. */
  124415. protected _forceAlphaTest: boolean;
  124416. /**
  124417. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124418. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124419. */
  124420. protected _useAlphaFresnel: boolean;
  124421. /**
  124422. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124423. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124424. */
  124425. protected _useLinearAlphaFresnel: boolean;
  124426. /**
  124427. * The transparency mode of the material.
  124428. */
  124429. protected _transparencyMode: Nullable<number>;
  124430. /**
  124431. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124432. * from cos thetav and roughness:
  124433. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124434. */
  124435. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124436. /**
  124437. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124438. */
  124439. protected _forceIrradianceInFragment: boolean;
  124440. /**
  124441. * Force normal to face away from face.
  124442. */
  124443. protected _forceNormalForward: boolean;
  124444. /**
  124445. * Enables specular anti aliasing in the PBR shader.
  124446. * It will both interacts on the Geometry for analytical and IBL lighting.
  124447. * It also prefilter the roughness map based on the bump values.
  124448. */
  124449. protected _enableSpecularAntiAliasing: boolean;
  124450. /**
  124451. * Default configuration related to image processing available in the PBR Material.
  124452. */
  124453. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124454. /**
  124455. * Keep track of the image processing observer to allow dispose and replace.
  124456. */
  124457. private _imageProcessingObserver;
  124458. /**
  124459. * Attaches a new image processing configuration to the PBR Material.
  124460. * @param configuration
  124461. */
  124462. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124463. /**
  124464. * Stores the available render targets.
  124465. */
  124466. private _renderTargets;
  124467. /**
  124468. * Sets the global ambient color for the material used in lighting calculations.
  124469. */
  124470. private _globalAmbientColor;
  124471. /**
  124472. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124473. */
  124474. private _useLogarithmicDepth;
  124475. /**
  124476. * If set to true, no lighting calculations will be applied.
  124477. */
  124478. private _unlit;
  124479. private _debugMode;
  124480. /**
  124481. * @hidden
  124482. * This is reserved for the inspector.
  124483. * Defines the material debug mode.
  124484. * It helps seeing only some components of the material while troubleshooting.
  124485. */
  124486. debugMode: number;
  124487. /**
  124488. * @hidden
  124489. * This is reserved for the inspector.
  124490. * Specify from where on screen the debug mode should start.
  124491. * The value goes from -1 (full screen) to 1 (not visible)
  124492. * It helps with side by side comparison against the final render
  124493. * This defaults to -1
  124494. */
  124495. private debugLimit;
  124496. /**
  124497. * @hidden
  124498. * This is reserved for the inspector.
  124499. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124500. * You can use the factor to better multiply the final value.
  124501. */
  124502. private debugFactor;
  124503. /**
  124504. * Defines the clear coat layer parameters for the material.
  124505. */
  124506. readonly clearCoat: PBRClearCoatConfiguration;
  124507. /**
  124508. * Defines the anisotropic parameters for the material.
  124509. */
  124510. readonly anisotropy: PBRAnisotropicConfiguration;
  124511. /**
  124512. * Defines the BRDF parameters for the material.
  124513. */
  124514. readonly brdf: PBRBRDFConfiguration;
  124515. /**
  124516. * Defines the Sheen parameters for the material.
  124517. */
  124518. readonly sheen: PBRSheenConfiguration;
  124519. /**
  124520. * Defines the SubSurface parameters for the material.
  124521. */
  124522. readonly subSurface: PBRSubSurfaceConfiguration;
  124523. /**
  124524. * Custom callback helping to override the default shader used in the material.
  124525. */
  124526. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124527. protected _rebuildInParallel: boolean;
  124528. /**
  124529. * Instantiates a new PBRMaterial instance.
  124530. *
  124531. * @param name The material name
  124532. * @param scene The scene the material will be use in.
  124533. */
  124534. constructor(name: string, scene: Scene);
  124535. /**
  124536. * Gets a boolean indicating that current material needs to register RTT
  124537. */
  124538. get hasRenderTargetTextures(): boolean;
  124539. /**
  124540. * Gets the name of the material class.
  124541. */
  124542. getClassName(): string;
  124543. /**
  124544. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124545. */
  124546. get useLogarithmicDepth(): boolean;
  124547. /**
  124548. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124549. */
  124550. set useLogarithmicDepth(value: boolean);
  124551. /**
  124552. * Gets the current transparency mode.
  124553. */
  124554. get transparencyMode(): Nullable<number>;
  124555. /**
  124556. * Sets the transparency mode of the material.
  124557. *
  124558. * | Value | Type | Description |
  124559. * | ----- | ----------------------------------- | ----------- |
  124560. * | 0 | OPAQUE | |
  124561. * | 1 | ALPHATEST | |
  124562. * | 2 | ALPHABLEND | |
  124563. * | 3 | ALPHATESTANDBLEND | |
  124564. *
  124565. */
  124566. set transparencyMode(value: Nullable<number>);
  124567. /**
  124568. * Returns true if alpha blending should be disabled.
  124569. */
  124570. private get _disableAlphaBlending();
  124571. /**
  124572. * Specifies whether or not this material should be rendered in alpha blend mode.
  124573. */
  124574. needAlphaBlending(): boolean;
  124575. /**
  124576. * Specifies if the mesh will require alpha blending.
  124577. * @param mesh - BJS mesh.
  124578. */
  124579. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124580. /**
  124581. * Specifies whether or not this material should be rendered in alpha test mode.
  124582. */
  124583. needAlphaTesting(): boolean;
  124584. /**
  124585. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124586. */
  124587. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124588. /**
  124589. * Gets the texture used for the alpha test.
  124590. */
  124591. getAlphaTestTexture(): Nullable<BaseTexture>;
  124592. /**
  124593. * Specifies that the submesh is ready to be used.
  124594. * @param mesh - BJS mesh.
  124595. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124596. * @param useInstances - Specifies that instances should be used.
  124597. * @returns - boolean indicating that the submesh is ready or not.
  124598. */
  124599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124600. /**
  124601. * Specifies if the material uses metallic roughness workflow.
  124602. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124603. */
  124604. isMetallicWorkflow(): boolean;
  124605. private _prepareEffect;
  124606. private _prepareDefines;
  124607. /**
  124608. * Force shader compilation
  124609. */
  124610. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124611. /**
  124612. * Initializes the uniform buffer layout for the shader.
  124613. */
  124614. buildUniformLayout(): void;
  124615. /**
  124616. * Unbinds the material from the mesh
  124617. */
  124618. unbind(): void;
  124619. /**
  124620. * Binds the submesh data.
  124621. * @param world - The world matrix.
  124622. * @param mesh - The BJS mesh.
  124623. * @param subMesh - A submesh of the BJS mesh.
  124624. */
  124625. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124626. /**
  124627. * Returns the animatable textures.
  124628. * @returns - Array of animatable textures.
  124629. */
  124630. getAnimatables(): IAnimatable[];
  124631. /**
  124632. * Returns the texture used for reflections.
  124633. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124634. */
  124635. private _getReflectionTexture;
  124636. /**
  124637. * Returns an array of the actively used textures.
  124638. * @returns - Array of BaseTextures
  124639. */
  124640. getActiveTextures(): BaseTexture[];
  124641. /**
  124642. * Checks to see if a texture is used in the material.
  124643. * @param texture - Base texture to use.
  124644. * @returns - Boolean specifying if a texture is used in the material.
  124645. */
  124646. hasTexture(texture: BaseTexture): boolean;
  124647. /**
  124648. * Disposes the resources of the material.
  124649. * @param forceDisposeEffect - Forces the disposal of effects.
  124650. * @param forceDisposeTextures - Forces the disposal of all textures.
  124651. */
  124652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124653. }
  124654. }
  124655. declare module BABYLON {
  124656. /**
  124657. * The Physically based material of BJS.
  124658. *
  124659. * This offers the main features of a standard PBR material.
  124660. * For more information, please refer to the documentation :
  124661. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124662. */
  124663. export class PBRMaterial extends PBRBaseMaterial {
  124664. /**
  124665. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124666. */
  124667. static readonly PBRMATERIAL_OPAQUE: number;
  124668. /**
  124669. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124670. */
  124671. static readonly PBRMATERIAL_ALPHATEST: number;
  124672. /**
  124673. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124674. */
  124675. static readonly PBRMATERIAL_ALPHABLEND: number;
  124676. /**
  124677. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124678. * They are also discarded below the alpha cutoff threshold to improve performances.
  124679. */
  124680. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124681. /**
  124682. * Defines the default value of how much AO map is occluding the analytical lights
  124683. * (point spot...).
  124684. */
  124685. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124686. /**
  124687. * Intensity of the direct lights e.g. the four lights available in your scene.
  124688. * This impacts both the direct diffuse and specular highlights.
  124689. */
  124690. directIntensity: number;
  124691. /**
  124692. * Intensity of the emissive part of the material.
  124693. * This helps controlling the emissive effect without modifying the emissive color.
  124694. */
  124695. emissiveIntensity: number;
  124696. /**
  124697. * Intensity of the environment e.g. how much the environment will light the object
  124698. * either through harmonics for rough material or through the refelction for shiny ones.
  124699. */
  124700. environmentIntensity: number;
  124701. /**
  124702. * This is a special control allowing the reduction of the specular highlights coming from the
  124703. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124704. */
  124705. specularIntensity: number;
  124706. /**
  124707. * Debug Control allowing disabling the bump map on this material.
  124708. */
  124709. disableBumpMap: boolean;
  124710. /**
  124711. * AKA Diffuse Texture in standard nomenclature.
  124712. */
  124713. albedoTexture: BaseTexture;
  124714. /**
  124715. * AKA Occlusion Texture in other nomenclature.
  124716. */
  124717. ambientTexture: BaseTexture;
  124718. /**
  124719. * AKA Occlusion Texture Intensity in other nomenclature.
  124720. */
  124721. ambientTextureStrength: number;
  124722. /**
  124723. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124724. * 1 means it completely occludes it
  124725. * 0 mean it has no impact
  124726. */
  124727. ambientTextureImpactOnAnalyticalLights: number;
  124728. /**
  124729. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124730. */
  124731. opacityTexture: BaseTexture;
  124732. /**
  124733. * Stores the reflection values in a texture.
  124734. */
  124735. reflectionTexture: Nullable<BaseTexture>;
  124736. /**
  124737. * Stores the emissive values in a texture.
  124738. */
  124739. emissiveTexture: BaseTexture;
  124740. /**
  124741. * AKA Specular texture in other nomenclature.
  124742. */
  124743. reflectivityTexture: BaseTexture;
  124744. /**
  124745. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124746. */
  124747. metallicTexture: BaseTexture;
  124748. /**
  124749. * Specifies the metallic scalar of the metallic/roughness workflow.
  124750. * Can also be used to scale the metalness values of the metallic texture.
  124751. */
  124752. metallic: Nullable<number>;
  124753. /**
  124754. * Specifies the roughness scalar of the metallic/roughness workflow.
  124755. * Can also be used to scale the roughness values of the metallic texture.
  124756. */
  124757. roughness: Nullable<number>;
  124758. /**
  124759. * Specifies the an F0 factor to help configuring the material F0.
  124760. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124761. * to 0.5 the previously hard coded value stays the same.
  124762. * Can also be used to scale the F0 values of the metallic texture.
  124763. */
  124764. metallicF0Factor: number;
  124765. /**
  124766. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124767. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124768. * your expectation as it multiplies with the texture data.
  124769. */
  124770. useMetallicF0FactorFromMetallicTexture: boolean;
  124771. /**
  124772. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124773. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124774. */
  124775. microSurfaceTexture: BaseTexture;
  124776. /**
  124777. * Stores surface normal data used to displace a mesh in a texture.
  124778. */
  124779. bumpTexture: BaseTexture;
  124780. /**
  124781. * Stores the pre-calculated light information of a mesh in a texture.
  124782. */
  124783. lightmapTexture: BaseTexture;
  124784. /**
  124785. * Stores the refracted light information in a texture.
  124786. */
  124787. get refractionTexture(): Nullable<BaseTexture>;
  124788. set refractionTexture(value: Nullable<BaseTexture>);
  124789. /**
  124790. * The color of a material in ambient lighting.
  124791. */
  124792. ambientColor: Color3;
  124793. /**
  124794. * AKA Diffuse Color in other nomenclature.
  124795. */
  124796. albedoColor: Color3;
  124797. /**
  124798. * AKA Specular Color in other nomenclature.
  124799. */
  124800. reflectivityColor: Color3;
  124801. /**
  124802. * The color reflected from the material.
  124803. */
  124804. reflectionColor: Color3;
  124805. /**
  124806. * The color emitted from the material.
  124807. */
  124808. emissiveColor: Color3;
  124809. /**
  124810. * AKA Glossiness in other nomenclature.
  124811. */
  124812. microSurface: number;
  124813. /**
  124814. * source material index of refraction (IOR)' / 'destination material IOR.
  124815. */
  124816. get indexOfRefraction(): number;
  124817. set indexOfRefraction(value: number);
  124818. /**
  124819. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124820. */
  124821. get invertRefractionY(): boolean;
  124822. set invertRefractionY(value: boolean);
  124823. /**
  124824. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124825. * Materials half opaque for instance using refraction could benefit from this control.
  124826. */
  124827. get linkRefractionWithTransparency(): boolean;
  124828. set linkRefractionWithTransparency(value: boolean);
  124829. /**
  124830. * If true, the light map contains occlusion information instead of lighting info.
  124831. */
  124832. useLightmapAsShadowmap: boolean;
  124833. /**
  124834. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124835. */
  124836. useAlphaFromAlbedoTexture: boolean;
  124837. /**
  124838. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124839. */
  124840. forceAlphaTest: boolean;
  124841. /**
  124842. * Defines the alpha limits in alpha test mode.
  124843. */
  124844. alphaCutOff: number;
  124845. /**
  124846. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124847. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124848. */
  124849. useSpecularOverAlpha: boolean;
  124850. /**
  124851. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124852. */
  124853. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124854. /**
  124855. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124856. */
  124857. useRoughnessFromMetallicTextureAlpha: boolean;
  124858. /**
  124859. * Specifies if the metallic texture contains the roughness information in its green channel.
  124860. */
  124861. useRoughnessFromMetallicTextureGreen: boolean;
  124862. /**
  124863. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124864. */
  124865. useMetallnessFromMetallicTextureBlue: boolean;
  124866. /**
  124867. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124868. */
  124869. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124870. /**
  124871. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124872. */
  124873. useAmbientInGrayScale: boolean;
  124874. /**
  124875. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124876. * The material will try to infer what glossiness each pixel should be.
  124877. */
  124878. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124879. /**
  124880. * BJS is using an harcoded light falloff based on a manually sets up range.
  124881. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124882. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124883. */
  124884. get usePhysicalLightFalloff(): boolean;
  124885. /**
  124886. * BJS is using an harcoded light falloff based on a manually sets up range.
  124887. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124888. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124889. */
  124890. set usePhysicalLightFalloff(value: boolean);
  124891. /**
  124892. * In order to support the falloff compatibility with gltf, a special mode has been added
  124893. * to reproduce the gltf light falloff.
  124894. */
  124895. get useGLTFLightFalloff(): boolean;
  124896. /**
  124897. * In order to support the falloff compatibility with gltf, a special mode has been added
  124898. * to reproduce the gltf light falloff.
  124899. */
  124900. set useGLTFLightFalloff(value: boolean);
  124901. /**
  124902. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124903. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124904. */
  124905. useRadianceOverAlpha: boolean;
  124906. /**
  124907. * Allows using an object space normal map (instead of tangent space).
  124908. */
  124909. useObjectSpaceNormalMap: boolean;
  124910. /**
  124911. * Allows using the bump map in parallax mode.
  124912. */
  124913. useParallax: boolean;
  124914. /**
  124915. * Allows using the bump map in parallax occlusion mode.
  124916. */
  124917. useParallaxOcclusion: boolean;
  124918. /**
  124919. * Controls the scale bias of the parallax mode.
  124920. */
  124921. parallaxScaleBias: number;
  124922. /**
  124923. * If sets to true, disables all the lights affecting the material.
  124924. */
  124925. disableLighting: boolean;
  124926. /**
  124927. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124928. */
  124929. forceIrradianceInFragment: boolean;
  124930. /**
  124931. * Number of Simultaneous lights allowed on the material.
  124932. */
  124933. maxSimultaneousLights: number;
  124934. /**
  124935. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124936. */
  124937. invertNormalMapX: boolean;
  124938. /**
  124939. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124940. */
  124941. invertNormalMapY: boolean;
  124942. /**
  124943. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124944. */
  124945. twoSidedLighting: boolean;
  124946. /**
  124947. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124948. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124949. */
  124950. useAlphaFresnel: boolean;
  124951. /**
  124952. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124953. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124954. */
  124955. useLinearAlphaFresnel: boolean;
  124956. /**
  124957. * Let user defines the brdf lookup texture used for IBL.
  124958. * A default 8bit version is embedded but you could point at :
  124959. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124960. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124961. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124962. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124963. */
  124964. environmentBRDFTexture: Nullable<BaseTexture>;
  124965. /**
  124966. * Force normal to face away from face.
  124967. */
  124968. forceNormalForward: boolean;
  124969. /**
  124970. * Enables specular anti aliasing in the PBR shader.
  124971. * It will both interacts on the Geometry for analytical and IBL lighting.
  124972. * It also prefilter the roughness map based on the bump values.
  124973. */
  124974. enableSpecularAntiAliasing: boolean;
  124975. /**
  124976. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124977. * makes the reflect vector face the model (under horizon).
  124978. */
  124979. useHorizonOcclusion: boolean;
  124980. /**
  124981. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124982. * too much the area relying on ambient texture to define their ambient occlusion.
  124983. */
  124984. useRadianceOcclusion: boolean;
  124985. /**
  124986. * If set to true, no lighting calculations will be applied.
  124987. */
  124988. unlit: boolean;
  124989. /**
  124990. * Gets the image processing configuration used either in this material.
  124991. */
  124992. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124993. /**
  124994. * Sets the Default image processing configuration used either in the this material.
  124995. *
  124996. * If sets to null, the scene one is in use.
  124997. */
  124998. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124999. /**
  125000. * Gets wether the color curves effect is enabled.
  125001. */
  125002. get cameraColorCurvesEnabled(): boolean;
  125003. /**
  125004. * Sets wether the color curves effect is enabled.
  125005. */
  125006. set cameraColorCurvesEnabled(value: boolean);
  125007. /**
  125008. * Gets wether the color grading effect is enabled.
  125009. */
  125010. get cameraColorGradingEnabled(): boolean;
  125011. /**
  125012. * Gets wether the color grading effect is enabled.
  125013. */
  125014. set cameraColorGradingEnabled(value: boolean);
  125015. /**
  125016. * Gets wether tonemapping is enabled or not.
  125017. */
  125018. get cameraToneMappingEnabled(): boolean;
  125019. /**
  125020. * Sets wether tonemapping is enabled or not
  125021. */
  125022. set cameraToneMappingEnabled(value: boolean);
  125023. /**
  125024. * The camera exposure used on this material.
  125025. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125026. * This corresponds to a photographic exposure.
  125027. */
  125028. get cameraExposure(): number;
  125029. /**
  125030. * The camera exposure used on this material.
  125031. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125032. * This corresponds to a photographic exposure.
  125033. */
  125034. set cameraExposure(value: number);
  125035. /**
  125036. * Gets The camera contrast used on this material.
  125037. */
  125038. get cameraContrast(): number;
  125039. /**
  125040. * Sets The camera contrast used on this material.
  125041. */
  125042. set cameraContrast(value: number);
  125043. /**
  125044. * Gets the Color Grading 2D Lookup Texture.
  125045. */
  125046. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125047. /**
  125048. * Sets the Color Grading 2D Lookup Texture.
  125049. */
  125050. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125051. /**
  125052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125054. * 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;
  125055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125056. */
  125057. get cameraColorCurves(): Nullable<ColorCurves>;
  125058. /**
  125059. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125060. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125061. * 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;
  125062. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125063. */
  125064. set cameraColorCurves(value: Nullable<ColorCurves>);
  125065. /**
  125066. * Instantiates a new PBRMaterial instance.
  125067. *
  125068. * @param name The material name
  125069. * @param scene The scene the material will be use in.
  125070. */
  125071. constructor(name: string, scene: Scene);
  125072. /**
  125073. * Returns the name of this material class.
  125074. */
  125075. getClassName(): string;
  125076. /**
  125077. * Makes a duplicate of the current material.
  125078. * @param name - name to use for the new material.
  125079. */
  125080. clone(name: string): PBRMaterial;
  125081. /**
  125082. * Serializes this PBR Material.
  125083. * @returns - An object with the serialized material.
  125084. */
  125085. serialize(): any;
  125086. /**
  125087. * Parses a PBR Material from a serialized object.
  125088. * @param source - Serialized object.
  125089. * @param scene - BJS scene instance.
  125090. * @param rootUrl - url for the scene object
  125091. * @returns - PBRMaterial
  125092. */
  125093. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125094. }
  125095. }
  125096. declare module BABYLON {
  125097. /**
  125098. * Direct draw surface info
  125099. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125100. */
  125101. export interface DDSInfo {
  125102. /**
  125103. * Width of the texture
  125104. */
  125105. width: number;
  125106. /**
  125107. * Width of the texture
  125108. */
  125109. height: number;
  125110. /**
  125111. * Number of Mipmaps for the texture
  125112. * @see https://en.wikipedia.org/wiki/Mipmap
  125113. */
  125114. mipmapCount: number;
  125115. /**
  125116. * If the textures format is a known fourCC format
  125117. * @see https://www.fourcc.org/
  125118. */
  125119. isFourCC: boolean;
  125120. /**
  125121. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125122. */
  125123. isRGB: boolean;
  125124. /**
  125125. * If the texture is a lumincance format
  125126. */
  125127. isLuminance: boolean;
  125128. /**
  125129. * If this is a cube texture
  125130. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125131. */
  125132. isCube: boolean;
  125133. /**
  125134. * If the texture is a compressed format eg. FOURCC_DXT1
  125135. */
  125136. isCompressed: boolean;
  125137. /**
  125138. * The dxgiFormat of the texture
  125139. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125140. */
  125141. dxgiFormat: number;
  125142. /**
  125143. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125144. */
  125145. textureType: number;
  125146. /**
  125147. * Sphericle polynomial created for the dds texture
  125148. */
  125149. sphericalPolynomial?: SphericalPolynomial;
  125150. }
  125151. /**
  125152. * Class used to provide DDS decompression tools
  125153. */
  125154. export class DDSTools {
  125155. /**
  125156. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125157. */
  125158. static StoreLODInAlphaChannel: boolean;
  125159. /**
  125160. * Gets DDS information from an array buffer
  125161. * @param data defines the array buffer view to read data from
  125162. * @returns the DDS information
  125163. */
  125164. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125165. private static _FloatView;
  125166. private static _Int32View;
  125167. private static _ToHalfFloat;
  125168. private static _FromHalfFloat;
  125169. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125170. private static _GetHalfFloatRGBAArrayBuffer;
  125171. private static _GetFloatRGBAArrayBuffer;
  125172. private static _GetFloatAsUIntRGBAArrayBuffer;
  125173. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125174. private static _GetRGBAArrayBuffer;
  125175. private static _ExtractLongWordOrder;
  125176. private static _GetRGBArrayBuffer;
  125177. private static _GetLuminanceArrayBuffer;
  125178. /**
  125179. * Uploads DDS Levels to a Babylon Texture
  125180. * @hidden
  125181. */
  125182. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125183. }
  125184. interface ThinEngine {
  125185. /**
  125186. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125187. * @param rootUrl defines the url where the file to load is located
  125188. * @param scene defines the current scene
  125189. * @param lodScale defines scale to apply to the mip map selection
  125190. * @param lodOffset defines offset to apply to the mip map selection
  125191. * @param onLoad defines an optional callback raised when the texture is loaded
  125192. * @param onError defines an optional callback raised if there is an issue to load the texture
  125193. * @param format defines the format of the data
  125194. * @param forcedExtension defines the extension to use to pick the right loader
  125195. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125196. * @returns the cube texture as an InternalTexture
  125197. */
  125198. 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;
  125199. }
  125200. }
  125201. declare module BABYLON {
  125202. /**
  125203. * Implementation of the DDS Texture Loader.
  125204. * @hidden
  125205. */
  125206. export class _DDSTextureLoader implements IInternalTextureLoader {
  125207. /**
  125208. * Defines wether the loader supports cascade loading the different faces.
  125209. */
  125210. readonly supportCascades: boolean;
  125211. /**
  125212. * This returns if the loader support the current file information.
  125213. * @param extension defines the file extension of the file being loaded
  125214. * @returns true if the loader can load the specified file
  125215. */
  125216. canLoad(extension: string): boolean;
  125217. /**
  125218. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125219. * @param data contains the texture data
  125220. * @param texture defines the BabylonJS internal texture
  125221. * @param createPolynomials will be true if polynomials have been requested
  125222. * @param onLoad defines the callback to trigger once the texture is ready
  125223. * @param onError defines the callback to trigger in case of error
  125224. */
  125225. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125226. /**
  125227. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125228. * @param data contains the texture data
  125229. * @param texture defines the BabylonJS internal texture
  125230. * @param callback defines the method to call once ready to upload
  125231. */
  125232. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125233. }
  125234. }
  125235. declare module BABYLON {
  125236. /**
  125237. * Implementation of the ENV Texture Loader.
  125238. * @hidden
  125239. */
  125240. export class _ENVTextureLoader implements IInternalTextureLoader {
  125241. /**
  125242. * Defines wether the loader supports cascade loading the different faces.
  125243. */
  125244. readonly supportCascades: boolean;
  125245. /**
  125246. * This returns if the loader support the current file information.
  125247. * @param extension defines the file extension of the file being loaded
  125248. * @returns true if the loader can load the specified file
  125249. */
  125250. canLoad(extension: string): boolean;
  125251. /**
  125252. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125253. * @param data contains the texture data
  125254. * @param texture defines the BabylonJS internal texture
  125255. * @param createPolynomials will be true if polynomials have been requested
  125256. * @param onLoad defines the callback to trigger once the texture is ready
  125257. * @param onError defines the callback to trigger in case of error
  125258. */
  125259. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125260. /**
  125261. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125262. * @param data contains the texture data
  125263. * @param texture defines the BabylonJS internal texture
  125264. * @param callback defines the method to call once ready to upload
  125265. */
  125266. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125267. }
  125268. }
  125269. declare module BABYLON {
  125270. /**
  125271. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125272. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125273. */
  125274. export class KhronosTextureContainer {
  125275. /** contents of the KTX container file */
  125276. data: ArrayBufferView;
  125277. private static HEADER_LEN;
  125278. private static COMPRESSED_2D;
  125279. private static COMPRESSED_3D;
  125280. private static TEX_2D;
  125281. private static TEX_3D;
  125282. /**
  125283. * Gets the openGL type
  125284. */
  125285. glType: number;
  125286. /**
  125287. * Gets the openGL type size
  125288. */
  125289. glTypeSize: number;
  125290. /**
  125291. * Gets the openGL format
  125292. */
  125293. glFormat: number;
  125294. /**
  125295. * Gets the openGL internal format
  125296. */
  125297. glInternalFormat: number;
  125298. /**
  125299. * Gets the base internal format
  125300. */
  125301. glBaseInternalFormat: number;
  125302. /**
  125303. * Gets image width in pixel
  125304. */
  125305. pixelWidth: number;
  125306. /**
  125307. * Gets image height in pixel
  125308. */
  125309. pixelHeight: number;
  125310. /**
  125311. * Gets image depth in pixels
  125312. */
  125313. pixelDepth: number;
  125314. /**
  125315. * Gets the number of array elements
  125316. */
  125317. numberOfArrayElements: number;
  125318. /**
  125319. * Gets the number of faces
  125320. */
  125321. numberOfFaces: number;
  125322. /**
  125323. * Gets the number of mipmap levels
  125324. */
  125325. numberOfMipmapLevels: number;
  125326. /**
  125327. * Gets the bytes of key value data
  125328. */
  125329. bytesOfKeyValueData: number;
  125330. /**
  125331. * Gets the load type
  125332. */
  125333. loadType: number;
  125334. /**
  125335. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125336. */
  125337. isInvalid: boolean;
  125338. /**
  125339. * Creates a new KhronosTextureContainer
  125340. * @param data contents of the KTX container file
  125341. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125342. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125343. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125344. */
  125345. constructor(
  125346. /** contents of the KTX container file */
  125347. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125348. /**
  125349. * Uploads KTX content to a Babylon Texture.
  125350. * It is assumed that the texture has already been created & is currently bound
  125351. * @hidden
  125352. */
  125353. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125354. private _upload2DCompressedLevels;
  125355. /**
  125356. * Checks if the given data starts with a KTX file identifier.
  125357. * @param data the data to check
  125358. * @returns true if the data is a KTX file or false otherwise
  125359. */
  125360. static IsValid(data: ArrayBufferView): boolean;
  125361. }
  125362. }
  125363. declare module BABYLON {
  125364. /**
  125365. * Class for loading KTX2 files
  125366. * !!! Experimental Extension Subject to Changes !!!
  125367. * @hidden
  125368. */
  125369. export class KhronosTextureContainer2 {
  125370. private static _ModulePromise;
  125371. private static _TranscodeFormat;
  125372. constructor(engine: ThinEngine);
  125373. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125374. private _determineTranscodeFormat;
  125375. /**
  125376. * Checks if the given data starts with a KTX2 file identifier.
  125377. * @param data the data to check
  125378. * @returns true if the data is a KTX2 file or false otherwise
  125379. */
  125380. static IsValid(data: ArrayBufferView): boolean;
  125381. }
  125382. }
  125383. declare module BABYLON {
  125384. /**
  125385. * Implementation of the KTX Texture Loader.
  125386. * @hidden
  125387. */
  125388. export class _KTXTextureLoader implements IInternalTextureLoader {
  125389. /**
  125390. * Defines wether the loader supports cascade loading the different faces.
  125391. */
  125392. readonly supportCascades: boolean;
  125393. /**
  125394. * This returns if the loader support the current file information.
  125395. * @param extension defines the file extension of the file being loaded
  125396. * @returns true if the loader can load the specified file
  125397. */
  125398. canLoad(extension: string): boolean;
  125399. /**
  125400. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125401. * @param data contains the texture data
  125402. * @param texture defines the BabylonJS internal texture
  125403. * @param createPolynomials will be true if polynomials have been requested
  125404. * @param onLoad defines the callback to trigger once the texture is ready
  125405. * @param onError defines the callback to trigger in case of error
  125406. */
  125407. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125408. /**
  125409. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125410. * @param data contains the texture data
  125411. * @param texture defines the BabylonJS internal texture
  125412. * @param callback defines the method to call once ready to upload
  125413. */
  125414. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125415. }
  125416. }
  125417. declare module BABYLON {
  125418. /** @hidden */
  125419. export var _forceSceneHelpersToBundle: boolean;
  125420. interface Scene {
  125421. /**
  125422. * Creates a default light for the scene.
  125423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125424. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125425. */
  125426. createDefaultLight(replace?: boolean): void;
  125427. /**
  125428. * Creates a default camera for the scene.
  125429. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125431. * @param replace has default false, when true replaces the active camera in the scene
  125432. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125433. */
  125434. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125435. /**
  125436. * Creates a default camera and a default light.
  125437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125438. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125439. * @param replace has the default false, when true replaces the active camera/light in the scene
  125440. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125441. */
  125442. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125443. /**
  125444. * Creates a new sky box
  125445. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125446. * @param environmentTexture defines the texture to use as environment texture
  125447. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125448. * @param scale defines the overall scale of the skybox
  125449. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125450. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125451. * @returns a new mesh holding the sky box
  125452. */
  125453. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125454. /**
  125455. * Creates a new environment
  125456. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125457. * @param options defines the options you can use to configure the environment
  125458. * @returns the new EnvironmentHelper
  125459. */
  125460. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125461. /**
  125462. * Creates a new VREXperienceHelper
  125463. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125464. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125465. * @returns a new VREXperienceHelper
  125466. */
  125467. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125468. /**
  125469. * Creates a new WebXRDefaultExperience
  125470. * @see http://doc.babylonjs.com/how_to/webxr
  125471. * @param options experience options
  125472. * @returns a promise for a new WebXRDefaultExperience
  125473. */
  125474. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125475. }
  125476. }
  125477. declare module BABYLON {
  125478. /**
  125479. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125480. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125481. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125482. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125483. */
  125484. export class VideoDome extends TransformNode {
  125485. /**
  125486. * Define the video source as a Monoscopic panoramic 360 video.
  125487. */
  125488. static readonly MODE_MONOSCOPIC: number;
  125489. /**
  125490. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125491. */
  125492. static readonly MODE_TOPBOTTOM: number;
  125493. /**
  125494. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125495. */
  125496. static readonly MODE_SIDEBYSIDE: number;
  125497. private _halfDome;
  125498. private _useDirectMapping;
  125499. /**
  125500. * The video texture being displayed on the sphere
  125501. */
  125502. protected _videoTexture: VideoTexture;
  125503. /**
  125504. * Gets the video texture being displayed on the sphere
  125505. */
  125506. get videoTexture(): VideoTexture;
  125507. /**
  125508. * The skybox material
  125509. */
  125510. protected _material: BackgroundMaterial;
  125511. /**
  125512. * The surface used for the skybox
  125513. */
  125514. protected _mesh: Mesh;
  125515. /**
  125516. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125517. */
  125518. private _halfDomeMask;
  125519. /**
  125520. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125521. * Also see the options.resolution property.
  125522. */
  125523. get fovMultiplier(): number;
  125524. set fovMultiplier(value: number);
  125525. private _videoMode;
  125526. /**
  125527. * Gets or set the current video mode for the video. It can be:
  125528. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125529. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125530. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125531. */
  125532. get videoMode(): number;
  125533. set videoMode(value: number);
  125534. /**
  125535. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125536. *
  125537. */
  125538. get halfDome(): boolean;
  125539. /**
  125540. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125541. */
  125542. set halfDome(enabled: boolean);
  125543. /**
  125544. * Oberserver used in Stereoscopic VR Mode.
  125545. */
  125546. private _onBeforeCameraRenderObserver;
  125547. /**
  125548. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125549. * @param name Element's name, child elements will append suffixes for their own names.
  125550. * @param urlsOrVideo defines the url(s) or the video element to use
  125551. * @param options An object containing optional or exposed sub element properties
  125552. */
  125553. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125554. resolution?: number;
  125555. clickToPlay?: boolean;
  125556. autoPlay?: boolean;
  125557. loop?: boolean;
  125558. size?: number;
  125559. poster?: string;
  125560. faceForward?: boolean;
  125561. useDirectMapping?: boolean;
  125562. halfDomeMode?: boolean;
  125563. }, scene: Scene);
  125564. private _changeVideoMode;
  125565. /**
  125566. * Releases resources associated with this node.
  125567. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125568. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125569. */
  125570. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125571. }
  125572. }
  125573. declare module BABYLON {
  125574. /**
  125575. * This class can be used to get instrumentation data from a Babylon engine
  125576. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125577. */
  125578. export class EngineInstrumentation implements IDisposable {
  125579. /**
  125580. * Define the instrumented engine.
  125581. */
  125582. engine: Engine;
  125583. private _captureGPUFrameTime;
  125584. private _gpuFrameTimeToken;
  125585. private _gpuFrameTime;
  125586. private _captureShaderCompilationTime;
  125587. private _shaderCompilationTime;
  125588. private _onBeginFrameObserver;
  125589. private _onEndFrameObserver;
  125590. private _onBeforeShaderCompilationObserver;
  125591. private _onAfterShaderCompilationObserver;
  125592. /**
  125593. * Gets the perf counter used for GPU frame time
  125594. */
  125595. get gpuFrameTimeCounter(): PerfCounter;
  125596. /**
  125597. * Gets the GPU frame time capture status
  125598. */
  125599. get captureGPUFrameTime(): boolean;
  125600. /**
  125601. * Enable or disable the GPU frame time capture
  125602. */
  125603. set captureGPUFrameTime(value: boolean);
  125604. /**
  125605. * Gets the perf counter used for shader compilation time
  125606. */
  125607. get shaderCompilationTimeCounter(): PerfCounter;
  125608. /**
  125609. * Gets the shader compilation time capture status
  125610. */
  125611. get captureShaderCompilationTime(): boolean;
  125612. /**
  125613. * Enable or disable the shader compilation time capture
  125614. */
  125615. set captureShaderCompilationTime(value: boolean);
  125616. /**
  125617. * Instantiates a new engine instrumentation.
  125618. * This class can be used to get instrumentation data from a Babylon engine
  125619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125620. * @param engine Defines the engine to instrument
  125621. */
  125622. constructor(
  125623. /**
  125624. * Define the instrumented engine.
  125625. */
  125626. engine: Engine);
  125627. /**
  125628. * Dispose and release associated resources.
  125629. */
  125630. dispose(): void;
  125631. }
  125632. }
  125633. declare module BABYLON {
  125634. /**
  125635. * This class can be used to get instrumentation data from a Babylon engine
  125636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125637. */
  125638. export class SceneInstrumentation implements IDisposable {
  125639. /**
  125640. * Defines the scene to instrument
  125641. */
  125642. scene: Scene;
  125643. private _captureActiveMeshesEvaluationTime;
  125644. private _activeMeshesEvaluationTime;
  125645. private _captureRenderTargetsRenderTime;
  125646. private _renderTargetsRenderTime;
  125647. private _captureFrameTime;
  125648. private _frameTime;
  125649. private _captureRenderTime;
  125650. private _renderTime;
  125651. private _captureInterFrameTime;
  125652. private _interFrameTime;
  125653. private _captureParticlesRenderTime;
  125654. private _particlesRenderTime;
  125655. private _captureSpritesRenderTime;
  125656. private _spritesRenderTime;
  125657. private _capturePhysicsTime;
  125658. private _physicsTime;
  125659. private _captureAnimationsTime;
  125660. private _animationsTime;
  125661. private _captureCameraRenderTime;
  125662. private _cameraRenderTime;
  125663. private _onBeforeActiveMeshesEvaluationObserver;
  125664. private _onAfterActiveMeshesEvaluationObserver;
  125665. private _onBeforeRenderTargetsRenderObserver;
  125666. private _onAfterRenderTargetsRenderObserver;
  125667. private _onAfterRenderObserver;
  125668. private _onBeforeDrawPhaseObserver;
  125669. private _onAfterDrawPhaseObserver;
  125670. private _onBeforeAnimationsObserver;
  125671. private _onBeforeParticlesRenderingObserver;
  125672. private _onAfterParticlesRenderingObserver;
  125673. private _onBeforeSpritesRenderingObserver;
  125674. private _onAfterSpritesRenderingObserver;
  125675. private _onBeforePhysicsObserver;
  125676. private _onAfterPhysicsObserver;
  125677. private _onAfterAnimationsObserver;
  125678. private _onBeforeCameraRenderObserver;
  125679. private _onAfterCameraRenderObserver;
  125680. /**
  125681. * Gets the perf counter used for active meshes evaluation time
  125682. */
  125683. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125684. /**
  125685. * Gets the active meshes evaluation time capture status
  125686. */
  125687. get captureActiveMeshesEvaluationTime(): boolean;
  125688. /**
  125689. * Enable or disable the active meshes evaluation time capture
  125690. */
  125691. set captureActiveMeshesEvaluationTime(value: boolean);
  125692. /**
  125693. * Gets the perf counter used for render targets render time
  125694. */
  125695. get renderTargetsRenderTimeCounter(): PerfCounter;
  125696. /**
  125697. * Gets the render targets render time capture status
  125698. */
  125699. get captureRenderTargetsRenderTime(): boolean;
  125700. /**
  125701. * Enable or disable the render targets render time capture
  125702. */
  125703. set captureRenderTargetsRenderTime(value: boolean);
  125704. /**
  125705. * Gets the perf counter used for particles render time
  125706. */
  125707. get particlesRenderTimeCounter(): PerfCounter;
  125708. /**
  125709. * Gets the particles render time capture status
  125710. */
  125711. get captureParticlesRenderTime(): boolean;
  125712. /**
  125713. * Enable or disable the particles render time capture
  125714. */
  125715. set captureParticlesRenderTime(value: boolean);
  125716. /**
  125717. * Gets the perf counter used for sprites render time
  125718. */
  125719. get spritesRenderTimeCounter(): PerfCounter;
  125720. /**
  125721. * Gets the sprites render time capture status
  125722. */
  125723. get captureSpritesRenderTime(): boolean;
  125724. /**
  125725. * Enable or disable the sprites render time capture
  125726. */
  125727. set captureSpritesRenderTime(value: boolean);
  125728. /**
  125729. * Gets the perf counter used for physics time
  125730. */
  125731. get physicsTimeCounter(): PerfCounter;
  125732. /**
  125733. * Gets the physics time capture status
  125734. */
  125735. get capturePhysicsTime(): boolean;
  125736. /**
  125737. * Enable or disable the physics time capture
  125738. */
  125739. set capturePhysicsTime(value: boolean);
  125740. /**
  125741. * Gets the perf counter used for animations time
  125742. */
  125743. get animationsTimeCounter(): PerfCounter;
  125744. /**
  125745. * Gets the animations time capture status
  125746. */
  125747. get captureAnimationsTime(): boolean;
  125748. /**
  125749. * Enable or disable the animations time capture
  125750. */
  125751. set captureAnimationsTime(value: boolean);
  125752. /**
  125753. * Gets the perf counter used for frame time capture
  125754. */
  125755. get frameTimeCounter(): PerfCounter;
  125756. /**
  125757. * Gets the frame time capture status
  125758. */
  125759. get captureFrameTime(): boolean;
  125760. /**
  125761. * Enable or disable the frame time capture
  125762. */
  125763. set captureFrameTime(value: boolean);
  125764. /**
  125765. * Gets the perf counter used for inter-frames time capture
  125766. */
  125767. get interFrameTimeCounter(): PerfCounter;
  125768. /**
  125769. * Gets the inter-frames time capture status
  125770. */
  125771. get captureInterFrameTime(): boolean;
  125772. /**
  125773. * Enable or disable the inter-frames time capture
  125774. */
  125775. set captureInterFrameTime(value: boolean);
  125776. /**
  125777. * Gets the perf counter used for render time capture
  125778. */
  125779. get renderTimeCounter(): PerfCounter;
  125780. /**
  125781. * Gets the render time capture status
  125782. */
  125783. get captureRenderTime(): boolean;
  125784. /**
  125785. * Enable or disable the render time capture
  125786. */
  125787. set captureRenderTime(value: boolean);
  125788. /**
  125789. * Gets the perf counter used for camera render time capture
  125790. */
  125791. get cameraRenderTimeCounter(): PerfCounter;
  125792. /**
  125793. * Gets the camera render time capture status
  125794. */
  125795. get captureCameraRenderTime(): boolean;
  125796. /**
  125797. * Enable or disable the camera render time capture
  125798. */
  125799. set captureCameraRenderTime(value: boolean);
  125800. /**
  125801. * Gets the perf counter used for draw calls
  125802. */
  125803. get drawCallsCounter(): PerfCounter;
  125804. /**
  125805. * Instantiates a new scene instrumentation.
  125806. * This class can be used to get instrumentation data from a Babylon engine
  125807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125808. * @param scene Defines the scene to instrument
  125809. */
  125810. constructor(
  125811. /**
  125812. * Defines the scene to instrument
  125813. */
  125814. scene: Scene);
  125815. /**
  125816. * Dispose and release associated resources.
  125817. */
  125818. dispose(): void;
  125819. }
  125820. }
  125821. declare module BABYLON {
  125822. /** @hidden */
  125823. export var glowMapGenerationPixelShader: {
  125824. name: string;
  125825. shader: string;
  125826. };
  125827. }
  125828. declare module BABYLON {
  125829. /** @hidden */
  125830. export var glowMapGenerationVertexShader: {
  125831. name: string;
  125832. shader: string;
  125833. };
  125834. }
  125835. declare module BABYLON {
  125836. /**
  125837. * Effect layer options. This helps customizing the behaviour
  125838. * of the effect layer.
  125839. */
  125840. export interface IEffectLayerOptions {
  125841. /**
  125842. * Multiplication factor apply to the canvas size to compute the render target size
  125843. * used to generated the objects (the smaller the faster).
  125844. */
  125845. mainTextureRatio: number;
  125846. /**
  125847. * Enforces a fixed size texture to ensure effect stability across devices.
  125848. */
  125849. mainTextureFixedSize?: number;
  125850. /**
  125851. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125852. */
  125853. alphaBlendingMode: number;
  125854. /**
  125855. * The camera attached to the layer.
  125856. */
  125857. camera: Nullable<Camera>;
  125858. /**
  125859. * The rendering group to draw the layer in.
  125860. */
  125861. renderingGroupId: number;
  125862. }
  125863. /**
  125864. * The effect layer Helps adding post process effect blended with the main pass.
  125865. *
  125866. * This can be for instance use to generate glow or higlight effects on the scene.
  125867. *
  125868. * The effect layer class can not be used directly and is intented to inherited from to be
  125869. * customized per effects.
  125870. */
  125871. export abstract class EffectLayer {
  125872. private _vertexBuffers;
  125873. private _indexBuffer;
  125874. private _cachedDefines;
  125875. private _effectLayerMapGenerationEffect;
  125876. private _effectLayerOptions;
  125877. private _mergeEffect;
  125878. protected _scene: Scene;
  125879. protected _engine: Engine;
  125880. protected _maxSize: number;
  125881. protected _mainTextureDesiredSize: ISize;
  125882. protected _mainTexture: RenderTargetTexture;
  125883. protected _shouldRender: boolean;
  125884. protected _postProcesses: PostProcess[];
  125885. protected _textures: BaseTexture[];
  125886. protected _emissiveTextureAndColor: {
  125887. texture: Nullable<BaseTexture>;
  125888. color: Color4;
  125889. };
  125890. /**
  125891. * The name of the layer
  125892. */
  125893. name: string;
  125894. /**
  125895. * The clear color of the texture used to generate the glow map.
  125896. */
  125897. neutralColor: Color4;
  125898. /**
  125899. * Specifies whether the highlight layer is enabled or not.
  125900. */
  125901. isEnabled: boolean;
  125902. /**
  125903. * Gets the camera attached to the layer.
  125904. */
  125905. get camera(): Nullable<Camera>;
  125906. /**
  125907. * Gets the rendering group id the layer should render in.
  125908. */
  125909. get renderingGroupId(): number;
  125910. set renderingGroupId(renderingGroupId: number);
  125911. /**
  125912. * An event triggered when the effect layer has been disposed.
  125913. */
  125914. onDisposeObservable: Observable<EffectLayer>;
  125915. /**
  125916. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125917. */
  125918. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125919. /**
  125920. * An event triggered when the generated texture is being merged in the scene.
  125921. */
  125922. onBeforeComposeObservable: Observable<EffectLayer>;
  125923. /**
  125924. * An event triggered when the mesh is rendered into the effect render target.
  125925. */
  125926. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125927. /**
  125928. * An event triggered after the mesh has been rendered into the effect render target.
  125929. */
  125930. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125931. /**
  125932. * An event triggered when the generated texture has been merged in the scene.
  125933. */
  125934. onAfterComposeObservable: Observable<EffectLayer>;
  125935. /**
  125936. * An event triggered when the efffect layer changes its size.
  125937. */
  125938. onSizeChangedObservable: Observable<EffectLayer>;
  125939. /** @hidden */
  125940. static _SceneComponentInitialization: (scene: Scene) => void;
  125941. /**
  125942. * Instantiates a new effect Layer and references it in the scene.
  125943. * @param name The name of the layer
  125944. * @param scene The scene to use the layer in
  125945. */
  125946. constructor(
  125947. /** The Friendly of the effect in the scene */
  125948. name: string, scene: Scene);
  125949. /**
  125950. * Get the effect name of the layer.
  125951. * @return The effect name
  125952. */
  125953. abstract getEffectName(): string;
  125954. /**
  125955. * Checks for the readiness of the element composing the layer.
  125956. * @param subMesh the mesh to check for
  125957. * @param useInstances specify whether or not to use instances to render the mesh
  125958. * @return true if ready otherwise, false
  125959. */
  125960. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125961. /**
  125962. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125963. * @returns true if the effect requires stencil during the main canvas render pass.
  125964. */
  125965. abstract needStencil(): boolean;
  125966. /**
  125967. * Create the merge effect. This is the shader use to blit the information back
  125968. * to the main canvas at the end of the scene rendering.
  125969. * @returns The effect containing the shader used to merge the effect on the main canvas
  125970. */
  125971. protected abstract _createMergeEffect(): Effect;
  125972. /**
  125973. * Creates the render target textures and post processes used in the effect layer.
  125974. */
  125975. protected abstract _createTextureAndPostProcesses(): void;
  125976. /**
  125977. * Implementation specific of rendering the generating effect on the main canvas.
  125978. * @param effect The effect used to render through
  125979. */
  125980. protected abstract _internalRender(effect: Effect): void;
  125981. /**
  125982. * Sets the required values for both the emissive texture and and the main color.
  125983. */
  125984. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125985. /**
  125986. * Free any resources and references associated to a mesh.
  125987. * Internal use
  125988. * @param mesh The mesh to free.
  125989. */
  125990. abstract _disposeMesh(mesh: Mesh): void;
  125991. /**
  125992. * Serializes this layer (Glow or Highlight for example)
  125993. * @returns a serialized layer object
  125994. */
  125995. abstract serialize?(): any;
  125996. /**
  125997. * Initializes the effect layer with the required options.
  125998. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125999. */
  126000. protected _init(options: Partial<IEffectLayerOptions>): void;
  126001. /**
  126002. * Generates the index buffer of the full screen quad blending to the main canvas.
  126003. */
  126004. private _generateIndexBuffer;
  126005. /**
  126006. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126007. */
  126008. private _generateVertexBuffer;
  126009. /**
  126010. * Sets the main texture desired size which is the closest power of two
  126011. * of the engine canvas size.
  126012. */
  126013. private _setMainTextureSize;
  126014. /**
  126015. * Creates the main texture for the effect layer.
  126016. */
  126017. protected _createMainTexture(): void;
  126018. /**
  126019. * Adds specific effects defines.
  126020. * @param defines The defines to add specifics to.
  126021. */
  126022. protected _addCustomEffectDefines(defines: string[]): void;
  126023. /**
  126024. * Checks for the readiness of the element composing the layer.
  126025. * @param subMesh the mesh to check for
  126026. * @param useInstances specify whether or not to use instances to render the mesh
  126027. * @param emissiveTexture the associated emissive texture used to generate the glow
  126028. * @return true if ready otherwise, false
  126029. */
  126030. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126031. /**
  126032. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126033. */
  126034. render(): void;
  126035. /**
  126036. * Determine if a given mesh will be used in the current effect.
  126037. * @param mesh mesh to test
  126038. * @returns true if the mesh will be used
  126039. */
  126040. hasMesh(mesh: AbstractMesh): boolean;
  126041. /**
  126042. * Returns true if the layer contains information to display, otherwise false.
  126043. * @returns true if the glow layer should be rendered
  126044. */
  126045. shouldRender(): boolean;
  126046. /**
  126047. * Returns true if the mesh should render, otherwise false.
  126048. * @param mesh The mesh to render
  126049. * @returns true if it should render otherwise false
  126050. */
  126051. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126052. /**
  126053. * Returns true if the mesh can be rendered, otherwise false.
  126054. * @param mesh The mesh to render
  126055. * @param material The material used on the mesh
  126056. * @returns true if it can be rendered otherwise false
  126057. */
  126058. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126059. /**
  126060. * Returns true if the mesh should render, otherwise false.
  126061. * @param mesh The mesh to render
  126062. * @returns true if it should render otherwise false
  126063. */
  126064. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126065. /**
  126066. * Renders the submesh passed in parameter to the generation map.
  126067. */
  126068. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126069. /**
  126070. * Defines whether the current material of the mesh should be use to render the effect.
  126071. * @param mesh defines the current mesh to render
  126072. */
  126073. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126074. /**
  126075. * Rebuild the required buffers.
  126076. * @hidden Internal use only.
  126077. */
  126078. _rebuild(): void;
  126079. /**
  126080. * Dispose only the render target textures and post process.
  126081. */
  126082. private _disposeTextureAndPostProcesses;
  126083. /**
  126084. * Dispose the highlight layer and free resources.
  126085. */
  126086. dispose(): void;
  126087. /**
  126088. * Gets the class name of the effect layer
  126089. * @returns the string with the class name of the effect layer
  126090. */
  126091. getClassName(): string;
  126092. /**
  126093. * Creates an effect layer from parsed effect layer data
  126094. * @param parsedEffectLayer defines effect layer data
  126095. * @param scene defines the current scene
  126096. * @param rootUrl defines the root URL containing the effect layer information
  126097. * @returns a parsed effect Layer
  126098. */
  126099. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126100. }
  126101. }
  126102. declare module BABYLON {
  126103. interface AbstractScene {
  126104. /**
  126105. * The list of effect layers (highlights/glow) added to the scene
  126106. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126107. * @see http://doc.babylonjs.com/how_to/glow_layer
  126108. */
  126109. effectLayers: Array<EffectLayer>;
  126110. /**
  126111. * Removes the given effect layer from this scene.
  126112. * @param toRemove defines the effect layer to remove
  126113. * @returns the index of the removed effect layer
  126114. */
  126115. removeEffectLayer(toRemove: EffectLayer): number;
  126116. /**
  126117. * Adds the given effect layer to this scene
  126118. * @param newEffectLayer defines the effect layer to add
  126119. */
  126120. addEffectLayer(newEffectLayer: EffectLayer): void;
  126121. }
  126122. /**
  126123. * Defines the layer scene component responsible to manage any effect layers
  126124. * in a given scene.
  126125. */
  126126. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126127. /**
  126128. * The component name helpfull to identify the component in the list of scene components.
  126129. */
  126130. readonly name: string;
  126131. /**
  126132. * The scene the component belongs to.
  126133. */
  126134. scene: Scene;
  126135. private _engine;
  126136. private _renderEffects;
  126137. private _needStencil;
  126138. private _previousStencilState;
  126139. /**
  126140. * Creates a new instance of the component for the given scene
  126141. * @param scene Defines the scene to register the component in
  126142. */
  126143. constructor(scene: Scene);
  126144. /**
  126145. * Registers the component in a given scene
  126146. */
  126147. register(): void;
  126148. /**
  126149. * Rebuilds the elements related to this component in case of
  126150. * context lost for instance.
  126151. */
  126152. rebuild(): void;
  126153. /**
  126154. * Serializes the component data to the specified json object
  126155. * @param serializationObject The object to serialize to
  126156. */
  126157. serialize(serializationObject: any): void;
  126158. /**
  126159. * Adds all the elements from the container to the scene
  126160. * @param container the container holding the elements
  126161. */
  126162. addFromContainer(container: AbstractScene): void;
  126163. /**
  126164. * Removes all the elements in the container from the scene
  126165. * @param container contains the elements to remove
  126166. * @param dispose if the removed element should be disposed (default: false)
  126167. */
  126168. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126169. /**
  126170. * Disposes the component and the associated ressources.
  126171. */
  126172. dispose(): void;
  126173. private _isReadyForMesh;
  126174. private _renderMainTexture;
  126175. private _setStencil;
  126176. private _setStencilBack;
  126177. private _draw;
  126178. private _drawCamera;
  126179. private _drawRenderingGroup;
  126180. }
  126181. }
  126182. declare module BABYLON {
  126183. /** @hidden */
  126184. export var glowMapMergePixelShader: {
  126185. name: string;
  126186. shader: string;
  126187. };
  126188. }
  126189. declare module BABYLON {
  126190. /** @hidden */
  126191. export var glowMapMergeVertexShader: {
  126192. name: string;
  126193. shader: string;
  126194. };
  126195. }
  126196. declare module BABYLON {
  126197. interface AbstractScene {
  126198. /**
  126199. * Return a the first highlight layer of the scene with a given name.
  126200. * @param name The name of the highlight layer to look for.
  126201. * @return The highlight layer if found otherwise null.
  126202. */
  126203. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126204. }
  126205. /**
  126206. * Glow layer options. This helps customizing the behaviour
  126207. * of the glow layer.
  126208. */
  126209. export interface IGlowLayerOptions {
  126210. /**
  126211. * Multiplication factor apply to the canvas size to compute the render target size
  126212. * used to generated the glowing objects (the smaller the faster).
  126213. */
  126214. mainTextureRatio: number;
  126215. /**
  126216. * Enforces a fixed size texture to ensure resize independant blur.
  126217. */
  126218. mainTextureFixedSize?: number;
  126219. /**
  126220. * How big is the kernel of the blur texture.
  126221. */
  126222. blurKernelSize: number;
  126223. /**
  126224. * The camera attached to the layer.
  126225. */
  126226. camera: Nullable<Camera>;
  126227. /**
  126228. * Enable MSAA by chosing the number of samples.
  126229. */
  126230. mainTextureSamples?: number;
  126231. /**
  126232. * The rendering group to draw the layer in.
  126233. */
  126234. renderingGroupId: number;
  126235. }
  126236. /**
  126237. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126238. *
  126239. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126240. *
  126241. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126242. */
  126243. export class GlowLayer extends EffectLayer {
  126244. /**
  126245. * Effect Name of the layer.
  126246. */
  126247. static readonly EffectName: string;
  126248. /**
  126249. * The default blur kernel size used for the glow.
  126250. */
  126251. static DefaultBlurKernelSize: number;
  126252. /**
  126253. * The default texture size ratio used for the glow.
  126254. */
  126255. static DefaultTextureRatio: number;
  126256. /**
  126257. * Sets the kernel size of the blur.
  126258. */
  126259. set blurKernelSize(value: number);
  126260. /**
  126261. * Gets the kernel size of the blur.
  126262. */
  126263. get blurKernelSize(): number;
  126264. /**
  126265. * Sets the glow intensity.
  126266. */
  126267. set intensity(value: number);
  126268. /**
  126269. * Gets the glow intensity.
  126270. */
  126271. get intensity(): number;
  126272. private _options;
  126273. private _intensity;
  126274. private _horizontalBlurPostprocess1;
  126275. private _verticalBlurPostprocess1;
  126276. private _horizontalBlurPostprocess2;
  126277. private _verticalBlurPostprocess2;
  126278. private _blurTexture1;
  126279. private _blurTexture2;
  126280. private _postProcesses1;
  126281. private _postProcesses2;
  126282. private _includedOnlyMeshes;
  126283. private _excludedMeshes;
  126284. private _meshesUsingTheirOwnMaterials;
  126285. /**
  126286. * Callback used to let the user override the color selection on a per mesh basis
  126287. */
  126288. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126289. /**
  126290. * Callback used to let the user override the texture selection on a per mesh basis
  126291. */
  126292. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126293. /**
  126294. * Instantiates a new glow Layer and references it to the scene.
  126295. * @param name The name of the layer
  126296. * @param scene The scene to use the layer in
  126297. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126298. */
  126299. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126300. /**
  126301. * Get the effect name of the layer.
  126302. * @return The effect name
  126303. */
  126304. getEffectName(): string;
  126305. /**
  126306. * Create the merge effect. This is the shader use to blit the information back
  126307. * to the main canvas at the end of the scene rendering.
  126308. */
  126309. protected _createMergeEffect(): Effect;
  126310. /**
  126311. * Creates the render target textures and post processes used in the glow layer.
  126312. */
  126313. protected _createTextureAndPostProcesses(): void;
  126314. /**
  126315. * Checks for the readiness of the element composing the layer.
  126316. * @param subMesh the mesh to check for
  126317. * @param useInstances specify wether or not to use instances to render the mesh
  126318. * @param emissiveTexture the associated emissive texture used to generate the glow
  126319. * @return true if ready otherwise, false
  126320. */
  126321. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126322. /**
  126323. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126324. */
  126325. needStencil(): boolean;
  126326. /**
  126327. * Returns true if the mesh can be rendered, otherwise false.
  126328. * @param mesh The mesh to render
  126329. * @param material The material used on the mesh
  126330. * @returns true if it can be rendered otherwise false
  126331. */
  126332. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126333. /**
  126334. * Implementation specific of rendering the generating effect on the main canvas.
  126335. * @param effect The effect used to render through
  126336. */
  126337. protected _internalRender(effect: Effect): void;
  126338. /**
  126339. * Sets the required values for both the emissive texture and and the main color.
  126340. */
  126341. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126342. /**
  126343. * Returns true if the mesh should render, otherwise false.
  126344. * @param mesh The mesh to render
  126345. * @returns true if it should render otherwise false
  126346. */
  126347. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126348. /**
  126349. * Adds specific effects defines.
  126350. * @param defines The defines to add specifics to.
  126351. */
  126352. protected _addCustomEffectDefines(defines: string[]): void;
  126353. /**
  126354. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126355. * @param mesh The mesh to exclude from the glow layer
  126356. */
  126357. addExcludedMesh(mesh: Mesh): void;
  126358. /**
  126359. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126360. * @param mesh The mesh to remove
  126361. */
  126362. removeExcludedMesh(mesh: Mesh): void;
  126363. /**
  126364. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126365. * @param mesh The mesh to include in the glow layer
  126366. */
  126367. addIncludedOnlyMesh(mesh: Mesh): void;
  126368. /**
  126369. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126370. * @param mesh The mesh to remove
  126371. */
  126372. removeIncludedOnlyMesh(mesh: Mesh): void;
  126373. /**
  126374. * Determine if a given mesh will be used in the glow layer
  126375. * @param mesh The mesh to test
  126376. * @returns true if the mesh will be highlighted by the current glow layer
  126377. */
  126378. hasMesh(mesh: AbstractMesh): boolean;
  126379. /**
  126380. * Defines whether the current material of the mesh should be use to render the effect.
  126381. * @param mesh defines the current mesh to render
  126382. */
  126383. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126384. /**
  126385. * Add a mesh to be rendered through its own material and not with emissive only.
  126386. * @param mesh The mesh for which we need to use its material
  126387. */
  126388. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126389. /**
  126390. * Remove a mesh from being rendered through its own material and not with emissive only.
  126391. * @param mesh The mesh for which we need to not use its material
  126392. */
  126393. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126394. /**
  126395. * Free any resources and references associated to a mesh.
  126396. * Internal use
  126397. * @param mesh The mesh to free.
  126398. * @hidden
  126399. */
  126400. _disposeMesh(mesh: Mesh): void;
  126401. /**
  126402. * Gets the class name of the effect layer
  126403. * @returns the string with the class name of the effect layer
  126404. */
  126405. getClassName(): string;
  126406. /**
  126407. * Serializes this glow layer
  126408. * @returns a serialized glow layer object
  126409. */
  126410. serialize(): any;
  126411. /**
  126412. * Creates a Glow Layer from parsed glow layer data
  126413. * @param parsedGlowLayer defines glow layer data
  126414. * @param scene defines the current scene
  126415. * @param rootUrl defines the root URL containing the glow layer information
  126416. * @returns a parsed Glow Layer
  126417. */
  126418. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126419. }
  126420. }
  126421. declare module BABYLON {
  126422. /** @hidden */
  126423. export var glowBlurPostProcessPixelShader: {
  126424. name: string;
  126425. shader: string;
  126426. };
  126427. }
  126428. declare module BABYLON {
  126429. interface AbstractScene {
  126430. /**
  126431. * Return a the first highlight layer of the scene with a given name.
  126432. * @param name The name of the highlight layer to look for.
  126433. * @return The highlight layer if found otherwise null.
  126434. */
  126435. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126436. }
  126437. /**
  126438. * Highlight layer options. This helps customizing the behaviour
  126439. * of the highlight layer.
  126440. */
  126441. export interface IHighlightLayerOptions {
  126442. /**
  126443. * Multiplication factor apply to the canvas size to compute the render target size
  126444. * used to generated the glowing objects (the smaller the faster).
  126445. */
  126446. mainTextureRatio: number;
  126447. /**
  126448. * Enforces a fixed size texture to ensure resize independant blur.
  126449. */
  126450. mainTextureFixedSize?: number;
  126451. /**
  126452. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126453. * of the picture to blur (the smaller the faster).
  126454. */
  126455. blurTextureSizeRatio: number;
  126456. /**
  126457. * How big in texel of the blur texture is the vertical blur.
  126458. */
  126459. blurVerticalSize: number;
  126460. /**
  126461. * How big in texel of the blur texture is the horizontal blur.
  126462. */
  126463. blurHorizontalSize: number;
  126464. /**
  126465. * Alpha blending mode used to apply the blur. Default is combine.
  126466. */
  126467. alphaBlendingMode: number;
  126468. /**
  126469. * The camera attached to the layer.
  126470. */
  126471. camera: Nullable<Camera>;
  126472. /**
  126473. * Should we display highlight as a solid stroke?
  126474. */
  126475. isStroke?: boolean;
  126476. /**
  126477. * The rendering group to draw the layer in.
  126478. */
  126479. renderingGroupId: number;
  126480. }
  126481. /**
  126482. * The highlight layer Helps adding a glow effect around a mesh.
  126483. *
  126484. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126485. * glowy meshes to your scene.
  126486. *
  126487. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126488. */
  126489. export class HighlightLayer extends EffectLayer {
  126490. name: string;
  126491. /**
  126492. * Effect Name of the highlight layer.
  126493. */
  126494. static readonly EffectName: string;
  126495. /**
  126496. * The neutral color used during the preparation of the glow effect.
  126497. * This is black by default as the blend operation is a blend operation.
  126498. */
  126499. static NeutralColor: Color4;
  126500. /**
  126501. * Stencil value used for glowing meshes.
  126502. */
  126503. static GlowingMeshStencilReference: number;
  126504. /**
  126505. * Stencil value used for the other meshes in the scene.
  126506. */
  126507. static NormalMeshStencilReference: number;
  126508. /**
  126509. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126510. */
  126511. innerGlow: boolean;
  126512. /**
  126513. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126514. */
  126515. outerGlow: boolean;
  126516. /**
  126517. * Specifies the horizontal size of the blur.
  126518. */
  126519. set blurHorizontalSize(value: number);
  126520. /**
  126521. * Specifies the vertical size of the blur.
  126522. */
  126523. set blurVerticalSize(value: number);
  126524. /**
  126525. * Gets the horizontal size of the blur.
  126526. */
  126527. get blurHorizontalSize(): number;
  126528. /**
  126529. * Gets the vertical size of the blur.
  126530. */
  126531. get blurVerticalSize(): number;
  126532. /**
  126533. * An event triggered when the highlight layer is being blurred.
  126534. */
  126535. onBeforeBlurObservable: Observable<HighlightLayer>;
  126536. /**
  126537. * An event triggered when the highlight layer has been blurred.
  126538. */
  126539. onAfterBlurObservable: Observable<HighlightLayer>;
  126540. private _instanceGlowingMeshStencilReference;
  126541. private _options;
  126542. private _downSamplePostprocess;
  126543. private _horizontalBlurPostprocess;
  126544. private _verticalBlurPostprocess;
  126545. private _blurTexture;
  126546. private _meshes;
  126547. private _excludedMeshes;
  126548. /**
  126549. * Instantiates a new highlight Layer and references it to the scene..
  126550. * @param name The name of the layer
  126551. * @param scene The scene to use the layer in
  126552. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126553. */
  126554. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126555. /**
  126556. * Get the effect name of the layer.
  126557. * @return The effect name
  126558. */
  126559. getEffectName(): string;
  126560. /**
  126561. * Create the merge effect. This is the shader use to blit the information back
  126562. * to the main canvas at the end of the scene rendering.
  126563. */
  126564. protected _createMergeEffect(): Effect;
  126565. /**
  126566. * Creates the render target textures and post processes used in the highlight layer.
  126567. */
  126568. protected _createTextureAndPostProcesses(): void;
  126569. /**
  126570. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126571. */
  126572. needStencil(): boolean;
  126573. /**
  126574. * Checks for the readiness of the element composing the layer.
  126575. * @param subMesh the mesh to check for
  126576. * @param useInstances specify wether or not to use instances to render the mesh
  126577. * @param emissiveTexture the associated emissive texture used to generate the glow
  126578. * @return true if ready otherwise, false
  126579. */
  126580. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126581. /**
  126582. * Implementation specific of rendering the generating effect on the main canvas.
  126583. * @param effect The effect used to render through
  126584. */
  126585. protected _internalRender(effect: Effect): void;
  126586. /**
  126587. * Returns true if the layer contains information to display, otherwise false.
  126588. */
  126589. shouldRender(): boolean;
  126590. /**
  126591. * Returns true if the mesh should render, otherwise false.
  126592. * @param mesh The mesh to render
  126593. * @returns true if it should render otherwise false
  126594. */
  126595. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126596. /**
  126597. * Sets the required values for both the emissive texture and and the main color.
  126598. */
  126599. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126600. /**
  126601. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126602. * @param mesh The mesh to exclude from the highlight layer
  126603. */
  126604. addExcludedMesh(mesh: Mesh): void;
  126605. /**
  126606. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126607. * @param mesh The mesh to highlight
  126608. */
  126609. removeExcludedMesh(mesh: Mesh): void;
  126610. /**
  126611. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126612. * @param mesh mesh to test
  126613. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126614. */
  126615. hasMesh(mesh: AbstractMesh): boolean;
  126616. /**
  126617. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126618. * @param mesh The mesh to highlight
  126619. * @param color The color of the highlight
  126620. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126621. */
  126622. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126623. /**
  126624. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126625. * @param mesh The mesh to highlight
  126626. */
  126627. removeMesh(mesh: Mesh): void;
  126628. /**
  126629. * Remove all the meshes currently referenced in the highlight layer
  126630. */
  126631. removeAllMeshes(): void;
  126632. /**
  126633. * Force the stencil to the normal expected value for none glowing parts
  126634. */
  126635. private _defaultStencilReference;
  126636. /**
  126637. * Free any resources and references associated to a mesh.
  126638. * Internal use
  126639. * @param mesh The mesh to free.
  126640. * @hidden
  126641. */
  126642. _disposeMesh(mesh: Mesh): void;
  126643. /**
  126644. * Dispose the highlight layer and free resources.
  126645. */
  126646. dispose(): void;
  126647. /**
  126648. * Gets the class name of the effect layer
  126649. * @returns the string with the class name of the effect layer
  126650. */
  126651. getClassName(): string;
  126652. /**
  126653. * Serializes this Highlight layer
  126654. * @returns a serialized Highlight layer object
  126655. */
  126656. serialize(): any;
  126657. /**
  126658. * Creates a Highlight layer from parsed Highlight layer data
  126659. * @param parsedHightlightLayer defines the Highlight layer data
  126660. * @param scene defines the current scene
  126661. * @param rootUrl defines the root URL containing the Highlight layer information
  126662. * @returns a parsed Highlight layer
  126663. */
  126664. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126665. }
  126666. }
  126667. declare module BABYLON {
  126668. interface AbstractScene {
  126669. /**
  126670. * The list of layers (background and foreground) of the scene
  126671. */
  126672. layers: Array<Layer>;
  126673. }
  126674. /**
  126675. * Defines the layer scene component responsible to manage any layers
  126676. * in a given scene.
  126677. */
  126678. export class LayerSceneComponent implements ISceneComponent {
  126679. /**
  126680. * The component name helpfull to identify the component in the list of scene components.
  126681. */
  126682. readonly name: string;
  126683. /**
  126684. * The scene the component belongs to.
  126685. */
  126686. scene: Scene;
  126687. private _engine;
  126688. /**
  126689. * Creates a new instance of the component for the given scene
  126690. * @param scene Defines the scene to register the component in
  126691. */
  126692. constructor(scene: Scene);
  126693. /**
  126694. * Registers the component in a given scene
  126695. */
  126696. register(): void;
  126697. /**
  126698. * Rebuilds the elements related to this component in case of
  126699. * context lost for instance.
  126700. */
  126701. rebuild(): void;
  126702. /**
  126703. * Disposes the component and the associated ressources.
  126704. */
  126705. dispose(): void;
  126706. private _draw;
  126707. private _drawCameraPredicate;
  126708. private _drawCameraBackground;
  126709. private _drawCameraForeground;
  126710. private _drawRenderTargetPredicate;
  126711. private _drawRenderTargetBackground;
  126712. private _drawRenderTargetForeground;
  126713. /**
  126714. * Adds all the elements from the container to the scene
  126715. * @param container the container holding the elements
  126716. */
  126717. addFromContainer(container: AbstractScene): void;
  126718. /**
  126719. * Removes all the elements in the container from the scene
  126720. * @param container contains the elements to remove
  126721. * @param dispose if the removed element should be disposed (default: false)
  126722. */
  126723. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126724. }
  126725. }
  126726. declare module BABYLON {
  126727. /** @hidden */
  126728. export var layerPixelShader: {
  126729. name: string;
  126730. shader: string;
  126731. };
  126732. }
  126733. declare module BABYLON {
  126734. /** @hidden */
  126735. export var layerVertexShader: {
  126736. name: string;
  126737. shader: string;
  126738. };
  126739. }
  126740. declare module BABYLON {
  126741. /**
  126742. * This represents a full screen 2d layer.
  126743. * This can be useful to display a picture in the background of your scene for instance.
  126744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126745. */
  126746. export class Layer {
  126747. /**
  126748. * Define the name of the layer.
  126749. */
  126750. name: string;
  126751. /**
  126752. * Define the texture the layer should display.
  126753. */
  126754. texture: Nullable<Texture>;
  126755. /**
  126756. * Is the layer in background or foreground.
  126757. */
  126758. isBackground: boolean;
  126759. /**
  126760. * Define the color of the layer (instead of texture).
  126761. */
  126762. color: Color4;
  126763. /**
  126764. * Define the scale of the layer in order to zoom in out of the texture.
  126765. */
  126766. scale: Vector2;
  126767. /**
  126768. * Define an offset for the layer in order to shift the texture.
  126769. */
  126770. offset: Vector2;
  126771. /**
  126772. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126773. */
  126774. alphaBlendingMode: number;
  126775. /**
  126776. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126777. * Alpha test will not mix with the background color in case of transparency.
  126778. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126779. */
  126780. alphaTest: boolean;
  126781. /**
  126782. * Define a mask to restrict the layer to only some of the scene cameras.
  126783. */
  126784. layerMask: number;
  126785. /**
  126786. * Define the list of render target the layer is visible into.
  126787. */
  126788. renderTargetTextures: RenderTargetTexture[];
  126789. /**
  126790. * Define if the layer is only used in renderTarget or if it also
  126791. * renders in the main frame buffer of the canvas.
  126792. */
  126793. renderOnlyInRenderTargetTextures: boolean;
  126794. private _scene;
  126795. private _vertexBuffers;
  126796. private _indexBuffer;
  126797. private _effect;
  126798. private _previousDefines;
  126799. /**
  126800. * An event triggered when the layer is disposed.
  126801. */
  126802. onDisposeObservable: Observable<Layer>;
  126803. private _onDisposeObserver;
  126804. /**
  126805. * Back compatibility with callback before the onDisposeObservable existed.
  126806. * The set callback will be triggered when the layer has been disposed.
  126807. */
  126808. set onDispose(callback: () => void);
  126809. /**
  126810. * An event triggered before rendering the scene
  126811. */
  126812. onBeforeRenderObservable: Observable<Layer>;
  126813. private _onBeforeRenderObserver;
  126814. /**
  126815. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126816. * The set callback will be triggered just before rendering the layer.
  126817. */
  126818. set onBeforeRender(callback: () => void);
  126819. /**
  126820. * An event triggered after rendering the scene
  126821. */
  126822. onAfterRenderObservable: Observable<Layer>;
  126823. private _onAfterRenderObserver;
  126824. /**
  126825. * Back compatibility with callback before the onAfterRenderObservable existed.
  126826. * The set callback will be triggered just after rendering the layer.
  126827. */
  126828. set onAfterRender(callback: () => void);
  126829. /**
  126830. * Instantiates a new layer.
  126831. * This represents a full screen 2d layer.
  126832. * This can be useful to display a picture in the background of your scene for instance.
  126833. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126834. * @param name Define the name of the layer in the scene
  126835. * @param imgUrl Define the url of the texture to display in the layer
  126836. * @param scene Define the scene the layer belongs to
  126837. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126838. * @param color Defines a color for the layer
  126839. */
  126840. constructor(
  126841. /**
  126842. * Define the name of the layer.
  126843. */
  126844. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126845. private _createIndexBuffer;
  126846. /** @hidden */
  126847. _rebuild(): void;
  126848. /**
  126849. * Renders the layer in the scene.
  126850. */
  126851. render(): void;
  126852. /**
  126853. * Disposes and releases the associated ressources.
  126854. */
  126855. dispose(): void;
  126856. }
  126857. }
  126858. declare module BABYLON {
  126859. /** @hidden */
  126860. export var lensFlarePixelShader: {
  126861. name: string;
  126862. shader: string;
  126863. };
  126864. }
  126865. declare module BABYLON {
  126866. /** @hidden */
  126867. export var lensFlareVertexShader: {
  126868. name: string;
  126869. shader: string;
  126870. };
  126871. }
  126872. declare module BABYLON {
  126873. /**
  126874. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126875. * It is usually composed of several `lensFlare`.
  126876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126877. */
  126878. export class LensFlareSystem {
  126879. /**
  126880. * Define the name of the lens flare system
  126881. */
  126882. name: string;
  126883. /**
  126884. * List of lens flares used in this system.
  126885. */
  126886. lensFlares: LensFlare[];
  126887. /**
  126888. * Define a limit from the border the lens flare can be visible.
  126889. */
  126890. borderLimit: number;
  126891. /**
  126892. * Define a viewport border we do not want to see the lens flare in.
  126893. */
  126894. viewportBorder: number;
  126895. /**
  126896. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126897. */
  126898. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126899. /**
  126900. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126901. */
  126902. layerMask: number;
  126903. /**
  126904. * Define the id of the lens flare system in the scene.
  126905. * (equal to name by default)
  126906. */
  126907. id: string;
  126908. private _scene;
  126909. private _emitter;
  126910. private _vertexBuffers;
  126911. private _indexBuffer;
  126912. private _effect;
  126913. private _positionX;
  126914. private _positionY;
  126915. private _isEnabled;
  126916. /** @hidden */
  126917. static _SceneComponentInitialization: (scene: Scene) => void;
  126918. /**
  126919. * Instantiates a lens flare system.
  126920. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126921. * It is usually composed of several `lensFlare`.
  126922. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126923. * @param name Define the name of the lens flare system in the scene
  126924. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126925. * @param scene Define the scene the lens flare system belongs to
  126926. */
  126927. constructor(
  126928. /**
  126929. * Define the name of the lens flare system
  126930. */
  126931. name: string, emitter: any, scene: Scene);
  126932. /**
  126933. * Define if the lens flare system is enabled.
  126934. */
  126935. get isEnabled(): boolean;
  126936. set isEnabled(value: boolean);
  126937. /**
  126938. * Get the scene the effects belongs to.
  126939. * @returns the scene holding the lens flare system
  126940. */
  126941. getScene(): Scene;
  126942. /**
  126943. * Get the emitter of the lens flare system.
  126944. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126945. * @returns the emitter of the lens flare system
  126946. */
  126947. getEmitter(): any;
  126948. /**
  126949. * Set the emitter of the lens flare system.
  126950. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126951. * @param newEmitter Define the new emitter of the system
  126952. */
  126953. setEmitter(newEmitter: any): void;
  126954. /**
  126955. * Get the lens flare system emitter position.
  126956. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126957. * @returns the position
  126958. */
  126959. getEmitterPosition(): Vector3;
  126960. /**
  126961. * @hidden
  126962. */
  126963. computeEffectivePosition(globalViewport: Viewport): boolean;
  126964. /** @hidden */
  126965. _isVisible(): boolean;
  126966. /**
  126967. * @hidden
  126968. */
  126969. render(): boolean;
  126970. /**
  126971. * Dispose and release the lens flare with its associated resources.
  126972. */
  126973. dispose(): void;
  126974. /**
  126975. * Parse a lens flare system from a JSON repressentation
  126976. * @param parsedLensFlareSystem Define the JSON to parse
  126977. * @param scene Define the scene the parsed system should be instantiated in
  126978. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126979. * @returns the parsed system
  126980. */
  126981. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126982. /**
  126983. * Serialize the current Lens Flare System into a JSON representation.
  126984. * @returns the serialized JSON
  126985. */
  126986. serialize(): any;
  126987. }
  126988. }
  126989. declare module BABYLON {
  126990. /**
  126991. * This represents one of the lens effect in a `lensFlareSystem`.
  126992. * It controls one of the indiviual texture used in the effect.
  126993. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126994. */
  126995. export class LensFlare {
  126996. /**
  126997. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126998. */
  126999. size: number;
  127000. /**
  127001. * 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.
  127002. */
  127003. position: number;
  127004. /**
  127005. * Define the lens color.
  127006. */
  127007. color: Color3;
  127008. /**
  127009. * Define the lens texture.
  127010. */
  127011. texture: Nullable<Texture>;
  127012. /**
  127013. * Define the alpha mode to render this particular lens.
  127014. */
  127015. alphaMode: number;
  127016. private _system;
  127017. /**
  127018. * Creates a new Lens Flare.
  127019. * This represents one of the lens effect in a `lensFlareSystem`.
  127020. * It controls one of the indiviual texture used in the effect.
  127021. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127022. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127023. * @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.
  127024. * @param color Define the lens color
  127025. * @param imgUrl Define the lens texture url
  127026. * @param system Define the `lensFlareSystem` this flare is part of
  127027. * @returns The newly created Lens Flare
  127028. */
  127029. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127030. /**
  127031. * Instantiates a new Lens Flare.
  127032. * This represents one of the lens effect in a `lensFlareSystem`.
  127033. * It controls one of the indiviual texture used in the effect.
  127034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127035. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127036. * @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.
  127037. * @param color Define the lens color
  127038. * @param imgUrl Define the lens texture url
  127039. * @param system Define the `lensFlareSystem` this flare is part of
  127040. */
  127041. constructor(
  127042. /**
  127043. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127044. */
  127045. size: number,
  127046. /**
  127047. * 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.
  127048. */
  127049. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127050. /**
  127051. * Dispose and release the lens flare with its associated resources.
  127052. */
  127053. dispose(): void;
  127054. }
  127055. }
  127056. declare module BABYLON {
  127057. interface AbstractScene {
  127058. /**
  127059. * The list of lens flare system added to the scene
  127060. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127061. */
  127062. lensFlareSystems: Array<LensFlareSystem>;
  127063. /**
  127064. * Removes the given lens flare system from this scene.
  127065. * @param toRemove The lens flare system to remove
  127066. * @returns The index of the removed lens flare system
  127067. */
  127068. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127069. /**
  127070. * Adds the given lens flare system to this scene
  127071. * @param newLensFlareSystem The lens flare system to add
  127072. */
  127073. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127074. /**
  127075. * Gets a lens flare system using its name
  127076. * @param name defines the name to look for
  127077. * @returns the lens flare system or null if not found
  127078. */
  127079. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127080. /**
  127081. * Gets a lens flare system using its id
  127082. * @param id defines the id to look for
  127083. * @returns the lens flare system or null if not found
  127084. */
  127085. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127086. }
  127087. /**
  127088. * Defines the lens flare scene component responsible to manage any lens flares
  127089. * in a given scene.
  127090. */
  127091. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127092. /**
  127093. * The component name helpfull to identify the component in the list of scene components.
  127094. */
  127095. readonly name: string;
  127096. /**
  127097. * The scene the component belongs to.
  127098. */
  127099. scene: Scene;
  127100. /**
  127101. * Creates a new instance of the component for the given scene
  127102. * @param scene Defines the scene to register the component in
  127103. */
  127104. constructor(scene: Scene);
  127105. /**
  127106. * Registers the component in a given scene
  127107. */
  127108. register(): void;
  127109. /**
  127110. * Rebuilds the elements related to this component in case of
  127111. * context lost for instance.
  127112. */
  127113. rebuild(): void;
  127114. /**
  127115. * Adds all the elements from the container to the scene
  127116. * @param container the container holding the elements
  127117. */
  127118. addFromContainer(container: AbstractScene): void;
  127119. /**
  127120. * Removes all the elements in the container from the scene
  127121. * @param container contains the elements to remove
  127122. * @param dispose if the removed element should be disposed (default: false)
  127123. */
  127124. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127125. /**
  127126. * Serializes the component data to the specified json object
  127127. * @param serializationObject The object to serialize to
  127128. */
  127129. serialize(serializationObject: any): void;
  127130. /**
  127131. * Disposes the component and the associated ressources.
  127132. */
  127133. dispose(): void;
  127134. private _draw;
  127135. }
  127136. }
  127137. declare module BABYLON {
  127138. /** @hidden */
  127139. export var depthPixelShader: {
  127140. name: string;
  127141. shader: string;
  127142. };
  127143. }
  127144. declare module BABYLON {
  127145. /** @hidden */
  127146. export var depthVertexShader: {
  127147. name: string;
  127148. shader: string;
  127149. };
  127150. }
  127151. declare module BABYLON {
  127152. /**
  127153. * This represents a depth renderer in Babylon.
  127154. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127155. */
  127156. export class DepthRenderer {
  127157. private _scene;
  127158. private _depthMap;
  127159. private _effect;
  127160. private readonly _storeNonLinearDepth;
  127161. private readonly _clearColor;
  127162. /** Get if the depth renderer is using packed depth or not */
  127163. readonly isPacked: boolean;
  127164. private _cachedDefines;
  127165. private _camera;
  127166. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127167. enabled: boolean;
  127168. /**
  127169. * Specifiess that the depth renderer will only be used within
  127170. * the camera it is created for.
  127171. * This can help forcing its rendering during the camera processing.
  127172. */
  127173. useOnlyInActiveCamera: boolean;
  127174. /** @hidden */
  127175. static _SceneComponentInitialization: (scene: Scene) => void;
  127176. /**
  127177. * Instantiates a depth renderer
  127178. * @param scene The scene the renderer belongs to
  127179. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127180. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127181. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127182. */
  127183. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127184. /**
  127185. * Creates the depth rendering effect and checks if the effect is ready.
  127186. * @param subMesh The submesh to be used to render the depth map of
  127187. * @param useInstances If multiple world instances should be used
  127188. * @returns if the depth renderer is ready to render the depth map
  127189. */
  127190. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127191. /**
  127192. * Gets the texture which the depth map will be written to.
  127193. * @returns The depth map texture
  127194. */
  127195. getDepthMap(): RenderTargetTexture;
  127196. /**
  127197. * Disposes of the depth renderer.
  127198. */
  127199. dispose(): void;
  127200. }
  127201. }
  127202. declare module BABYLON {
  127203. /** @hidden */
  127204. export var minmaxReduxPixelShader: {
  127205. name: string;
  127206. shader: string;
  127207. };
  127208. }
  127209. declare module BABYLON {
  127210. /**
  127211. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127212. * and maximum values from all values of the texture.
  127213. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127214. * The source values are read from the red channel of the texture.
  127215. */
  127216. export class MinMaxReducer {
  127217. /**
  127218. * Observable triggered when the computation has been performed
  127219. */
  127220. onAfterReductionPerformed: Observable<{
  127221. min: number;
  127222. max: number;
  127223. }>;
  127224. protected _camera: Camera;
  127225. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127226. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127227. protected _postProcessManager: PostProcessManager;
  127228. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127229. protected _forceFullscreenViewport: boolean;
  127230. /**
  127231. * Creates a min/max reducer
  127232. * @param camera The camera to use for the post processes
  127233. */
  127234. constructor(camera: Camera);
  127235. /**
  127236. * Gets the texture used to read the values from.
  127237. */
  127238. get sourceTexture(): Nullable<RenderTargetTexture>;
  127239. /**
  127240. * Sets the source texture to read the values from.
  127241. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127242. * because in such textures '1' value must not be taken into account to compute the maximum
  127243. * as this value is used to clear the texture.
  127244. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127245. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127246. * @param depthRedux Indicates if the texture is a depth texture or not
  127247. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127248. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127249. */
  127250. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127251. /**
  127252. * Defines the refresh rate of the computation.
  127253. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127254. */
  127255. get refreshRate(): number;
  127256. set refreshRate(value: number);
  127257. protected _activated: boolean;
  127258. /**
  127259. * Gets the activation status of the reducer
  127260. */
  127261. get activated(): boolean;
  127262. /**
  127263. * Activates the reduction computation.
  127264. * When activated, the observers registered in onAfterReductionPerformed are
  127265. * called after the compuation is performed
  127266. */
  127267. activate(): void;
  127268. /**
  127269. * Deactivates the reduction computation.
  127270. */
  127271. deactivate(): void;
  127272. /**
  127273. * Disposes the min/max reducer
  127274. * @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.
  127275. */
  127276. dispose(disposeAll?: boolean): void;
  127277. }
  127278. }
  127279. declare module BABYLON {
  127280. /**
  127281. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127282. */
  127283. export class DepthReducer extends MinMaxReducer {
  127284. private _depthRenderer;
  127285. private _depthRendererId;
  127286. /**
  127287. * Gets the depth renderer used for the computation.
  127288. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127289. */
  127290. get depthRenderer(): Nullable<DepthRenderer>;
  127291. /**
  127292. * Creates a depth reducer
  127293. * @param camera The camera used to render the depth texture
  127294. */
  127295. constructor(camera: Camera);
  127296. /**
  127297. * Sets the depth renderer to use to generate the depth map
  127298. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127299. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127300. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127301. */
  127302. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127303. /** @hidden */
  127304. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127305. /**
  127306. * Activates the reduction computation.
  127307. * When activated, the observers registered in onAfterReductionPerformed are
  127308. * called after the compuation is performed
  127309. */
  127310. activate(): void;
  127311. /**
  127312. * Deactivates the reduction computation.
  127313. */
  127314. deactivate(): void;
  127315. /**
  127316. * Disposes the depth reducer
  127317. * @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.
  127318. */
  127319. dispose(disposeAll?: boolean): void;
  127320. }
  127321. }
  127322. declare module BABYLON {
  127323. /**
  127324. * A CSM implementation allowing casting shadows on large scenes.
  127325. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127326. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127327. */
  127328. export class CascadedShadowGenerator extends ShadowGenerator {
  127329. private static readonly frustumCornersNDCSpace;
  127330. /**
  127331. * Name of the CSM class
  127332. */
  127333. static CLASSNAME: string;
  127334. /**
  127335. * Defines the default number of cascades used by the CSM.
  127336. */
  127337. static readonly DEFAULT_CASCADES_COUNT: number;
  127338. /**
  127339. * Defines the minimum number of cascades used by the CSM.
  127340. */
  127341. static readonly MIN_CASCADES_COUNT: number;
  127342. /**
  127343. * Defines the maximum number of cascades used by the CSM.
  127344. */
  127345. static readonly MAX_CASCADES_COUNT: number;
  127346. protected _validateFilter(filter: number): number;
  127347. /**
  127348. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127349. */
  127350. penumbraDarkness: number;
  127351. private _numCascades;
  127352. /**
  127353. * Gets or set the number of cascades used by the CSM.
  127354. */
  127355. get numCascades(): number;
  127356. set numCascades(value: number);
  127357. /**
  127358. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127359. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127360. */
  127361. stabilizeCascades: boolean;
  127362. private _freezeShadowCastersBoundingInfo;
  127363. private _freezeShadowCastersBoundingInfoObservable;
  127364. /**
  127365. * Enables or disables the shadow casters bounding info computation.
  127366. * If your shadow casters don't move, you can disable this feature.
  127367. * If it is enabled, the bounding box computation is done every frame.
  127368. */
  127369. get freezeShadowCastersBoundingInfo(): boolean;
  127370. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127371. private _scbiMin;
  127372. private _scbiMax;
  127373. protected _computeShadowCastersBoundingInfo(): void;
  127374. protected _shadowCastersBoundingInfo: BoundingInfo;
  127375. /**
  127376. * Gets or sets the shadow casters bounding info.
  127377. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127378. * so that the system won't overwrite the bounds you provide
  127379. */
  127380. get shadowCastersBoundingInfo(): BoundingInfo;
  127381. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127382. protected _breaksAreDirty: boolean;
  127383. protected _minDistance: number;
  127384. protected _maxDistance: number;
  127385. /**
  127386. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127387. *
  127388. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127389. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127390. * @param min minimal distance for the breaks (default to 0.)
  127391. * @param max maximal distance for the breaks (default to 1.)
  127392. */
  127393. setMinMaxDistance(min: number, max: number): void;
  127394. /** Gets the minimal distance used in the cascade break computation */
  127395. get minDistance(): number;
  127396. /** Gets the maximal distance used in the cascade break computation */
  127397. get maxDistance(): number;
  127398. /**
  127399. * Gets the class name of that object
  127400. * @returns "CascadedShadowGenerator"
  127401. */
  127402. getClassName(): string;
  127403. private _cascadeMinExtents;
  127404. private _cascadeMaxExtents;
  127405. /**
  127406. * Gets a cascade minimum extents
  127407. * @param cascadeIndex index of the cascade
  127408. * @returns the minimum cascade extents
  127409. */
  127410. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127411. /**
  127412. * Gets a cascade maximum extents
  127413. * @param cascadeIndex index of the cascade
  127414. * @returns the maximum cascade extents
  127415. */
  127416. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127417. private _cascades;
  127418. private _currentLayer;
  127419. private _viewSpaceFrustumsZ;
  127420. private _viewMatrices;
  127421. private _projectionMatrices;
  127422. private _transformMatrices;
  127423. private _transformMatricesAsArray;
  127424. private _frustumLengths;
  127425. private _lightSizeUVCorrection;
  127426. private _depthCorrection;
  127427. private _frustumCornersWorldSpace;
  127428. private _frustumCenter;
  127429. private _shadowCameraPos;
  127430. private _shadowMaxZ;
  127431. /**
  127432. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127433. * It defaults to camera.maxZ
  127434. */
  127435. get shadowMaxZ(): number;
  127436. /**
  127437. * Sets the shadow max z distance.
  127438. */
  127439. set shadowMaxZ(value: number);
  127440. protected _debug: boolean;
  127441. /**
  127442. * Gets or sets the debug flag.
  127443. * When enabled, the cascades are materialized by different colors on the screen.
  127444. */
  127445. get debug(): boolean;
  127446. set debug(dbg: boolean);
  127447. private _depthClamp;
  127448. /**
  127449. * Gets or sets the depth clamping value.
  127450. *
  127451. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127452. * to account for the shadow casters far away.
  127453. *
  127454. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127455. */
  127456. get depthClamp(): boolean;
  127457. set depthClamp(value: boolean);
  127458. private _cascadeBlendPercentage;
  127459. /**
  127460. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127461. * It defaults to 0.1 (10% blending).
  127462. */
  127463. get cascadeBlendPercentage(): number;
  127464. set cascadeBlendPercentage(value: number);
  127465. private _lambda;
  127466. /**
  127467. * Gets or set the lambda parameter.
  127468. * This parameter is used to split the camera frustum and create the cascades.
  127469. * 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.
  127470. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127471. */
  127472. get lambda(): number;
  127473. set lambda(value: number);
  127474. /**
  127475. * Gets the view matrix corresponding to a given cascade
  127476. * @param cascadeNum cascade to retrieve the view matrix from
  127477. * @returns the cascade view matrix
  127478. */
  127479. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127480. /**
  127481. * Gets the projection matrix corresponding to a given cascade
  127482. * @param cascadeNum cascade to retrieve the projection matrix from
  127483. * @returns the cascade projection matrix
  127484. */
  127485. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127486. /**
  127487. * Gets the transformation matrix corresponding to a given cascade
  127488. * @param cascadeNum cascade to retrieve the transformation matrix from
  127489. * @returns the cascade transformation matrix
  127490. */
  127491. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127492. private _depthRenderer;
  127493. /**
  127494. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127495. *
  127496. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127497. *
  127498. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127499. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127500. * @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
  127501. */
  127502. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127503. private _depthReducer;
  127504. private _autoCalcDepthBounds;
  127505. /**
  127506. * Gets or sets the autoCalcDepthBounds property.
  127507. *
  127508. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127509. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127510. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127511. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127512. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127513. */
  127514. get autoCalcDepthBounds(): boolean;
  127515. set autoCalcDepthBounds(value: boolean);
  127516. /**
  127517. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127518. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127519. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127520. * for setting the refresh rate on the renderer yourself!
  127521. */
  127522. get autoCalcDepthBoundsRefreshRate(): number;
  127523. set autoCalcDepthBoundsRefreshRate(value: number);
  127524. /**
  127525. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127526. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127527. * you change the camera near/far planes!
  127528. */
  127529. splitFrustum(): void;
  127530. private _splitFrustum;
  127531. private _computeMatrices;
  127532. private _computeFrustumInWorldSpace;
  127533. private _computeCascadeFrustum;
  127534. /** @hidden */
  127535. static _SceneComponentInitialization: (scene: Scene) => void;
  127536. /**
  127537. * Creates a Cascaded Shadow Generator object.
  127538. * A ShadowGenerator is the required tool to use the shadows.
  127539. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127540. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127541. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127542. * @param light The directional light object generating the shadows.
  127543. * @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.
  127544. */
  127545. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127546. protected _initializeGenerator(): void;
  127547. protected _createTargetRenderTexture(): void;
  127548. protected _initializeShadowMap(): void;
  127549. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127550. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127551. /**
  127552. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127553. * @param defines Defines of the material we want to update
  127554. * @param lightIndex Index of the light in the enabled light list of the material
  127555. */
  127556. prepareDefines(defines: any, lightIndex: number): void;
  127557. /**
  127558. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127559. * defined in the generator but impacting the effect).
  127560. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127561. * @param effect The effect we are binfing the information for
  127562. */
  127563. bindShadowLight(lightIndex: string, effect: Effect): void;
  127564. /**
  127565. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127566. * (eq to view projection * shadow projection matrices)
  127567. * @returns The transform matrix used to create the shadow map
  127568. */
  127569. getTransformMatrix(): Matrix;
  127570. /**
  127571. * Disposes the ShadowGenerator.
  127572. * Returns nothing.
  127573. */
  127574. dispose(): void;
  127575. /**
  127576. * Serializes the shadow generator setup to a json object.
  127577. * @returns The serialized JSON object
  127578. */
  127579. serialize(): any;
  127580. /**
  127581. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127582. * @param parsedShadowGenerator The JSON object to parse
  127583. * @param scene The scene to create the shadow map for
  127584. * @returns The parsed shadow generator
  127585. */
  127586. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127587. }
  127588. }
  127589. declare module BABYLON {
  127590. /**
  127591. * Defines the shadow generator component responsible to manage any shadow generators
  127592. * in a given scene.
  127593. */
  127594. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127595. /**
  127596. * The component name helpfull to identify the component in the list of scene components.
  127597. */
  127598. readonly name: string;
  127599. /**
  127600. * The scene the component belongs to.
  127601. */
  127602. scene: Scene;
  127603. /**
  127604. * Creates a new instance of the component for the given scene
  127605. * @param scene Defines the scene to register the component in
  127606. */
  127607. constructor(scene: Scene);
  127608. /**
  127609. * Registers the component in a given scene
  127610. */
  127611. register(): void;
  127612. /**
  127613. * Rebuilds the elements related to this component in case of
  127614. * context lost for instance.
  127615. */
  127616. rebuild(): void;
  127617. /**
  127618. * Serializes the component data to the specified json object
  127619. * @param serializationObject The object to serialize to
  127620. */
  127621. serialize(serializationObject: any): void;
  127622. /**
  127623. * Adds all the elements from the container to the scene
  127624. * @param container the container holding the elements
  127625. */
  127626. addFromContainer(container: AbstractScene): void;
  127627. /**
  127628. * Removes all the elements in the container from the scene
  127629. * @param container contains the elements to remove
  127630. * @param dispose if the removed element should be disposed (default: false)
  127631. */
  127632. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127633. /**
  127634. * Rebuilds the elements related to this component in case of
  127635. * context lost for instance.
  127636. */
  127637. dispose(): void;
  127638. private _gatherRenderTargets;
  127639. }
  127640. }
  127641. declare module BABYLON {
  127642. /**
  127643. * A point light is a light defined by an unique point in world space.
  127644. * The light is emitted in every direction from this point.
  127645. * A good example of a point light is a standard light bulb.
  127646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127647. */
  127648. export class PointLight extends ShadowLight {
  127649. private _shadowAngle;
  127650. /**
  127651. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127652. * This specifies what angle the shadow will use to be created.
  127653. *
  127654. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127655. */
  127656. get shadowAngle(): number;
  127657. /**
  127658. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127659. * This specifies what angle the shadow will use to be created.
  127660. *
  127661. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127662. */
  127663. set shadowAngle(value: number);
  127664. /**
  127665. * Gets the direction if it has been set.
  127666. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127667. */
  127668. get direction(): Vector3;
  127669. /**
  127670. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127671. */
  127672. set direction(value: Vector3);
  127673. /**
  127674. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127675. * A PointLight emits the light in every direction.
  127676. * It can cast shadows.
  127677. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127678. * ```javascript
  127679. * var pointLight = new PointLight("pl", camera.position, scene);
  127680. * ```
  127681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127682. * @param name The light friendly name
  127683. * @param position The position of the point light in the scene
  127684. * @param scene The scene the lights belongs to
  127685. */
  127686. constructor(name: string, position: Vector3, scene: Scene);
  127687. /**
  127688. * Returns the string "PointLight"
  127689. * @returns the class name
  127690. */
  127691. getClassName(): string;
  127692. /**
  127693. * Returns the integer 0.
  127694. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127695. */
  127696. getTypeID(): number;
  127697. /**
  127698. * Specifies wether or not the shadowmap should be a cube texture.
  127699. * @returns true if the shadowmap needs to be a cube texture.
  127700. */
  127701. needCube(): boolean;
  127702. /**
  127703. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127706. */
  127707. getShadowDirection(faceIndex?: number): Vector3;
  127708. /**
  127709. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127710. * - fov = PI / 2
  127711. * - aspect ratio : 1.0
  127712. * - z-near and far equal to the active camera minZ and maxZ.
  127713. * Returns the PointLight.
  127714. */
  127715. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127716. protected _buildUniformLayout(): void;
  127717. /**
  127718. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127719. * @param effect The effect to update
  127720. * @param lightIndex The index of the light in the effect to update
  127721. * @returns The point light
  127722. */
  127723. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127725. /**
  127726. * Prepares the list of defines specific to the light type.
  127727. * @param defines the list of defines
  127728. * @param lightIndex defines the index of the light for the effect
  127729. */
  127730. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127731. }
  127732. }
  127733. declare module BABYLON {
  127734. /**
  127735. * Header information of HDR texture files.
  127736. */
  127737. export interface HDRInfo {
  127738. /**
  127739. * The height of the texture in pixels.
  127740. */
  127741. height: number;
  127742. /**
  127743. * The width of the texture in pixels.
  127744. */
  127745. width: number;
  127746. /**
  127747. * The index of the beginning of the data in the binary file.
  127748. */
  127749. dataPosition: number;
  127750. }
  127751. /**
  127752. * This groups tools to convert HDR texture to native colors array.
  127753. */
  127754. export class HDRTools {
  127755. private static Ldexp;
  127756. private static Rgbe2float;
  127757. private static readStringLine;
  127758. /**
  127759. * Reads header information from an RGBE texture stored in a native array.
  127760. * More information on this format are available here:
  127761. * https://en.wikipedia.org/wiki/RGBE_image_format
  127762. *
  127763. * @param uint8array The binary file stored in native array.
  127764. * @return The header information.
  127765. */
  127766. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127767. /**
  127768. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127769. * This RGBE texture needs to store the information as a panorama.
  127770. *
  127771. * More information on this format are available here:
  127772. * https://en.wikipedia.org/wiki/RGBE_image_format
  127773. *
  127774. * @param buffer The binary file stored in an array buffer.
  127775. * @param size The expected size of the extracted cubemap.
  127776. * @return The Cube Map information.
  127777. */
  127778. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127779. /**
  127780. * Returns the pixels data extracted from an RGBE texture.
  127781. * This pixels will be stored left to right up to down in the R G B order in one array.
  127782. *
  127783. * More information on this format are available here:
  127784. * https://en.wikipedia.org/wiki/RGBE_image_format
  127785. *
  127786. * @param uint8array The binary file stored in an array buffer.
  127787. * @param hdrInfo The header information of the file.
  127788. * @return The pixels data in RGB right to left up to down order.
  127789. */
  127790. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127791. private static RGBE_ReadPixels_RLE;
  127792. }
  127793. }
  127794. declare module BABYLON {
  127795. /**
  127796. * This represents a texture coming from an HDR input.
  127797. *
  127798. * The only supported format is currently panorama picture stored in RGBE format.
  127799. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127800. */
  127801. export class HDRCubeTexture extends BaseTexture {
  127802. private static _facesMapping;
  127803. private _generateHarmonics;
  127804. private _noMipmap;
  127805. private _textureMatrix;
  127806. private _size;
  127807. private _onLoad;
  127808. private _onError;
  127809. /**
  127810. * The texture URL.
  127811. */
  127812. url: string;
  127813. /**
  127814. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127815. */
  127816. coordinatesMode: number;
  127817. protected _isBlocking: boolean;
  127818. /**
  127819. * Sets wether or not the texture is blocking during loading.
  127820. */
  127821. set isBlocking(value: boolean);
  127822. /**
  127823. * Gets wether or not the texture is blocking during loading.
  127824. */
  127825. get isBlocking(): boolean;
  127826. protected _rotationY: number;
  127827. /**
  127828. * Sets texture matrix rotation angle around Y axis in radians.
  127829. */
  127830. set rotationY(value: number);
  127831. /**
  127832. * Gets texture matrix rotation angle around Y axis radians.
  127833. */
  127834. get rotationY(): number;
  127835. /**
  127836. * Gets or sets the center of the bounding box associated with the cube texture
  127837. * It must define where the camera used to render the texture was set
  127838. */
  127839. boundingBoxPosition: Vector3;
  127840. private _boundingBoxSize;
  127841. /**
  127842. * Gets or sets the size of the bounding box associated with the cube texture
  127843. * When defined, the cubemap will switch to local mode
  127844. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127845. * @example https://www.babylonjs-playground.com/#RNASML
  127846. */
  127847. set boundingBoxSize(value: Vector3);
  127848. get boundingBoxSize(): Vector3;
  127849. /**
  127850. * Instantiates an HDRTexture from the following parameters.
  127851. *
  127852. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127853. * @param scene The scene the texture will be used in
  127854. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127855. * @param noMipmap Forces to not generate the mipmap if true
  127856. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127857. * @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)
  127858. * @param reserved Reserved flag for internal use.
  127859. */
  127860. 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>);
  127861. /**
  127862. * Get the current class name of the texture useful for serialization or dynamic coding.
  127863. * @returns "HDRCubeTexture"
  127864. */
  127865. getClassName(): string;
  127866. /**
  127867. * Occurs when the file is raw .hdr file.
  127868. */
  127869. private loadTexture;
  127870. clone(): HDRCubeTexture;
  127871. delayLoad(): void;
  127872. /**
  127873. * Get the texture reflection matrix used to rotate/transform the reflection.
  127874. * @returns the reflection matrix
  127875. */
  127876. getReflectionTextureMatrix(): Matrix;
  127877. /**
  127878. * Set the texture reflection matrix used to rotate/transform the reflection.
  127879. * @param value Define the reflection matrix to set
  127880. */
  127881. setReflectionTextureMatrix(value: Matrix): void;
  127882. /**
  127883. * Parses a JSON representation of an HDR Texture in order to create the texture
  127884. * @param parsedTexture Define the JSON representation
  127885. * @param scene Define the scene the texture should be created in
  127886. * @param rootUrl Define the root url in case we need to load relative dependencies
  127887. * @returns the newly created texture after parsing
  127888. */
  127889. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127890. serialize(): any;
  127891. }
  127892. }
  127893. declare module BABYLON {
  127894. /**
  127895. * Class used to control physics engine
  127896. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127897. */
  127898. export class PhysicsEngine implements IPhysicsEngine {
  127899. private _physicsPlugin;
  127900. /**
  127901. * Global value used to control the smallest number supported by the simulation
  127902. */
  127903. static Epsilon: number;
  127904. private _impostors;
  127905. private _joints;
  127906. private _subTimeStep;
  127907. /**
  127908. * Gets the gravity vector used by the simulation
  127909. */
  127910. gravity: Vector3;
  127911. /**
  127912. * Factory used to create the default physics plugin.
  127913. * @returns The default physics plugin
  127914. */
  127915. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127916. /**
  127917. * Creates a new Physics Engine
  127918. * @param gravity defines the gravity vector used by the simulation
  127919. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127920. */
  127921. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127922. /**
  127923. * Sets the gravity vector used by the simulation
  127924. * @param gravity defines the gravity vector to use
  127925. */
  127926. setGravity(gravity: Vector3): void;
  127927. /**
  127928. * Set the time step of the physics engine.
  127929. * Default is 1/60.
  127930. * To slow it down, enter 1/600 for example.
  127931. * To speed it up, 1/30
  127932. * @param newTimeStep defines the new timestep to apply to this world.
  127933. */
  127934. setTimeStep(newTimeStep?: number): void;
  127935. /**
  127936. * Get the time step of the physics engine.
  127937. * @returns the current time step
  127938. */
  127939. getTimeStep(): number;
  127940. /**
  127941. * Set the sub time step of the physics engine.
  127942. * Default is 0 meaning there is no sub steps
  127943. * To increase physics resolution precision, set a small value (like 1 ms)
  127944. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127945. */
  127946. setSubTimeStep(subTimeStep?: number): void;
  127947. /**
  127948. * Get the sub time step of the physics engine.
  127949. * @returns the current sub time step
  127950. */
  127951. getSubTimeStep(): number;
  127952. /**
  127953. * Release all resources
  127954. */
  127955. dispose(): void;
  127956. /**
  127957. * Gets the name of the current physics plugin
  127958. * @returns the name of the plugin
  127959. */
  127960. getPhysicsPluginName(): string;
  127961. /**
  127962. * Adding a new impostor for the impostor tracking.
  127963. * This will be done by the impostor itself.
  127964. * @param impostor the impostor to add
  127965. */
  127966. addImpostor(impostor: PhysicsImpostor): void;
  127967. /**
  127968. * Remove an impostor from the engine.
  127969. * This impostor and its mesh will not longer be updated by the physics engine.
  127970. * @param impostor the impostor to remove
  127971. */
  127972. removeImpostor(impostor: PhysicsImpostor): void;
  127973. /**
  127974. * Add a joint to the physics engine
  127975. * @param mainImpostor defines the main impostor to which the joint is added.
  127976. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127977. * @param joint defines the joint that will connect both impostors.
  127978. */
  127979. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127980. /**
  127981. * Removes a joint from the simulation
  127982. * @param mainImpostor defines the impostor used with the joint
  127983. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127984. * @param joint defines the joint to remove
  127985. */
  127986. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127987. /**
  127988. * Called by the scene. No need to call it.
  127989. * @param delta defines the timespam between frames
  127990. */
  127991. _step(delta: number): void;
  127992. /**
  127993. * Gets the current plugin used to run the simulation
  127994. * @returns current plugin
  127995. */
  127996. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127997. /**
  127998. * Gets the list of physic impostors
  127999. * @returns an array of PhysicsImpostor
  128000. */
  128001. getImpostors(): Array<PhysicsImpostor>;
  128002. /**
  128003. * Gets the impostor for a physics enabled object
  128004. * @param object defines the object impersonated by the impostor
  128005. * @returns the PhysicsImpostor or null if not found
  128006. */
  128007. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128008. /**
  128009. * Gets the impostor for a physics body object
  128010. * @param body defines physics body used by the impostor
  128011. * @returns the PhysicsImpostor or null if not found
  128012. */
  128013. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128014. /**
  128015. * Does a raycast in the physics world
  128016. * @param from when should the ray start?
  128017. * @param to when should the ray end?
  128018. * @returns PhysicsRaycastResult
  128019. */
  128020. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128021. }
  128022. }
  128023. declare module BABYLON {
  128024. /** @hidden */
  128025. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128026. private _useDeltaForWorldStep;
  128027. world: any;
  128028. name: string;
  128029. private _physicsMaterials;
  128030. private _fixedTimeStep;
  128031. private _cannonRaycastResult;
  128032. private _raycastResult;
  128033. private _physicsBodysToRemoveAfterStep;
  128034. BJSCANNON: any;
  128035. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128036. setGravity(gravity: Vector3): void;
  128037. setTimeStep(timeStep: number): void;
  128038. getTimeStep(): number;
  128039. executeStep(delta: number): void;
  128040. private _removeMarkedPhysicsBodiesFromWorld;
  128041. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128042. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128043. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128044. private _processChildMeshes;
  128045. removePhysicsBody(impostor: PhysicsImpostor): void;
  128046. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128047. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128048. private _addMaterial;
  128049. private _checkWithEpsilon;
  128050. private _createShape;
  128051. private _createHeightmap;
  128052. private _minus90X;
  128053. private _plus90X;
  128054. private _tmpPosition;
  128055. private _tmpDeltaPosition;
  128056. private _tmpUnityRotation;
  128057. private _updatePhysicsBodyTransformation;
  128058. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128059. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128060. isSupported(): boolean;
  128061. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128062. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128063. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128064. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128065. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128066. getBodyMass(impostor: PhysicsImpostor): number;
  128067. getBodyFriction(impostor: PhysicsImpostor): number;
  128068. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128069. getBodyRestitution(impostor: PhysicsImpostor): number;
  128070. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128071. sleepBody(impostor: PhysicsImpostor): void;
  128072. wakeUpBody(impostor: PhysicsImpostor): void;
  128073. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128074. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128075. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128076. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128077. getRadius(impostor: PhysicsImpostor): number;
  128078. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128079. dispose(): void;
  128080. private _extendNamespace;
  128081. /**
  128082. * Does a raycast in the physics world
  128083. * @param from when should the ray start?
  128084. * @param to when should the ray end?
  128085. * @returns PhysicsRaycastResult
  128086. */
  128087. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128088. }
  128089. }
  128090. declare module BABYLON {
  128091. /** @hidden */
  128092. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128093. world: any;
  128094. name: string;
  128095. BJSOIMO: any;
  128096. private _raycastResult;
  128097. constructor(iterations?: number, oimoInjection?: any);
  128098. setGravity(gravity: Vector3): void;
  128099. setTimeStep(timeStep: number): void;
  128100. getTimeStep(): number;
  128101. private _tmpImpostorsArray;
  128102. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128103. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128104. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128105. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128106. private _tmpPositionVector;
  128107. removePhysicsBody(impostor: PhysicsImpostor): void;
  128108. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128109. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128110. isSupported(): boolean;
  128111. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128112. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128113. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128114. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128115. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128116. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128117. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128118. getBodyMass(impostor: PhysicsImpostor): number;
  128119. getBodyFriction(impostor: PhysicsImpostor): number;
  128120. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128121. getBodyRestitution(impostor: PhysicsImpostor): number;
  128122. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128123. sleepBody(impostor: PhysicsImpostor): void;
  128124. wakeUpBody(impostor: PhysicsImpostor): void;
  128125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128126. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128129. getRadius(impostor: PhysicsImpostor): number;
  128130. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128131. dispose(): void;
  128132. /**
  128133. * Does a raycast in the physics world
  128134. * @param from when should the ray start?
  128135. * @param to when should the ray end?
  128136. * @returns PhysicsRaycastResult
  128137. */
  128138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128139. }
  128140. }
  128141. declare module BABYLON {
  128142. /**
  128143. * Class containing static functions to help procedurally build meshes
  128144. */
  128145. export class RibbonBuilder {
  128146. /**
  128147. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128148. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128149. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128150. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128151. * * 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
  128152. * * 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
  128153. * * 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
  128154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128157. * * 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
  128158. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128159. * * 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
  128160. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128162. * @param name defines the name of the mesh
  128163. * @param options defines the options used to create the mesh
  128164. * @param scene defines the hosting scene
  128165. * @returns the ribbon mesh
  128166. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128167. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128168. */
  128169. static CreateRibbon(name: string, options: {
  128170. pathArray: Vector3[][];
  128171. closeArray?: boolean;
  128172. closePath?: boolean;
  128173. offset?: number;
  128174. updatable?: boolean;
  128175. sideOrientation?: number;
  128176. frontUVs?: Vector4;
  128177. backUVs?: Vector4;
  128178. instance?: Mesh;
  128179. invertUV?: boolean;
  128180. uvs?: Vector2[];
  128181. colors?: Color4[];
  128182. }, scene?: Nullable<Scene>): Mesh;
  128183. }
  128184. }
  128185. declare module BABYLON {
  128186. /**
  128187. * Class containing static functions to help procedurally build meshes
  128188. */
  128189. export class ShapeBuilder {
  128190. /**
  128191. * 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.
  128192. * * 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.
  128193. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128194. * * 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.
  128195. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128196. * * 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
  128197. * * 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
  128198. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128203. * @param name defines the name of the mesh
  128204. * @param options defines the options used to create the mesh
  128205. * @param scene defines the hosting scene
  128206. * @returns the extruded shape mesh
  128207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128209. */
  128210. static ExtrudeShape(name: string, options: {
  128211. shape: Vector3[];
  128212. path: Vector3[];
  128213. scale?: number;
  128214. rotation?: number;
  128215. cap?: number;
  128216. updatable?: boolean;
  128217. sideOrientation?: number;
  128218. frontUVs?: Vector4;
  128219. backUVs?: Vector4;
  128220. instance?: Mesh;
  128221. invertUV?: boolean;
  128222. }, scene?: Nullable<Scene>): Mesh;
  128223. /**
  128224. * Creates an custom extruded shape mesh.
  128225. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128226. * * 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.
  128227. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128228. * * 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
  128229. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128230. * * 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
  128231. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128232. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128233. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128234. * * 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
  128235. * * 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
  128236. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128241. * @param name defines the name of the mesh
  128242. * @param options defines the options used to create the mesh
  128243. * @param scene defines the hosting scene
  128244. * @returns the custom extruded shape mesh
  128245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128248. */
  128249. static ExtrudeShapeCustom(name: string, options: {
  128250. shape: Vector3[];
  128251. path: Vector3[];
  128252. scaleFunction?: any;
  128253. rotationFunction?: any;
  128254. ribbonCloseArray?: boolean;
  128255. ribbonClosePath?: boolean;
  128256. cap?: number;
  128257. updatable?: boolean;
  128258. sideOrientation?: number;
  128259. frontUVs?: Vector4;
  128260. backUVs?: Vector4;
  128261. instance?: Mesh;
  128262. invertUV?: boolean;
  128263. }, scene?: Nullable<Scene>): Mesh;
  128264. private static _ExtrudeShapeGeneric;
  128265. }
  128266. }
  128267. declare module BABYLON {
  128268. /**
  128269. * AmmoJS Physics plugin
  128270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128271. * @see https://github.com/kripken/ammo.js/
  128272. */
  128273. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128274. private _useDeltaForWorldStep;
  128275. /**
  128276. * Reference to the Ammo library
  128277. */
  128278. bjsAMMO: any;
  128279. /**
  128280. * Created ammoJS world which physics bodies are added to
  128281. */
  128282. world: any;
  128283. /**
  128284. * Name of the plugin
  128285. */
  128286. name: string;
  128287. private _timeStep;
  128288. private _fixedTimeStep;
  128289. private _maxSteps;
  128290. private _tmpQuaternion;
  128291. private _tmpAmmoTransform;
  128292. private _tmpAmmoQuaternion;
  128293. private _tmpAmmoConcreteContactResultCallback;
  128294. private _collisionConfiguration;
  128295. private _dispatcher;
  128296. private _overlappingPairCache;
  128297. private _solver;
  128298. private _softBodySolver;
  128299. private _tmpAmmoVectorA;
  128300. private _tmpAmmoVectorB;
  128301. private _tmpAmmoVectorC;
  128302. private _tmpAmmoVectorD;
  128303. private _tmpContactCallbackResult;
  128304. private _tmpAmmoVectorRCA;
  128305. private _tmpAmmoVectorRCB;
  128306. private _raycastResult;
  128307. private static readonly DISABLE_COLLISION_FLAG;
  128308. private static readonly KINEMATIC_FLAG;
  128309. private static readonly DISABLE_DEACTIVATION_FLAG;
  128310. /**
  128311. * Initializes the ammoJS plugin
  128312. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128313. * @param ammoInjection can be used to inject your own ammo reference
  128314. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128315. */
  128316. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128317. /**
  128318. * Sets the gravity of the physics world (m/(s^2))
  128319. * @param gravity Gravity to set
  128320. */
  128321. setGravity(gravity: Vector3): void;
  128322. /**
  128323. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128324. * @param timeStep timestep to use in seconds
  128325. */
  128326. setTimeStep(timeStep: number): void;
  128327. /**
  128328. * 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)
  128329. * @param fixedTimeStep fixedTimeStep to use in seconds
  128330. */
  128331. setFixedTimeStep(fixedTimeStep: number): void;
  128332. /**
  128333. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128334. * @param maxSteps the maximum number of steps by the physics engine per frame
  128335. */
  128336. setMaxSteps(maxSteps: number): void;
  128337. /**
  128338. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128339. * @returns the current timestep in seconds
  128340. */
  128341. getTimeStep(): number;
  128342. /**
  128343. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128344. */
  128345. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128346. private _isImpostorInContact;
  128347. private _isImpostorPairInContact;
  128348. private _stepSimulation;
  128349. /**
  128350. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128351. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128352. * After the step the babylon meshes are set to the position of the physics imposters
  128353. * @param delta amount of time to step forward
  128354. * @param impostors array of imposters to update before/after the step
  128355. */
  128356. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128357. /**
  128358. * Update babylon mesh to match physics world object
  128359. * @param impostor imposter to match
  128360. */
  128361. private _afterSoftStep;
  128362. /**
  128363. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128364. * @param impostor imposter to match
  128365. */
  128366. private _ropeStep;
  128367. /**
  128368. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128369. * @param impostor imposter to match
  128370. */
  128371. private _softbodyOrClothStep;
  128372. private _tmpVector;
  128373. private _tmpMatrix;
  128374. /**
  128375. * Applies an impulse on the imposter
  128376. * @param impostor imposter to apply impulse to
  128377. * @param force amount of force to be applied to the imposter
  128378. * @param contactPoint the location to apply the impulse on the imposter
  128379. */
  128380. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128381. /**
  128382. * Applies a force on the imposter
  128383. * @param impostor imposter to apply force
  128384. * @param force amount of force to be applied to the imposter
  128385. * @param contactPoint the location to apply the force on the imposter
  128386. */
  128387. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128388. /**
  128389. * Creates a physics body using the plugin
  128390. * @param impostor the imposter to create the physics body on
  128391. */
  128392. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128393. /**
  128394. * Removes the physics body from the imposter and disposes of the body's memory
  128395. * @param impostor imposter to remove the physics body from
  128396. */
  128397. removePhysicsBody(impostor: PhysicsImpostor): void;
  128398. /**
  128399. * Generates a joint
  128400. * @param impostorJoint the imposter joint to create the joint with
  128401. */
  128402. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128403. /**
  128404. * Removes a joint
  128405. * @param impostorJoint the imposter joint to remove the joint from
  128406. */
  128407. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128408. private _addMeshVerts;
  128409. /**
  128410. * Initialise the soft body vertices to match its object's (mesh) vertices
  128411. * Softbody vertices (nodes) are in world space and to match this
  128412. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128413. * @param impostor to create the softbody for
  128414. */
  128415. private _softVertexData;
  128416. /**
  128417. * Create an impostor's soft body
  128418. * @param impostor to create the softbody for
  128419. */
  128420. private _createSoftbody;
  128421. /**
  128422. * Create cloth for an impostor
  128423. * @param impostor to create the softbody for
  128424. */
  128425. private _createCloth;
  128426. /**
  128427. * Create rope for an impostor
  128428. * @param impostor to create the softbody for
  128429. */
  128430. private _createRope;
  128431. /**
  128432. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128433. * @param impostor to create the custom physics shape for
  128434. */
  128435. private _createCustom;
  128436. private _addHullVerts;
  128437. private _createShape;
  128438. /**
  128439. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128440. * @param impostor imposter containing the physics body and babylon object
  128441. */
  128442. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128443. /**
  128444. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128445. * @param impostor imposter containing the physics body and babylon object
  128446. * @param newPosition new position
  128447. * @param newRotation new rotation
  128448. */
  128449. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128450. /**
  128451. * If this plugin is supported
  128452. * @returns true if its supported
  128453. */
  128454. isSupported(): boolean;
  128455. /**
  128456. * Sets the linear velocity of the physics body
  128457. * @param impostor imposter to set the velocity on
  128458. * @param velocity velocity to set
  128459. */
  128460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128461. /**
  128462. * Sets the angular velocity of the physics body
  128463. * @param impostor imposter to set the velocity on
  128464. * @param velocity velocity to set
  128465. */
  128466. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128467. /**
  128468. * gets the linear velocity
  128469. * @param impostor imposter to get linear velocity from
  128470. * @returns linear velocity
  128471. */
  128472. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128473. /**
  128474. * gets the angular velocity
  128475. * @param impostor imposter to get angular velocity from
  128476. * @returns angular velocity
  128477. */
  128478. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128479. /**
  128480. * Sets the mass of physics body
  128481. * @param impostor imposter to set the mass on
  128482. * @param mass mass to set
  128483. */
  128484. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128485. /**
  128486. * Gets the mass of the physics body
  128487. * @param impostor imposter to get the mass from
  128488. * @returns mass
  128489. */
  128490. getBodyMass(impostor: PhysicsImpostor): number;
  128491. /**
  128492. * Gets friction of the impostor
  128493. * @param impostor impostor to get friction from
  128494. * @returns friction value
  128495. */
  128496. getBodyFriction(impostor: PhysicsImpostor): number;
  128497. /**
  128498. * Sets friction of the impostor
  128499. * @param impostor impostor to set friction on
  128500. * @param friction friction value
  128501. */
  128502. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128503. /**
  128504. * Gets restitution of the impostor
  128505. * @param impostor impostor to get restitution from
  128506. * @returns restitution value
  128507. */
  128508. getBodyRestitution(impostor: PhysicsImpostor): number;
  128509. /**
  128510. * Sets resitution of the impostor
  128511. * @param impostor impostor to set resitution on
  128512. * @param restitution resitution value
  128513. */
  128514. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128515. /**
  128516. * Gets pressure inside the impostor
  128517. * @param impostor impostor to get pressure from
  128518. * @returns pressure value
  128519. */
  128520. getBodyPressure(impostor: PhysicsImpostor): number;
  128521. /**
  128522. * Sets pressure inside a soft body impostor
  128523. * Cloth and rope must remain 0 pressure
  128524. * @param impostor impostor to set pressure on
  128525. * @param pressure pressure value
  128526. */
  128527. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128528. /**
  128529. * Gets stiffness of the impostor
  128530. * @param impostor impostor to get stiffness from
  128531. * @returns pressure value
  128532. */
  128533. getBodyStiffness(impostor: PhysicsImpostor): number;
  128534. /**
  128535. * Sets stiffness of the impostor
  128536. * @param impostor impostor to set stiffness on
  128537. * @param stiffness stiffness value from 0 to 1
  128538. */
  128539. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128540. /**
  128541. * Gets velocityIterations of the impostor
  128542. * @param impostor impostor to get velocity iterations from
  128543. * @returns velocityIterations value
  128544. */
  128545. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128546. /**
  128547. * Sets velocityIterations of the impostor
  128548. * @param impostor impostor to set velocity iterations on
  128549. * @param velocityIterations velocityIterations value
  128550. */
  128551. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128552. /**
  128553. * Gets positionIterations of the impostor
  128554. * @param impostor impostor to get position iterations from
  128555. * @returns positionIterations value
  128556. */
  128557. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128558. /**
  128559. * Sets positionIterations of the impostor
  128560. * @param impostor impostor to set position on
  128561. * @param positionIterations positionIterations value
  128562. */
  128563. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128564. /**
  128565. * Append an anchor to a cloth object
  128566. * @param impostor is the cloth impostor to add anchor to
  128567. * @param otherImpostor is the rigid impostor to anchor to
  128568. * @param width ratio across width from 0 to 1
  128569. * @param height ratio up height from 0 to 1
  128570. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128571. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128572. */
  128573. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128574. /**
  128575. * Append an hook to a rope object
  128576. * @param impostor is the rope impostor to add hook to
  128577. * @param otherImpostor is the rigid impostor to hook to
  128578. * @param length ratio along the rope from 0 to 1
  128579. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128580. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128581. */
  128582. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128583. /**
  128584. * Sleeps the physics body and stops it from being active
  128585. * @param impostor impostor to sleep
  128586. */
  128587. sleepBody(impostor: PhysicsImpostor): void;
  128588. /**
  128589. * Activates the physics body
  128590. * @param impostor impostor to activate
  128591. */
  128592. wakeUpBody(impostor: PhysicsImpostor): void;
  128593. /**
  128594. * Updates the distance parameters of the joint
  128595. * @param joint joint to update
  128596. * @param maxDistance maximum distance of the joint
  128597. * @param minDistance minimum distance of the joint
  128598. */
  128599. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128600. /**
  128601. * Sets a motor on the joint
  128602. * @param joint joint to set motor on
  128603. * @param speed speed of the motor
  128604. * @param maxForce maximum force of the motor
  128605. * @param motorIndex index of the motor
  128606. */
  128607. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128608. /**
  128609. * Sets the motors limit
  128610. * @param joint joint to set limit on
  128611. * @param upperLimit upper limit
  128612. * @param lowerLimit lower limit
  128613. */
  128614. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128615. /**
  128616. * Syncs the position and rotation of a mesh with the impostor
  128617. * @param mesh mesh to sync
  128618. * @param impostor impostor to update the mesh with
  128619. */
  128620. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128621. /**
  128622. * Gets the radius of the impostor
  128623. * @param impostor impostor to get radius from
  128624. * @returns the radius
  128625. */
  128626. getRadius(impostor: PhysicsImpostor): number;
  128627. /**
  128628. * Gets the box size of the impostor
  128629. * @param impostor impostor to get box size from
  128630. * @param result the resulting box size
  128631. */
  128632. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128633. /**
  128634. * Disposes of the impostor
  128635. */
  128636. dispose(): void;
  128637. /**
  128638. * Does a raycast in the physics world
  128639. * @param from when should the ray start?
  128640. * @param to when should the ray end?
  128641. * @returns PhysicsRaycastResult
  128642. */
  128643. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128644. }
  128645. }
  128646. declare module BABYLON {
  128647. interface AbstractScene {
  128648. /**
  128649. * The list of reflection probes added to the scene
  128650. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128651. */
  128652. reflectionProbes: Array<ReflectionProbe>;
  128653. /**
  128654. * Removes the given reflection probe from this scene.
  128655. * @param toRemove The reflection probe to remove
  128656. * @returns The index of the removed reflection probe
  128657. */
  128658. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128659. /**
  128660. * Adds the given reflection probe to this scene.
  128661. * @param newReflectionProbe The reflection probe to add
  128662. */
  128663. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128664. }
  128665. /**
  128666. * Class used to generate realtime reflection / refraction cube textures
  128667. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128668. */
  128669. export class ReflectionProbe {
  128670. /** defines the name of the probe */
  128671. name: string;
  128672. private _scene;
  128673. private _renderTargetTexture;
  128674. private _projectionMatrix;
  128675. private _viewMatrix;
  128676. private _target;
  128677. private _add;
  128678. private _attachedMesh;
  128679. private _invertYAxis;
  128680. /** Gets or sets probe position (center of the cube map) */
  128681. position: Vector3;
  128682. /**
  128683. * Creates a new reflection probe
  128684. * @param name defines the name of the probe
  128685. * @param size defines the texture resolution (for each face)
  128686. * @param scene defines the hosting scene
  128687. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128688. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128689. */
  128690. constructor(
  128691. /** defines the name of the probe */
  128692. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128693. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128694. get samples(): number;
  128695. set samples(value: number);
  128696. /** Gets or sets the refresh rate to use (on every frame by default) */
  128697. get refreshRate(): number;
  128698. set refreshRate(value: number);
  128699. /**
  128700. * Gets the hosting scene
  128701. * @returns a Scene
  128702. */
  128703. getScene(): Scene;
  128704. /** Gets the internal CubeTexture used to render to */
  128705. get cubeTexture(): RenderTargetTexture;
  128706. /** Gets the list of meshes to render */
  128707. get renderList(): Nullable<AbstractMesh[]>;
  128708. /**
  128709. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128710. * @param mesh defines the mesh to attach to
  128711. */
  128712. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128713. /**
  128714. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128715. * @param renderingGroupId The rendering group id corresponding to its index
  128716. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128717. */
  128718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128719. /**
  128720. * Clean all associated resources
  128721. */
  128722. dispose(): void;
  128723. /**
  128724. * Converts the reflection probe information to a readable string for debug purpose.
  128725. * @param fullDetails Supports for multiple levels of logging within scene loading
  128726. * @returns the human readable reflection probe info
  128727. */
  128728. toString(fullDetails?: boolean): string;
  128729. /**
  128730. * Get the class name of the relfection probe.
  128731. * @returns "ReflectionProbe"
  128732. */
  128733. getClassName(): string;
  128734. /**
  128735. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128736. * @returns The JSON representation of the texture
  128737. */
  128738. serialize(): any;
  128739. /**
  128740. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128741. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128742. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128743. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128744. * @returns The parsed reflection probe if successful
  128745. */
  128746. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128747. }
  128748. }
  128749. declare module BABYLON {
  128750. /** @hidden */
  128751. export var _BabylonLoaderRegistered: boolean;
  128752. /**
  128753. * Helps setting up some configuration for the babylon file loader.
  128754. */
  128755. export class BabylonFileLoaderConfiguration {
  128756. /**
  128757. * The loader does not allow injecting custom physix engine into the plugins.
  128758. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128759. * So you could set this variable to your engine import to make it work.
  128760. */
  128761. static LoaderInjectedPhysicsEngine: any;
  128762. }
  128763. }
  128764. declare module BABYLON {
  128765. /**
  128766. * The Physically based simple base material of BJS.
  128767. *
  128768. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128769. * It is used as the base class for both the specGloss and metalRough conventions.
  128770. */
  128771. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128772. /**
  128773. * Number of Simultaneous lights allowed on the material.
  128774. */
  128775. maxSimultaneousLights: number;
  128776. /**
  128777. * If sets to true, disables all the lights affecting the material.
  128778. */
  128779. disableLighting: boolean;
  128780. /**
  128781. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128782. */
  128783. environmentTexture: BaseTexture;
  128784. /**
  128785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128786. */
  128787. invertNormalMapX: boolean;
  128788. /**
  128789. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128790. */
  128791. invertNormalMapY: boolean;
  128792. /**
  128793. * Normal map used in the model.
  128794. */
  128795. normalTexture: BaseTexture;
  128796. /**
  128797. * Emissivie color used to self-illuminate the model.
  128798. */
  128799. emissiveColor: Color3;
  128800. /**
  128801. * Emissivie texture used to self-illuminate the model.
  128802. */
  128803. emissiveTexture: BaseTexture;
  128804. /**
  128805. * Occlusion Channel Strenght.
  128806. */
  128807. occlusionStrength: number;
  128808. /**
  128809. * Occlusion Texture of the material (adding extra occlusion effects).
  128810. */
  128811. occlusionTexture: BaseTexture;
  128812. /**
  128813. * Defines the alpha limits in alpha test mode.
  128814. */
  128815. alphaCutOff: number;
  128816. /**
  128817. * Gets the current double sided mode.
  128818. */
  128819. get doubleSided(): boolean;
  128820. /**
  128821. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128822. */
  128823. set doubleSided(value: boolean);
  128824. /**
  128825. * Stores the pre-calculated light information of a mesh in a texture.
  128826. */
  128827. lightmapTexture: BaseTexture;
  128828. /**
  128829. * If true, the light map contains occlusion information instead of lighting info.
  128830. */
  128831. useLightmapAsShadowmap: boolean;
  128832. /**
  128833. * Instantiates a new PBRMaterial instance.
  128834. *
  128835. * @param name The material name
  128836. * @param scene The scene the material will be use in.
  128837. */
  128838. constructor(name: string, scene: Scene);
  128839. getClassName(): string;
  128840. }
  128841. }
  128842. declare module BABYLON {
  128843. /**
  128844. * The PBR material of BJS following the metal roughness convention.
  128845. *
  128846. * This fits to the PBR convention in the GLTF definition:
  128847. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128848. */
  128849. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128850. /**
  128851. * The base color has two different interpretations depending on the value of metalness.
  128852. * When the material is a metal, the base color is the specific measured reflectance value
  128853. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128854. * of the material.
  128855. */
  128856. baseColor: Color3;
  128857. /**
  128858. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128859. * well as opacity information in the alpha channel.
  128860. */
  128861. baseTexture: BaseTexture;
  128862. /**
  128863. * Specifies the metallic scalar value of the material.
  128864. * Can also be used to scale the metalness values of the metallic texture.
  128865. */
  128866. metallic: number;
  128867. /**
  128868. * Specifies the roughness scalar value of the material.
  128869. * Can also be used to scale the roughness values of the metallic texture.
  128870. */
  128871. roughness: number;
  128872. /**
  128873. * Texture containing both the metallic value in the B channel and the
  128874. * roughness value in the G channel to keep better precision.
  128875. */
  128876. metallicRoughnessTexture: BaseTexture;
  128877. /**
  128878. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128879. *
  128880. * @param name The material name
  128881. * @param scene The scene the material will be use in.
  128882. */
  128883. constructor(name: string, scene: Scene);
  128884. /**
  128885. * Return the currrent class name of the material.
  128886. */
  128887. getClassName(): string;
  128888. /**
  128889. * Makes a duplicate of the current material.
  128890. * @param name - name to use for the new material.
  128891. */
  128892. clone(name: string): PBRMetallicRoughnessMaterial;
  128893. /**
  128894. * Serialize the material to a parsable JSON object.
  128895. */
  128896. serialize(): any;
  128897. /**
  128898. * Parses a JSON object correponding to the serialize function.
  128899. */
  128900. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128901. }
  128902. }
  128903. declare module BABYLON {
  128904. /**
  128905. * The PBR material of BJS following the specular glossiness convention.
  128906. *
  128907. * This fits to the PBR convention in the GLTF definition:
  128908. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128909. */
  128910. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128911. /**
  128912. * Specifies the diffuse color of the material.
  128913. */
  128914. diffuseColor: Color3;
  128915. /**
  128916. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128917. * channel.
  128918. */
  128919. diffuseTexture: BaseTexture;
  128920. /**
  128921. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128922. */
  128923. specularColor: Color3;
  128924. /**
  128925. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128926. */
  128927. glossiness: number;
  128928. /**
  128929. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128930. */
  128931. specularGlossinessTexture: BaseTexture;
  128932. /**
  128933. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128934. *
  128935. * @param name The material name
  128936. * @param scene The scene the material will be use in.
  128937. */
  128938. constructor(name: string, scene: Scene);
  128939. /**
  128940. * Return the currrent class name of the material.
  128941. */
  128942. getClassName(): string;
  128943. /**
  128944. * Makes a duplicate of the current material.
  128945. * @param name - name to use for the new material.
  128946. */
  128947. clone(name: string): PBRSpecularGlossinessMaterial;
  128948. /**
  128949. * Serialize the material to a parsable JSON object.
  128950. */
  128951. serialize(): any;
  128952. /**
  128953. * Parses a JSON object correponding to the serialize function.
  128954. */
  128955. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128956. }
  128957. }
  128958. declare module BABYLON {
  128959. /**
  128960. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128961. * It can help converting any input color in a desired output one. This can then be used to create effects
  128962. * from sepia, black and white to sixties or futuristic rendering...
  128963. *
  128964. * The only supported format is currently 3dl.
  128965. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128966. */
  128967. export class ColorGradingTexture extends BaseTexture {
  128968. /**
  128969. * The current texture matrix. (will always be identity in color grading texture)
  128970. */
  128971. private _textureMatrix;
  128972. /**
  128973. * The texture URL.
  128974. */
  128975. url: string;
  128976. /**
  128977. * Empty line regex stored for GC.
  128978. */
  128979. private static _noneEmptyLineRegex;
  128980. private _engine;
  128981. /**
  128982. * Instantiates a ColorGradingTexture from the following parameters.
  128983. *
  128984. * @param url The location of the color gradind data (currently only supporting 3dl)
  128985. * @param scene The scene the texture will be used in
  128986. */
  128987. constructor(url: string, scene: Scene);
  128988. /**
  128989. * Returns the texture matrix used in most of the material.
  128990. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128991. */
  128992. getTextureMatrix(): Matrix;
  128993. /**
  128994. * Occurs when the file being loaded is a .3dl LUT file.
  128995. */
  128996. private load3dlTexture;
  128997. /**
  128998. * Starts the loading process of the texture.
  128999. */
  129000. private loadTexture;
  129001. /**
  129002. * Clones the color gradind texture.
  129003. */
  129004. clone(): ColorGradingTexture;
  129005. /**
  129006. * Called during delayed load for textures.
  129007. */
  129008. delayLoad(): void;
  129009. /**
  129010. * Parses a color grading texture serialized by Babylon.
  129011. * @param parsedTexture The texture information being parsedTexture
  129012. * @param scene The scene to load the texture in
  129013. * @param rootUrl The root url of the data assets to load
  129014. * @return A color gradind texture
  129015. */
  129016. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129017. /**
  129018. * Serializes the LUT texture to json format.
  129019. */
  129020. serialize(): any;
  129021. }
  129022. }
  129023. declare module BABYLON {
  129024. /**
  129025. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129026. */
  129027. export class EquiRectangularCubeTexture extends BaseTexture {
  129028. /** The six faces of the cube. */
  129029. private static _FacesMapping;
  129030. private _noMipmap;
  129031. private _onLoad;
  129032. private _onError;
  129033. /** The size of the cubemap. */
  129034. private _size;
  129035. /** The buffer of the image. */
  129036. private _buffer;
  129037. /** The width of the input image. */
  129038. private _width;
  129039. /** The height of the input image. */
  129040. private _height;
  129041. /** The URL to the image. */
  129042. url: string;
  129043. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129044. coordinatesMode: number;
  129045. /**
  129046. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129047. * @param url The location of the image
  129048. * @param scene The scene the texture will be used in
  129049. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129050. * @param noMipmap Forces to not generate the mipmap if true
  129051. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129052. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129053. * @param onLoad — defines a callback called when texture is loaded
  129054. * @param onError — defines a callback called if there is an error
  129055. */
  129056. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129057. /**
  129058. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129059. */
  129060. private loadImage;
  129061. /**
  129062. * Convert the image buffer into a cubemap and create a CubeTexture.
  129063. */
  129064. private loadTexture;
  129065. /**
  129066. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129067. * @param buffer The ArrayBuffer that should be converted.
  129068. * @returns The buffer as Float32Array.
  129069. */
  129070. private getFloat32ArrayFromArrayBuffer;
  129071. /**
  129072. * Get the current class name of the texture useful for serialization or dynamic coding.
  129073. * @returns "EquiRectangularCubeTexture"
  129074. */
  129075. getClassName(): string;
  129076. /**
  129077. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129078. * @returns A clone of the current EquiRectangularCubeTexture.
  129079. */
  129080. clone(): EquiRectangularCubeTexture;
  129081. }
  129082. }
  129083. declare module BABYLON {
  129084. /**
  129085. * Based on jsTGALoader - Javascript loader for TGA file
  129086. * By Vincent Thibault
  129087. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129088. */
  129089. export class TGATools {
  129090. private static _TYPE_INDEXED;
  129091. private static _TYPE_RGB;
  129092. private static _TYPE_GREY;
  129093. private static _TYPE_RLE_INDEXED;
  129094. private static _TYPE_RLE_RGB;
  129095. private static _TYPE_RLE_GREY;
  129096. private static _ORIGIN_MASK;
  129097. private static _ORIGIN_SHIFT;
  129098. private static _ORIGIN_BL;
  129099. private static _ORIGIN_BR;
  129100. private static _ORIGIN_UL;
  129101. private static _ORIGIN_UR;
  129102. /**
  129103. * Gets the header of a TGA file
  129104. * @param data defines the TGA data
  129105. * @returns the header
  129106. */
  129107. static GetTGAHeader(data: Uint8Array): any;
  129108. /**
  129109. * Uploads TGA content to a Babylon Texture
  129110. * @hidden
  129111. */
  129112. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129113. /** @hidden */
  129114. 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;
  129115. /** @hidden */
  129116. 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;
  129117. /** @hidden */
  129118. 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;
  129119. /** @hidden */
  129120. 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;
  129121. /** @hidden */
  129122. 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;
  129123. /** @hidden */
  129124. 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;
  129125. }
  129126. }
  129127. declare module BABYLON {
  129128. /**
  129129. * Implementation of the TGA Texture Loader.
  129130. * @hidden
  129131. */
  129132. export class _TGATextureLoader implements IInternalTextureLoader {
  129133. /**
  129134. * Defines wether the loader supports cascade loading the different faces.
  129135. */
  129136. readonly supportCascades: boolean;
  129137. /**
  129138. * This returns if the loader support the current file information.
  129139. * @param extension defines the file extension of the file being loaded
  129140. * @returns true if the loader can load the specified file
  129141. */
  129142. canLoad(extension: string): boolean;
  129143. /**
  129144. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129145. * @param data contains the texture data
  129146. * @param texture defines the BabylonJS internal texture
  129147. * @param createPolynomials will be true if polynomials have been requested
  129148. * @param onLoad defines the callback to trigger once the texture is ready
  129149. * @param onError defines the callback to trigger in case of error
  129150. */
  129151. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129152. /**
  129153. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129154. * @param data contains the texture data
  129155. * @param texture defines the BabylonJS internal texture
  129156. * @param callback defines the method to call once ready to upload
  129157. */
  129158. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129159. }
  129160. }
  129161. declare module BABYLON {
  129162. /**
  129163. * Info about the .basis files
  129164. */
  129165. class BasisFileInfo {
  129166. /**
  129167. * If the file has alpha
  129168. */
  129169. hasAlpha: boolean;
  129170. /**
  129171. * Info about each image of the basis file
  129172. */
  129173. images: Array<{
  129174. levels: Array<{
  129175. width: number;
  129176. height: number;
  129177. transcodedPixels: ArrayBufferView;
  129178. }>;
  129179. }>;
  129180. }
  129181. /**
  129182. * Result of transcoding a basis file
  129183. */
  129184. class TranscodeResult {
  129185. /**
  129186. * Info about the .basis file
  129187. */
  129188. fileInfo: BasisFileInfo;
  129189. /**
  129190. * Format to use when loading the file
  129191. */
  129192. format: number;
  129193. }
  129194. /**
  129195. * Configuration options for the Basis transcoder
  129196. */
  129197. export class BasisTranscodeConfiguration {
  129198. /**
  129199. * Supported compression formats used to determine the supported output format of the transcoder
  129200. */
  129201. supportedCompressionFormats?: {
  129202. /**
  129203. * etc1 compression format
  129204. */
  129205. etc1?: boolean;
  129206. /**
  129207. * s3tc compression format
  129208. */
  129209. s3tc?: boolean;
  129210. /**
  129211. * pvrtc compression format
  129212. */
  129213. pvrtc?: boolean;
  129214. /**
  129215. * etc2 compression format
  129216. */
  129217. etc2?: boolean;
  129218. };
  129219. /**
  129220. * If mipmap levels should be loaded for transcoded images (Default: true)
  129221. */
  129222. loadMipmapLevels?: boolean;
  129223. /**
  129224. * Index of a single image to load (Default: all images)
  129225. */
  129226. loadSingleImage?: number;
  129227. }
  129228. /**
  129229. * Used to load .Basis files
  129230. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129231. */
  129232. export class BasisTools {
  129233. private static _IgnoreSupportedFormats;
  129234. /**
  129235. * URL to use when loading the basis transcoder
  129236. */
  129237. static JSModuleURL: string;
  129238. /**
  129239. * URL to use when loading the wasm module for the transcoder
  129240. */
  129241. static WasmModuleURL: string;
  129242. /**
  129243. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129244. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129245. * @returns internal format corresponding to the Basis format
  129246. */
  129247. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129248. private static _WorkerPromise;
  129249. private static _Worker;
  129250. private static _actionId;
  129251. private static _CreateWorkerAsync;
  129252. /**
  129253. * Transcodes a loaded image file to compressed pixel data
  129254. * @param data image data to transcode
  129255. * @param config configuration options for the transcoding
  129256. * @returns a promise resulting in the transcoded image
  129257. */
  129258. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129259. /**
  129260. * Loads a texture from the transcode result
  129261. * @param texture texture load to
  129262. * @param transcodeResult the result of transcoding the basis file to load from
  129263. */
  129264. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129265. }
  129266. }
  129267. declare module BABYLON {
  129268. /**
  129269. * Loader for .basis file format
  129270. */
  129271. export class _BasisTextureLoader implements IInternalTextureLoader {
  129272. /**
  129273. * Defines whether the loader supports cascade loading the different faces.
  129274. */
  129275. readonly supportCascades: boolean;
  129276. /**
  129277. * This returns if the loader support the current file information.
  129278. * @param extension defines the file extension of the file being loaded
  129279. * @returns true if the loader can load the specified file
  129280. */
  129281. canLoad(extension: string): boolean;
  129282. /**
  129283. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129284. * @param data contains the texture data
  129285. * @param texture defines the BabylonJS internal texture
  129286. * @param createPolynomials will be true if polynomials have been requested
  129287. * @param onLoad defines the callback to trigger once the texture is ready
  129288. * @param onError defines the callback to trigger in case of error
  129289. */
  129290. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129291. /**
  129292. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129293. * @param data contains the texture data
  129294. * @param texture defines the BabylonJS internal texture
  129295. * @param callback defines the method to call once ready to upload
  129296. */
  129297. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129298. }
  129299. }
  129300. declare module BABYLON {
  129301. /**
  129302. * 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.
  129303. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129304. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129305. */
  129306. export class CustomProceduralTexture extends ProceduralTexture {
  129307. private _animate;
  129308. private _time;
  129309. private _config;
  129310. private _texturePath;
  129311. /**
  129312. * Instantiates a new Custom Procedural Texture.
  129313. * 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.
  129314. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129315. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129316. * @param name Define the name of the texture
  129317. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129318. * @param size Define the size of the texture to create
  129319. * @param scene Define the scene the texture belongs to
  129320. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129321. * @param generateMipMaps Define if the texture should creates mip maps or not
  129322. */
  129323. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129324. private _loadJson;
  129325. /**
  129326. * Is the texture ready to be used ? (rendered at least once)
  129327. * @returns true if ready, otherwise, false.
  129328. */
  129329. isReady(): boolean;
  129330. /**
  129331. * Render the texture to its associated render target.
  129332. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129333. */
  129334. render(useCameraPostProcess?: boolean): void;
  129335. /**
  129336. * Update the list of dependant textures samplers in the shader.
  129337. */
  129338. updateTextures(): void;
  129339. /**
  129340. * Update the uniform values of the procedural texture in the shader.
  129341. */
  129342. updateShaderUniforms(): void;
  129343. /**
  129344. * Define if the texture animates or not.
  129345. */
  129346. get animate(): boolean;
  129347. set animate(value: boolean);
  129348. }
  129349. }
  129350. declare module BABYLON {
  129351. /** @hidden */
  129352. export var noisePixelShader: {
  129353. name: string;
  129354. shader: string;
  129355. };
  129356. }
  129357. declare module BABYLON {
  129358. /**
  129359. * Class used to generate noise procedural textures
  129360. */
  129361. export class NoiseProceduralTexture extends ProceduralTexture {
  129362. private _time;
  129363. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129364. brightness: number;
  129365. /** Defines the number of octaves to process */
  129366. octaves: number;
  129367. /** Defines the level of persistence (0.8 by default) */
  129368. persistence: number;
  129369. /** Gets or sets animation speed factor (default is 1) */
  129370. animationSpeedFactor: number;
  129371. /**
  129372. * Creates a new NoiseProceduralTexture
  129373. * @param name defines the name fo the texture
  129374. * @param size defines the size of the texture (default is 256)
  129375. * @param scene defines the hosting scene
  129376. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129377. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129378. */
  129379. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129380. private _updateShaderUniforms;
  129381. protected _getDefines(): string;
  129382. /** Generate the current state of the procedural texture */
  129383. render(useCameraPostProcess?: boolean): void;
  129384. /**
  129385. * Serializes this noise procedural texture
  129386. * @returns a serialized noise procedural texture object
  129387. */
  129388. serialize(): any;
  129389. /**
  129390. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129391. * @param parsedTexture defines parsed texture data
  129392. * @param scene defines the current scene
  129393. * @param rootUrl defines the root URL containing noise procedural texture information
  129394. * @returns a parsed NoiseProceduralTexture
  129395. */
  129396. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129397. }
  129398. }
  129399. declare module BABYLON {
  129400. /**
  129401. * Raw cube texture where the raw buffers are passed in
  129402. */
  129403. export class RawCubeTexture extends CubeTexture {
  129404. /**
  129405. * Creates a cube texture where the raw buffers are passed in.
  129406. * @param scene defines the scene the texture is attached to
  129407. * @param data defines the array of data to use to create each face
  129408. * @param size defines the size of the textures
  129409. * @param format defines the format of the data
  129410. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129411. * @param generateMipMaps defines if the engine should generate the mip levels
  129412. * @param invertY defines if data must be stored with Y axis inverted
  129413. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129414. * @param compression defines the compression used (null by default)
  129415. */
  129416. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129417. /**
  129418. * Updates the raw cube texture.
  129419. * @param data defines the data to store
  129420. * @param format defines the data format
  129421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129422. * @param invertY defines if data must be stored with Y axis inverted
  129423. * @param compression defines the compression used (null by default)
  129424. * @param level defines which level of the texture to update
  129425. */
  129426. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129427. /**
  129428. * Updates a raw cube texture with RGBD encoded data.
  129429. * @param data defines the array of data [mipmap][face] to use to create each face
  129430. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129431. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129432. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129433. * @returns a promsie that resolves when the operation is complete
  129434. */
  129435. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129436. /**
  129437. * Clones the raw cube texture.
  129438. * @return a new cube texture
  129439. */
  129440. clone(): CubeTexture;
  129441. /** @hidden */
  129442. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129443. }
  129444. }
  129445. declare module BABYLON {
  129446. /**
  129447. * Class used to store 3D textures containing user data
  129448. */
  129449. export class RawTexture3D extends Texture {
  129450. /** Gets or sets the texture format to use */
  129451. format: number;
  129452. private _engine;
  129453. /**
  129454. * Create a new RawTexture3D
  129455. * @param data defines the data of the texture
  129456. * @param width defines the width of the texture
  129457. * @param height defines the height of the texture
  129458. * @param depth defines the depth of the texture
  129459. * @param format defines the texture format to use
  129460. * @param scene defines the hosting scene
  129461. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129462. * @param invertY defines if texture must be stored with Y axis inverted
  129463. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129464. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129465. */
  129466. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129467. /** Gets or sets the texture format to use */
  129468. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129469. /**
  129470. * Update the texture with new data
  129471. * @param data defines the data to store in the texture
  129472. */
  129473. update(data: ArrayBufferView): void;
  129474. }
  129475. }
  129476. declare module BABYLON {
  129477. /**
  129478. * Class used to store 2D array textures containing user data
  129479. */
  129480. export class RawTexture2DArray extends Texture {
  129481. /** Gets or sets the texture format to use */
  129482. format: number;
  129483. private _engine;
  129484. /**
  129485. * Create a new RawTexture2DArray
  129486. * @param data defines the data of the texture
  129487. * @param width defines the width of the texture
  129488. * @param height defines the height of the texture
  129489. * @param depth defines the number of layers of the texture
  129490. * @param format defines the texture format to use
  129491. * @param scene defines the hosting scene
  129492. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129493. * @param invertY defines if texture must be stored with Y axis inverted
  129494. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129495. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129496. */
  129497. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129498. /** Gets or sets the texture format to use */
  129499. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129500. /**
  129501. * Update the texture with new data
  129502. * @param data defines the data to store in the texture
  129503. */
  129504. update(data: ArrayBufferView): void;
  129505. }
  129506. }
  129507. declare module BABYLON {
  129508. /**
  129509. * Creates a refraction texture used by refraction channel of the standard material.
  129510. * It is like a mirror but to see through a material.
  129511. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129512. */
  129513. export class RefractionTexture extends RenderTargetTexture {
  129514. /**
  129515. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129516. * 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.
  129517. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129518. */
  129519. refractionPlane: Plane;
  129520. /**
  129521. * Define how deep under the surface we should see.
  129522. */
  129523. depth: number;
  129524. /**
  129525. * Creates a refraction texture used by refraction channel of the standard material.
  129526. * It is like a mirror but to see through a material.
  129527. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129528. * @param name Define the texture name
  129529. * @param size Define the size of the underlying texture
  129530. * @param scene Define the scene the refraction belongs to
  129531. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129532. */
  129533. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129534. /**
  129535. * Clone the refraction texture.
  129536. * @returns the cloned texture
  129537. */
  129538. clone(): RefractionTexture;
  129539. /**
  129540. * Serialize the texture to a JSON representation you could use in Parse later on
  129541. * @returns the serialized JSON representation
  129542. */
  129543. serialize(): any;
  129544. }
  129545. }
  129546. declare module BABYLON {
  129547. /**
  129548. * Defines the options related to the creation of an HtmlElementTexture
  129549. */
  129550. export interface IHtmlElementTextureOptions {
  129551. /**
  129552. * Defines wether mip maps should be created or not.
  129553. */
  129554. generateMipMaps?: boolean;
  129555. /**
  129556. * Defines the sampling mode of the texture.
  129557. */
  129558. samplingMode?: number;
  129559. /**
  129560. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129561. */
  129562. engine: Nullable<ThinEngine>;
  129563. /**
  129564. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129565. */
  129566. scene: Nullable<Scene>;
  129567. }
  129568. /**
  129569. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129570. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129571. * is automatically managed.
  129572. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129573. * in your application.
  129574. *
  129575. * As the update is not automatic, you need to call them manually.
  129576. */
  129577. export class HtmlElementTexture extends BaseTexture {
  129578. /**
  129579. * The texture URL.
  129580. */
  129581. element: HTMLVideoElement | HTMLCanvasElement;
  129582. private static readonly DefaultOptions;
  129583. private _textureMatrix;
  129584. private _engine;
  129585. private _isVideo;
  129586. private _generateMipMaps;
  129587. private _samplingMode;
  129588. /**
  129589. * Instantiates a HtmlElementTexture from the following parameters.
  129590. *
  129591. * @param name Defines the name of the texture
  129592. * @param element Defines the video or canvas the texture is filled with
  129593. * @param options Defines the other none mandatory texture creation options
  129594. */
  129595. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129596. private _createInternalTexture;
  129597. /**
  129598. * Returns the texture matrix used in most of the material.
  129599. */
  129600. getTextureMatrix(): Matrix;
  129601. /**
  129602. * Updates the content of the texture.
  129603. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129604. */
  129605. update(invertY?: Nullable<boolean>): void;
  129606. }
  129607. }
  129608. declare module BABYLON {
  129609. /**
  129610. * Defines the basic options interface of a TexturePacker Frame
  129611. */
  129612. export interface ITexturePackerFrame {
  129613. /**
  129614. * The frame ID
  129615. */
  129616. id: number;
  129617. /**
  129618. * The frames Scale
  129619. */
  129620. scale: Vector2;
  129621. /**
  129622. * The Frames offset
  129623. */
  129624. offset: Vector2;
  129625. }
  129626. /**
  129627. * This is a support class for frame Data on texture packer sets.
  129628. */
  129629. export class TexturePackerFrame implements ITexturePackerFrame {
  129630. /**
  129631. * The frame ID
  129632. */
  129633. id: number;
  129634. /**
  129635. * The frames Scale
  129636. */
  129637. scale: Vector2;
  129638. /**
  129639. * The Frames offset
  129640. */
  129641. offset: Vector2;
  129642. /**
  129643. * Initializes a texture package frame.
  129644. * @param id The numerical frame identifier
  129645. * @param scale Scalar Vector2 for UV frame
  129646. * @param offset Vector2 for the frame position in UV units.
  129647. * @returns TexturePackerFrame
  129648. */
  129649. constructor(id: number, scale: Vector2, offset: Vector2);
  129650. }
  129651. }
  129652. declare module BABYLON {
  129653. /**
  129654. * Defines the basic options interface of a TexturePacker
  129655. */
  129656. export interface ITexturePackerOptions {
  129657. /**
  129658. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129659. */
  129660. map?: string[];
  129661. /**
  129662. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129663. */
  129664. uvsIn?: string;
  129665. /**
  129666. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129667. */
  129668. uvsOut?: string;
  129669. /**
  129670. * number representing the layout style. Defaults to LAYOUT_STRIP
  129671. */
  129672. layout?: number;
  129673. /**
  129674. * number of columns if using custom column count layout(2). This defaults to 4.
  129675. */
  129676. colnum?: number;
  129677. /**
  129678. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129679. */
  129680. updateInputMeshes?: boolean;
  129681. /**
  129682. * boolean flag to dispose all the source textures. Defaults to true.
  129683. */
  129684. disposeSources?: boolean;
  129685. /**
  129686. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129687. */
  129688. fillBlanks?: boolean;
  129689. /**
  129690. * string value representing the context fill style color. Defaults to 'black'.
  129691. */
  129692. customFillColor?: string;
  129693. /**
  129694. * Width and Height Value of each Frame in the TexturePacker Sets
  129695. */
  129696. frameSize?: number;
  129697. /**
  129698. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129699. */
  129700. paddingRatio?: number;
  129701. /**
  129702. * Number that declares the fill method for the padding gutter.
  129703. */
  129704. paddingMode?: number;
  129705. /**
  129706. * If in SUBUV_COLOR padding mode what color to use.
  129707. */
  129708. paddingColor?: Color3 | Color4;
  129709. }
  129710. /**
  129711. * Defines the basic interface of a TexturePacker JSON File
  129712. */
  129713. export interface ITexturePackerJSON {
  129714. /**
  129715. * The frame ID
  129716. */
  129717. name: string;
  129718. /**
  129719. * The base64 channel data
  129720. */
  129721. sets: any;
  129722. /**
  129723. * The options of the Packer
  129724. */
  129725. options: ITexturePackerOptions;
  129726. /**
  129727. * The frame data of the Packer
  129728. */
  129729. frames: Array<number>;
  129730. }
  129731. /**
  129732. * This is a support class that generates a series of packed texture sets.
  129733. * @see https://doc.babylonjs.com/babylon101/materials
  129734. */
  129735. export class TexturePacker {
  129736. /** Packer Layout Constant 0 */
  129737. static readonly LAYOUT_STRIP: number;
  129738. /** Packer Layout Constant 1 */
  129739. static readonly LAYOUT_POWER2: number;
  129740. /** Packer Layout Constant 2 */
  129741. static readonly LAYOUT_COLNUM: number;
  129742. /** Packer Layout Constant 0 */
  129743. static readonly SUBUV_WRAP: number;
  129744. /** Packer Layout Constant 1 */
  129745. static readonly SUBUV_EXTEND: number;
  129746. /** Packer Layout Constant 2 */
  129747. static readonly SUBUV_COLOR: number;
  129748. /** The Name of the Texture Package */
  129749. name: string;
  129750. /** The scene scope of the TexturePacker */
  129751. scene: Scene;
  129752. /** The Meshes to target */
  129753. meshes: AbstractMesh[];
  129754. /** Arguments passed with the Constructor */
  129755. options: ITexturePackerOptions;
  129756. /** The promise that is started upon initialization */
  129757. promise: Nullable<Promise<TexturePacker | string>>;
  129758. /** The Container object for the channel sets that are generated */
  129759. sets: object;
  129760. /** The Container array for the frames that are generated */
  129761. frames: TexturePackerFrame[];
  129762. /** The expected number of textures the system is parsing. */
  129763. private _expecting;
  129764. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129765. private _paddingValue;
  129766. /**
  129767. * Initializes a texture package series from an array of meshes or a single mesh.
  129768. * @param name The name of the package
  129769. * @param meshes The target meshes to compose the package from
  129770. * @param options The arguments that texture packer should follow while building.
  129771. * @param scene The scene which the textures are scoped to.
  129772. * @returns TexturePacker
  129773. */
  129774. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129775. /**
  129776. * Starts the package process
  129777. * @param resolve The promises resolution function
  129778. * @returns TexturePacker
  129779. */
  129780. private _createFrames;
  129781. /**
  129782. * Calculates the Size of the Channel Sets
  129783. * @returns Vector2
  129784. */
  129785. private _calculateSize;
  129786. /**
  129787. * Calculates the UV data for the frames.
  129788. * @param baseSize the base frameSize
  129789. * @param padding the base frame padding
  129790. * @param dtSize size of the Dynamic Texture for that channel
  129791. * @param dtUnits is 1/dtSize
  129792. * @param update flag to update the input meshes
  129793. */
  129794. private _calculateMeshUVFrames;
  129795. /**
  129796. * Calculates the frames Offset.
  129797. * @param index of the frame
  129798. * @returns Vector2
  129799. */
  129800. private _getFrameOffset;
  129801. /**
  129802. * Updates a Mesh to the frame data
  129803. * @param mesh that is the target
  129804. * @param frameID or the frame index
  129805. */
  129806. private _updateMeshUV;
  129807. /**
  129808. * Updates a Meshes materials to use the texture packer channels
  129809. * @param m is the mesh to target
  129810. * @param force all channels on the packer to be set.
  129811. */
  129812. private _updateTextureReferences;
  129813. /**
  129814. * Public method to set a Mesh to a frame
  129815. * @param m that is the target
  129816. * @param frameID or the frame index
  129817. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129818. */
  129819. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129820. /**
  129821. * Starts the async promise to compile the texture packer.
  129822. * @returns Promise<void>
  129823. */
  129824. processAsync(): Promise<void>;
  129825. /**
  129826. * Disposes all textures associated with this packer
  129827. */
  129828. dispose(): void;
  129829. /**
  129830. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129831. * @param imageType is the image type to use.
  129832. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129833. */
  129834. download(imageType?: string, quality?: number): void;
  129835. /**
  129836. * Public method to load a texturePacker JSON file.
  129837. * @param data of the JSON file in string format.
  129838. */
  129839. updateFromJSON(data: string): void;
  129840. }
  129841. }
  129842. declare module BABYLON {
  129843. /**
  129844. * Enum used to define the target of a block
  129845. */
  129846. export enum NodeMaterialBlockTargets {
  129847. /** Vertex shader */
  129848. Vertex = 1,
  129849. /** Fragment shader */
  129850. Fragment = 2,
  129851. /** Neutral */
  129852. Neutral = 4,
  129853. /** Vertex and Fragment */
  129854. VertexAndFragment = 3
  129855. }
  129856. }
  129857. declare module BABYLON {
  129858. /**
  129859. * Defines the kind of connection point for node based material
  129860. */
  129861. export enum NodeMaterialBlockConnectionPointTypes {
  129862. /** Float */
  129863. Float = 1,
  129864. /** Int */
  129865. Int = 2,
  129866. /** Vector2 */
  129867. Vector2 = 4,
  129868. /** Vector3 */
  129869. Vector3 = 8,
  129870. /** Vector4 */
  129871. Vector4 = 16,
  129872. /** Color3 */
  129873. Color3 = 32,
  129874. /** Color4 */
  129875. Color4 = 64,
  129876. /** Matrix */
  129877. Matrix = 128,
  129878. /** Detect type based on connection */
  129879. AutoDetect = 1024,
  129880. /** Output type that will be defined by input type */
  129881. BasedOnInput = 2048
  129882. }
  129883. }
  129884. declare module BABYLON {
  129885. /**
  129886. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129887. */
  129888. export enum NodeMaterialBlockConnectionPointMode {
  129889. /** Value is an uniform */
  129890. Uniform = 0,
  129891. /** Value is a mesh attribute */
  129892. Attribute = 1,
  129893. /** Value is a varying between vertex and fragment shaders */
  129894. Varying = 2,
  129895. /** Mode is undefined */
  129896. Undefined = 3
  129897. }
  129898. }
  129899. declare module BABYLON {
  129900. /**
  129901. * Enum used to define system values e.g. values automatically provided by the system
  129902. */
  129903. export enum NodeMaterialSystemValues {
  129904. /** World */
  129905. World = 1,
  129906. /** View */
  129907. View = 2,
  129908. /** Projection */
  129909. Projection = 3,
  129910. /** ViewProjection */
  129911. ViewProjection = 4,
  129912. /** WorldView */
  129913. WorldView = 5,
  129914. /** WorldViewProjection */
  129915. WorldViewProjection = 6,
  129916. /** CameraPosition */
  129917. CameraPosition = 7,
  129918. /** Fog Color */
  129919. FogColor = 8,
  129920. /** Delta time */
  129921. DeltaTime = 9
  129922. }
  129923. }
  129924. declare module BABYLON {
  129925. /**
  129926. * Root class for all node material optimizers
  129927. */
  129928. export class NodeMaterialOptimizer {
  129929. /**
  129930. * Function used to optimize a NodeMaterial graph
  129931. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129932. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129933. */
  129934. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129935. }
  129936. }
  129937. declare module BABYLON {
  129938. /**
  129939. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129940. */
  129941. export class TransformBlock extends NodeMaterialBlock {
  129942. /**
  129943. * Defines the value to use to complement W value to transform it to a Vector4
  129944. */
  129945. complementW: number;
  129946. /**
  129947. * Defines the value to use to complement z value to transform it to a Vector4
  129948. */
  129949. complementZ: number;
  129950. /**
  129951. * Creates a new TransformBlock
  129952. * @param name defines the block name
  129953. */
  129954. constructor(name: string);
  129955. /**
  129956. * Gets the current class name
  129957. * @returns the class name
  129958. */
  129959. getClassName(): string;
  129960. /**
  129961. * Gets the vector input
  129962. */
  129963. get vector(): NodeMaterialConnectionPoint;
  129964. /**
  129965. * Gets the output component
  129966. */
  129967. get output(): NodeMaterialConnectionPoint;
  129968. /**
  129969. * Gets the xyz output component
  129970. */
  129971. get xyz(): NodeMaterialConnectionPoint;
  129972. /**
  129973. * Gets the matrix transform input
  129974. */
  129975. get transform(): NodeMaterialConnectionPoint;
  129976. protected _buildBlock(state: NodeMaterialBuildState): this;
  129977. serialize(): any;
  129978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129979. protected _dumpPropertiesCode(): string;
  129980. }
  129981. }
  129982. declare module BABYLON {
  129983. /**
  129984. * Block used to output the vertex position
  129985. */
  129986. export class VertexOutputBlock extends NodeMaterialBlock {
  129987. /**
  129988. * Creates a new VertexOutputBlock
  129989. * @param name defines the block name
  129990. */
  129991. constructor(name: string);
  129992. /**
  129993. * Gets the current class name
  129994. * @returns the class name
  129995. */
  129996. getClassName(): string;
  129997. /**
  129998. * Gets the vector input component
  129999. */
  130000. get vector(): NodeMaterialConnectionPoint;
  130001. protected _buildBlock(state: NodeMaterialBuildState): this;
  130002. }
  130003. }
  130004. declare module BABYLON {
  130005. /**
  130006. * Block used to output the final color
  130007. */
  130008. export class FragmentOutputBlock extends NodeMaterialBlock {
  130009. /**
  130010. * Create a new FragmentOutputBlock
  130011. * @param name defines the block name
  130012. */
  130013. constructor(name: string);
  130014. /**
  130015. * Gets the current class name
  130016. * @returns the class name
  130017. */
  130018. getClassName(): string;
  130019. /**
  130020. * Gets the rgba input component
  130021. */
  130022. get rgba(): NodeMaterialConnectionPoint;
  130023. /**
  130024. * Gets the rgb input component
  130025. */
  130026. get rgb(): NodeMaterialConnectionPoint;
  130027. /**
  130028. * Gets the a input component
  130029. */
  130030. get a(): NodeMaterialConnectionPoint;
  130031. protected _buildBlock(state: NodeMaterialBuildState): this;
  130032. }
  130033. }
  130034. declare module BABYLON {
  130035. /**
  130036. * Block used to read a reflection texture from a sampler
  130037. */
  130038. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130039. private _define3DName;
  130040. private _defineCubicName;
  130041. private _defineExplicitName;
  130042. private _defineProjectionName;
  130043. private _defineLocalCubicName;
  130044. private _defineSphericalName;
  130045. private _definePlanarName;
  130046. private _defineEquirectangularName;
  130047. private _defineMirroredEquirectangularFixedName;
  130048. private _defineEquirectangularFixedName;
  130049. private _defineSkyboxName;
  130050. private _cubeSamplerName;
  130051. private _2DSamplerName;
  130052. private _positionUVWName;
  130053. private _directionWName;
  130054. private _reflectionCoordsName;
  130055. private _reflection2DCoordsName;
  130056. private _reflectionColorName;
  130057. private _reflectionMatrixName;
  130058. /**
  130059. * Gets or sets the texture associated with the node
  130060. */
  130061. texture: Nullable<BaseTexture>;
  130062. /**
  130063. * Create a new TextureBlock
  130064. * @param name defines the block name
  130065. */
  130066. constructor(name: string);
  130067. /**
  130068. * Gets the current class name
  130069. * @returns the class name
  130070. */
  130071. getClassName(): string;
  130072. /**
  130073. * Gets the world position input component
  130074. */
  130075. get position(): NodeMaterialConnectionPoint;
  130076. /**
  130077. * Gets the world position input component
  130078. */
  130079. get worldPosition(): NodeMaterialConnectionPoint;
  130080. /**
  130081. * Gets the world normal input component
  130082. */
  130083. get worldNormal(): NodeMaterialConnectionPoint;
  130084. /**
  130085. * Gets the world input component
  130086. */
  130087. get world(): NodeMaterialConnectionPoint;
  130088. /**
  130089. * Gets the camera (or eye) position component
  130090. */
  130091. get cameraPosition(): NodeMaterialConnectionPoint;
  130092. /**
  130093. * Gets the view input component
  130094. */
  130095. get view(): NodeMaterialConnectionPoint;
  130096. /**
  130097. * Gets the rgb output component
  130098. */
  130099. get rgb(): NodeMaterialConnectionPoint;
  130100. /**
  130101. * Gets the r output component
  130102. */
  130103. get r(): NodeMaterialConnectionPoint;
  130104. /**
  130105. * Gets the g output component
  130106. */
  130107. get g(): NodeMaterialConnectionPoint;
  130108. /**
  130109. * Gets the b output component
  130110. */
  130111. get b(): NodeMaterialConnectionPoint;
  130112. autoConfigure(material: NodeMaterial): void;
  130113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130114. isReady(): boolean;
  130115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130116. private _injectVertexCode;
  130117. private _writeOutput;
  130118. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130119. protected _dumpPropertiesCode(): string;
  130120. serialize(): any;
  130121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130122. }
  130123. }
  130124. declare module BABYLON {
  130125. /**
  130126. * Interface used to configure the node material editor
  130127. */
  130128. export interface INodeMaterialEditorOptions {
  130129. /** Define the URl to load node editor script */
  130130. editorURL?: string;
  130131. }
  130132. /** @hidden */
  130133. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130134. NORMAL: boolean;
  130135. TANGENT: boolean;
  130136. UV1: boolean;
  130137. /** BONES */
  130138. NUM_BONE_INFLUENCERS: number;
  130139. BonesPerMesh: number;
  130140. BONETEXTURE: boolean;
  130141. /** MORPH TARGETS */
  130142. MORPHTARGETS: boolean;
  130143. MORPHTARGETS_NORMAL: boolean;
  130144. MORPHTARGETS_TANGENT: boolean;
  130145. MORPHTARGETS_UV: boolean;
  130146. NUM_MORPH_INFLUENCERS: number;
  130147. /** IMAGE PROCESSING */
  130148. IMAGEPROCESSING: boolean;
  130149. VIGNETTE: boolean;
  130150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130151. VIGNETTEBLENDMODEOPAQUE: boolean;
  130152. TONEMAPPING: boolean;
  130153. TONEMAPPING_ACES: boolean;
  130154. CONTRAST: boolean;
  130155. EXPOSURE: boolean;
  130156. COLORCURVES: boolean;
  130157. COLORGRADING: boolean;
  130158. COLORGRADING3D: boolean;
  130159. SAMPLER3DGREENDEPTH: boolean;
  130160. SAMPLER3DBGRMAP: boolean;
  130161. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130162. /** MISC. */
  130163. BUMPDIRECTUV: number;
  130164. constructor();
  130165. setValue(name: string, value: boolean): void;
  130166. }
  130167. /**
  130168. * Class used to configure NodeMaterial
  130169. */
  130170. export interface INodeMaterialOptions {
  130171. /**
  130172. * Defines if blocks should emit comments
  130173. */
  130174. emitComments: boolean;
  130175. }
  130176. /**
  130177. * Class used to create a node based material built by assembling shader blocks
  130178. */
  130179. export class NodeMaterial extends PushMaterial {
  130180. private static _BuildIdGenerator;
  130181. private _options;
  130182. private _vertexCompilationState;
  130183. private _fragmentCompilationState;
  130184. private _sharedData;
  130185. private _buildId;
  130186. private _buildWasSuccessful;
  130187. private _cachedWorldViewMatrix;
  130188. private _cachedWorldViewProjectionMatrix;
  130189. private _optimizers;
  130190. private _animationFrame;
  130191. /** Define the Url to load node editor script */
  130192. static EditorURL: string;
  130193. /** Define the Url to load snippets */
  130194. static SnippetUrl: string;
  130195. private BJSNODEMATERIALEDITOR;
  130196. /** Get the inspector from bundle or global */
  130197. private _getGlobalNodeMaterialEditor;
  130198. /**
  130199. * Gets or sets data used by visual editor
  130200. * @see https://nme.babylonjs.com
  130201. */
  130202. editorData: any;
  130203. /**
  130204. * 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)
  130205. */
  130206. ignoreAlpha: boolean;
  130207. /**
  130208. * Defines the maximum number of lights that can be used in the material
  130209. */
  130210. maxSimultaneousLights: number;
  130211. /**
  130212. * Observable raised when the material is built
  130213. */
  130214. onBuildObservable: Observable<NodeMaterial>;
  130215. /**
  130216. * Gets or sets the root nodes of the material vertex shader
  130217. */
  130218. _vertexOutputNodes: NodeMaterialBlock[];
  130219. /**
  130220. * Gets or sets the root nodes of the material fragment (pixel) shader
  130221. */
  130222. _fragmentOutputNodes: NodeMaterialBlock[];
  130223. /** Gets or sets options to control the node material overall behavior */
  130224. get options(): INodeMaterialOptions;
  130225. set options(options: INodeMaterialOptions);
  130226. /**
  130227. * Default configuration related to image processing available in the standard Material.
  130228. */
  130229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130230. /**
  130231. * Gets the image processing configuration used either in this material.
  130232. */
  130233. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130234. /**
  130235. * Sets the Default image processing configuration used either in the this material.
  130236. *
  130237. * If sets to null, the scene one is in use.
  130238. */
  130239. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130240. /**
  130241. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130242. */
  130243. attachedBlocks: NodeMaterialBlock[];
  130244. /**
  130245. * Create a new node based material
  130246. * @param name defines the material name
  130247. * @param scene defines the hosting scene
  130248. * @param options defines creation option
  130249. */
  130250. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130251. /**
  130252. * Gets the current class name of the material e.g. "NodeMaterial"
  130253. * @returns the class name
  130254. */
  130255. getClassName(): string;
  130256. /**
  130257. * Keep track of the image processing observer to allow dispose and replace.
  130258. */
  130259. private _imageProcessingObserver;
  130260. /**
  130261. * Attaches a new image processing configuration to the Standard Material.
  130262. * @param configuration
  130263. */
  130264. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130265. /**
  130266. * Get a block by its name
  130267. * @param name defines the name of the block to retrieve
  130268. * @returns the required block or null if not found
  130269. */
  130270. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130271. /**
  130272. * Get a block by its name
  130273. * @param predicate defines the predicate used to find the good candidate
  130274. * @returns the required block or null if not found
  130275. */
  130276. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130277. /**
  130278. * Get an input block by its name
  130279. * @param predicate defines the predicate used to find the good candidate
  130280. * @returns the required input block or null if not found
  130281. */
  130282. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130283. /**
  130284. * Gets the list of input blocks attached to this material
  130285. * @returns an array of InputBlocks
  130286. */
  130287. getInputBlocks(): InputBlock[];
  130288. /**
  130289. * Adds a new optimizer to the list of optimizers
  130290. * @param optimizer defines the optimizers to add
  130291. * @returns the current material
  130292. */
  130293. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130294. /**
  130295. * Remove an optimizer from the list of optimizers
  130296. * @param optimizer defines the optimizers to remove
  130297. * @returns the current material
  130298. */
  130299. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130300. /**
  130301. * Add a new block to the list of output nodes
  130302. * @param node defines the node to add
  130303. * @returns the current material
  130304. */
  130305. addOutputNode(node: NodeMaterialBlock): this;
  130306. /**
  130307. * Remove a block from the list of root nodes
  130308. * @param node defines the node to remove
  130309. * @returns the current material
  130310. */
  130311. removeOutputNode(node: NodeMaterialBlock): this;
  130312. private _addVertexOutputNode;
  130313. private _removeVertexOutputNode;
  130314. private _addFragmentOutputNode;
  130315. private _removeFragmentOutputNode;
  130316. /**
  130317. * Specifies if the material will require alpha blending
  130318. * @returns a boolean specifying if alpha blending is needed
  130319. */
  130320. needAlphaBlending(): boolean;
  130321. /**
  130322. * Specifies if this material should be rendered in alpha test mode
  130323. * @returns a boolean specifying if an alpha test is needed.
  130324. */
  130325. needAlphaTesting(): boolean;
  130326. private _initializeBlock;
  130327. private _resetDualBlocks;
  130328. /**
  130329. * Remove a block from the current node material
  130330. * @param block defines the block to remove
  130331. */
  130332. removeBlock(block: NodeMaterialBlock): void;
  130333. /**
  130334. * Build the material and generates the inner effect
  130335. * @param verbose defines if the build should log activity
  130336. */
  130337. build(verbose?: boolean): void;
  130338. /**
  130339. * Runs an otpimization phase to try to improve the shader code
  130340. */
  130341. optimize(): void;
  130342. private _prepareDefinesForAttributes;
  130343. /**
  130344. * Get if the submesh is ready to be used and all its information available.
  130345. * Child classes can use it to update shaders
  130346. * @param mesh defines the mesh to check
  130347. * @param subMesh defines which submesh to check
  130348. * @param useInstances specifies that instances should be used
  130349. * @returns a boolean indicating that the submesh is ready or not
  130350. */
  130351. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130352. /**
  130353. * Get a string representing the shaders built by the current node graph
  130354. */
  130355. get compiledShaders(): string;
  130356. /**
  130357. * Binds the world matrix to the material
  130358. * @param world defines the world transformation matrix
  130359. */
  130360. bindOnlyWorldMatrix(world: Matrix): void;
  130361. /**
  130362. * Binds the submesh to this material by preparing the effect and shader to draw
  130363. * @param world defines the world transformation matrix
  130364. * @param mesh defines the mesh containing the submesh
  130365. * @param subMesh defines the submesh to bind the material to
  130366. */
  130367. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130368. /**
  130369. * Gets the active textures from the material
  130370. * @returns an array of textures
  130371. */
  130372. getActiveTextures(): BaseTexture[];
  130373. /**
  130374. * Gets the list of texture blocks
  130375. * @returns an array of texture blocks
  130376. */
  130377. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130378. /**
  130379. * Specifies if the material uses a texture
  130380. * @param texture defines the texture to check against the material
  130381. * @returns a boolean specifying if the material uses the texture
  130382. */
  130383. hasTexture(texture: BaseTexture): boolean;
  130384. /**
  130385. * Disposes the material
  130386. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130387. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130388. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130389. */
  130390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130391. /** Creates the node editor window. */
  130392. private _createNodeEditor;
  130393. /**
  130394. * Launch the node material editor
  130395. * @param config Define the configuration of the editor
  130396. * @return a promise fulfilled when the node editor is visible
  130397. */
  130398. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130399. /**
  130400. * Clear the current material
  130401. */
  130402. clear(): void;
  130403. /**
  130404. * Clear the current material and set it to a default state
  130405. */
  130406. setToDefault(): void;
  130407. /**
  130408. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130409. * @param url defines the url to load from
  130410. * @returns a promise that will fullfil when the material is fully loaded
  130411. */
  130412. loadAsync(url: string): Promise<void>;
  130413. private _gatherBlocks;
  130414. /**
  130415. * Generate a string containing the code declaration required to create an equivalent of this material
  130416. * @returns a string
  130417. */
  130418. generateCode(): string;
  130419. /**
  130420. * Serializes this material in a JSON representation
  130421. * @returns the serialized material object
  130422. */
  130423. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130424. private _restoreConnections;
  130425. /**
  130426. * Clear the current graph and load a new one from a serialization object
  130427. * @param source defines the JSON representation of the material
  130428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130429. */
  130430. loadFromSerialization(source: any, rootUrl?: string): void;
  130431. /**
  130432. * Creates a node material from parsed material data
  130433. * @param source defines the JSON representation of the material
  130434. * @param scene defines the hosting scene
  130435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130436. * @returns a new node material
  130437. */
  130438. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130439. /**
  130440. * Creates a node material from a snippet saved in a remote file
  130441. * @param name defines the name of the material to create
  130442. * @param url defines the url to load from
  130443. * @param scene defines the hosting scene
  130444. * @returns a promise that will resolve to the new node material
  130445. */
  130446. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130447. /**
  130448. * Creates a node material from a snippet saved by the node material editor
  130449. * @param snippetId defines the snippet to load
  130450. * @param scene defines the hosting scene
  130451. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130452. * @returns a promise that will resolve to the new node material
  130453. */
  130454. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130455. /**
  130456. * Creates a new node material set to default basic configuration
  130457. * @param name defines the name of the material
  130458. * @param scene defines the hosting scene
  130459. * @returns a new NodeMaterial
  130460. */
  130461. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130462. }
  130463. }
  130464. declare module BABYLON {
  130465. /**
  130466. * Block used to read a texture from a sampler
  130467. */
  130468. export class TextureBlock extends NodeMaterialBlock {
  130469. private _defineName;
  130470. private _linearDefineName;
  130471. private _tempTextureRead;
  130472. private _samplerName;
  130473. private _transformedUVName;
  130474. private _textureTransformName;
  130475. private _textureInfoName;
  130476. private _mainUVName;
  130477. private _mainUVDefineName;
  130478. /**
  130479. * Gets or sets the texture associated with the node
  130480. */
  130481. texture: Nullable<Texture>;
  130482. /**
  130483. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130484. */
  130485. convertToGammaSpace: boolean;
  130486. /**
  130487. * Create a new TextureBlock
  130488. * @param name defines the block name
  130489. */
  130490. constructor(name: string);
  130491. /**
  130492. * Gets the current class name
  130493. * @returns the class name
  130494. */
  130495. getClassName(): string;
  130496. /**
  130497. * Gets the uv input component
  130498. */
  130499. get uv(): NodeMaterialConnectionPoint;
  130500. /**
  130501. * Gets the rgba output component
  130502. */
  130503. get rgba(): NodeMaterialConnectionPoint;
  130504. /**
  130505. * Gets the rgb output component
  130506. */
  130507. get rgb(): NodeMaterialConnectionPoint;
  130508. /**
  130509. * Gets the r output component
  130510. */
  130511. get r(): NodeMaterialConnectionPoint;
  130512. /**
  130513. * Gets the g output component
  130514. */
  130515. get g(): NodeMaterialConnectionPoint;
  130516. /**
  130517. * Gets the b output component
  130518. */
  130519. get b(): NodeMaterialConnectionPoint;
  130520. /**
  130521. * Gets the a output component
  130522. */
  130523. get a(): NodeMaterialConnectionPoint;
  130524. get target(): NodeMaterialBlockTargets;
  130525. autoConfigure(material: NodeMaterial): void;
  130526. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130528. isReady(): boolean;
  130529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130530. private get _isMixed();
  130531. private _injectVertexCode;
  130532. private _writeTextureRead;
  130533. private _writeOutput;
  130534. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130535. protected _dumpPropertiesCode(): string;
  130536. serialize(): any;
  130537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130538. }
  130539. }
  130540. declare module BABYLON {
  130541. /**
  130542. * Class used to store shared data between 2 NodeMaterialBuildState
  130543. */
  130544. export class NodeMaterialBuildStateSharedData {
  130545. /**
  130546. * Gets the list of emitted varyings
  130547. */
  130548. temps: string[];
  130549. /**
  130550. * Gets the list of emitted varyings
  130551. */
  130552. varyings: string[];
  130553. /**
  130554. * Gets the varying declaration string
  130555. */
  130556. varyingDeclaration: string;
  130557. /**
  130558. * Input blocks
  130559. */
  130560. inputBlocks: InputBlock[];
  130561. /**
  130562. * Input blocks
  130563. */
  130564. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130565. /**
  130566. * Bindable blocks (Blocks that need to set data to the effect)
  130567. */
  130568. bindableBlocks: NodeMaterialBlock[];
  130569. /**
  130570. * List of blocks that can provide a compilation fallback
  130571. */
  130572. blocksWithFallbacks: NodeMaterialBlock[];
  130573. /**
  130574. * List of blocks that can provide a define update
  130575. */
  130576. blocksWithDefines: NodeMaterialBlock[];
  130577. /**
  130578. * List of blocks that can provide a repeatable content
  130579. */
  130580. repeatableContentBlocks: NodeMaterialBlock[];
  130581. /**
  130582. * List of blocks that can provide a dynamic list of uniforms
  130583. */
  130584. dynamicUniformBlocks: NodeMaterialBlock[];
  130585. /**
  130586. * List of blocks that can block the isReady function for the material
  130587. */
  130588. blockingBlocks: NodeMaterialBlock[];
  130589. /**
  130590. * Gets the list of animated inputs
  130591. */
  130592. animatedInputs: InputBlock[];
  130593. /**
  130594. * Build Id used to avoid multiple recompilations
  130595. */
  130596. buildId: number;
  130597. /** List of emitted variables */
  130598. variableNames: {
  130599. [key: string]: number;
  130600. };
  130601. /** List of emitted defines */
  130602. defineNames: {
  130603. [key: string]: number;
  130604. };
  130605. /** Should emit comments? */
  130606. emitComments: boolean;
  130607. /** Emit build activity */
  130608. verbose: boolean;
  130609. /** Gets or sets the hosting scene */
  130610. scene: Scene;
  130611. /**
  130612. * Gets the compilation hints emitted at compilation time
  130613. */
  130614. hints: {
  130615. needWorldViewMatrix: boolean;
  130616. needWorldViewProjectionMatrix: boolean;
  130617. needAlphaBlending: boolean;
  130618. needAlphaTesting: boolean;
  130619. };
  130620. /**
  130621. * List of compilation checks
  130622. */
  130623. checks: {
  130624. emitVertex: boolean;
  130625. emitFragment: boolean;
  130626. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130627. };
  130628. /** Creates a new shared data */
  130629. constructor();
  130630. /**
  130631. * Emits console errors and exceptions if there is a failing check
  130632. */
  130633. emitErrors(): void;
  130634. }
  130635. }
  130636. declare module BABYLON {
  130637. /**
  130638. * Class used to store node based material build state
  130639. */
  130640. export class NodeMaterialBuildState {
  130641. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130642. supportUniformBuffers: boolean;
  130643. /**
  130644. * Gets the list of emitted attributes
  130645. */
  130646. attributes: string[];
  130647. /**
  130648. * Gets the list of emitted uniforms
  130649. */
  130650. uniforms: string[];
  130651. /**
  130652. * Gets the list of emitted constants
  130653. */
  130654. constants: string[];
  130655. /**
  130656. * Gets the list of emitted samplers
  130657. */
  130658. samplers: string[];
  130659. /**
  130660. * Gets the list of emitted functions
  130661. */
  130662. functions: {
  130663. [key: string]: string;
  130664. };
  130665. /**
  130666. * Gets the list of emitted extensions
  130667. */
  130668. extensions: {
  130669. [key: string]: string;
  130670. };
  130671. /**
  130672. * Gets the target of the compilation state
  130673. */
  130674. target: NodeMaterialBlockTargets;
  130675. /**
  130676. * Gets the list of emitted counters
  130677. */
  130678. counters: {
  130679. [key: string]: number;
  130680. };
  130681. /**
  130682. * Shared data between multiple NodeMaterialBuildState instances
  130683. */
  130684. sharedData: NodeMaterialBuildStateSharedData;
  130685. /** @hidden */
  130686. _vertexState: NodeMaterialBuildState;
  130687. /** @hidden */
  130688. _attributeDeclaration: string;
  130689. /** @hidden */
  130690. _uniformDeclaration: string;
  130691. /** @hidden */
  130692. _constantDeclaration: string;
  130693. /** @hidden */
  130694. _samplerDeclaration: string;
  130695. /** @hidden */
  130696. _varyingTransfer: string;
  130697. private _repeatableContentAnchorIndex;
  130698. /** @hidden */
  130699. _builtCompilationString: string;
  130700. /**
  130701. * Gets the emitted compilation strings
  130702. */
  130703. compilationString: string;
  130704. /**
  130705. * Finalize the compilation strings
  130706. * @param state defines the current compilation state
  130707. */
  130708. finalize(state: NodeMaterialBuildState): void;
  130709. /** @hidden */
  130710. get _repeatableContentAnchor(): string;
  130711. /** @hidden */
  130712. _getFreeVariableName(prefix: string): string;
  130713. /** @hidden */
  130714. _getFreeDefineName(prefix: string): string;
  130715. /** @hidden */
  130716. _excludeVariableName(name: string): void;
  130717. /** @hidden */
  130718. _emit2DSampler(name: string): void;
  130719. /** @hidden */
  130720. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130721. /** @hidden */
  130722. _emitExtension(name: string, extension: string): void;
  130723. /** @hidden */
  130724. _emitFunction(name: string, code: string, comments: string): void;
  130725. /** @hidden */
  130726. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130727. replaceStrings?: {
  130728. search: RegExp;
  130729. replace: string;
  130730. }[];
  130731. repeatKey?: string;
  130732. }): string;
  130733. /** @hidden */
  130734. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130735. repeatKey?: string;
  130736. removeAttributes?: boolean;
  130737. removeUniforms?: boolean;
  130738. removeVaryings?: boolean;
  130739. removeIfDef?: boolean;
  130740. replaceStrings?: {
  130741. search: RegExp;
  130742. replace: string;
  130743. }[];
  130744. }, storeKey?: string): void;
  130745. /** @hidden */
  130746. _registerTempVariable(name: string): boolean;
  130747. /** @hidden */
  130748. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130749. /** @hidden */
  130750. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130751. /** @hidden */
  130752. _emitFloat(value: number): string;
  130753. }
  130754. }
  130755. declare module BABYLON {
  130756. /**
  130757. * Defines a block that can be used inside a node based material
  130758. */
  130759. export class NodeMaterialBlock {
  130760. private _buildId;
  130761. private _buildTarget;
  130762. private _target;
  130763. private _isFinalMerger;
  130764. private _isInput;
  130765. protected _isUnique: boolean;
  130766. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130767. inputsAreExclusive: boolean;
  130768. /** @hidden */
  130769. _codeVariableName: string;
  130770. /** @hidden */
  130771. _inputs: NodeMaterialConnectionPoint[];
  130772. /** @hidden */
  130773. _outputs: NodeMaterialConnectionPoint[];
  130774. /** @hidden */
  130775. _preparationId: number;
  130776. /**
  130777. * Gets or sets the name of the block
  130778. */
  130779. name: string;
  130780. /**
  130781. * Gets or sets the unique id of the node
  130782. */
  130783. uniqueId: number;
  130784. /**
  130785. * Gets or sets the comments associated with this block
  130786. */
  130787. comments: string;
  130788. /**
  130789. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130790. */
  130791. get isUnique(): boolean;
  130792. /**
  130793. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130794. */
  130795. get isFinalMerger(): boolean;
  130796. /**
  130797. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130798. */
  130799. get isInput(): boolean;
  130800. /**
  130801. * Gets or sets the build Id
  130802. */
  130803. get buildId(): number;
  130804. set buildId(value: number);
  130805. /**
  130806. * Gets or sets the target of the block
  130807. */
  130808. get target(): NodeMaterialBlockTargets;
  130809. set target(value: NodeMaterialBlockTargets);
  130810. /**
  130811. * Gets the list of input points
  130812. */
  130813. get inputs(): NodeMaterialConnectionPoint[];
  130814. /** Gets the list of output points */
  130815. get outputs(): NodeMaterialConnectionPoint[];
  130816. /**
  130817. * Find an input by its name
  130818. * @param name defines the name of the input to look for
  130819. * @returns the input or null if not found
  130820. */
  130821. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130822. /**
  130823. * Find an output by its name
  130824. * @param name defines the name of the outputto look for
  130825. * @returns the output or null if not found
  130826. */
  130827. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130828. /**
  130829. * Creates a new NodeMaterialBlock
  130830. * @param name defines the block name
  130831. * @param target defines the target of that block (Vertex by default)
  130832. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130833. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130834. */
  130835. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130836. /**
  130837. * Initialize the block and prepare the context for build
  130838. * @param state defines the state that will be used for the build
  130839. */
  130840. initialize(state: NodeMaterialBuildState): void;
  130841. /**
  130842. * Bind data to effect. Will only be called for blocks with isBindable === true
  130843. * @param effect defines the effect to bind data to
  130844. * @param nodeMaterial defines the hosting NodeMaterial
  130845. * @param mesh defines the mesh that will be rendered
  130846. */
  130847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130848. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130849. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130850. protected _writeFloat(value: number): string;
  130851. /**
  130852. * Gets the current class name e.g. "NodeMaterialBlock"
  130853. * @returns the class name
  130854. */
  130855. getClassName(): string;
  130856. /**
  130857. * Register a new input. Must be called inside a block constructor
  130858. * @param name defines the connection point name
  130859. * @param type defines the connection point type
  130860. * @param isOptional defines a boolean indicating that this input can be omitted
  130861. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130862. * @returns the current block
  130863. */
  130864. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130865. /**
  130866. * Register a new output. Must be called inside a block constructor
  130867. * @param name defines the connection point name
  130868. * @param type defines the connection point type
  130869. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130870. * @returns the current block
  130871. */
  130872. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130873. /**
  130874. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130875. * @param forOutput defines an optional connection point to check compatibility with
  130876. * @returns the first available input or null
  130877. */
  130878. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130879. /**
  130880. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130881. * @param forBlock defines an optional block to check compatibility with
  130882. * @returns the first available input or null
  130883. */
  130884. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130885. /**
  130886. * Gets the sibling of the given output
  130887. * @param current defines the current output
  130888. * @returns the next output in the list or null
  130889. */
  130890. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130891. /**
  130892. * Connect current block with another block
  130893. * @param other defines the block to connect with
  130894. * @param options define the various options to help pick the right connections
  130895. * @returns the current block
  130896. */
  130897. connectTo(other: NodeMaterialBlock, options?: {
  130898. input?: string;
  130899. output?: string;
  130900. outputSwizzle?: string;
  130901. }): this | undefined;
  130902. protected _buildBlock(state: NodeMaterialBuildState): void;
  130903. /**
  130904. * Add uniforms, samplers and uniform buffers at compilation time
  130905. * @param state defines the state to update
  130906. * @param nodeMaterial defines the node material requesting the update
  130907. * @param defines defines the material defines to update
  130908. * @param uniformBuffers defines the list of uniform buffer names
  130909. */
  130910. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130911. /**
  130912. * Add potential fallbacks if shader compilation fails
  130913. * @param mesh defines the mesh to be rendered
  130914. * @param fallbacks defines the current prioritized list of fallbacks
  130915. */
  130916. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130917. /**
  130918. * Initialize defines for shader compilation
  130919. * @param mesh defines the mesh to be rendered
  130920. * @param nodeMaterial defines the node material requesting the update
  130921. * @param defines defines the material defines to update
  130922. * @param useInstances specifies that instances should be used
  130923. */
  130924. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130925. /**
  130926. * Update defines for shader compilation
  130927. * @param mesh defines the mesh to be rendered
  130928. * @param nodeMaterial defines the node material requesting the update
  130929. * @param defines defines the material defines to update
  130930. * @param useInstances specifies that instances should be used
  130931. */
  130932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130933. /**
  130934. * Lets the block try to connect some inputs automatically
  130935. * @param material defines the hosting NodeMaterial
  130936. */
  130937. autoConfigure(material: NodeMaterial): void;
  130938. /**
  130939. * Function called when a block is declared as repeatable content generator
  130940. * @param vertexShaderState defines the current compilation state for the vertex shader
  130941. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130942. * @param mesh defines the mesh to be rendered
  130943. * @param defines defines the material defines to update
  130944. */
  130945. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130946. /**
  130947. * Checks if the block is ready
  130948. * @param mesh defines the mesh to be rendered
  130949. * @param nodeMaterial defines the node material requesting the update
  130950. * @param defines defines the material defines to update
  130951. * @param useInstances specifies that instances should be used
  130952. * @returns true if the block is ready
  130953. */
  130954. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130955. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130956. private _processBuild;
  130957. /**
  130958. * Compile the current node and generate the shader code
  130959. * @param state defines the current compilation state (uniforms, samplers, current string)
  130960. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130961. * @returns true if already built
  130962. */
  130963. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130964. protected _inputRename(name: string): string;
  130965. protected _outputRename(name: string): string;
  130966. protected _dumpPropertiesCode(): string;
  130967. /** @hidden */
  130968. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130969. /** @hidden */
  130970. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130971. /**
  130972. * Clone the current block to a new identical block
  130973. * @param scene defines the hosting scene
  130974. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130975. * @returns a copy of the current block
  130976. */
  130977. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130978. /**
  130979. * Serializes this block in a JSON representation
  130980. * @returns the serialized block object
  130981. */
  130982. serialize(): any;
  130983. /** @hidden */
  130984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130985. /**
  130986. * Release resources
  130987. */
  130988. dispose(): void;
  130989. }
  130990. }
  130991. declare module BABYLON {
  130992. /**
  130993. * Enum defining the type of animations supported by InputBlock
  130994. */
  130995. export enum AnimatedInputBlockTypes {
  130996. /** No animation */
  130997. None = 0,
  130998. /** Time based animation. Will only work for floats */
  130999. Time = 1
  131000. }
  131001. }
  131002. declare module BABYLON {
  131003. /**
  131004. * Block used to expose an input value
  131005. */
  131006. export class InputBlock extends NodeMaterialBlock {
  131007. private _mode;
  131008. private _associatedVariableName;
  131009. private _storedValue;
  131010. private _valueCallback;
  131011. private _type;
  131012. private _animationType;
  131013. /** Gets or set a value used to limit the range of float values */
  131014. min: number;
  131015. /** Gets or set a value used to limit the range of float values */
  131016. max: number;
  131017. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131018. isBoolean: boolean;
  131019. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131020. matrixMode: number;
  131021. /** @hidden */
  131022. _systemValue: Nullable<NodeMaterialSystemValues>;
  131023. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131024. visibleInInspector: boolean;
  131025. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131026. isConstant: boolean;
  131027. /** Gets or sets the group to use to display this block in the Inspector */
  131028. groupInInspector: string;
  131029. /** Gets an observable raised when the value is changed */
  131030. onValueChangedObservable: Observable<InputBlock>;
  131031. /**
  131032. * Gets or sets the connection point type (default is float)
  131033. */
  131034. get type(): NodeMaterialBlockConnectionPointTypes;
  131035. /**
  131036. * Creates a new InputBlock
  131037. * @param name defines the block name
  131038. * @param target defines the target of that block (Vertex by default)
  131039. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131040. */
  131041. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131042. /**
  131043. * Gets the output component
  131044. */
  131045. get output(): NodeMaterialConnectionPoint;
  131046. /**
  131047. * Set the source of this connection point to a vertex attribute
  131048. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131049. * @returns the current connection point
  131050. */
  131051. setAsAttribute(attributeName?: string): InputBlock;
  131052. /**
  131053. * Set the source of this connection point to a system value
  131054. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131055. * @returns the current connection point
  131056. */
  131057. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131058. /**
  131059. * Gets or sets the value of that point.
  131060. * Please note that this value will be ignored if valueCallback is defined
  131061. */
  131062. get value(): any;
  131063. set value(value: any);
  131064. /**
  131065. * Gets or sets a callback used to get the value of that point.
  131066. * Please note that setting this value will force the connection point to ignore the value property
  131067. */
  131068. get valueCallback(): () => any;
  131069. set valueCallback(value: () => any);
  131070. /**
  131071. * Gets or sets the associated variable name in the shader
  131072. */
  131073. get associatedVariableName(): string;
  131074. set associatedVariableName(value: string);
  131075. /** Gets or sets the type of animation applied to the input */
  131076. get animationType(): AnimatedInputBlockTypes;
  131077. set animationType(value: AnimatedInputBlockTypes);
  131078. /**
  131079. * Gets a boolean indicating that this connection point not defined yet
  131080. */
  131081. get isUndefined(): boolean;
  131082. /**
  131083. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131084. * In this case the connection point name must be the name of the uniform to use.
  131085. * Can only be set on inputs
  131086. */
  131087. get isUniform(): boolean;
  131088. set isUniform(value: boolean);
  131089. /**
  131090. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131091. * In this case the connection point name must be the name of the attribute to use
  131092. * Can only be set on inputs
  131093. */
  131094. get isAttribute(): boolean;
  131095. set isAttribute(value: boolean);
  131096. /**
  131097. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131098. * Can only be set on exit points
  131099. */
  131100. get isVarying(): boolean;
  131101. set isVarying(value: boolean);
  131102. /**
  131103. * Gets a boolean indicating that the current connection point is a system value
  131104. */
  131105. get isSystemValue(): boolean;
  131106. /**
  131107. * Gets or sets the current well known value or null if not defined as a system value
  131108. */
  131109. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131110. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131111. /**
  131112. * Gets the current class name
  131113. * @returns the class name
  131114. */
  131115. getClassName(): string;
  131116. /**
  131117. * Animate the input if animationType !== None
  131118. * @param scene defines the rendering scene
  131119. */
  131120. animate(scene: Scene): void;
  131121. private _emitDefine;
  131122. initialize(state: NodeMaterialBuildState): void;
  131123. /**
  131124. * Set the input block to its default value (based on its type)
  131125. */
  131126. setDefaultValue(): void;
  131127. private _emitConstant;
  131128. private _emit;
  131129. /** @hidden */
  131130. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131131. /** @hidden */
  131132. _transmit(effect: Effect, scene: Scene): void;
  131133. protected _buildBlock(state: NodeMaterialBuildState): void;
  131134. protected _dumpPropertiesCode(): string;
  131135. dispose(): void;
  131136. serialize(): any;
  131137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131138. }
  131139. }
  131140. declare module BABYLON {
  131141. /**
  131142. * Enum used to define the compatibility state between two connection points
  131143. */
  131144. export enum NodeMaterialConnectionPointCompatibilityStates {
  131145. /** Points are compatibles */
  131146. Compatible = 0,
  131147. /** Points are incompatible because of their types */
  131148. TypeIncompatible = 1,
  131149. /** Points are incompatible because of their targets (vertex vs fragment) */
  131150. TargetIncompatible = 2
  131151. }
  131152. /**
  131153. * Defines the direction of a connection point
  131154. */
  131155. export enum NodeMaterialConnectionPointDirection {
  131156. /** Input */
  131157. Input = 0,
  131158. /** Output */
  131159. Output = 1
  131160. }
  131161. /**
  131162. * Defines a connection point for a block
  131163. */
  131164. export class NodeMaterialConnectionPoint {
  131165. /** @hidden */
  131166. _ownerBlock: NodeMaterialBlock;
  131167. /** @hidden */
  131168. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131169. private _endpoints;
  131170. private _associatedVariableName;
  131171. private _direction;
  131172. /** @hidden */
  131173. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131174. /** @hidden */
  131175. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131176. private _type;
  131177. /** @hidden */
  131178. _enforceAssociatedVariableName: boolean;
  131179. /** Gets the direction of the point */
  131180. get direction(): NodeMaterialConnectionPointDirection;
  131181. /**
  131182. * Gets or sets the additional types supported by this connection point
  131183. */
  131184. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131185. /**
  131186. * Gets or sets the additional types excluded by this connection point
  131187. */
  131188. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131189. /**
  131190. * Observable triggered when this point is connected
  131191. */
  131192. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131193. /**
  131194. * Gets or sets the associated variable name in the shader
  131195. */
  131196. get associatedVariableName(): string;
  131197. set associatedVariableName(value: string);
  131198. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131199. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131200. /**
  131201. * Gets or sets the connection point type (default is float)
  131202. */
  131203. get type(): NodeMaterialBlockConnectionPointTypes;
  131204. set type(value: NodeMaterialBlockConnectionPointTypes);
  131205. /**
  131206. * Gets or sets the connection point name
  131207. */
  131208. name: string;
  131209. /**
  131210. * Gets or sets a boolean indicating that this connection point can be omitted
  131211. */
  131212. isOptional: boolean;
  131213. /**
  131214. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131215. */
  131216. define: string;
  131217. /** @hidden */
  131218. _prioritizeVertex: boolean;
  131219. private _target;
  131220. /** Gets or sets the target of that connection point */
  131221. get target(): NodeMaterialBlockTargets;
  131222. set target(value: NodeMaterialBlockTargets);
  131223. /**
  131224. * Gets a boolean indicating that the current point is connected
  131225. */
  131226. get isConnected(): boolean;
  131227. /**
  131228. * Gets a boolean indicating that the current point is connected to an input block
  131229. */
  131230. get isConnectedToInputBlock(): boolean;
  131231. /**
  131232. * Gets a the connected input block (if any)
  131233. */
  131234. get connectInputBlock(): Nullable<InputBlock>;
  131235. /** Get the other side of the connection (if any) */
  131236. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131237. /** Get the block that owns this connection point */
  131238. get ownerBlock(): NodeMaterialBlock;
  131239. /** Get the block connected on the other side of this connection (if any) */
  131240. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131241. /** Get the block connected on the endpoints of this connection (if any) */
  131242. get connectedBlocks(): Array<NodeMaterialBlock>;
  131243. /** Gets the list of connected endpoints */
  131244. get endpoints(): NodeMaterialConnectionPoint[];
  131245. /** Gets a boolean indicating if that output point is connected to at least one input */
  131246. get hasEndpoints(): boolean;
  131247. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131248. get isConnectedInVertexShader(): boolean;
  131249. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131250. get isConnectedInFragmentShader(): boolean;
  131251. /**
  131252. * Creates a new connection point
  131253. * @param name defines the connection point name
  131254. * @param ownerBlock defines the block hosting this connection point
  131255. * @param direction defines the direction of the connection point
  131256. */
  131257. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131258. /**
  131259. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131260. * @returns the class name
  131261. */
  131262. getClassName(): string;
  131263. /**
  131264. * Gets a boolean indicating if the current point can be connected to another point
  131265. * @param connectionPoint defines the other connection point
  131266. * @returns a boolean
  131267. */
  131268. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131269. /**
  131270. * Gets a number indicating if the current point can be connected to another point
  131271. * @param connectionPoint defines the other connection point
  131272. * @returns a number defining the compatibility state
  131273. */
  131274. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131275. /**
  131276. * Connect this point to another connection point
  131277. * @param connectionPoint defines the other connection point
  131278. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131279. * @returns the current connection point
  131280. */
  131281. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131282. /**
  131283. * Disconnect this point from one of his endpoint
  131284. * @param endpoint defines the other connection point
  131285. * @returns the current connection point
  131286. */
  131287. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131288. /**
  131289. * Serializes this point in a JSON representation
  131290. * @returns the serialized point object
  131291. */
  131292. serialize(): any;
  131293. /**
  131294. * Release resources
  131295. */
  131296. dispose(): void;
  131297. }
  131298. }
  131299. declare module BABYLON {
  131300. /**
  131301. * Block used to add support for vertex skinning (bones)
  131302. */
  131303. export class BonesBlock extends NodeMaterialBlock {
  131304. /**
  131305. * Creates a new BonesBlock
  131306. * @param name defines the block name
  131307. */
  131308. constructor(name: string);
  131309. /**
  131310. * Initialize the block and prepare the context for build
  131311. * @param state defines the state that will be used for the build
  131312. */
  131313. initialize(state: NodeMaterialBuildState): void;
  131314. /**
  131315. * Gets the current class name
  131316. * @returns the class name
  131317. */
  131318. getClassName(): string;
  131319. /**
  131320. * Gets the matrix indices input component
  131321. */
  131322. get matricesIndices(): NodeMaterialConnectionPoint;
  131323. /**
  131324. * Gets the matrix weights input component
  131325. */
  131326. get matricesWeights(): NodeMaterialConnectionPoint;
  131327. /**
  131328. * Gets the extra matrix indices input component
  131329. */
  131330. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131331. /**
  131332. * Gets the extra matrix weights input component
  131333. */
  131334. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131335. /**
  131336. * Gets the world input component
  131337. */
  131338. get world(): NodeMaterialConnectionPoint;
  131339. /**
  131340. * Gets the output component
  131341. */
  131342. get output(): NodeMaterialConnectionPoint;
  131343. autoConfigure(material: NodeMaterial): void;
  131344. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131347. protected _buildBlock(state: NodeMaterialBuildState): this;
  131348. }
  131349. }
  131350. declare module BABYLON {
  131351. /**
  131352. * Block used to add support for instances
  131353. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131354. */
  131355. export class InstancesBlock extends NodeMaterialBlock {
  131356. /**
  131357. * Creates a new InstancesBlock
  131358. * @param name defines the block name
  131359. */
  131360. constructor(name: string);
  131361. /**
  131362. * Gets the current class name
  131363. * @returns the class name
  131364. */
  131365. getClassName(): string;
  131366. /**
  131367. * Gets the first world row input component
  131368. */
  131369. get world0(): NodeMaterialConnectionPoint;
  131370. /**
  131371. * Gets the second world row input component
  131372. */
  131373. get world1(): NodeMaterialConnectionPoint;
  131374. /**
  131375. * Gets the third world row input component
  131376. */
  131377. get world2(): NodeMaterialConnectionPoint;
  131378. /**
  131379. * Gets the forth world row input component
  131380. */
  131381. get world3(): NodeMaterialConnectionPoint;
  131382. /**
  131383. * Gets the world input component
  131384. */
  131385. get world(): NodeMaterialConnectionPoint;
  131386. /**
  131387. * Gets the output component
  131388. */
  131389. get output(): NodeMaterialConnectionPoint;
  131390. /**
  131391. * Gets the isntanceID component
  131392. */
  131393. get instanceID(): NodeMaterialConnectionPoint;
  131394. autoConfigure(material: NodeMaterial): void;
  131395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131396. protected _buildBlock(state: NodeMaterialBuildState): this;
  131397. }
  131398. }
  131399. declare module BABYLON {
  131400. /**
  131401. * Block used to add morph targets support to vertex shader
  131402. */
  131403. export class MorphTargetsBlock extends NodeMaterialBlock {
  131404. private _repeatableContentAnchor;
  131405. /**
  131406. * Create a new MorphTargetsBlock
  131407. * @param name defines the block name
  131408. */
  131409. constructor(name: string);
  131410. /**
  131411. * Gets the current class name
  131412. * @returns the class name
  131413. */
  131414. getClassName(): string;
  131415. /**
  131416. * Gets the position input component
  131417. */
  131418. get position(): NodeMaterialConnectionPoint;
  131419. /**
  131420. * Gets the normal input component
  131421. */
  131422. get normal(): NodeMaterialConnectionPoint;
  131423. /**
  131424. * Gets the tangent input component
  131425. */
  131426. get tangent(): NodeMaterialConnectionPoint;
  131427. /**
  131428. * Gets the tangent input component
  131429. */
  131430. get uv(): NodeMaterialConnectionPoint;
  131431. /**
  131432. * Gets the position output component
  131433. */
  131434. get positionOutput(): NodeMaterialConnectionPoint;
  131435. /**
  131436. * Gets the normal output component
  131437. */
  131438. get normalOutput(): NodeMaterialConnectionPoint;
  131439. /**
  131440. * Gets the tangent output component
  131441. */
  131442. get tangentOutput(): NodeMaterialConnectionPoint;
  131443. /**
  131444. * Gets the tangent output component
  131445. */
  131446. get uvOutput(): NodeMaterialConnectionPoint;
  131447. initialize(state: NodeMaterialBuildState): void;
  131448. autoConfigure(material: NodeMaterial): void;
  131449. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131451. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131452. protected _buildBlock(state: NodeMaterialBuildState): this;
  131453. }
  131454. }
  131455. declare module BABYLON {
  131456. /**
  131457. * Block used to get data information from a light
  131458. */
  131459. export class LightInformationBlock extends NodeMaterialBlock {
  131460. private _lightDataUniformName;
  131461. private _lightColorUniformName;
  131462. private _lightTypeDefineName;
  131463. /**
  131464. * Gets or sets the light associated with this block
  131465. */
  131466. light: Nullable<Light>;
  131467. /**
  131468. * Creates a new LightInformationBlock
  131469. * @param name defines the block name
  131470. */
  131471. constructor(name: string);
  131472. /**
  131473. * Gets the current class name
  131474. * @returns the class name
  131475. */
  131476. getClassName(): string;
  131477. /**
  131478. * Gets the world position input component
  131479. */
  131480. get worldPosition(): NodeMaterialConnectionPoint;
  131481. /**
  131482. * Gets the direction output component
  131483. */
  131484. get direction(): NodeMaterialConnectionPoint;
  131485. /**
  131486. * Gets the direction output component
  131487. */
  131488. get color(): NodeMaterialConnectionPoint;
  131489. /**
  131490. * Gets the direction output component
  131491. */
  131492. get intensity(): NodeMaterialConnectionPoint;
  131493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131495. protected _buildBlock(state: NodeMaterialBuildState): this;
  131496. serialize(): any;
  131497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131498. }
  131499. }
  131500. declare module BABYLON {
  131501. /**
  131502. * Block used to add image processing support to fragment shader
  131503. */
  131504. export class ImageProcessingBlock extends NodeMaterialBlock {
  131505. /**
  131506. * Create a new ImageProcessingBlock
  131507. * @param name defines the block name
  131508. */
  131509. constructor(name: string);
  131510. /**
  131511. * Gets the current class name
  131512. * @returns the class name
  131513. */
  131514. getClassName(): string;
  131515. /**
  131516. * Gets the color input component
  131517. */
  131518. get color(): NodeMaterialConnectionPoint;
  131519. /**
  131520. * Gets the output component
  131521. */
  131522. get output(): NodeMaterialConnectionPoint;
  131523. /**
  131524. * Initialize the block and prepare the context for build
  131525. * @param state defines the state that will be used for the build
  131526. */
  131527. initialize(state: NodeMaterialBuildState): void;
  131528. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131530. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131531. protected _buildBlock(state: NodeMaterialBuildState): this;
  131532. }
  131533. }
  131534. declare module BABYLON {
  131535. /**
  131536. * Block used to pertub normals based on a normal map
  131537. */
  131538. export class PerturbNormalBlock extends NodeMaterialBlock {
  131539. private _tangentSpaceParameterName;
  131540. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131541. invertX: boolean;
  131542. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131543. invertY: boolean;
  131544. /**
  131545. * Create a new PerturbNormalBlock
  131546. * @param name defines the block name
  131547. */
  131548. constructor(name: string);
  131549. /**
  131550. * Gets the current class name
  131551. * @returns the class name
  131552. */
  131553. getClassName(): string;
  131554. /**
  131555. * Gets the world position input component
  131556. */
  131557. get worldPosition(): NodeMaterialConnectionPoint;
  131558. /**
  131559. * Gets the world normal input component
  131560. */
  131561. get worldNormal(): NodeMaterialConnectionPoint;
  131562. /**
  131563. * Gets the world tangent input component
  131564. */
  131565. get worldTangent(): NodeMaterialConnectionPoint;
  131566. /**
  131567. * Gets the uv input component
  131568. */
  131569. get uv(): NodeMaterialConnectionPoint;
  131570. /**
  131571. * Gets the normal map color input component
  131572. */
  131573. get normalMapColor(): NodeMaterialConnectionPoint;
  131574. /**
  131575. * Gets the strength input component
  131576. */
  131577. get strength(): NodeMaterialConnectionPoint;
  131578. /**
  131579. * Gets the output component
  131580. */
  131581. get output(): NodeMaterialConnectionPoint;
  131582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131584. autoConfigure(material: NodeMaterial): void;
  131585. protected _buildBlock(state: NodeMaterialBuildState): this;
  131586. protected _dumpPropertiesCode(): string;
  131587. serialize(): any;
  131588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131589. }
  131590. }
  131591. declare module BABYLON {
  131592. /**
  131593. * Block used to discard a pixel if a value is smaller than a cutoff
  131594. */
  131595. export class DiscardBlock extends NodeMaterialBlock {
  131596. /**
  131597. * Create a new DiscardBlock
  131598. * @param name defines the block name
  131599. */
  131600. constructor(name: string);
  131601. /**
  131602. * Gets the current class name
  131603. * @returns the class name
  131604. */
  131605. getClassName(): string;
  131606. /**
  131607. * Gets the color input component
  131608. */
  131609. get value(): NodeMaterialConnectionPoint;
  131610. /**
  131611. * Gets the cutoff input component
  131612. */
  131613. get cutoff(): NodeMaterialConnectionPoint;
  131614. protected _buildBlock(state: NodeMaterialBuildState): this;
  131615. }
  131616. }
  131617. declare module BABYLON {
  131618. /**
  131619. * Block used to test if the fragment shader is front facing
  131620. */
  131621. export class FrontFacingBlock extends NodeMaterialBlock {
  131622. /**
  131623. * Creates a new FrontFacingBlock
  131624. * @param name defines the block name
  131625. */
  131626. constructor(name: string);
  131627. /**
  131628. * Gets the current class name
  131629. * @returns the class name
  131630. */
  131631. getClassName(): string;
  131632. /**
  131633. * Gets the output component
  131634. */
  131635. get output(): NodeMaterialConnectionPoint;
  131636. protected _buildBlock(state: NodeMaterialBuildState): this;
  131637. }
  131638. }
  131639. declare module BABYLON {
  131640. /**
  131641. * Block used to get the derivative value on x and y of a given input
  131642. */
  131643. export class DerivativeBlock extends NodeMaterialBlock {
  131644. /**
  131645. * Create a new DerivativeBlock
  131646. * @param name defines the block name
  131647. */
  131648. constructor(name: string);
  131649. /**
  131650. * Gets the current class name
  131651. * @returns the class name
  131652. */
  131653. getClassName(): string;
  131654. /**
  131655. * Gets the input component
  131656. */
  131657. get input(): NodeMaterialConnectionPoint;
  131658. /**
  131659. * Gets the derivative output on x
  131660. */
  131661. get dx(): NodeMaterialConnectionPoint;
  131662. /**
  131663. * Gets the derivative output on y
  131664. */
  131665. get dy(): NodeMaterialConnectionPoint;
  131666. protected _buildBlock(state: NodeMaterialBuildState): this;
  131667. }
  131668. }
  131669. declare module BABYLON {
  131670. /**
  131671. * Block used to add support for scene fog
  131672. */
  131673. export class FogBlock extends NodeMaterialBlock {
  131674. private _fogDistanceName;
  131675. private _fogParameters;
  131676. /**
  131677. * Create a new FogBlock
  131678. * @param name defines the block name
  131679. */
  131680. constructor(name: string);
  131681. /**
  131682. * Gets the current class name
  131683. * @returns the class name
  131684. */
  131685. getClassName(): string;
  131686. /**
  131687. * Gets the world position input component
  131688. */
  131689. get worldPosition(): NodeMaterialConnectionPoint;
  131690. /**
  131691. * Gets the view input component
  131692. */
  131693. get view(): NodeMaterialConnectionPoint;
  131694. /**
  131695. * Gets the color input component
  131696. */
  131697. get input(): NodeMaterialConnectionPoint;
  131698. /**
  131699. * Gets the fog color input component
  131700. */
  131701. get fogColor(): NodeMaterialConnectionPoint;
  131702. /**
  131703. * Gets the output component
  131704. */
  131705. get output(): NodeMaterialConnectionPoint;
  131706. autoConfigure(material: NodeMaterial): void;
  131707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131709. protected _buildBlock(state: NodeMaterialBuildState): this;
  131710. }
  131711. }
  131712. declare module BABYLON {
  131713. /**
  131714. * Block used to add light in the fragment shader
  131715. */
  131716. export class LightBlock extends NodeMaterialBlock {
  131717. private _lightId;
  131718. /**
  131719. * Gets or sets the light associated with this block
  131720. */
  131721. light: Nullable<Light>;
  131722. /**
  131723. * Create a new LightBlock
  131724. * @param name defines the block name
  131725. */
  131726. constructor(name: string);
  131727. /**
  131728. * Gets the current class name
  131729. * @returns the class name
  131730. */
  131731. getClassName(): string;
  131732. /**
  131733. * Gets the world position input component
  131734. */
  131735. get worldPosition(): NodeMaterialConnectionPoint;
  131736. /**
  131737. * Gets the world normal input component
  131738. */
  131739. get worldNormal(): NodeMaterialConnectionPoint;
  131740. /**
  131741. * Gets the camera (or eye) position component
  131742. */
  131743. get cameraPosition(): NodeMaterialConnectionPoint;
  131744. /**
  131745. * Gets the glossiness component
  131746. */
  131747. get glossiness(): NodeMaterialConnectionPoint;
  131748. /**
  131749. * Gets the glossinness power component
  131750. */
  131751. get glossPower(): NodeMaterialConnectionPoint;
  131752. /**
  131753. * Gets the diffuse color component
  131754. */
  131755. get diffuseColor(): NodeMaterialConnectionPoint;
  131756. /**
  131757. * Gets the specular color component
  131758. */
  131759. get specularColor(): NodeMaterialConnectionPoint;
  131760. /**
  131761. * Gets the diffuse output component
  131762. */
  131763. get diffuseOutput(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Gets the specular output component
  131766. */
  131767. get specularOutput(): NodeMaterialConnectionPoint;
  131768. /**
  131769. * Gets the shadow output component
  131770. */
  131771. get shadow(): NodeMaterialConnectionPoint;
  131772. autoConfigure(material: NodeMaterial): void;
  131773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131774. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131775. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131776. private _injectVertexCode;
  131777. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131778. serialize(): any;
  131779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131780. }
  131781. }
  131782. declare module BABYLON {
  131783. /**
  131784. * Block used to multiply 2 values
  131785. */
  131786. export class MultiplyBlock extends NodeMaterialBlock {
  131787. /**
  131788. * Creates a new MultiplyBlock
  131789. * @param name defines the block name
  131790. */
  131791. constructor(name: string);
  131792. /**
  131793. * Gets the current class name
  131794. * @returns the class name
  131795. */
  131796. getClassName(): string;
  131797. /**
  131798. * Gets the left operand input component
  131799. */
  131800. get left(): NodeMaterialConnectionPoint;
  131801. /**
  131802. * Gets the right operand input component
  131803. */
  131804. get right(): NodeMaterialConnectionPoint;
  131805. /**
  131806. * Gets the output component
  131807. */
  131808. get output(): NodeMaterialConnectionPoint;
  131809. protected _buildBlock(state: NodeMaterialBuildState): this;
  131810. }
  131811. }
  131812. declare module BABYLON {
  131813. /**
  131814. * Block used to add 2 vectors
  131815. */
  131816. export class AddBlock extends NodeMaterialBlock {
  131817. /**
  131818. * Creates a new AddBlock
  131819. * @param name defines the block name
  131820. */
  131821. constructor(name: string);
  131822. /**
  131823. * Gets the current class name
  131824. * @returns the class name
  131825. */
  131826. getClassName(): string;
  131827. /**
  131828. * Gets the left operand input component
  131829. */
  131830. get left(): NodeMaterialConnectionPoint;
  131831. /**
  131832. * Gets the right operand input component
  131833. */
  131834. get right(): NodeMaterialConnectionPoint;
  131835. /**
  131836. * Gets the output component
  131837. */
  131838. get output(): NodeMaterialConnectionPoint;
  131839. protected _buildBlock(state: NodeMaterialBuildState): this;
  131840. }
  131841. }
  131842. declare module BABYLON {
  131843. /**
  131844. * Block used to scale a vector by a float
  131845. */
  131846. export class ScaleBlock extends NodeMaterialBlock {
  131847. /**
  131848. * Creates a new ScaleBlock
  131849. * @param name defines the block name
  131850. */
  131851. constructor(name: string);
  131852. /**
  131853. * Gets the current class name
  131854. * @returns the class name
  131855. */
  131856. getClassName(): string;
  131857. /**
  131858. * Gets the input component
  131859. */
  131860. get input(): NodeMaterialConnectionPoint;
  131861. /**
  131862. * Gets the factor input component
  131863. */
  131864. get factor(): NodeMaterialConnectionPoint;
  131865. /**
  131866. * Gets the output component
  131867. */
  131868. get output(): NodeMaterialConnectionPoint;
  131869. protected _buildBlock(state: NodeMaterialBuildState): this;
  131870. }
  131871. }
  131872. declare module BABYLON {
  131873. /**
  131874. * Block used to clamp a float
  131875. */
  131876. export class ClampBlock extends NodeMaterialBlock {
  131877. /** Gets or sets the minimum range */
  131878. minimum: number;
  131879. /** Gets or sets the maximum range */
  131880. maximum: number;
  131881. /**
  131882. * Creates a new ClampBlock
  131883. * @param name defines the block name
  131884. */
  131885. constructor(name: string);
  131886. /**
  131887. * Gets the current class name
  131888. * @returns the class name
  131889. */
  131890. getClassName(): string;
  131891. /**
  131892. * Gets the value input component
  131893. */
  131894. get value(): NodeMaterialConnectionPoint;
  131895. /**
  131896. * Gets the output component
  131897. */
  131898. get output(): NodeMaterialConnectionPoint;
  131899. protected _buildBlock(state: NodeMaterialBuildState): this;
  131900. protected _dumpPropertiesCode(): string;
  131901. serialize(): any;
  131902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131903. }
  131904. }
  131905. declare module BABYLON {
  131906. /**
  131907. * Block used to apply a cross product between 2 vectors
  131908. */
  131909. export class CrossBlock extends NodeMaterialBlock {
  131910. /**
  131911. * Creates a new CrossBlock
  131912. * @param name defines the block name
  131913. */
  131914. constructor(name: string);
  131915. /**
  131916. * Gets the current class name
  131917. * @returns the class name
  131918. */
  131919. getClassName(): string;
  131920. /**
  131921. * Gets the left operand input component
  131922. */
  131923. get left(): NodeMaterialConnectionPoint;
  131924. /**
  131925. * Gets the right operand input component
  131926. */
  131927. get right(): NodeMaterialConnectionPoint;
  131928. /**
  131929. * Gets the output component
  131930. */
  131931. get output(): NodeMaterialConnectionPoint;
  131932. protected _buildBlock(state: NodeMaterialBuildState): this;
  131933. }
  131934. }
  131935. declare module BABYLON {
  131936. /**
  131937. * Block used to apply a dot product between 2 vectors
  131938. */
  131939. export class DotBlock extends NodeMaterialBlock {
  131940. /**
  131941. * Creates a new DotBlock
  131942. * @param name defines the block name
  131943. */
  131944. constructor(name: string);
  131945. /**
  131946. * Gets the current class name
  131947. * @returns the class name
  131948. */
  131949. getClassName(): string;
  131950. /**
  131951. * Gets the left operand input component
  131952. */
  131953. get left(): NodeMaterialConnectionPoint;
  131954. /**
  131955. * Gets the right operand input component
  131956. */
  131957. get right(): NodeMaterialConnectionPoint;
  131958. /**
  131959. * Gets the output component
  131960. */
  131961. get output(): NodeMaterialConnectionPoint;
  131962. protected _buildBlock(state: NodeMaterialBuildState): this;
  131963. }
  131964. }
  131965. declare module BABYLON {
  131966. /**
  131967. * Block used to remap a float from a range to a new one
  131968. */
  131969. export class RemapBlock extends NodeMaterialBlock {
  131970. /**
  131971. * Gets or sets the source range
  131972. */
  131973. sourceRange: Vector2;
  131974. /**
  131975. * Gets or sets the target range
  131976. */
  131977. targetRange: Vector2;
  131978. /**
  131979. * Creates a new RemapBlock
  131980. * @param name defines the block name
  131981. */
  131982. constructor(name: string);
  131983. /**
  131984. * Gets the current class name
  131985. * @returns the class name
  131986. */
  131987. getClassName(): string;
  131988. /**
  131989. * Gets the input component
  131990. */
  131991. get input(): NodeMaterialConnectionPoint;
  131992. /**
  131993. * Gets the source min input component
  131994. */
  131995. get sourceMin(): NodeMaterialConnectionPoint;
  131996. /**
  131997. * Gets the source max input component
  131998. */
  131999. get sourceMax(): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Gets the target min input component
  132002. */
  132003. get targetMin(): NodeMaterialConnectionPoint;
  132004. /**
  132005. * Gets the target max input component
  132006. */
  132007. get targetMax(): NodeMaterialConnectionPoint;
  132008. /**
  132009. * Gets the output component
  132010. */
  132011. get output(): NodeMaterialConnectionPoint;
  132012. protected _buildBlock(state: NodeMaterialBuildState): this;
  132013. protected _dumpPropertiesCode(): string;
  132014. serialize(): any;
  132015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132016. }
  132017. }
  132018. declare module BABYLON {
  132019. /**
  132020. * Block used to normalize a vector
  132021. */
  132022. export class NormalizeBlock extends NodeMaterialBlock {
  132023. /**
  132024. * Creates a new NormalizeBlock
  132025. * @param name defines the block name
  132026. */
  132027. constructor(name: string);
  132028. /**
  132029. * Gets the current class name
  132030. * @returns the class name
  132031. */
  132032. getClassName(): string;
  132033. /**
  132034. * Gets the input component
  132035. */
  132036. get input(): NodeMaterialConnectionPoint;
  132037. /**
  132038. * Gets the output component
  132039. */
  132040. get output(): NodeMaterialConnectionPoint;
  132041. protected _buildBlock(state: NodeMaterialBuildState): this;
  132042. }
  132043. }
  132044. declare module BABYLON {
  132045. /**
  132046. * Operations supported by the Trigonometry block
  132047. */
  132048. export enum TrigonometryBlockOperations {
  132049. /** Cos */
  132050. Cos = 0,
  132051. /** Sin */
  132052. Sin = 1,
  132053. /** Abs */
  132054. Abs = 2,
  132055. /** Exp */
  132056. Exp = 3,
  132057. /** Exp2 */
  132058. Exp2 = 4,
  132059. /** Round */
  132060. Round = 5,
  132061. /** Floor */
  132062. Floor = 6,
  132063. /** Ceiling */
  132064. Ceiling = 7,
  132065. /** Square root */
  132066. Sqrt = 8,
  132067. /** Log */
  132068. Log = 9,
  132069. /** Tangent */
  132070. Tan = 10,
  132071. /** Arc tangent */
  132072. ArcTan = 11,
  132073. /** Arc cosinus */
  132074. ArcCos = 12,
  132075. /** Arc sinus */
  132076. ArcSin = 13,
  132077. /** Fraction */
  132078. Fract = 14,
  132079. /** Sign */
  132080. Sign = 15,
  132081. /** To radians (from degrees) */
  132082. Radians = 16,
  132083. /** To degrees (from radians) */
  132084. Degrees = 17
  132085. }
  132086. /**
  132087. * Block used to apply trigonometry operation to floats
  132088. */
  132089. export class TrigonometryBlock extends NodeMaterialBlock {
  132090. /**
  132091. * Gets or sets the operation applied by the block
  132092. */
  132093. operation: TrigonometryBlockOperations;
  132094. /**
  132095. * Creates a new TrigonometryBlock
  132096. * @param name defines the block name
  132097. */
  132098. constructor(name: string);
  132099. /**
  132100. * Gets the current class name
  132101. * @returns the class name
  132102. */
  132103. getClassName(): string;
  132104. /**
  132105. * Gets the input component
  132106. */
  132107. get input(): NodeMaterialConnectionPoint;
  132108. /**
  132109. * Gets the output component
  132110. */
  132111. get output(): NodeMaterialConnectionPoint;
  132112. protected _buildBlock(state: NodeMaterialBuildState): this;
  132113. serialize(): any;
  132114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132115. protected _dumpPropertiesCode(): string;
  132116. }
  132117. }
  132118. declare module BABYLON {
  132119. /**
  132120. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132121. */
  132122. export class ColorMergerBlock extends NodeMaterialBlock {
  132123. /**
  132124. * Create a new ColorMergerBlock
  132125. * @param name defines the block name
  132126. */
  132127. constructor(name: string);
  132128. /**
  132129. * Gets the current class name
  132130. * @returns the class name
  132131. */
  132132. getClassName(): string;
  132133. /**
  132134. * Gets the rgb component (input)
  132135. */
  132136. get rgbIn(): NodeMaterialConnectionPoint;
  132137. /**
  132138. * Gets the r component (input)
  132139. */
  132140. get r(): NodeMaterialConnectionPoint;
  132141. /**
  132142. * Gets the g component (input)
  132143. */
  132144. get g(): NodeMaterialConnectionPoint;
  132145. /**
  132146. * Gets the b component (input)
  132147. */
  132148. get b(): NodeMaterialConnectionPoint;
  132149. /**
  132150. * Gets the a component (input)
  132151. */
  132152. get a(): NodeMaterialConnectionPoint;
  132153. /**
  132154. * Gets the rgba component (output)
  132155. */
  132156. get rgba(): NodeMaterialConnectionPoint;
  132157. /**
  132158. * Gets the rgb component (output)
  132159. */
  132160. get rgbOut(): NodeMaterialConnectionPoint;
  132161. /**
  132162. * Gets the rgb component (output)
  132163. * @deprecated Please use rgbOut instead.
  132164. */
  132165. get rgb(): NodeMaterialConnectionPoint;
  132166. protected _buildBlock(state: NodeMaterialBuildState): this;
  132167. }
  132168. }
  132169. declare module BABYLON {
  132170. /**
  132171. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132172. */
  132173. export class VectorMergerBlock extends NodeMaterialBlock {
  132174. /**
  132175. * Create a new VectorMergerBlock
  132176. * @param name defines the block name
  132177. */
  132178. constructor(name: string);
  132179. /**
  132180. * Gets the current class name
  132181. * @returns the class name
  132182. */
  132183. getClassName(): string;
  132184. /**
  132185. * Gets the xyz component (input)
  132186. */
  132187. get xyzIn(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the xy component (input)
  132190. */
  132191. get xyIn(): NodeMaterialConnectionPoint;
  132192. /**
  132193. * Gets the x component (input)
  132194. */
  132195. get x(): NodeMaterialConnectionPoint;
  132196. /**
  132197. * Gets the y component (input)
  132198. */
  132199. get y(): NodeMaterialConnectionPoint;
  132200. /**
  132201. * Gets the z component (input)
  132202. */
  132203. get z(): NodeMaterialConnectionPoint;
  132204. /**
  132205. * Gets the w component (input)
  132206. */
  132207. get w(): NodeMaterialConnectionPoint;
  132208. /**
  132209. * Gets the xyzw component (output)
  132210. */
  132211. get xyzw(): NodeMaterialConnectionPoint;
  132212. /**
  132213. * Gets the xyz component (output)
  132214. */
  132215. get xyzOut(): NodeMaterialConnectionPoint;
  132216. /**
  132217. * Gets the xy component (output)
  132218. */
  132219. get xyOut(): NodeMaterialConnectionPoint;
  132220. /**
  132221. * Gets the xy component (output)
  132222. * @deprecated Please use xyOut instead.
  132223. */
  132224. get xy(): NodeMaterialConnectionPoint;
  132225. /**
  132226. * Gets the xyz component (output)
  132227. * @deprecated Please use xyzOut instead.
  132228. */
  132229. get xyz(): NodeMaterialConnectionPoint;
  132230. protected _buildBlock(state: NodeMaterialBuildState): this;
  132231. }
  132232. }
  132233. declare module BABYLON {
  132234. /**
  132235. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132236. */
  132237. export class ColorSplitterBlock extends NodeMaterialBlock {
  132238. /**
  132239. * Create a new ColorSplitterBlock
  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 rgba component (input)
  132250. */
  132251. get rgba(): NodeMaterialConnectionPoint;
  132252. /**
  132253. * Gets the rgb component (input)
  132254. */
  132255. get rgbIn(): NodeMaterialConnectionPoint;
  132256. /**
  132257. * Gets the rgb component (output)
  132258. */
  132259. get rgbOut(): NodeMaterialConnectionPoint;
  132260. /**
  132261. * Gets the r component (output)
  132262. */
  132263. get r(): NodeMaterialConnectionPoint;
  132264. /**
  132265. * Gets the g component (output)
  132266. */
  132267. get g(): NodeMaterialConnectionPoint;
  132268. /**
  132269. * Gets the b component (output)
  132270. */
  132271. get b(): NodeMaterialConnectionPoint;
  132272. /**
  132273. * Gets the a component (output)
  132274. */
  132275. get a(): NodeMaterialConnectionPoint;
  132276. protected _inputRename(name: string): string;
  132277. protected _outputRename(name: string): string;
  132278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132279. }
  132280. }
  132281. declare module BABYLON {
  132282. /**
  132283. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132284. */
  132285. export class VectorSplitterBlock extends NodeMaterialBlock {
  132286. /**
  132287. * Create a new VectorSplitterBlock
  132288. * @param name defines the block name
  132289. */
  132290. constructor(name: string);
  132291. /**
  132292. * Gets the current class name
  132293. * @returns the class name
  132294. */
  132295. getClassName(): string;
  132296. /**
  132297. * Gets the xyzw component (input)
  132298. */
  132299. get xyzw(): NodeMaterialConnectionPoint;
  132300. /**
  132301. * Gets the xyz component (input)
  132302. */
  132303. get xyzIn(): NodeMaterialConnectionPoint;
  132304. /**
  132305. * Gets the xy component (input)
  132306. */
  132307. get xyIn(): NodeMaterialConnectionPoint;
  132308. /**
  132309. * Gets the xyz component (output)
  132310. */
  132311. get xyzOut(): NodeMaterialConnectionPoint;
  132312. /**
  132313. * Gets the xy component (output)
  132314. */
  132315. get xyOut(): NodeMaterialConnectionPoint;
  132316. /**
  132317. * Gets the x component (output)
  132318. */
  132319. get x(): NodeMaterialConnectionPoint;
  132320. /**
  132321. * Gets the y component (output)
  132322. */
  132323. get y(): NodeMaterialConnectionPoint;
  132324. /**
  132325. * Gets the z component (output)
  132326. */
  132327. get z(): NodeMaterialConnectionPoint;
  132328. /**
  132329. * Gets the w component (output)
  132330. */
  132331. get w(): NodeMaterialConnectionPoint;
  132332. protected _inputRename(name: string): string;
  132333. protected _outputRename(name: string): string;
  132334. protected _buildBlock(state: NodeMaterialBuildState): this;
  132335. }
  132336. }
  132337. declare module BABYLON {
  132338. /**
  132339. * Block used to lerp between 2 values
  132340. */
  132341. export class LerpBlock extends NodeMaterialBlock {
  132342. /**
  132343. * Creates a new LerpBlock
  132344. * @param name defines the block name
  132345. */
  132346. constructor(name: string);
  132347. /**
  132348. * Gets the current class name
  132349. * @returns the class name
  132350. */
  132351. getClassName(): string;
  132352. /**
  132353. * Gets the left operand input component
  132354. */
  132355. get left(): NodeMaterialConnectionPoint;
  132356. /**
  132357. * Gets the right operand input component
  132358. */
  132359. get right(): NodeMaterialConnectionPoint;
  132360. /**
  132361. * Gets the gradient operand input component
  132362. */
  132363. get gradient(): NodeMaterialConnectionPoint;
  132364. /**
  132365. * Gets the output component
  132366. */
  132367. get output(): NodeMaterialConnectionPoint;
  132368. protected _buildBlock(state: NodeMaterialBuildState): this;
  132369. }
  132370. }
  132371. declare module BABYLON {
  132372. /**
  132373. * Block used to divide 2 vectors
  132374. */
  132375. export class DivideBlock extends NodeMaterialBlock {
  132376. /**
  132377. * Creates a new DivideBlock
  132378. * @param name defines the block name
  132379. */
  132380. constructor(name: string);
  132381. /**
  132382. * Gets the current class name
  132383. * @returns the class name
  132384. */
  132385. getClassName(): string;
  132386. /**
  132387. * Gets the left operand input component
  132388. */
  132389. get left(): NodeMaterialConnectionPoint;
  132390. /**
  132391. * Gets the right operand input component
  132392. */
  132393. get right(): NodeMaterialConnectionPoint;
  132394. /**
  132395. * Gets the output component
  132396. */
  132397. get output(): NodeMaterialConnectionPoint;
  132398. protected _buildBlock(state: NodeMaterialBuildState): this;
  132399. }
  132400. }
  132401. declare module BABYLON {
  132402. /**
  132403. * Block used to subtract 2 vectors
  132404. */
  132405. export class SubtractBlock extends NodeMaterialBlock {
  132406. /**
  132407. * Creates a new SubtractBlock
  132408. * @param name defines the block name
  132409. */
  132410. constructor(name: string);
  132411. /**
  132412. * Gets the current class name
  132413. * @returns the class name
  132414. */
  132415. getClassName(): string;
  132416. /**
  132417. * Gets the left operand input component
  132418. */
  132419. get left(): NodeMaterialConnectionPoint;
  132420. /**
  132421. * Gets the right operand input component
  132422. */
  132423. get right(): NodeMaterialConnectionPoint;
  132424. /**
  132425. * Gets the output component
  132426. */
  132427. get output(): NodeMaterialConnectionPoint;
  132428. protected _buildBlock(state: NodeMaterialBuildState): this;
  132429. }
  132430. }
  132431. declare module BABYLON {
  132432. /**
  132433. * Block used to step a value
  132434. */
  132435. export class StepBlock extends NodeMaterialBlock {
  132436. /**
  132437. * Creates a new StepBlock
  132438. * @param name defines the block name
  132439. */
  132440. constructor(name: string);
  132441. /**
  132442. * Gets the current class name
  132443. * @returns the class name
  132444. */
  132445. getClassName(): string;
  132446. /**
  132447. * Gets the value operand input component
  132448. */
  132449. get value(): NodeMaterialConnectionPoint;
  132450. /**
  132451. * Gets the edge operand input component
  132452. */
  132453. get edge(): NodeMaterialConnectionPoint;
  132454. /**
  132455. * Gets the output component
  132456. */
  132457. get output(): NodeMaterialConnectionPoint;
  132458. protected _buildBlock(state: NodeMaterialBuildState): this;
  132459. }
  132460. }
  132461. declare module BABYLON {
  132462. /**
  132463. * Block used to get the opposite (1 - x) of a value
  132464. */
  132465. export class OneMinusBlock extends NodeMaterialBlock {
  132466. /**
  132467. * Creates a new OneMinusBlock
  132468. * @param name defines the block name
  132469. */
  132470. constructor(name: string);
  132471. /**
  132472. * Gets the current class name
  132473. * @returns the class name
  132474. */
  132475. getClassName(): string;
  132476. /**
  132477. * Gets the input component
  132478. */
  132479. get input(): NodeMaterialConnectionPoint;
  132480. /**
  132481. * Gets the output component
  132482. */
  132483. get output(): NodeMaterialConnectionPoint;
  132484. protected _buildBlock(state: NodeMaterialBuildState): this;
  132485. }
  132486. }
  132487. declare module BABYLON {
  132488. /**
  132489. * Block used to get the view direction
  132490. */
  132491. export class ViewDirectionBlock extends NodeMaterialBlock {
  132492. /**
  132493. * Creates a new ViewDirectionBlock
  132494. * @param name defines the block name
  132495. */
  132496. constructor(name: string);
  132497. /**
  132498. * Gets the current class name
  132499. * @returns the class name
  132500. */
  132501. getClassName(): string;
  132502. /**
  132503. * Gets the world position component
  132504. */
  132505. get worldPosition(): NodeMaterialConnectionPoint;
  132506. /**
  132507. * Gets the camera position component
  132508. */
  132509. get cameraPosition(): NodeMaterialConnectionPoint;
  132510. /**
  132511. * Gets the output component
  132512. */
  132513. get output(): NodeMaterialConnectionPoint;
  132514. autoConfigure(material: NodeMaterial): void;
  132515. protected _buildBlock(state: NodeMaterialBuildState): this;
  132516. }
  132517. }
  132518. declare module BABYLON {
  132519. /**
  132520. * Block used to compute fresnel value
  132521. */
  132522. export class FresnelBlock extends NodeMaterialBlock {
  132523. /**
  132524. * Create a new FresnelBlock
  132525. * @param name defines the block name
  132526. */
  132527. constructor(name: string);
  132528. /**
  132529. * Gets the current class name
  132530. * @returns the class name
  132531. */
  132532. getClassName(): string;
  132533. /**
  132534. * Gets the world normal input component
  132535. */
  132536. get worldNormal(): NodeMaterialConnectionPoint;
  132537. /**
  132538. * Gets the view direction input component
  132539. */
  132540. get viewDirection(): NodeMaterialConnectionPoint;
  132541. /**
  132542. * Gets the bias input component
  132543. */
  132544. get bias(): NodeMaterialConnectionPoint;
  132545. /**
  132546. * Gets the camera (or eye) position component
  132547. */
  132548. get power(): NodeMaterialConnectionPoint;
  132549. /**
  132550. * Gets the fresnel output component
  132551. */
  132552. get fresnel(): NodeMaterialConnectionPoint;
  132553. autoConfigure(material: NodeMaterial): void;
  132554. protected _buildBlock(state: NodeMaterialBuildState): this;
  132555. }
  132556. }
  132557. declare module BABYLON {
  132558. /**
  132559. * Block used to get the max of 2 values
  132560. */
  132561. export class MaxBlock extends NodeMaterialBlock {
  132562. /**
  132563. * Creates a new MaxBlock
  132564. * @param name defines the block name
  132565. */
  132566. constructor(name: string);
  132567. /**
  132568. * Gets the current class name
  132569. * @returns the class name
  132570. */
  132571. getClassName(): string;
  132572. /**
  132573. * Gets the left operand input component
  132574. */
  132575. get left(): NodeMaterialConnectionPoint;
  132576. /**
  132577. * Gets the right operand input component
  132578. */
  132579. get right(): NodeMaterialConnectionPoint;
  132580. /**
  132581. * Gets the output component
  132582. */
  132583. get output(): NodeMaterialConnectionPoint;
  132584. protected _buildBlock(state: NodeMaterialBuildState): this;
  132585. }
  132586. }
  132587. declare module BABYLON {
  132588. /**
  132589. * Block used to get the min of 2 values
  132590. */
  132591. export class MinBlock extends NodeMaterialBlock {
  132592. /**
  132593. * Creates a new MinBlock
  132594. * @param name defines the block name
  132595. */
  132596. constructor(name: string);
  132597. /**
  132598. * Gets the current class name
  132599. * @returns the class name
  132600. */
  132601. getClassName(): string;
  132602. /**
  132603. * Gets the left operand input component
  132604. */
  132605. get left(): NodeMaterialConnectionPoint;
  132606. /**
  132607. * Gets the right operand input component
  132608. */
  132609. get right(): NodeMaterialConnectionPoint;
  132610. /**
  132611. * Gets the output component
  132612. */
  132613. get output(): NodeMaterialConnectionPoint;
  132614. protected _buildBlock(state: NodeMaterialBuildState): this;
  132615. }
  132616. }
  132617. declare module BABYLON {
  132618. /**
  132619. * Block used to get the distance between 2 values
  132620. */
  132621. export class DistanceBlock extends NodeMaterialBlock {
  132622. /**
  132623. * Creates a new DistanceBlock
  132624. * @param name defines the block name
  132625. */
  132626. constructor(name: string);
  132627. /**
  132628. * Gets the current class name
  132629. * @returns the class name
  132630. */
  132631. getClassName(): string;
  132632. /**
  132633. * Gets the left operand input component
  132634. */
  132635. get left(): NodeMaterialConnectionPoint;
  132636. /**
  132637. * Gets the right operand input component
  132638. */
  132639. get right(): NodeMaterialConnectionPoint;
  132640. /**
  132641. * Gets the output component
  132642. */
  132643. get output(): NodeMaterialConnectionPoint;
  132644. protected _buildBlock(state: NodeMaterialBuildState): this;
  132645. }
  132646. }
  132647. declare module BABYLON {
  132648. /**
  132649. * Block used to get the length of a vector
  132650. */
  132651. export class LengthBlock extends NodeMaterialBlock {
  132652. /**
  132653. * Creates a new LengthBlock
  132654. * @param name defines the block name
  132655. */
  132656. constructor(name: string);
  132657. /**
  132658. * Gets the current class name
  132659. * @returns the class name
  132660. */
  132661. getClassName(): string;
  132662. /**
  132663. * Gets the value input component
  132664. */
  132665. get value(): NodeMaterialConnectionPoint;
  132666. /**
  132667. * Gets the output component
  132668. */
  132669. get output(): NodeMaterialConnectionPoint;
  132670. protected _buildBlock(state: NodeMaterialBuildState): this;
  132671. }
  132672. }
  132673. declare module BABYLON {
  132674. /**
  132675. * Block used to get negative version of a value (i.e. x * -1)
  132676. */
  132677. export class NegateBlock extends NodeMaterialBlock {
  132678. /**
  132679. * Creates a new NegateBlock
  132680. * @param name defines the block name
  132681. */
  132682. constructor(name: string);
  132683. /**
  132684. * Gets the current class name
  132685. * @returns the class name
  132686. */
  132687. getClassName(): string;
  132688. /**
  132689. * Gets the value input component
  132690. */
  132691. get value(): NodeMaterialConnectionPoint;
  132692. /**
  132693. * Gets the output component
  132694. */
  132695. get output(): NodeMaterialConnectionPoint;
  132696. protected _buildBlock(state: NodeMaterialBuildState): this;
  132697. }
  132698. }
  132699. declare module BABYLON {
  132700. /**
  132701. * Block used to get the value of the first parameter raised to the power of the second
  132702. */
  132703. export class PowBlock extends NodeMaterialBlock {
  132704. /**
  132705. * Creates a new PowBlock
  132706. * @param name defines the block name
  132707. */
  132708. constructor(name: string);
  132709. /**
  132710. * Gets the current class name
  132711. * @returns the class name
  132712. */
  132713. getClassName(): string;
  132714. /**
  132715. * Gets the value operand input component
  132716. */
  132717. get value(): NodeMaterialConnectionPoint;
  132718. /**
  132719. * Gets the power operand input component
  132720. */
  132721. get power(): NodeMaterialConnectionPoint;
  132722. /**
  132723. * Gets the output component
  132724. */
  132725. get output(): NodeMaterialConnectionPoint;
  132726. protected _buildBlock(state: NodeMaterialBuildState): this;
  132727. }
  132728. }
  132729. declare module BABYLON {
  132730. /**
  132731. * Block used to get a random number
  132732. */
  132733. export class RandomNumberBlock extends NodeMaterialBlock {
  132734. /**
  132735. * Creates a new RandomNumberBlock
  132736. * @param name defines the block name
  132737. */
  132738. constructor(name: string);
  132739. /**
  132740. * Gets the current class name
  132741. * @returns the class name
  132742. */
  132743. getClassName(): string;
  132744. /**
  132745. * Gets the seed input component
  132746. */
  132747. get seed(): NodeMaterialConnectionPoint;
  132748. /**
  132749. * Gets the output component
  132750. */
  132751. get output(): NodeMaterialConnectionPoint;
  132752. protected _buildBlock(state: NodeMaterialBuildState): this;
  132753. }
  132754. }
  132755. declare module BABYLON {
  132756. /**
  132757. * Block used to compute arc tangent of 2 values
  132758. */
  132759. export class ArcTan2Block extends NodeMaterialBlock {
  132760. /**
  132761. * Creates a new ArcTan2Block
  132762. * @param name defines the block name
  132763. */
  132764. constructor(name: string);
  132765. /**
  132766. * Gets the current class name
  132767. * @returns the class name
  132768. */
  132769. getClassName(): string;
  132770. /**
  132771. * Gets the x operand input component
  132772. */
  132773. get x(): NodeMaterialConnectionPoint;
  132774. /**
  132775. * Gets the y operand input component
  132776. */
  132777. get y(): NodeMaterialConnectionPoint;
  132778. /**
  132779. * Gets the output component
  132780. */
  132781. get output(): NodeMaterialConnectionPoint;
  132782. protected _buildBlock(state: NodeMaterialBuildState): this;
  132783. }
  132784. }
  132785. declare module BABYLON {
  132786. /**
  132787. * Block used to smooth step a value
  132788. */
  132789. export class SmoothStepBlock extends NodeMaterialBlock {
  132790. /**
  132791. * Creates a new SmoothStepBlock
  132792. * @param name defines the block name
  132793. */
  132794. constructor(name: string);
  132795. /**
  132796. * Gets the current class name
  132797. * @returns the class name
  132798. */
  132799. getClassName(): string;
  132800. /**
  132801. * Gets the value operand input component
  132802. */
  132803. get value(): NodeMaterialConnectionPoint;
  132804. /**
  132805. * Gets the first edge operand input component
  132806. */
  132807. get edge0(): NodeMaterialConnectionPoint;
  132808. /**
  132809. * Gets the second edge operand input component
  132810. */
  132811. get edge1(): NodeMaterialConnectionPoint;
  132812. /**
  132813. * Gets the output component
  132814. */
  132815. get output(): NodeMaterialConnectionPoint;
  132816. protected _buildBlock(state: NodeMaterialBuildState): this;
  132817. }
  132818. }
  132819. declare module BABYLON {
  132820. /**
  132821. * Block used to get the reciprocal (1 / x) of a value
  132822. */
  132823. export class ReciprocalBlock extends NodeMaterialBlock {
  132824. /**
  132825. * Creates a new ReciprocalBlock
  132826. * @param name defines the block name
  132827. */
  132828. constructor(name: string);
  132829. /**
  132830. * Gets the current class name
  132831. * @returns the class name
  132832. */
  132833. getClassName(): string;
  132834. /**
  132835. * Gets the input component
  132836. */
  132837. get input(): NodeMaterialConnectionPoint;
  132838. /**
  132839. * Gets the output component
  132840. */
  132841. get output(): NodeMaterialConnectionPoint;
  132842. protected _buildBlock(state: NodeMaterialBuildState): this;
  132843. }
  132844. }
  132845. declare module BABYLON {
  132846. /**
  132847. * Block used to replace a color by another one
  132848. */
  132849. export class ReplaceColorBlock extends NodeMaterialBlock {
  132850. /**
  132851. * Creates a new ReplaceColorBlock
  132852. * @param name defines the block name
  132853. */
  132854. constructor(name: string);
  132855. /**
  132856. * Gets the current class name
  132857. * @returns the class name
  132858. */
  132859. getClassName(): string;
  132860. /**
  132861. * Gets the value input component
  132862. */
  132863. get value(): NodeMaterialConnectionPoint;
  132864. /**
  132865. * Gets the reference input component
  132866. */
  132867. get reference(): NodeMaterialConnectionPoint;
  132868. /**
  132869. * Gets the distance input component
  132870. */
  132871. get distance(): NodeMaterialConnectionPoint;
  132872. /**
  132873. * Gets the replacement input component
  132874. */
  132875. get replacement(): NodeMaterialConnectionPoint;
  132876. /**
  132877. * Gets the output component
  132878. */
  132879. get output(): NodeMaterialConnectionPoint;
  132880. protected _buildBlock(state: NodeMaterialBuildState): this;
  132881. }
  132882. }
  132883. declare module BABYLON {
  132884. /**
  132885. * Block used to posterize a value
  132886. * @see https://en.wikipedia.org/wiki/Posterization
  132887. */
  132888. export class PosterizeBlock extends NodeMaterialBlock {
  132889. /**
  132890. * Creates a new PosterizeBlock
  132891. * @param name defines the block name
  132892. */
  132893. constructor(name: string);
  132894. /**
  132895. * Gets the current class name
  132896. * @returns the class name
  132897. */
  132898. getClassName(): string;
  132899. /**
  132900. * Gets the value input component
  132901. */
  132902. get value(): NodeMaterialConnectionPoint;
  132903. /**
  132904. * Gets the steps input component
  132905. */
  132906. get steps(): 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. * Operations supported by the Wave block
  132917. */
  132918. export enum WaveBlockKind {
  132919. /** SawTooth */
  132920. SawTooth = 0,
  132921. /** Square */
  132922. Square = 1,
  132923. /** Triangle */
  132924. Triangle = 2
  132925. }
  132926. /**
  132927. * Block used to apply wave operation to floats
  132928. */
  132929. export class WaveBlock extends NodeMaterialBlock {
  132930. /**
  132931. * Gets or sets the kibnd of wave to be applied by the block
  132932. */
  132933. kind: WaveBlockKind;
  132934. /**
  132935. * Creates a new WaveBlock
  132936. * @param name defines the block name
  132937. */
  132938. constructor(name: string);
  132939. /**
  132940. * Gets the current class name
  132941. * @returns the class name
  132942. */
  132943. getClassName(): string;
  132944. /**
  132945. * Gets the input component
  132946. */
  132947. get input(): NodeMaterialConnectionPoint;
  132948. /**
  132949. * Gets the output component
  132950. */
  132951. get output(): NodeMaterialConnectionPoint;
  132952. protected _buildBlock(state: NodeMaterialBuildState): this;
  132953. serialize(): any;
  132954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132955. }
  132956. }
  132957. declare module BABYLON {
  132958. /**
  132959. * Class used to store a color step for the GradientBlock
  132960. */
  132961. export class GradientBlockColorStep {
  132962. /**
  132963. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132964. */
  132965. step: number;
  132966. /**
  132967. * Gets or sets the color associated with this step
  132968. */
  132969. color: Color3;
  132970. /**
  132971. * Creates a new GradientBlockColorStep
  132972. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132973. * @param color defines the color associated with this step
  132974. */
  132975. constructor(
  132976. /**
  132977. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132978. */
  132979. step: number,
  132980. /**
  132981. * Gets or sets the color associated with this step
  132982. */
  132983. color: Color3);
  132984. }
  132985. /**
  132986. * Block used to return a color from a gradient based on an input value between 0 and 1
  132987. */
  132988. export class GradientBlock extends NodeMaterialBlock {
  132989. /**
  132990. * Gets or sets the list of color steps
  132991. */
  132992. colorSteps: GradientBlockColorStep[];
  132993. /**
  132994. * Creates a new GradientBlock
  132995. * @param name defines the block name
  132996. */
  132997. constructor(name: string);
  132998. /**
  132999. * Gets the current class name
  133000. * @returns the class name
  133001. */
  133002. getClassName(): string;
  133003. /**
  133004. * Gets the gradient input component
  133005. */
  133006. get gradient(): NodeMaterialConnectionPoint;
  133007. /**
  133008. * Gets the output component
  133009. */
  133010. get output(): NodeMaterialConnectionPoint;
  133011. private _writeColorConstant;
  133012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133013. serialize(): any;
  133014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133015. protected _dumpPropertiesCode(): string;
  133016. }
  133017. }
  133018. declare module BABYLON {
  133019. /**
  133020. * Block used to normalize lerp between 2 values
  133021. */
  133022. export class NLerpBlock extends NodeMaterialBlock {
  133023. /**
  133024. * Creates a new NLerpBlock
  133025. * @param name defines the block name
  133026. */
  133027. constructor(name: string);
  133028. /**
  133029. * Gets the current class name
  133030. * @returns the class name
  133031. */
  133032. getClassName(): string;
  133033. /**
  133034. * Gets the left operand input component
  133035. */
  133036. get left(): NodeMaterialConnectionPoint;
  133037. /**
  133038. * Gets the right operand input component
  133039. */
  133040. get right(): NodeMaterialConnectionPoint;
  133041. /**
  133042. * Gets the gradient operand input component
  133043. */
  133044. get gradient(): NodeMaterialConnectionPoint;
  133045. /**
  133046. * Gets the output component
  133047. */
  133048. get output(): NodeMaterialConnectionPoint;
  133049. protected _buildBlock(state: NodeMaterialBuildState): this;
  133050. }
  133051. }
  133052. declare module BABYLON {
  133053. /**
  133054. * block used to Generate a Worley Noise 3D Noise Pattern
  133055. */
  133056. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133057. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133058. manhattanDistance: boolean;
  133059. /**
  133060. * Creates a new WorleyNoise3DBlock
  133061. * @param name defines the block name
  133062. */
  133063. constructor(name: string);
  133064. /**
  133065. * Gets the current class name
  133066. * @returns the class name
  133067. */
  133068. getClassName(): string;
  133069. /**
  133070. * Gets the seed input component
  133071. */
  133072. get seed(): NodeMaterialConnectionPoint;
  133073. /**
  133074. * Gets the jitter input component
  133075. */
  133076. get jitter(): NodeMaterialConnectionPoint;
  133077. /**
  133078. * Gets the output component
  133079. */
  133080. get output(): NodeMaterialConnectionPoint;
  133081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133082. /**
  133083. * Exposes the properties to the UI?
  133084. */
  133085. protected _dumpPropertiesCode(): string;
  133086. /**
  133087. * Exposes the properties to the Seralize?
  133088. */
  133089. serialize(): any;
  133090. /**
  133091. * Exposes the properties to the deseralize?
  133092. */
  133093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133094. }
  133095. }
  133096. declare module BABYLON {
  133097. /**
  133098. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133099. */
  133100. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133101. /**
  133102. * Creates a new SimplexPerlin3DBlock
  133103. * @param name defines the block name
  133104. */
  133105. constructor(name: string);
  133106. /**
  133107. * Gets the current class name
  133108. * @returns the class name
  133109. */
  133110. getClassName(): string;
  133111. /**
  133112. * Gets the seed operand input component
  133113. */
  133114. get seed(): NodeMaterialConnectionPoint;
  133115. /**
  133116. * Gets the output component
  133117. */
  133118. get output(): NodeMaterialConnectionPoint;
  133119. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133120. }
  133121. }
  133122. declare module BABYLON {
  133123. /**
  133124. * Block used to blend normals
  133125. */
  133126. export class NormalBlendBlock extends NodeMaterialBlock {
  133127. /**
  133128. * Creates a new NormalBlendBlock
  133129. * @param name defines the block name
  133130. */
  133131. constructor(name: string);
  133132. /**
  133133. * Gets the current class name
  133134. * @returns the class name
  133135. */
  133136. getClassName(): string;
  133137. /**
  133138. * Gets the first input component
  133139. */
  133140. get normalMap0(): NodeMaterialConnectionPoint;
  133141. /**
  133142. * Gets the second input component
  133143. */
  133144. get normalMap1(): NodeMaterialConnectionPoint;
  133145. /**
  133146. * Gets the output component
  133147. */
  133148. get output(): NodeMaterialConnectionPoint;
  133149. protected _buildBlock(state: NodeMaterialBuildState): this;
  133150. }
  133151. }
  133152. declare module BABYLON {
  133153. /**
  133154. * Block used to rotate a 2d vector by a given angle
  133155. */
  133156. export class Rotate2dBlock extends NodeMaterialBlock {
  133157. /**
  133158. * Creates a new Rotate2dBlock
  133159. * @param name defines the block name
  133160. */
  133161. constructor(name: string);
  133162. /**
  133163. * Gets the current class name
  133164. * @returns the class name
  133165. */
  133166. getClassName(): string;
  133167. /**
  133168. * Gets the input vector
  133169. */
  133170. get input(): NodeMaterialConnectionPoint;
  133171. /**
  133172. * Gets the input angle
  133173. */
  133174. get angle(): NodeMaterialConnectionPoint;
  133175. /**
  133176. * Gets the output component
  133177. */
  133178. get output(): NodeMaterialConnectionPoint;
  133179. autoConfigure(material: NodeMaterial): void;
  133180. protected _buildBlock(state: NodeMaterialBuildState): this;
  133181. }
  133182. }
  133183. declare module BABYLON {
  133184. /**
  133185. * Block used to get the reflected vector from a direction and a normal
  133186. */
  133187. export class ReflectBlock extends NodeMaterialBlock {
  133188. /**
  133189. * Creates a new ReflectBlock
  133190. * @param name defines the block name
  133191. */
  133192. constructor(name: string);
  133193. /**
  133194. * Gets the current class name
  133195. * @returns the class name
  133196. */
  133197. getClassName(): string;
  133198. /**
  133199. * Gets the incident component
  133200. */
  133201. get incident(): NodeMaterialConnectionPoint;
  133202. /**
  133203. * Gets the normal component
  133204. */
  133205. get normal(): NodeMaterialConnectionPoint;
  133206. /**
  133207. * Gets the output component
  133208. */
  133209. get output(): NodeMaterialConnectionPoint;
  133210. protected _buildBlock(state: NodeMaterialBuildState): this;
  133211. }
  133212. }
  133213. declare module BABYLON {
  133214. /**
  133215. * Block used to get the refracted vector from a direction and a normal
  133216. */
  133217. export class RefractBlock extends NodeMaterialBlock {
  133218. /**
  133219. * Creates a new RefractBlock
  133220. * @param name defines the block name
  133221. */
  133222. constructor(name: string);
  133223. /**
  133224. * Gets the current class name
  133225. * @returns the class name
  133226. */
  133227. getClassName(): string;
  133228. /**
  133229. * Gets the incident component
  133230. */
  133231. get incident(): NodeMaterialConnectionPoint;
  133232. /**
  133233. * Gets the normal component
  133234. */
  133235. get normal(): NodeMaterialConnectionPoint;
  133236. /**
  133237. * Gets the index of refraction component
  133238. */
  133239. get ior(): NodeMaterialConnectionPoint;
  133240. /**
  133241. * Gets the output component
  133242. */
  133243. get output(): NodeMaterialConnectionPoint;
  133244. protected _buildBlock(state: NodeMaterialBuildState): this;
  133245. }
  133246. }
  133247. declare module BABYLON {
  133248. /**
  133249. * Block used to desaturate a color
  133250. */
  133251. export class DesaturateBlock extends NodeMaterialBlock {
  133252. /**
  133253. * Creates a new DesaturateBlock
  133254. * @param name defines the block name
  133255. */
  133256. constructor(name: string);
  133257. /**
  133258. * Gets the current class name
  133259. * @returns the class name
  133260. */
  133261. getClassName(): string;
  133262. /**
  133263. * Gets the color operand input component
  133264. */
  133265. get color(): NodeMaterialConnectionPoint;
  133266. /**
  133267. * Gets the level operand input component
  133268. */
  133269. get level(): NodeMaterialConnectionPoint;
  133270. /**
  133271. * Gets the output component
  133272. */
  133273. get output(): NodeMaterialConnectionPoint;
  133274. protected _buildBlock(state: NodeMaterialBuildState): this;
  133275. }
  133276. }
  133277. declare module BABYLON {
  133278. /**
  133279. * Effect Render Options
  133280. */
  133281. export interface IEffectRendererOptions {
  133282. /**
  133283. * Defines the vertices positions.
  133284. */
  133285. positions?: number[];
  133286. /**
  133287. * Defines the indices.
  133288. */
  133289. indices?: number[];
  133290. }
  133291. /**
  133292. * Helper class to render one or more effects
  133293. */
  133294. export class EffectRenderer {
  133295. private engine;
  133296. private static _DefaultOptions;
  133297. private _vertexBuffers;
  133298. private _indexBuffer;
  133299. private _ringBufferIndex;
  133300. private _ringScreenBuffer;
  133301. private _fullscreenViewport;
  133302. private _getNextFrameBuffer;
  133303. /**
  133304. * Creates an effect renderer
  133305. * @param engine the engine to use for rendering
  133306. * @param options defines the options of the effect renderer
  133307. */
  133308. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133309. /**
  133310. * Sets the current viewport in normalized coordinates 0-1
  133311. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133312. */
  133313. setViewport(viewport?: Viewport): void;
  133314. /**
  133315. * Binds the embedded attributes buffer to the effect.
  133316. * @param effect Defines the effect to bind the attributes for
  133317. */
  133318. bindBuffers(effect: Effect): void;
  133319. /**
  133320. * Sets the current effect wrapper to use during draw.
  133321. * The effect needs to be ready before calling this api.
  133322. * This also sets the default full screen position attribute.
  133323. * @param effectWrapper Defines the effect to draw with
  133324. */
  133325. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133326. /**
  133327. * Draws a full screen quad.
  133328. */
  133329. draw(): void;
  133330. /**
  133331. * renders one or more effects to a specified texture
  133332. * @param effectWrappers list of effects to renderer
  133333. * @param outputTexture texture to draw to, if null it will render to the screen
  133334. */
  133335. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133336. /**
  133337. * Disposes of the effect renderer
  133338. */
  133339. dispose(): void;
  133340. }
  133341. /**
  133342. * Options to create an EffectWrapper
  133343. */
  133344. interface EffectWrapperCreationOptions {
  133345. /**
  133346. * Engine to use to create the effect
  133347. */
  133348. engine: ThinEngine;
  133349. /**
  133350. * Fragment shader for the effect
  133351. */
  133352. fragmentShader: string;
  133353. /**
  133354. * Vertex shader for the effect
  133355. */
  133356. vertexShader?: string;
  133357. /**
  133358. * Attributes to use in the shader
  133359. */
  133360. attributeNames?: Array<string>;
  133361. /**
  133362. * Uniforms to use in the shader
  133363. */
  133364. uniformNames?: Array<string>;
  133365. /**
  133366. * Texture sampler names to use in the shader
  133367. */
  133368. samplerNames?: Array<string>;
  133369. /**
  133370. * The friendly name of the effect displayed in Spector.
  133371. */
  133372. name?: string;
  133373. }
  133374. /**
  133375. * Wraps an effect to be used for rendering
  133376. */
  133377. export class EffectWrapper {
  133378. /**
  133379. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133380. */
  133381. onApplyObservable: Observable<{}>;
  133382. /**
  133383. * The underlying effect
  133384. */
  133385. effect: Effect;
  133386. /**
  133387. * Creates an effect to be renderer
  133388. * @param creationOptions options to create the effect
  133389. */
  133390. constructor(creationOptions: EffectWrapperCreationOptions);
  133391. /**
  133392. * Disposes of the effect wrapper
  133393. */
  133394. dispose(): void;
  133395. }
  133396. }
  133397. declare module BABYLON {
  133398. /**
  133399. * Helper class to push actions to a pool of workers.
  133400. */
  133401. export class WorkerPool implements IDisposable {
  133402. private _workerInfos;
  133403. private _pendingActions;
  133404. /**
  133405. * Constructor
  133406. * @param workers Array of workers to use for actions
  133407. */
  133408. constructor(workers: Array<Worker>);
  133409. /**
  133410. * Terminates all workers and clears any pending actions.
  133411. */
  133412. dispose(): void;
  133413. /**
  133414. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133415. * pended until a worker has completed its action.
  133416. * @param action The action to perform. Call onComplete when the action is complete.
  133417. */
  133418. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133419. private _execute;
  133420. }
  133421. }
  133422. declare module BABYLON {
  133423. /**
  133424. * Configuration for Draco compression
  133425. */
  133426. export interface IDracoCompressionConfiguration {
  133427. /**
  133428. * Configuration for the decoder.
  133429. */
  133430. decoder: {
  133431. /**
  133432. * The url to the WebAssembly module.
  133433. */
  133434. wasmUrl?: string;
  133435. /**
  133436. * The url to the WebAssembly binary.
  133437. */
  133438. wasmBinaryUrl?: string;
  133439. /**
  133440. * The url to the fallback JavaScript module.
  133441. */
  133442. fallbackUrl?: string;
  133443. };
  133444. }
  133445. /**
  133446. * Draco compression (https://google.github.io/draco/)
  133447. *
  133448. * This class wraps the Draco module.
  133449. *
  133450. * **Encoder**
  133451. *
  133452. * The encoder is not currently implemented.
  133453. *
  133454. * **Decoder**
  133455. *
  133456. * 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.
  133457. *
  133458. * To update the configuration, use the following code:
  133459. * ```javascript
  133460. * DracoCompression.Configuration = {
  133461. * decoder: {
  133462. * wasmUrl: "<url to the WebAssembly library>",
  133463. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133464. * fallbackUrl: "<url to the fallback JavaScript library>",
  133465. * }
  133466. * };
  133467. * ```
  133468. *
  133469. * 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.
  133470. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133471. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133472. *
  133473. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133474. * ```javascript
  133475. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133476. * ```
  133477. *
  133478. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133479. */
  133480. export class DracoCompression implements IDisposable {
  133481. private _workerPoolPromise?;
  133482. private _decoderModulePromise?;
  133483. /**
  133484. * The configuration. Defaults to the following urls:
  133485. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133486. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133487. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133488. */
  133489. static Configuration: IDracoCompressionConfiguration;
  133490. /**
  133491. * Returns true if the decoder configuration is available.
  133492. */
  133493. static get DecoderAvailable(): boolean;
  133494. /**
  133495. * Default number of workers to create when creating the draco compression object.
  133496. */
  133497. static DefaultNumWorkers: number;
  133498. private static GetDefaultNumWorkers;
  133499. private static _Default;
  133500. /**
  133501. * Default instance for the draco compression object.
  133502. */
  133503. static get Default(): DracoCompression;
  133504. /**
  133505. * Constructor
  133506. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133507. */
  133508. constructor(numWorkers?: number);
  133509. /**
  133510. * Stop all async operations and release resources.
  133511. */
  133512. dispose(): void;
  133513. /**
  133514. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133515. * @returns a promise that resolves when ready
  133516. */
  133517. whenReadyAsync(): Promise<void>;
  133518. /**
  133519. * Decode Draco compressed mesh data to vertex data.
  133520. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133521. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133522. * @returns A promise that resolves with the decoded vertex data
  133523. */
  133524. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133525. [kind: string]: number;
  133526. }): Promise<VertexData>;
  133527. }
  133528. }
  133529. declare module BABYLON {
  133530. /**
  133531. * Class for building Constructive Solid Geometry
  133532. */
  133533. export class CSG {
  133534. private polygons;
  133535. /**
  133536. * The world matrix
  133537. */
  133538. matrix: Matrix;
  133539. /**
  133540. * Stores the position
  133541. */
  133542. position: Vector3;
  133543. /**
  133544. * Stores the rotation
  133545. */
  133546. rotation: Vector3;
  133547. /**
  133548. * Stores the rotation quaternion
  133549. */
  133550. rotationQuaternion: Nullable<Quaternion>;
  133551. /**
  133552. * Stores the scaling vector
  133553. */
  133554. scaling: Vector3;
  133555. /**
  133556. * Convert the Mesh to CSG
  133557. * @param mesh The Mesh to convert to CSG
  133558. * @returns A new CSG from the Mesh
  133559. */
  133560. static FromMesh(mesh: Mesh): CSG;
  133561. /**
  133562. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133563. * @param polygons Polygons used to construct a CSG solid
  133564. */
  133565. private static FromPolygons;
  133566. /**
  133567. * Clones, or makes a deep copy, of the CSG
  133568. * @returns A new CSG
  133569. */
  133570. clone(): CSG;
  133571. /**
  133572. * Unions this CSG with another CSG
  133573. * @param csg The CSG to union against this CSG
  133574. * @returns The unioned CSG
  133575. */
  133576. union(csg: CSG): CSG;
  133577. /**
  133578. * Unions this CSG with another CSG in place
  133579. * @param csg The CSG to union against this CSG
  133580. */
  133581. unionInPlace(csg: CSG): void;
  133582. /**
  133583. * Subtracts this CSG with another CSG
  133584. * @param csg The CSG to subtract against this CSG
  133585. * @returns A new CSG
  133586. */
  133587. subtract(csg: CSG): CSG;
  133588. /**
  133589. * Subtracts this CSG with another CSG in place
  133590. * @param csg The CSG to subtact against this CSG
  133591. */
  133592. subtractInPlace(csg: CSG): void;
  133593. /**
  133594. * Intersect this CSG with another CSG
  133595. * @param csg The CSG to intersect against this CSG
  133596. * @returns A new CSG
  133597. */
  133598. intersect(csg: CSG): CSG;
  133599. /**
  133600. * Intersects this CSG with another CSG in place
  133601. * @param csg The CSG to intersect against this CSG
  133602. */
  133603. intersectInPlace(csg: CSG): void;
  133604. /**
  133605. * Return a new CSG solid with solid and empty space switched. This solid is
  133606. * not modified.
  133607. * @returns A new CSG solid with solid and empty space switched
  133608. */
  133609. inverse(): CSG;
  133610. /**
  133611. * Inverses the CSG in place
  133612. */
  133613. inverseInPlace(): void;
  133614. /**
  133615. * This is used to keep meshes transformations so they can be restored
  133616. * when we build back a Babylon Mesh
  133617. * NB : All CSG operations are performed in world coordinates
  133618. * @param csg The CSG to copy the transform attributes from
  133619. * @returns This CSG
  133620. */
  133621. copyTransformAttributes(csg: CSG): CSG;
  133622. /**
  133623. * Build Raw mesh from CSG
  133624. * Coordinates here are in world space
  133625. * @param name The name of the mesh geometry
  133626. * @param scene The Scene
  133627. * @param keepSubMeshes Specifies if the submeshes should be kept
  133628. * @returns A new Mesh
  133629. */
  133630. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133631. /**
  133632. * Build Mesh from CSG taking material and transforms into account
  133633. * @param name The name of the Mesh
  133634. * @param material The material of the Mesh
  133635. * @param scene The Scene
  133636. * @param keepSubMeshes Specifies if submeshes should be kept
  133637. * @returns The new Mesh
  133638. */
  133639. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133640. }
  133641. }
  133642. declare module BABYLON {
  133643. /**
  133644. * Class used to create a trail following a mesh
  133645. */
  133646. export class TrailMesh extends Mesh {
  133647. private _generator;
  133648. private _autoStart;
  133649. private _running;
  133650. private _diameter;
  133651. private _length;
  133652. private _sectionPolygonPointsCount;
  133653. private _sectionVectors;
  133654. private _sectionNormalVectors;
  133655. private _beforeRenderObserver;
  133656. /**
  133657. * @constructor
  133658. * @param name The value used by scene.getMeshByName() to do a lookup.
  133659. * @param generator The mesh or transform node to generate a trail.
  133660. * @param scene The scene to add this mesh to.
  133661. * @param diameter Diameter of trailing mesh. Default is 1.
  133662. * @param length Length of trailing mesh. Default is 60.
  133663. * @param autoStart Automatically start trailing mesh. Default true.
  133664. */
  133665. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133666. /**
  133667. * "TrailMesh"
  133668. * @returns "TrailMesh"
  133669. */
  133670. getClassName(): string;
  133671. private _createMesh;
  133672. /**
  133673. * Start trailing mesh.
  133674. */
  133675. start(): void;
  133676. /**
  133677. * Stop trailing mesh.
  133678. */
  133679. stop(): void;
  133680. /**
  133681. * Update trailing mesh geometry.
  133682. */
  133683. update(): void;
  133684. /**
  133685. * Returns a new TrailMesh object.
  133686. * @param name is a string, the name given to the new mesh
  133687. * @param newGenerator use new generator object for cloned trail mesh
  133688. * @returns a new mesh
  133689. */
  133690. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133691. /**
  133692. * Serializes this trail mesh
  133693. * @param serializationObject object to write serialization to
  133694. */
  133695. serialize(serializationObject: any): void;
  133696. /**
  133697. * Parses a serialized trail mesh
  133698. * @param parsedMesh the serialized mesh
  133699. * @param scene the scene to create the trail mesh in
  133700. * @returns the created trail mesh
  133701. */
  133702. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133703. }
  133704. }
  133705. declare module BABYLON {
  133706. /**
  133707. * Class containing static functions to help procedurally build meshes
  133708. */
  133709. export class TiledBoxBuilder {
  133710. /**
  133711. * Creates a box mesh
  133712. * 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)
  133713. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133717. * @param name defines the name of the mesh
  133718. * @param options defines the options used to create the mesh
  133719. * @param scene defines the hosting scene
  133720. * @returns the box mesh
  133721. */
  133722. static CreateTiledBox(name: string, options: {
  133723. pattern?: number;
  133724. width?: number;
  133725. height?: number;
  133726. depth?: number;
  133727. tileSize?: number;
  133728. tileWidth?: number;
  133729. tileHeight?: number;
  133730. alignHorizontal?: number;
  133731. alignVertical?: number;
  133732. faceUV?: Vector4[];
  133733. faceColors?: Color4[];
  133734. sideOrientation?: number;
  133735. updatable?: boolean;
  133736. }, scene?: Nullable<Scene>): Mesh;
  133737. }
  133738. }
  133739. declare module BABYLON {
  133740. /**
  133741. * Class containing static functions to help procedurally build meshes
  133742. */
  133743. export class TorusKnotBuilder {
  133744. /**
  133745. * Creates a torus knot mesh
  133746. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133747. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133748. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133749. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133753. * @param name defines the name of the mesh
  133754. * @param options defines the options used to create the mesh
  133755. * @param scene defines the hosting scene
  133756. * @returns the torus knot mesh
  133757. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133758. */
  133759. static CreateTorusKnot(name: string, options: {
  133760. radius?: number;
  133761. tube?: number;
  133762. radialSegments?: number;
  133763. tubularSegments?: number;
  133764. p?: number;
  133765. q?: number;
  133766. updatable?: boolean;
  133767. sideOrientation?: number;
  133768. frontUVs?: Vector4;
  133769. backUVs?: Vector4;
  133770. }, scene: any): Mesh;
  133771. }
  133772. }
  133773. declare module BABYLON {
  133774. /**
  133775. * Polygon
  133776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133777. */
  133778. export class Polygon {
  133779. /**
  133780. * Creates a rectangle
  133781. * @param xmin bottom X coord
  133782. * @param ymin bottom Y coord
  133783. * @param xmax top X coord
  133784. * @param ymax top Y coord
  133785. * @returns points that make the resulting rectation
  133786. */
  133787. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133788. /**
  133789. * Creates a circle
  133790. * @param radius radius of circle
  133791. * @param cx scale in x
  133792. * @param cy scale in y
  133793. * @param numberOfSides number of sides that make up the circle
  133794. * @returns points that make the resulting circle
  133795. */
  133796. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133797. /**
  133798. * Creates a polygon from input string
  133799. * @param input Input polygon data
  133800. * @returns the parsed points
  133801. */
  133802. static Parse(input: string): Vector2[];
  133803. /**
  133804. * Starts building a polygon from x and y coordinates
  133805. * @param x x coordinate
  133806. * @param y y coordinate
  133807. * @returns the started path2
  133808. */
  133809. static StartingAt(x: number, y: number): Path2;
  133810. }
  133811. /**
  133812. * Builds a polygon
  133813. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133814. */
  133815. export class PolygonMeshBuilder {
  133816. private _points;
  133817. private _outlinepoints;
  133818. private _holes;
  133819. private _name;
  133820. private _scene;
  133821. private _epoints;
  133822. private _eholes;
  133823. private _addToepoint;
  133824. /**
  133825. * Babylon reference to the earcut plugin.
  133826. */
  133827. bjsEarcut: any;
  133828. /**
  133829. * Creates a PolygonMeshBuilder
  133830. * @param name name of the builder
  133831. * @param contours Path of the polygon
  133832. * @param scene scene to add to when creating the mesh
  133833. * @param earcutInjection can be used to inject your own earcut reference
  133834. */
  133835. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133836. /**
  133837. * Adds a whole within the polygon
  133838. * @param hole Array of points defining the hole
  133839. * @returns this
  133840. */
  133841. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133842. /**
  133843. * Creates the polygon
  133844. * @param updatable If the mesh should be updatable
  133845. * @param depth The depth of the mesh created
  133846. * @returns the created mesh
  133847. */
  133848. build(updatable?: boolean, depth?: number): Mesh;
  133849. /**
  133850. * Creates the polygon
  133851. * @param depth The depth of the mesh created
  133852. * @returns the created VertexData
  133853. */
  133854. buildVertexData(depth?: number): VertexData;
  133855. /**
  133856. * Adds a side to the polygon
  133857. * @param positions points that make the polygon
  133858. * @param normals normals of the polygon
  133859. * @param uvs uvs of the polygon
  133860. * @param indices indices of the polygon
  133861. * @param bounds bounds of the polygon
  133862. * @param points points of the polygon
  133863. * @param depth depth of the polygon
  133864. * @param flip flip of the polygon
  133865. */
  133866. private addSide;
  133867. }
  133868. }
  133869. declare module BABYLON {
  133870. /**
  133871. * Class containing static functions to help procedurally build meshes
  133872. */
  133873. export class PolygonBuilder {
  133874. /**
  133875. * Creates a polygon mesh
  133876. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133877. * * 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
  133878. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133881. * * Remember you can only change the shape positions, not their number when updating a polygon
  133882. * @param name defines the name of the mesh
  133883. * @param options defines the options used to create the mesh
  133884. * @param scene defines the hosting scene
  133885. * @param earcutInjection can be used to inject your own earcut reference
  133886. * @returns the polygon mesh
  133887. */
  133888. static CreatePolygon(name: string, options: {
  133889. shape: Vector3[];
  133890. holes?: Vector3[][];
  133891. depth?: number;
  133892. faceUV?: Vector4[];
  133893. faceColors?: Color4[];
  133894. updatable?: boolean;
  133895. sideOrientation?: number;
  133896. frontUVs?: Vector4;
  133897. backUVs?: Vector4;
  133898. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133899. /**
  133900. * Creates an extruded polygon mesh, with depth in the Y direction.
  133901. * * 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)
  133902. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133903. * @param name defines the name of the mesh
  133904. * @param options defines the options used to create the mesh
  133905. * @param scene defines the hosting scene
  133906. * @param earcutInjection can be used to inject your own earcut reference
  133907. * @returns the polygon mesh
  133908. */
  133909. static ExtrudePolygon(name: string, options: {
  133910. shape: Vector3[];
  133911. holes?: Vector3[][];
  133912. depth?: number;
  133913. faceUV?: Vector4[];
  133914. faceColors?: Color4[];
  133915. updatable?: boolean;
  133916. sideOrientation?: number;
  133917. frontUVs?: Vector4;
  133918. backUVs?: Vector4;
  133919. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133920. }
  133921. }
  133922. declare module BABYLON {
  133923. /**
  133924. * Class containing static functions to help procedurally build meshes
  133925. */
  133926. export class LatheBuilder {
  133927. /**
  133928. * Creates lathe mesh.
  133929. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133930. * * 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
  133931. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133932. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133933. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133934. * * 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
  133935. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133936. * * 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
  133937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133941. * @param name defines the name of the mesh
  133942. * @param options defines the options used to create the mesh
  133943. * @param scene defines the hosting scene
  133944. * @returns the lathe mesh
  133945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133946. */
  133947. static CreateLathe(name: string, options: {
  133948. shape: Vector3[];
  133949. radius?: number;
  133950. tessellation?: number;
  133951. clip?: number;
  133952. arc?: number;
  133953. closed?: boolean;
  133954. updatable?: boolean;
  133955. sideOrientation?: number;
  133956. frontUVs?: Vector4;
  133957. backUVs?: Vector4;
  133958. cap?: number;
  133959. invertUV?: boolean;
  133960. }, scene?: Nullable<Scene>): Mesh;
  133961. }
  133962. }
  133963. declare module BABYLON {
  133964. /**
  133965. * Class containing static functions to help procedurally build meshes
  133966. */
  133967. export class TiledPlaneBuilder {
  133968. /**
  133969. * Creates a tiled plane mesh
  133970. * * The parameter `pattern` will, depending on value, do nothing or
  133971. * * * flip (reflect about central vertical) alternate tiles across and up
  133972. * * * flip every tile on alternate rows
  133973. * * * rotate (180 degs) alternate tiles across and up
  133974. * * * rotate every tile on alternate rows
  133975. * * * flip and rotate alternate tiles across and up
  133976. * * * flip and rotate every tile on alternate rows
  133977. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133978. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133981. * * 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)
  133982. * * 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)
  133983. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133984. * @param name defines the name of the mesh
  133985. * @param options defines the options used to create the mesh
  133986. * @param scene defines the hosting scene
  133987. * @returns the box mesh
  133988. */
  133989. static CreateTiledPlane(name: string, options: {
  133990. pattern?: number;
  133991. tileSize?: number;
  133992. tileWidth?: number;
  133993. tileHeight?: number;
  133994. size?: number;
  133995. width?: number;
  133996. height?: number;
  133997. alignHorizontal?: number;
  133998. alignVertical?: number;
  133999. sideOrientation?: number;
  134000. frontUVs?: Vector4;
  134001. backUVs?: Vector4;
  134002. updatable?: boolean;
  134003. }, scene?: Nullable<Scene>): Mesh;
  134004. }
  134005. }
  134006. declare module BABYLON {
  134007. /**
  134008. * Class containing static functions to help procedurally build meshes
  134009. */
  134010. export class TubeBuilder {
  134011. /**
  134012. * Creates a tube mesh.
  134013. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134014. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134015. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134016. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134017. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134018. * * 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)
  134019. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134020. * * 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
  134021. * * 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
  134022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134026. * @param name defines the name of the mesh
  134027. * @param options defines the options used to create the mesh
  134028. * @param scene defines the hosting scene
  134029. * @returns the tube mesh
  134030. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134031. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134032. */
  134033. static CreateTube(name: string, options: {
  134034. path: Vector3[];
  134035. radius?: number;
  134036. tessellation?: number;
  134037. radiusFunction?: {
  134038. (i: number, distance: number): number;
  134039. };
  134040. cap?: number;
  134041. arc?: number;
  134042. updatable?: boolean;
  134043. sideOrientation?: number;
  134044. frontUVs?: Vector4;
  134045. backUVs?: Vector4;
  134046. instance?: Mesh;
  134047. invertUV?: boolean;
  134048. }, scene?: Nullable<Scene>): Mesh;
  134049. }
  134050. }
  134051. declare module BABYLON {
  134052. /**
  134053. * Class containing static functions to help procedurally build meshes
  134054. */
  134055. export class IcoSphereBuilder {
  134056. /**
  134057. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134058. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134059. * * 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`)
  134060. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134061. * * 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
  134062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134065. * @param name defines the name of the mesh
  134066. * @param options defines the options used to create the mesh
  134067. * @param scene defines the hosting scene
  134068. * @returns the icosahedron mesh
  134069. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134070. */
  134071. static CreateIcoSphere(name: string, options: {
  134072. radius?: number;
  134073. radiusX?: number;
  134074. radiusY?: number;
  134075. radiusZ?: number;
  134076. flat?: boolean;
  134077. subdivisions?: number;
  134078. sideOrientation?: number;
  134079. frontUVs?: Vector4;
  134080. backUVs?: Vector4;
  134081. updatable?: boolean;
  134082. }, scene?: Nullable<Scene>): Mesh;
  134083. }
  134084. }
  134085. declare module BABYLON {
  134086. /**
  134087. * Class containing static functions to help procedurally build meshes
  134088. */
  134089. export class DecalBuilder {
  134090. /**
  134091. * Creates a decal mesh.
  134092. * 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
  134093. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134094. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134095. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134096. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134097. * @param name defines the name of the mesh
  134098. * @param sourceMesh defines the mesh where the decal must be applied
  134099. * @param options defines the options used to create the mesh
  134100. * @param scene defines the hosting scene
  134101. * @returns the decal mesh
  134102. * @see https://doc.babylonjs.com/how_to/decals
  134103. */
  134104. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134105. position?: Vector3;
  134106. normal?: Vector3;
  134107. size?: Vector3;
  134108. angle?: number;
  134109. }): Mesh;
  134110. }
  134111. }
  134112. declare module BABYLON {
  134113. /**
  134114. * Class containing static functions to help procedurally build meshes
  134115. */
  134116. export class MeshBuilder {
  134117. /**
  134118. * Creates a box mesh
  134119. * * The parameter `size` sets the size (float) of each box side (default 1)
  134120. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134121. * * 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)
  134122. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134126. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134127. * @param name defines the name of the mesh
  134128. * @param options defines the options used to create the mesh
  134129. * @param scene defines the hosting scene
  134130. * @returns the box mesh
  134131. */
  134132. static CreateBox(name: string, options: {
  134133. size?: number;
  134134. width?: number;
  134135. height?: number;
  134136. depth?: number;
  134137. faceUV?: Vector4[];
  134138. faceColors?: Color4[];
  134139. sideOrientation?: number;
  134140. frontUVs?: Vector4;
  134141. backUVs?: Vector4;
  134142. updatable?: boolean;
  134143. }, scene?: Nullable<Scene>): Mesh;
  134144. /**
  134145. * Creates a tiled box mesh
  134146. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134148. * @param name defines the name of the mesh
  134149. * @param options defines the options used to create the mesh
  134150. * @param scene defines the hosting scene
  134151. * @returns the tiled box mesh
  134152. */
  134153. static CreateTiledBox(name: string, options: {
  134154. pattern?: number;
  134155. size?: number;
  134156. width?: number;
  134157. height?: number;
  134158. depth: number;
  134159. tileSize?: number;
  134160. tileWidth?: number;
  134161. tileHeight?: number;
  134162. faceUV?: Vector4[];
  134163. faceColors?: Color4[];
  134164. alignHorizontal?: number;
  134165. alignVertical?: number;
  134166. sideOrientation?: number;
  134167. updatable?: boolean;
  134168. }, scene?: Nullable<Scene>): Mesh;
  134169. /**
  134170. * Creates a sphere mesh
  134171. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134172. * * 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`)
  134173. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134174. * * 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
  134175. * * 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)
  134176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134179. * @param name defines the name of the mesh
  134180. * @param options defines the options used to create the mesh
  134181. * @param scene defines the hosting scene
  134182. * @returns the sphere mesh
  134183. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134184. */
  134185. static CreateSphere(name: string, options: {
  134186. segments?: number;
  134187. diameter?: number;
  134188. diameterX?: number;
  134189. diameterY?: number;
  134190. diameterZ?: number;
  134191. arc?: number;
  134192. slice?: number;
  134193. sideOrientation?: number;
  134194. frontUVs?: Vector4;
  134195. backUVs?: Vector4;
  134196. updatable?: boolean;
  134197. }, scene?: Nullable<Scene>): Mesh;
  134198. /**
  134199. * Creates a plane polygonal mesh. By default, this is a disc
  134200. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134201. * * 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
  134202. * * 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
  134203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134206. * @param name defines the name of the mesh
  134207. * @param options defines the options used to create the mesh
  134208. * @param scene defines the hosting scene
  134209. * @returns the plane polygonal mesh
  134210. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134211. */
  134212. static CreateDisc(name: string, options: {
  134213. radius?: number;
  134214. tessellation?: number;
  134215. arc?: number;
  134216. updatable?: boolean;
  134217. sideOrientation?: number;
  134218. frontUVs?: Vector4;
  134219. backUVs?: Vector4;
  134220. }, scene?: Nullable<Scene>): Mesh;
  134221. /**
  134222. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134223. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134224. * * 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`)
  134225. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134226. * * 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
  134227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134230. * @param name defines the name of the mesh
  134231. * @param options defines the options used to create the mesh
  134232. * @param scene defines the hosting scene
  134233. * @returns the icosahedron mesh
  134234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134235. */
  134236. static CreateIcoSphere(name: string, options: {
  134237. radius?: number;
  134238. radiusX?: number;
  134239. radiusY?: number;
  134240. radiusZ?: number;
  134241. flat?: boolean;
  134242. subdivisions?: number;
  134243. sideOrientation?: number;
  134244. frontUVs?: Vector4;
  134245. backUVs?: Vector4;
  134246. updatable?: boolean;
  134247. }, scene?: Nullable<Scene>): Mesh;
  134248. /**
  134249. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134250. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134251. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134252. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134253. * * 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
  134254. * * 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
  134255. * * 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
  134256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134259. * * 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
  134260. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134261. * * 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
  134262. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134264. * @param name defines the name of the mesh
  134265. * @param options defines the options used to create the mesh
  134266. * @param scene defines the hosting scene
  134267. * @returns the ribbon mesh
  134268. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134269. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134270. */
  134271. static CreateRibbon(name: string, options: {
  134272. pathArray: Vector3[][];
  134273. closeArray?: boolean;
  134274. closePath?: boolean;
  134275. offset?: number;
  134276. updatable?: boolean;
  134277. sideOrientation?: number;
  134278. frontUVs?: Vector4;
  134279. backUVs?: Vector4;
  134280. instance?: Mesh;
  134281. invertUV?: boolean;
  134282. uvs?: Vector2[];
  134283. colors?: Color4[];
  134284. }, scene?: Nullable<Scene>): Mesh;
  134285. /**
  134286. * Creates a cylinder or a cone mesh
  134287. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134288. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134289. * * 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.
  134290. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134291. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134292. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134293. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134294. * * 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).
  134295. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134296. * * 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).
  134297. * * 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
  134298. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134299. * * 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
  134300. * * 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.
  134301. * * If `enclose` is false, a ring surface is one element.
  134302. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134303. * * 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
  134304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134307. * @param name defines the name of the mesh
  134308. * @param options defines the options used to create the mesh
  134309. * @param scene defines the hosting scene
  134310. * @returns the cylinder mesh
  134311. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134312. */
  134313. static CreateCylinder(name: string, options: {
  134314. height?: number;
  134315. diameterTop?: number;
  134316. diameterBottom?: number;
  134317. diameter?: number;
  134318. tessellation?: number;
  134319. subdivisions?: number;
  134320. arc?: number;
  134321. faceColors?: Color4[];
  134322. faceUV?: Vector4[];
  134323. updatable?: boolean;
  134324. hasRings?: boolean;
  134325. enclose?: boolean;
  134326. cap?: number;
  134327. sideOrientation?: number;
  134328. frontUVs?: Vector4;
  134329. backUVs?: Vector4;
  134330. }, scene?: Nullable<Scene>): Mesh;
  134331. /**
  134332. * Creates a torus mesh
  134333. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134334. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134335. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134339. * @param name defines the name of the mesh
  134340. * @param options defines the options used to create the mesh
  134341. * @param scene defines the hosting scene
  134342. * @returns the torus mesh
  134343. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134344. */
  134345. static CreateTorus(name: string, options: {
  134346. diameter?: number;
  134347. thickness?: number;
  134348. tessellation?: number;
  134349. updatable?: boolean;
  134350. sideOrientation?: number;
  134351. frontUVs?: Vector4;
  134352. backUVs?: Vector4;
  134353. }, scene?: Nullable<Scene>): Mesh;
  134354. /**
  134355. * Creates a torus knot mesh
  134356. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134357. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134358. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134359. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 torus knot mesh
  134367. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134368. */
  134369. static CreateTorusKnot(name: string, options: {
  134370. radius?: number;
  134371. tube?: number;
  134372. radialSegments?: number;
  134373. tubularSegments?: number;
  134374. p?: number;
  134375. q?: number;
  134376. updatable?: boolean;
  134377. sideOrientation?: number;
  134378. frontUVs?: Vector4;
  134379. backUVs?: Vector4;
  134380. }, scene?: Nullable<Scene>): Mesh;
  134381. /**
  134382. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134383. * * 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
  134384. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134385. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134386. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134387. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134388. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134389. * * 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
  134390. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134393. * @param name defines the name of the new line system
  134394. * @param options defines the options used to create the line system
  134395. * @param scene defines the hosting scene
  134396. * @returns a new line system mesh
  134397. */
  134398. static CreateLineSystem(name: string, options: {
  134399. lines: Vector3[][];
  134400. updatable?: boolean;
  134401. instance?: Nullable<LinesMesh>;
  134402. colors?: Nullable<Color4[][]>;
  134403. useVertexAlpha?: boolean;
  134404. }, scene: Nullable<Scene>): LinesMesh;
  134405. /**
  134406. * Creates a line mesh
  134407. * 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
  134408. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134409. * * The parameter `points` is an array successive Vector3
  134410. * * 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
  134411. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134412. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134413. * * When updating an instance, remember that only point positions can change, not the number of points
  134414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134416. * @param name defines the name of the new line system
  134417. * @param options defines the options used to create the line system
  134418. * @param scene defines the hosting scene
  134419. * @returns a new line mesh
  134420. */
  134421. static CreateLines(name: string, options: {
  134422. points: Vector3[];
  134423. updatable?: boolean;
  134424. instance?: Nullable<LinesMesh>;
  134425. colors?: Color4[];
  134426. useVertexAlpha?: boolean;
  134427. }, scene?: Nullable<Scene>): LinesMesh;
  134428. /**
  134429. * Creates a dashed line mesh
  134430. * * 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
  134431. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134432. * * The parameter `points` is an array successive Vector3
  134433. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134434. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134435. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134436. * * 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
  134437. * * When updating an instance, remember that only point positions can change, not the number of points
  134438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134439. * @param name defines the name of the mesh
  134440. * @param options defines the options used to create the mesh
  134441. * @param scene defines the hosting scene
  134442. * @returns the dashed line mesh
  134443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134444. */
  134445. static CreateDashedLines(name: string, options: {
  134446. points: Vector3[];
  134447. dashSize?: number;
  134448. gapSize?: number;
  134449. dashNb?: number;
  134450. updatable?: boolean;
  134451. instance?: LinesMesh;
  134452. }, scene?: Nullable<Scene>): LinesMesh;
  134453. /**
  134454. * 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.
  134455. * * 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.
  134456. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134457. * * 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.
  134458. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134459. * * 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
  134460. * * 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
  134461. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134466. * @param name defines the name of the mesh
  134467. * @param options defines the options used to create the mesh
  134468. * @param scene defines the hosting scene
  134469. * @returns the extruded shape mesh
  134470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134472. */
  134473. static ExtrudeShape(name: string, options: {
  134474. shape: Vector3[];
  134475. path: Vector3[];
  134476. scale?: number;
  134477. rotation?: number;
  134478. cap?: number;
  134479. updatable?: boolean;
  134480. sideOrientation?: number;
  134481. frontUVs?: Vector4;
  134482. backUVs?: Vector4;
  134483. instance?: Mesh;
  134484. invertUV?: boolean;
  134485. }, scene?: Nullable<Scene>): Mesh;
  134486. /**
  134487. * Creates an custom extruded shape mesh.
  134488. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134489. * * 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.
  134490. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134491. * * 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
  134492. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134493. * * 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
  134494. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134495. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134496. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134497. * * 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
  134498. * * 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
  134499. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134504. * @param name defines the name of the mesh
  134505. * @param options defines the options used to create the mesh
  134506. * @param scene defines the hosting scene
  134507. * @returns the custom extruded shape mesh
  134508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134511. */
  134512. static ExtrudeShapeCustom(name: string, options: {
  134513. shape: Vector3[];
  134514. path: Vector3[];
  134515. scaleFunction?: any;
  134516. rotationFunction?: any;
  134517. ribbonCloseArray?: boolean;
  134518. ribbonClosePath?: boolean;
  134519. cap?: number;
  134520. updatable?: boolean;
  134521. sideOrientation?: number;
  134522. frontUVs?: Vector4;
  134523. backUVs?: Vector4;
  134524. instance?: Mesh;
  134525. invertUV?: boolean;
  134526. }, scene?: Nullable<Scene>): Mesh;
  134527. /**
  134528. * Creates lathe mesh.
  134529. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134530. * * 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
  134531. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134532. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134533. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134534. * * 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
  134535. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134536. * * 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
  134537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134541. * @param name defines the name of the mesh
  134542. * @param options defines the options used to create the mesh
  134543. * @param scene defines the hosting scene
  134544. * @returns the lathe mesh
  134545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134546. */
  134547. static CreateLathe(name: string, options: {
  134548. shape: Vector3[];
  134549. radius?: number;
  134550. tessellation?: number;
  134551. clip?: number;
  134552. arc?: number;
  134553. closed?: boolean;
  134554. updatable?: boolean;
  134555. sideOrientation?: number;
  134556. frontUVs?: Vector4;
  134557. backUVs?: Vector4;
  134558. cap?: number;
  134559. invertUV?: boolean;
  134560. }, scene?: Nullable<Scene>): Mesh;
  134561. /**
  134562. * Creates a tiled plane mesh
  134563. * * You can set a limited pattern arrangement with the tiles
  134564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134567. * @param name defines the name of the mesh
  134568. * @param options defines the options used to create the mesh
  134569. * @param scene defines the hosting scene
  134570. * @returns the plane mesh
  134571. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134572. */
  134573. static CreateTiledPlane(name: string, options: {
  134574. pattern?: number;
  134575. tileSize?: number;
  134576. tileWidth?: number;
  134577. tileHeight?: number;
  134578. size?: number;
  134579. width?: number;
  134580. height?: number;
  134581. alignHorizontal?: number;
  134582. alignVertical?: number;
  134583. sideOrientation?: number;
  134584. frontUVs?: Vector4;
  134585. backUVs?: Vector4;
  134586. updatable?: boolean;
  134587. }, scene?: Nullable<Scene>): Mesh;
  134588. /**
  134589. * Creates a plane mesh
  134590. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134591. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134592. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134596. * @param name defines the name of the mesh
  134597. * @param options defines the options used to create the mesh
  134598. * @param scene defines the hosting scene
  134599. * @returns the plane mesh
  134600. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134601. */
  134602. static CreatePlane(name: string, options: {
  134603. size?: number;
  134604. width?: number;
  134605. height?: number;
  134606. sideOrientation?: number;
  134607. frontUVs?: Vector4;
  134608. backUVs?: Vector4;
  134609. updatable?: boolean;
  134610. sourcePlane?: Plane;
  134611. }, scene?: Nullable<Scene>): Mesh;
  134612. /**
  134613. * Creates a ground mesh
  134614. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134615. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134617. * @param name defines the name of the mesh
  134618. * @param options defines the options used to create the mesh
  134619. * @param scene defines the hosting scene
  134620. * @returns the ground mesh
  134621. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134622. */
  134623. static CreateGround(name: string, options: {
  134624. width?: number;
  134625. height?: number;
  134626. subdivisions?: number;
  134627. subdivisionsX?: number;
  134628. subdivisionsY?: number;
  134629. updatable?: boolean;
  134630. }, scene?: Nullable<Scene>): Mesh;
  134631. /**
  134632. * Creates a tiled ground mesh
  134633. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134634. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134635. * * 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
  134636. * * 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
  134637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134638. * @param name defines the name of the mesh
  134639. * @param options defines the options used to create the mesh
  134640. * @param scene defines the hosting scene
  134641. * @returns the tiled ground mesh
  134642. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134643. */
  134644. static CreateTiledGround(name: string, options: {
  134645. xmin: number;
  134646. zmin: number;
  134647. xmax: number;
  134648. zmax: number;
  134649. subdivisions?: {
  134650. w: number;
  134651. h: number;
  134652. };
  134653. precision?: {
  134654. w: number;
  134655. h: number;
  134656. };
  134657. updatable?: boolean;
  134658. }, scene?: Nullable<Scene>): Mesh;
  134659. /**
  134660. * Creates a ground mesh from a height map
  134661. * * The parameter `url` sets the URL of the height map image resource.
  134662. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134663. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134664. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134665. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134666. * * 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.
  134667. * * 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).
  134668. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134670. * @param name defines the name of the mesh
  134671. * @param url defines the url to the height map
  134672. * @param options defines the options used to create the mesh
  134673. * @param scene defines the hosting scene
  134674. * @returns the ground mesh
  134675. * @see https://doc.babylonjs.com/babylon101/height_map
  134676. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134677. */
  134678. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134679. width?: number;
  134680. height?: number;
  134681. subdivisions?: number;
  134682. minHeight?: number;
  134683. maxHeight?: number;
  134684. colorFilter?: Color3;
  134685. alphaFilter?: number;
  134686. updatable?: boolean;
  134687. onReady?: (mesh: GroundMesh) => void;
  134688. }, scene?: Nullable<Scene>): GroundMesh;
  134689. /**
  134690. * Creates a polygon mesh
  134691. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134692. * * 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
  134693. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134696. * * Remember you can only change the shape positions, not their number when updating a polygon
  134697. * @param name defines the name of the mesh
  134698. * @param options defines the options used to create the mesh
  134699. * @param scene defines the hosting scene
  134700. * @param earcutInjection can be used to inject your own earcut reference
  134701. * @returns the polygon mesh
  134702. */
  134703. static CreatePolygon(name: string, options: {
  134704. shape: Vector3[];
  134705. holes?: Vector3[][];
  134706. depth?: number;
  134707. faceUV?: Vector4[];
  134708. faceColors?: Color4[];
  134709. updatable?: boolean;
  134710. sideOrientation?: number;
  134711. frontUVs?: Vector4;
  134712. backUVs?: Vector4;
  134713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134714. /**
  134715. * Creates an extruded polygon mesh, with depth in the Y direction.
  134716. * * 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)
  134717. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134718. * @param name defines the name of the mesh
  134719. * @param options defines the options used to create the mesh
  134720. * @param scene defines the hosting scene
  134721. * @param earcutInjection can be used to inject your own earcut reference
  134722. * @returns the polygon mesh
  134723. */
  134724. static ExtrudePolygon(name: string, options: {
  134725. shape: Vector3[];
  134726. holes?: Vector3[][];
  134727. depth?: number;
  134728. faceUV?: Vector4[];
  134729. faceColors?: Color4[];
  134730. updatable?: boolean;
  134731. sideOrientation?: number;
  134732. frontUVs?: Vector4;
  134733. backUVs?: Vector4;
  134734. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134735. /**
  134736. * Creates a tube mesh.
  134737. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134738. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134739. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134740. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134741. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134742. * * 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)
  134743. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134744. * * 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
  134745. * * 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
  134746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134750. * @param name defines the name of the mesh
  134751. * @param options defines the options used to create the mesh
  134752. * @param scene defines the hosting scene
  134753. * @returns the tube mesh
  134754. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134755. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134756. */
  134757. static CreateTube(name: string, options: {
  134758. path: Vector3[];
  134759. radius?: number;
  134760. tessellation?: number;
  134761. radiusFunction?: {
  134762. (i: number, distance: number): number;
  134763. };
  134764. cap?: number;
  134765. arc?: number;
  134766. updatable?: boolean;
  134767. sideOrientation?: number;
  134768. frontUVs?: Vector4;
  134769. backUVs?: Vector4;
  134770. instance?: Mesh;
  134771. invertUV?: boolean;
  134772. }, scene?: Nullable<Scene>): Mesh;
  134773. /**
  134774. * Creates a polyhedron mesh
  134775. * * 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
  134776. * * The parameter `size` (positive float, default 1) sets the polygon size
  134777. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134778. * * 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`
  134779. * * 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
  134780. * * 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)`)
  134781. * * 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
  134782. * * 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
  134783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134786. * @param name defines the name of the mesh
  134787. * @param options defines the options used to create the mesh
  134788. * @param scene defines the hosting scene
  134789. * @returns the polyhedron mesh
  134790. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134791. */
  134792. static CreatePolyhedron(name: string, options: {
  134793. type?: number;
  134794. size?: number;
  134795. sizeX?: number;
  134796. sizeY?: number;
  134797. sizeZ?: number;
  134798. custom?: any;
  134799. faceUV?: Vector4[];
  134800. faceColors?: Color4[];
  134801. flat?: boolean;
  134802. updatable?: boolean;
  134803. sideOrientation?: number;
  134804. frontUVs?: Vector4;
  134805. backUVs?: Vector4;
  134806. }, scene?: Nullable<Scene>): Mesh;
  134807. /**
  134808. * Creates a decal mesh.
  134809. * 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
  134810. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134811. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134812. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134813. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134814. * @param name defines the name of the mesh
  134815. * @param sourceMesh defines the mesh where the decal must be applied
  134816. * @param options defines the options used to create the mesh
  134817. * @param scene defines the hosting scene
  134818. * @returns the decal mesh
  134819. * @see https://doc.babylonjs.com/how_to/decals
  134820. */
  134821. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134822. position?: Vector3;
  134823. normal?: Vector3;
  134824. size?: Vector3;
  134825. angle?: number;
  134826. }): Mesh;
  134827. }
  134828. }
  134829. declare module BABYLON {
  134830. /**
  134831. * A simplifier interface for future simplification implementations
  134832. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134833. */
  134834. export interface ISimplifier {
  134835. /**
  134836. * Simplification of a given mesh according to the given settings.
  134837. * Since this requires computation, it is assumed that the function runs async.
  134838. * @param settings The settings of the simplification, including quality and distance
  134839. * @param successCallback A callback that will be called after the mesh was simplified.
  134840. * @param errorCallback in case of an error, this callback will be called. optional.
  134841. */
  134842. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134843. }
  134844. /**
  134845. * Expected simplification settings.
  134846. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134847. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134848. */
  134849. export interface ISimplificationSettings {
  134850. /**
  134851. * Gets or sets the expected quality
  134852. */
  134853. quality: number;
  134854. /**
  134855. * Gets or sets the distance when this optimized version should be used
  134856. */
  134857. distance: number;
  134858. /**
  134859. * Gets an already optimized mesh
  134860. */
  134861. optimizeMesh?: boolean;
  134862. }
  134863. /**
  134864. * Class used to specify simplification options
  134865. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134866. */
  134867. export class SimplificationSettings implements ISimplificationSettings {
  134868. /** expected quality */
  134869. quality: number;
  134870. /** distance when this optimized version should be used */
  134871. distance: number;
  134872. /** already optimized mesh */
  134873. optimizeMesh?: boolean | undefined;
  134874. /**
  134875. * Creates a SimplificationSettings
  134876. * @param quality expected quality
  134877. * @param distance distance when this optimized version should be used
  134878. * @param optimizeMesh already optimized mesh
  134879. */
  134880. constructor(
  134881. /** expected quality */
  134882. quality: number,
  134883. /** distance when this optimized version should be used */
  134884. distance: number,
  134885. /** already optimized mesh */
  134886. optimizeMesh?: boolean | undefined);
  134887. }
  134888. /**
  134889. * Interface used to define a simplification task
  134890. */
  134891. export interface ISimplificationTask {
  134892. /**
  134893. * Array of settings
  134894. */
  134895. settings: Array<ISimplificationSettings>;
  134896. /**
  134897. * Simplification type
  134898. */
  134899. simplificationType: SimplificationType;
  134900. /**
  134901. * Mesh to simplify
  134902. */
  134903. mesh: Mesh;
  134904. /**
  134905. * Callback called on success
  134906. */
  134907. successCallback?: () => void;
  134908. /**
  134909. * Defines if parallel processing can be used
  134910. */
  134911. parallelProcessing: boolean;
  134912. }
  134913. /**
  134914. * Queue used to order the simplification tasks
  134915. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134916. */
  134917. export class SimplificationQueue {
  134918. private _simplificationArray;
  134919. /**
  134920. * Gets a boolean indicating that the process is still running
  134921. */
  134922. running: boolean;
  134923. /**
  134924. * Creates a new queue
  134925. */
  134926. constructor();
  134927. /**
  134928. * Adds a new simplification task
  134929. * @param task defines a task to add
  134930. */
  134931. addTask(task: ISimplificationTask): void;
  134932. /**
  134933. * Execute next task
  134934. */
  134935. executeNext(): void;
  134936. /**
  134937. * Execute a simplification task
  134938. * @param task defines the task to run
  134939. */
  134940. runSimplification(task: ISimplificationTask): void;
  134941. private getSimplifier;
  134942. }
  134943. /**
  134944. * The implemented types of simplification
  134945. * At the moment only Quadratic Error Decimation is implemented
  134946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134947. */
  134948. export enum SimplificationType {
  134949. /** Quadratic error decimation */
  134950. QUADRATIC = 0
  134951. }
  134952. }
  134953. declare module BABYLON {
  134954. interface Scene {
  134955. /** @hidden (Backing field) */
  134956. _simplificationQueue: SimplificationQueue;
  134957. /**
  134958. * Gets or sets the simplification queue attached to the scene
  134959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134960. */
  134961. simplificationQueue: SimplificationQueue;
  134962. }
  134963. interface Mesh {
  134964. /**
  134965. * Simplify the mesh according to the given array of settings.
  134966. * Function will return immediately and will simplify async
  134967. * @param settings a collection of simplification settings
  134968. * @param parallelProcessing should all levels calculate parallel or one after the other
  134969. * @param simplificationType the type of simplification to run
  134970. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134971. * @returns the current mesh
  134972. */
  134973. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134974. }
  134975. /**
  134976. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134977. * created in a scene
  134978. */
  134979. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134980. /**
  134981. * The component name helpfull to identify the component in the list of scene components.
  134982. */
  134983. readonly name: string;
  134984. /**
  134985. * The scene the component belongs to.
  134986. */
  134987. scene: Scene;
  134988. /**
  134989. * Creates a new instance of the component for the given scene
  134990. * @param scene Defines the scene to register the component in
  134991. */
  134992. constructor(scene: Scene);
  134993. /**
  134994. * Registers the component in a given scene
  134995. */
  134996. register(): void;
  134997. /**
  134998. * Rebuilds the elements related to this component in case of
  134999. * context lost for instance.
  135000. */
  135001. rebuild(): void;
  135002. /**
  135003. * Disposes the component and the associated ressources
  135004. */
  135005. dispose(): void;
  135006. private _beforeCameraUpdate;
  135007. }
  135008. }
  135009. declare module BABYLON {
  135010. /**
  135011. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135012. */
  135013. export interface INavigationEnginePlugin {
  135014. /**
  135015. * plugin name
  135016. */
  135017. name: string;
  135018. /**
  135019. * Creates a navigation mesh
  135020. * @param meshes array of all the geometry used to compute the navigatio mesh
  135021. * @param parameters bunch of parameters used to filter geometry
  135022. */
  135023. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135024. /**
  135025. * Create a navigation mesh debug mesh
  135026. * @param scene is where the mesh will be added
  135027. * @returns debug display mesh
  135028. */
  135029. createDebugNavMesh(scene: Scene): Mesh;
  135030. /**
  135031. * Get a navigation mesh constrained position, closest to the parameter position
  135032. * @param position world position
  135033. * @returns the closest point to position constrained by the navigation mesh
  135034. */
  135035. getClosestPoint(position: Vector3): Vector3;
  135036. /**
  135037. * Get a navigation mesh constrained position, within a particular radius
  135038. * @param position world position
  135039. * @param maxRadius the maximum distance to the constrained world position
  135040. * @returns the closest point to position constrained by the navigation mesh
  135041. */
  135042. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135043. /**
  135044. * Compute the final position from a segment made of destination-position
  135045. * @param position world position
  135046. * @param destination world position
  135047. * @returns the resulting point along the navmesh
  135048. */
  135049. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135050. /**
  135051. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135052. * @param start world position
  135053. * @param end world position
  135054. * @returns array containing world position composing the path
  135055. */
  135056. computePath(start: Vector3, end: Vector3): Vector3[];
  135057. /**
  135058. * If this plugin is supported
  135059. * @returns true if plugin is supported
  135060. */
  135061. isSupported(): boolean;
  135062. /**
  135063. * Create a new Crowd so you can add agents
  135064. * @param maxAgents the maximum agent count in the crowd
  135065. * @param maxAgentRadius the maximum radius an agent can have
  135066. * @param scene to attach the crowd to
  135067. * @returns the crowd you can add agents to
  135068. */
  135069. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135070. /**
  135071. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135072. * The queries will try to find a solution within those bounds
  135073. * default is (1,1,1)
  135074. * @param extent x,y,z value that define the extent around the queries point of reference
  135075. */
  135076. setDefaultQueryExtent(extent: Vector3): void;
  135077. /**
  135078. * Get the Bounding box extent specified by setDefaultQueryExtent
  135079. * @returns the box extent values
  135080. */
  135081. getDefaultQueryExtent(): Vector3;
  135082. /**
  135083. * Release all resources
  135084. */
  135085. dispose(): void;
  135086. }
  135087. /**
  135088. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135089. */
  135090. export interface ICrowd {
  135091. /**
  135092. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135093. * You can attach anything to that node. The node position is updated in the scene update tick.
  135094. * @param pos world position that will be constrained by the navigation mesh
  135095. * @param parameters agent parameters
  135096. * @param transform hooked to the agent that will be update by the scene
  135097. * @returns agent index
  135098. */
  135099. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135100. /**
  135101. * Returns the agent position in world space
  135102. * @param index agent index returned by addAgent
  135103. * @returns world space position
  135104. */
  135105. getAgentPosition(index: number): Vector3;
  135106. /**
  135107. * Gets the agent velocity in world space
  135108. * @param index agent index returned by addAgent
  135109. * @returns world space velocity
  135110. */
  135111. getAgentVelocity(index: number): Vector3;
  135112. /**
  135113. * remove a particular agent previously created
  135114. * @param index agent index returned by addAgent
  135115. */
  135116. removeAgent(index: number): void;
  135117. /**
  135118. * get the list of all agents attached to this crowd
  135119. * @returns list of agent indices
  135120. */
  135121. getAgents(): number[];
  135122. /**
  135123. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135124. * @param deltaTime in seconds
  135125. */
  135126. update(deltaTime: number): void;
  135127. /**
  135128. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135129. * @param index agent index returned by addAgent
  135130. * @param destination targeted world position
  135131. */
  135132. agentGoto(index: number, destination: Vector3): void;
  135133. /**
  135134. * Teleport the agent to a new position
  135135. * @param index agent index returned by addAgent
  135136. * @param destination targeted world position
  135137. */
  135138. agentTeleport(index: number, destination: Vector3): void;
  135139. /**
  135140. * Update agent parameters
  135141. * @param index agent index returned by addAgent
  135142. * @param parameters agent parameters
  135143. */
  135144. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135145. /**
  135146. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135147. * The queries will try to find a solution within those bounds
  135148. * default is (1,1,1)
  135149. * @param extent x,y,z value that define the extent around the queries point of reference
  135150. */
  135151. setDefaultQueryExtent(extent: Vector3): void;
  135152. /**
  135153. * Get the Bounding box extent specified by setDefaultQueryExtent
  135154. * @returns the box extent values
  135155. */
  135156. getDefaultQueryExtent(): Vector3;
  135157. /**
  135158. * Release all resources
  135159. */
  135160. dispose(): void;
  135161. }
  135162. /**
  135163. * Configures an agent
  135164. */
  135165. export interface IAgentParameters {
  135166. /**
  135167. * Agent radius. [Limit: >= 0]
  135168. */
  135169. radius: number;
  135170. /**
  135171. * Agent height. [Limit: > 0]
  135172. */
  135173. height: number;
  135174. /**
  135175. * Maximum allowed acceleration. [Limit: >= 0]
  135176. */
  135177. maxAcceleration: number;
  135178. /**
  135179. * Maximum allowed speed. [Limit: >= 0]
  135180. */
  135181. maxSpeed: number;
  135182. /**
  135183. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135184. */
  135185. collisionQueryRange: number;
  135186. /**
  135187. * The path visibility optimization range. [Limit: > 0]
  135188. */
  135189. pathOptimizationRange: number;
  135190. /**
  135191. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135192. */
  135193. separationWeight: number;
  135194. }
  135195. /**
  135196. * Configures the navigation mesh creation
  135197. */
  135198. export interface INavMeshParameters {
  135199. /**
  135200. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135201. */
  135202. cs: number;
  135203. /**
  135204. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135205. */
  135206. ch: number;
  135207. /**
  135208. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135209. */
  135210. walkableSlopeAngle: number;
  135211. /**
  135212. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135213. * be considered walkable. [Limit: >= 3] [Units: vx]
  135214. */
  135215. walkableHeight: number;
  135216. /**
  135217. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135218. */
  135219. walkableClimb: number;
  135220. /**
  135221. * The distance to erode/shrink the walkable area of the heightfield away from
  135222. * obstructions. [Limit: >=0] [Units: vx]
  135223. */
  135224. walkableRadius: number;
  135225. /**
  135226. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135227. */
  135228. maxEdgeLen: number;
  135229. /**
  135230. * The maximum distance a simplfied contour's border edges should deviate
  135231. * the original raw contour. [Limit: >=0] [Units: vx]
  135232. */
  135233. maxSimplificationError: number;
  135234. /**
  135235. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135236. */
  135237. minRegionArea: number;
  135238. /**
  135239. * Any regions with a span count smaller than this value will, if possible,
  135240. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135241. */
  135242. mergeRegionArea: number;
  135243. /**
  135244. * The maximum number of vertices allowed for polygons generated during the
  135245. * contour to polygon conversion process. [Limit: >= 3]
  135246. */
  135247. maxVertsPerPoly: number;
  135248. /**
  135249. * Sets the sampling distance to use when generating the detail mesh.
  135250. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135251. */
  135252. detailSampleDist: number;
  135253. /**
  135254. * The maximum distance the detail mesh surface should deviate from heightfield
  135255. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135256. */
  135257. detailSampleMaxError: number;
  135258. }
  135259. }
  135260. declare module BABYLON {
  135261. /**
  135262. * RecastJS navigation plugin
  135263. */
  135264. export class RecastJSPlugin implements INavigationEnginePlugin {
  135265. /**
  135266. * Reference to the Recast library
  135267. */
  135268. bjsRECAST: any;
  135269. /**
  135270. * plugin name
  135271. */
  135272. name: string;
  135273. /**
  135274. * the first navmesh created. We might extend this to support multiple navmeshes
  135275. */
  135276. navMesh: any;
  135277. /**
  135278. * Initializes the recastJS plugin
  135279. * @param recastInjection can be used to inject your own recast reference
  135280. */
  135281. constructor(recastInjection?: any);
  135282. /**
  135283. * Creates a navigation mesh
  135284. * @param meshes array of all the geometry used to compute the navigatio mesh
  135285. * @param parameters bunch of parameters used to filter geometry
  135286. */
  135287. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135288. /**
  135289. * Create a navigation mesh debug mesh
  135290. * @param scene is where the mesh will be added
  135291. * @returns debug display mesh
  135292. */
  135293. createDebugNavMesh(scene: Scene): Mesh;
  135294. /**
  135295. * Get a navigation mesh constrained position, closest to the parameter position
  135296. * @param position world position
  135297. * @returns the closest point to position constrained by the navigation mesh
  135298. */
  135299. getClosestPoint(position: Vector3): Vector3;
  135300. /**
  135301. * Get a navigation mesh constrained position, within a particular radius
  135302. * @param position world position
  135303. * @param maxRadius the maximum distance to the constrained world position
  135304. * @returns the closest point to position constrained by the navigation mesh
  135305. */
  135306. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135307. /**
  135308. * Compute the final position from a segment made of destination-position
  135309. * @param position world position
  135310. * @param destination world position
  135311. * @returns the resulting point along the navmesh
  135312. */
  135313. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135314. /**
  135315. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135316. * @param start world position
  135317. * @param end world position
  135318. * @returns array containing world position composing the path
  135319. */
  135320. computePath(start: Vector3, end: Vector3): Vector3[];
  135321. /**
  135322. * Create a new Crowd so you can add agents
  135323. * @param maxAgents the maximum agent count in the crowd
  135324. * @param maxAgentRadius the maximum radius an agent can have
  135325. * @param scene to attach the crowd to
  135326. * @returns the crowd you can add agents to
  135327. */
  135328. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135329. /**
  135330. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135331. * The queries will try to find a solution within those bounds
  135332. * default is (1,1,1)
  135333. * @param extent x,y,z value that define the extent around the queries point of reference
  135334. */
  135335. setDefaultQueryExtent(extent: Vector3): void;
  135336. /**
  135337. * Get the Bounding box extent specified by setDefaultQueryExtent
  135338. * @returns the box extent values
  135339. */
  135340. getDefaultQueryExtent(): Vector3;
  135341. /**
  135342. * Disposes
  135343. */
  135344. dispose(): void;
  135345. /**
  135346. * If this plugin is supported
  135347. * @returns true if plugin is supported
  135348. */
  135349. isSupported(): boolean;
  135350. }
  135351. /**
  135352. * Recast detour crowd implementation
  135353. */
  135354. export class RecastJSCrowd implements ICrowd {
  135355. /**
  135356. * Recast/detour plugin
  135357. */
  135358. bjsRECASTPlugin: RecastJSPlugin;
  135359. /**
  135360. * Link to the detour crowd
  135361. */
  135362. recastCrowd: any;
  135363. /**
  135364. * One transform per agent
  135365. */
  135366. transforms: TransformNode[];
  135367. /**
  135368. * All agents created
  135369. */
  135370. agents: number[];
  135371. /**
  135372. * Link to the scene is kept to unregister the crowd from the scene
  135373. */
  135374. private _scene;
  135375. /**
  135376. * Observer for crowd updates
  135377. */
  135378. private _onBeforeAnimationsObserver;
  135379. /**
  135380. * Constructor
  135381. * @param plugin recastJS plugin
  135382. * @param maxAgents the maximum agent count in the crowd
  135383. * @param maxAgentRadius the maximum radius an agent can have
  135384. * @param scene to attach the crowd to
  135385. * @returns the crowd you can add agents to
  135386. */
  135387. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135388. /**
  135389. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135390. * You can attach anything to that node. The node position is updated in the scene update tick.
  135391. * @param pos world position that will be constrained by the navigation mesh
  135392. * @param parameters agent parameters
  135393. * @param transform hooked to the agent that will be update by the scene
  135394. * @returns agent index
  135395. */
  135396. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135397. /**
  135398. * Returns the agent position in world space
  135399. * @param index agent index returned by addAgent
  135400. * @returns world space position
  135401. */
  135402. getAgentPosition(index: number): Vector3;
  135403. /**
  135404. * Returns the agent velocity in world space
  135405. * @param index agent index returned by addAgent
  135406. * @returns world space velocity
  135407. */
  135408. getAgentVelocity(index: number): Vector3;
  135409. /**
  135410. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135411. * @param index agent index returned by addAgent
  135412. * @param destination targeted world position
  135413. */
  135414. agentGoto(index: number, destination: Vector3): void;
  135415. /**
  135416. * Teleport the agent to a new position
  135417. * @param index agent index returned by addAgent
  135418. * @param destination targeted world position
  135419. */
  135420. agentTeleport(index: number, destination: Vector3): void;
  135421. /**
  135422. * Update agent parameters
  135423. * @param index agent index returned by addAgent
  135424. * @param parameters agent parameters
  135425. */
  135426. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135427. /**
  135428. * remove a particular agent previously created
  135429. * @param index agent index returned by addAgent
  135430. */
  135431. removeAgent(index: number): void;
  135432. /**
  135433. * get the list of all agents attached to this crowd
  135434. * @returns list of agent indices
  135435. */
  135436. getAgents(): number[];
  135437. /**
  135438. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135439. * @param deltaTime in seconds
  135440. */
  135441. update(deltaTime: number): void;
  135442. /**
  135443. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135444. * The queries will try to find a solution within those bounds
  135445. * default is (1,1,1)
  135446. * @param extent x,y,z value that define the extent around the queries point of reference
  135447. */
  135448. setDefaultQueryExtent(extent: Vector3): void;
  135449. /**
  135450. * Get the Bounding box extent specified by setDefaultQueryExtent
  135451. * @returns the box extent values
  135452. */
  135453. getDefaultQueryExtent(): Vector3;
  135454. /**
  135455. * Release all resources
  135456. */
  135457. dispose(): void;
  135458. }
  135459. }
  135460. declare module BABYLON {
  135461. /**
  135462. * Class used to enable access to IndexedDB
  135463. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135464. */
  135465. export class Database implements IOfflineProvider {
  135466. private _callbackManifestChecked;
  135467. private _currentSceneUrl;
  135468. private _db;
  135469. private _enableSceneOffline;
  135470. private _enableTexturesOffline;
  135471. private _manifestVersionFound;
  135472. private _mustUpdateRessources;
  135473. private _hasReachedQuota;
  135474. private _isSupported;
  135475. private _idbFactory;
  135476. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135477. private static IsUASupportingBlobStorage;
  135478. /**
  135479. * Gets a boolean indicating if Database storate is enabled (off by default)
  135480. */
  135481. static IDBStorageEnabled: boolean;
  135482. /**
  135483. * Gets a boolean indicating if scene must be saved in the database
  135484. */
  135485. get enableSceneOffline(): boolean;
  135486. /**
  135487. * Gets a boolean indicating if textures must be saved in the database
  135488. */
  135489. get enableTexturesOffline(): boolean;
  135490. /**
  135491. * Creates a new Database
  135492. * @param urlToScene defines the url to load the scene
  135493. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135494. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135495. */
  135496. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135497. private static _ParseURL;
  135498. private static _ReturnFullUrlLocation;
  135499. private _checkManifestFile;
  135500. /**
  135501. * Open the database and make it available
  135502. * @param successCallback defines the callback to call on success
  135503. * @param errorCallback defines the callback to call on error
  135504. */
  135505. open(successCallback: () => void, errorCallback: () => void): void;
  135506. /**
  135507. * Loads an image from the database
  135508. * @param url defines the url to load from
  135509. * @param image defines the target DOM image
  135510. */
  135511. loadImage(url: string, image: HTMLImageElement): void;
  135512. private _loadImageFromDBAsync;
  135513. private _saveImageIntoDBAsync;
  135514. private _checkVersionFromDB;
  135515. private _loadVersionFromDBAsync;
  135516. private _saveVersionIntoDBAsync;
  135517. /**
  135518. * Loads a file from database
  135519. * @param url defines the URL to load from
  135520. * @param sceneLoaded defines a callback to call on success
  135521. * @param progressCallBack defines a callback to call when progress changed
  135522. * @param errorCallback defines a callback to call on error
  135523. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135524. */
  135525. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135526. private _loadFileAsync;
  135527. private _saveFileAsync;
  135528. /**
  135529. * Validates if xhr data is correct
  135530. * @param xhr defines the request to validate
  135531. * @param dataType defines the expected data type
  135532. * @returns true if data is correct
  135533. */
  135534. private static _ValidateXHRData;
  135535. }
  135536. }
  135537. declare module BABYLON {
  135538. /** @hidden */
  135539. export var gpuUpdateParticlesPixelShader: {
  135540. name: string;
  135541. shader: string;
  135542. };
  135543. }
  135544. declare module BABYLON {
  135545. /** @hidden */
  135546. export var gpuUpdateParticlesVertexShader: {
  135547. name: string;
  135548. shader: string;
  135549. };
  135550. }
  135551. declare module BABYLON {
  135552. /** @hidden */
  135553. export var clipPlaneFragmentDeclaration2: {
  135554. name: string;
  135555. shader: string;
  135556. };
  135557. }
  135558. declare module BABYLON {
  135559. /** @hidden */
  135560. export var gpuRenderParticlesPixelShader: {
  135561. name: string;
  135562. shader: string;
  135563. };
  135564. }
  135565. declare module BABYLON {
  135566. /** @hidden */
  135567. export var clipPlaneVertexDeclaration2: {
  135568. name: string;
  135569. shader: string;
  135570. };
  135571. }
  135572. declare module BABYLON {
  135573. /** @hidden */
  135574. export var gpuRenderParticlesVertexShader: {
  135575. name: string;
  135576. shader: string;
  135577. };
  135578. }
  135579. declare module BABYLON {
  135580. /**
  135581. * This represents a GPU particle system in Babylon
  135582. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135583. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135584. */
  135585. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135586. /**
  135587. * The layer mask we are rendering the particles through.
  135588. */
  135589. layerMask: number;
  135590. private _capacity;
  135591. private _activeCount;
  135592. private _currentActiveCount;
  135593. private _accumulatedCount;
  135594. private _renderEffect;
  135595. private _updateEffect;
  135596. private _buffer0;
  135597. private _buffer1;
  135598. private _spriteBuffer;
  135599. private _updateVAO;
  135600. private _renderVAO;
  135601. private _targetIndex;
  135602. private _sourceBuffer;
  135603. private _targetBuffer;
  135604. private _engine;
  135605. private _currentRenderId;
  135606. private _started;
  135607. private _stopped;
  135608. private _timeDelta;
  135609. private _randomTexture;
  135610. private _randomTexture2;
  135611. private _attributesStrideSize;
  135612. private _updateEffectOptions;
  135613. private _randomTextureSize;
  135614. private _actualFrame;
  135615. private readonly _rawTextureWidth;
  135616. /**
  135617. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135618. */
  135619. static get IsSupported(): boolean;
  135620. /**
  135621. * An event triggered when the system is disposed.
  135622. */
  135623. onDisposeObservable: Observable<GPUParticleSystem>;
  135624. /**
  135625. * Gets the maximum number of particles active at the same time.
  135626. * @returns The max number of active particles.
  135627. */
  135628. getCapacity(): number;
  135629. /**
  135630. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135631. * to override the particles.
  135632. */
  135633. forceDepthWrite: boolean;
  135634. /**
  135635. * Gets or set the number of active particles
  135636. */
  135637. get activeParticleCount(): number;
  135638. set activeParticleCount(value: number);
  135639. private _preWarmDone;
  135640. /**
  135641. * Is this system ready to be used/rendered
  135642. * @return true if the system is ready
  135643. */
  135644. isReady(): boolean;
  135645. /**
  135646. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135647. * @returns True if it has been started, otherwise false.
  135648. */
  135649. isStarted(): boolean;
  135650. /**
  135651. * Starts the particle system and begins to emit
  135652. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135653. */
  135654. start(delay?: number): void;
  135655. /**
  135656. * Stops the particle system.
  135657. */
  135658. stop(): void;
  135659. /**
  135660. * Remove all active particles
  135661. */
  135662. reset(): void;
  135663. /**
  135664. * Returns the string "GPUParticleSystem"
  135665. * @returns a string containing the class name
  135666. */
  135667. getClassName(): string;
  135668. private _colorGradientsTexture;
  135669. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135670. /**
  135671. * Adds a new color gradient
  135672. * @param gradient defines the gradient to use (between 0 and 1)
  135673. * @param color1 defines the color to affect to the specified gradient
  135674. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135675. * @returns the current particle system
  135676. */
  135677. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135678. /**
  135679. * Remove a specific color gradient
  135680. * @param gradient defines the gradient to remove
  135681. * @returns the current particle system
  135682. */
  135683. removeColorGradient(gradient: number): GPUParticleSystem;
  135684. private _angularSpeedGradientsTexture;
  135685. private _sizeGradientsTexture;
  135686. private _velocityGradientsTexture;
  135687. private _limitVelocityGradientsTexture;
  135688. private _dragGradientsTexture;
  135689. private _addFactorGradient;
  135690. /**
  135691. * Adds a new size gradient
  135692. * @param gradient defines the gradient to use (between 0 and 1)
  135693. * @param factor defines the size factor to affect to the specified gradient
  135694. * @returns the current particle system
  135695. */
  135696. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135697. /**
  135698. * Remove a specific size gradient
  135699. * @param gradient defines the gradient to remove
  135700. * @returns the current particle system
  135701. */
  135702. removeSizeGradient(gradient: number): GPUParticleSystem;
  135703. /**
  135704. * Adds a new angular speed gradient
  135705. * @param gradient defines the gradient to use (between 0 and 1)
  135706. * @param factor defines the angular speed to affect to the specified gradient
  135707. * @returns the current particle system
  135708. */
  135709. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135710. /**
  135711. * Remove a specific angular speed gradient
  135712. * @param gradient defines the gradient to remove
  135713. * @returns the current particle system
  135714. */
  135715. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135716. /**
  135717. * Adds a new velocity gradient
  135718. * @param gradient defines the gradient to use (between 0 and 1)
  135719. * @param factor defines the velocity to affect to the specified gradient
  135720. * @returns the current particle system
  135721. */
  135722. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135723. /**
  135724. * Remove a specific velocity gradient
  135725. * @param gradient defines the gradient to remove
  135726. * @returns the current particle system
  135727. */
  135728. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135729. /**
  135730. * Adds a new limit velocity gradient
  135731. * @param gradient defines the gradient to use (between 0 and 1)
  135732. * @param factor defines the limit velocity value to affect to the specified gradient
  135733. * @returns the current particle system
  135734. */
  135735. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135736. /**
  135737. * Remove a specific limit velocity gradient
  135738. * @param gradient defines the gradient to remove
  135739. * @returns the current particle system
  135740. */
  135741. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135742. /**
  135743. * Adds a new drag gradient
  135744. * @param gradient defines the gradient to use (between 0 and 1)
  135745. * @param factor defines the drag value to affect to the specified gradient
  135746. * @returns the current particle system
  135747. */
  135748. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135749. /**
  135750. * Remove a specific drag gradient
  135751. * @param gradient defines the gradient to remove
  135752. * @returns the current particle system
  135753. */
  135754. removeDragGradient(gradient: number): GPUParticleSystem;
  135755. /**
  135756. * Not supported by GPUParticleSystem
  135757. * @param gradient defines the gradient to use (between 0 and 1)
  135758. * @param factor defines the emit rate value to affect to the specified gradient
  135759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135760. * @returns the current particle system
  135761. */
  135762. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135763. /**
  135764. * Not supported by GPUParticleSystem
  135765. * @param gradient defines the gradient to remove
  135766. * @returns the current particle system
  135767. */
  135768. removeEmitRateGradient(gradient: number): IParticleSystem;
  135769. /**
  135770. * Not supported by GPUParticleSystem
  135771. * @param gradient defines the gradient to use (between 0 and 1)
  135772. * @param factor defines the start size value to affect to the specified gradient
  135773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135774. * @returns the current particle system
  135775. */
  135776. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135777. /**
  135778. * Not supported by GPUParticleSystem
  135779. * @param gradient defines the gradient to remove
  135780. * @returns the current particle system
  135781. */
  135782. removeStartSizeGradient(gradient: number): IParticleSystem;
  135783. /**
  135784. * Not supported by GPUParticleSystem
  135785. * @param gradient defines the gradient to use (between 0 and 1)
  135786. * @param min defines the color remap minimal range
  135787. * @param max defines the color remap maximal range
  135788. * @returns the current particle system
  135789. */
  135790. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135791. /**
  135792. * Not supported by GPUParticleSystem
  135793. * @param gradient defines the gradient to remove
  135794. * @returns the current particle system
  135795. */
  135796. removeColorRemapGradient(): IParticleSystem;
  135797. /**
  135798. * Not supported by GPUParticleSystem
  135799. * @param gradient defines the gradient to use (between 0 and 1)
  135800. * @param min defines the alpha remap minimal range
  135801. * @param max defines the alpha remap maximal range
  135802. * @returns the current particle system
  135803. */
  135804. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135805. /**
  135806. * Not supported by GPUParticleSystem
  135807. * @param gradient defines the gradient to remove
  135808. * @returns the current particle system
  135809. */
  135810. removeAlphaRemapGradient(): IParticleSystem;
  135811. /**
  135812. * Not supported by GPUParticleSystem
  135813. * @param gradient defines the gradient to use (between 0 and 1)
  135814. * @param color defines the color to affect to the specified gradient
  135815. * @returns the current particle system
  135816. */
  135817. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135818. /**
  135819. * Not supported by GPUParticleSystem
  135820. * @param gradient defines the gradient to remove
  135821. * @returns the current particle system
  135822. */
  135823. removeRampGradient(): IParticleSystem;
  135824. /**
  135825. * Not supported by GPUParticleSystem
  135826. * @returns the list of ramp gradients
  135827. */
  135828. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135829. /**
  135830. * Not supported by GPUParticleSystem
  135831. * Gets or sets a boolean indicating that ramp gradients must be used
  135832. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135833. */
  135834. get useRampGradients(): boolean;
  135835. set useRampGradients(value: boolean);
  135836. /**
  135837. * Not supported by GPUParticleSystem
  135838. * @param gradient defines the gradient to use (between 0 and 1)
  135839. * @param factor defines the life time factor to affect to the specified gradient
  135840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135841. * @returns the current particle system
  135842. */
  135843. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135844. /**
  135845. * Not supported by GPUParticleSystem
  135846. * @param gradient defines the gradient to remove
  135847. * @returns the current particle system
  135848. */
  135849. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135850. /**
  135851. * Instantiates a GPU particle system.
  135852. * 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.
  135853. * @param name The name of the particle system
  135854. * @param options The options used to create the system
  135855. * @param scene The scene the particle system belongs to
  135856. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135857. */
  135858. constructor(name: string, options: Partial<{
  135859. capacity: number;
  135860. randomTextureSize: number;
  135861. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135862. protected _reset(): void;
  135863. private _createUpdateVAO;
  135864. private _createRenderVAO;
  135865. private _initialize;
  135866. /** @hidden */
  135867. _recreateUpdateEffect(): void;
  135868. /** @hidden */
  135869. _recreateRenderEffect(): void;
  135870. /**
  135871. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135872. * @param preWarm defines if we are in the pre-warmimg phase
  135873. */
  135874. animate(preWarm?: boolean): void;
  135875. private _createFactorGradientTexture;
  135876. private _createSizeGradientTexture;
  135877. private _createAngularSpeedGradientTexture;
  135878. private _createVelocityGradientTexture;
  135879. private _createLimitVelocityGradientTexture;
  135880. private _createDragGradientTexture;
  135881. private _createColorGradientTexture;
  135882. /**
  135883. * Renders the particle system in its current state
  135884. * @param preWarm defines if the system should only update the particles but not render them
  135885. * @returns the current number of particles
  135886. */
  135887. render(preWarm?: boolean): number;
  135888. /**
  135889. * Rebuilds the particle system
  135890. */
  135891. rebuild(): void;
  135892. private _releaseBuffers;
  135893. private _releaseVAOs;
  135894. /**
  135895. * Disposes the particle system and free the associated resources
  135896. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135897. */
  135898. dispose(disposeTexture?: boolean): void;
  135899. /**
  135900. * Clones the particle system.
  135901. * @param name The name of the cloned object
  135902. * @param newEmitter The new emitter to use
  135903. * @returns the cloned particle system
  135904. */
  135905. clone(name: string, newEmitter: any): GPUParticleSystem;
  135906. /**
  135907. * Serializes the particle system to a JSON object.
  135908. * @returns the JSON object
  135909. */
  135910. serialize(): any;
  135911. /**
  135912. * Parses a JSON object to create a GPU particle system.
  135913. * @param parsedParticleSystem The JSON object to parse
  135914. * @param scene The scene to create the particle system in
  135915. * @param rootUrl The root url to use to load external dependencies like texture
  135916. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135917. * @returns the parsed GPU particle system
  135918. */
  135919. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135920. }
  135921. }
  135922. declare module BABYLON {
  135923. /**
  135924. * Represents a set of particle systems working together to create a specific effect
  135925. */
  135926. export class ParticleSystemSet implements IDisposable {
  135927. /**
  135928. * Gets or sets base Assets URL
  135929. */
  135930. static BaseAssetsUrl: string;
  135931. private _emitterCreationOptions;
  135932. private _emitterNode;
  135933. /**
  135934. * Gets the particle system list
  135935. */
  135936. systems: IParticleSystem[];
  135937. /**
  135938. * Gets the emitter node used with this set
  135939. */
  135940. get emitterNode(): Nullable<TransformNode>;
  135941. /**
  135942. * Creates a new emitter mesh as a sphere
  135943. * @param options defines the options used to create the sphere
  135944. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135945. * @param scene defines the hosting scene
  135946. */
  135947. setEmitterAsSphere(options: {
  135948. diameter: number;
  135949. segments: number;
  135950. color: Color3;
  135951. }, renderingGroupId: number, scene: Scene): void;
  135952. /**
  135953. * Starts all particle systems of the set
  135954. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135955. */
  135956. start(emitter?: AbstractMesh): void;
  135957. /**
  135958. * Release all associated resources
  135959. */
  135960. dispose(): void;
  135961. /**
  135962. * Serialize the set into a JSON compatible object
  135963. * @returns a JSON compatible representation of the set
  135964. */
  135965. serialize(): any;
  135966. /**
  135967. * Parse a new ParticleSystemSet from a serialized source
  135968. * @param data defines a JSON compatible representation of the set
  135969. * @param scene defines the hosting scene
  135970. * @param gpu defines if we want GPU particles or CPU particles
  135971. * @returns a new ParticleSystemSet
  135972. */
  135973. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135974. }
  135975. }
  135976. declare module BABYLON {
  135977. /**
  135978. * This class is made for on one-liner static method to help creating particle system set.
  135979. */
  135980. export class ParticleHelper {
  135981. /**
  135982. * Gets or sets base Assets URL
  135983. */
  135984. static BaseAssetsUrl: string;
  135985. /**
  135986. * Create a default particle system that you can tweak
  135987. * @param emitter defines the emitter to use
  135988. * @param capacity defines the system capacity (default is 500 particles)
  135989. * @param scene defines the hosting scene
  135990. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135991. * @returns the new Particle system
  135992. */
  135993. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135994. /**
  135995. * This is the main static method (one-liner) of this helper to create different particle systems
  135996. * @param type This string represents the type to the particle system to create
  135997. * @param scene The scene where the particle system should live
  135998. * @param gpu If the system will use gpu
  135999. * @returns the ParticleSystemSet created
  136000. */
  136001. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136002. /**
  136003. * Static function used to export a particle system to a ParticleSystemSet variable.
  136004. * Please note that the emitter shape is not exported
  136005. * @param systems defines the particle systems to export
  136006. * @returns the created particle system set
  136007. */
  136008. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136009. }
  136010. }
  136011. declare module BABYLON {
  136012. interface Engine {
  136013. /**
  136014. * Create an effect to use with particle systems.
  136015. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136016. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136017. * @param uniformsNames defines a list of attribute names
  136018. * @param samplers defines an array of string used to represent textures
  136019. * @param defines defines the string containing the defines to use to compile the shaders
  136020. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136021. * @param onCompiled defines a function to call when the effect creation is successful
  136022. * @param onError defines a function to call when the effect creation has failed
  136023. * @returns the new Effect
  136024. */
  136025. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136026. }
  136027. interface Mesh {
  136028. /**
  136029. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136030. * @returns an array of IParticleSystem
  136031. */
  136032. getEmittedParticleSystems(): IParticleSystem[];
  136033. /**
  136034. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136035. * @returns an array of IParticleSystem
  136036. */
  136037. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136038. }
  136039. /**
  136040. * @hidden
  136041. */
  136042. export var _IDoNeedToBeInTheBuild: number;
  136043. }
  136044. declare module BABYLON {
  136045. /** Defines the 4 color options */
  136046. export enum PointColor {
  136047. /** color value */
  136048. Color = 2,
  136049. /** uv value */
  136050. UV = 1,
  136051. /** random value */
  136052. Random = 0,
  136053. /** stated value */
  136054. Stated = 3
  136055. }
  136056. /**
  136057. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136058. * 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.
  136059. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136060. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136061. *
  136062. * Full documentation here : TO BE ENTERED
  136063. */
  136064. export class PointsCloudSystem implements IDisposable {
  136065. /**
  136066. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136067. * Example : var p = SPS.particles[i];
  136068. */
  136069. particles: CloudPoint[];
  136070. /**
  136071. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136072. */
  136073. nbParticles: number;
  136074. /**
  136075. * This a counter for your own usage. It's not set by any SPS functions.
  136076. */
  136077. counter: number;
  136078. /**
  136079. * The PCS name. This name is also given to the underlying mesh.
  136080. */
  136081. name: string;
  136082. /**
  136083. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136084. */
  136085. mesh: Mesh;
  136086. /**
  136087. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136088. * Please read :
  136089. */
  136090. vars: any;
  136091. /**
  136092. * @hidden
  136093. */
  136094. _size: number;
  136095. private _scene;
  136096. private _promises;
  136097. private _positions;
  136098. private _indices;
  136099. private _normals;
  136100. private _colors;
  136101. private _uvs;
  136102. private _indices32;
  136103. private _positions32;
  136104. private _colors32;
  136105. private _uvs32;
  136106. private _updatable;
  136107. private _isVisibilityBoxLocked;
  136108. private _alwaysVisible;
  136109. private _groups;
  136110. private _groupCounter;
  136111. private _computeParticleColor;
  136112. private _computeParticleTexture;
  136113. private _computeParticleRotation;
  136114. private _computeBoundingBox;
  136115. private _isReady;
  136116. /**
  136117. * Creates a PCS (Points Cloud System) object
  136118. * @param name (String) is the PCS name, this will be the underlying mesh name
  136119. * @param pointSize (number) is the size for each point
  136120. * @param scene (Scene) is the scene in which the PCS is added
  136121. * @param options defines the options of the PCS e.g.
  136122. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136123. */
  136124. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136125. updatable?: boolean;
  136126. });
  136127. /**
  136128. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136129. * If no points were added to the PCS, the returned mesh is just a single point.
  136130. * @returns a promise for the created mesh
  136131. */
  136132. buildMeshAsync(): Promise<Mesh>;
  136133. /**
  136134. * @hidden
  136135. */
  136136. private _buildMesh;
  136137. private _addParticle;
  136138. private _randomUnitVector;
  136139. private _getColorIndicesForCoord;
  136140. private _setPointsColorOrUV;
  136141. private _colorFromTexture;
  136142. private _calculateDensity;
  136143. /**
  136144. * Adds points to the PCS in random positions within a unit sphere
  136145. * @param nb (positive integer) the number of particles to be created from this model
  136146. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136147. * @returns the number of groups in the system
  136148. */
  136149. addPoints(nb: number, pointFunction?: any): number;
  136150. /**
  136151. * Adds points to the PCS from the surface of the model shape
  136152. * @param mesh is any Mesh object that will be used as a surface model for the points
  136153. * @param nb (positive integer) the number of particles to be created from this model
  136154. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136155. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136156. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136157. * @returns the number of groups in the system
  136158. */
  136159. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136160. /**
  136161. * Adds points to the PCS inside the model shape
  136162. * @param mesh is any Mesh object that will be used as a surface model for the points
  136163. * @param nb (positive integer) the number of particles to be created from this model
  136164. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136165. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136166. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136167. * @returns the number of groups in the system
  136168. */
  136169. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136170. /**
  136171. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136172. * This method calls `updateParticle()` for each particle of the SPS.
  136173. * For an animated SPS, it is usually called within the render loop.
  136174. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136175. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136176. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136177. * @returns the PCS.
  136178. */
  136179. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136180. /**
  136181. * Disposes the PCS.
  136182. */
  136183. dispose(): void;
  136184. /**
  136185. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136186. * doc :
  136187. * @returns the PCS.
  136188. */
  136189. refreshVisibleSize(): PointsCloudSystem;
  136190. /**
  136191. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136192. * @param size the size (float) of the visibility box
  136193. * note : this doesn't lock the PCS mesh bounding box.
  136194. * doc :
  136195. */
  136196. setVisibilityBox(size: number): void;
  136197. /**
  136198. * Gets whether the PCS is always visible or not
  136199. * doc :
  136200. */
  136201. get isAlwaysVisible(): boolean;
  136202. /**
  136203. * Sets the PCS as always visible or not
  136204. * doc :
  136205. */
  136206. set isAlwaysVisible(val: boolean);
  136207. /**
  136208. * Tells to `setParticles()` to compute the particle rotations or not
  136209. * Default value : false. The PCS is faster when it's set to false
  136210. * Note : particle rotations are only applied to parent particles
  136211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136212. */
  136213. set computeParticleRotation(val: boolean);
  136214. /**
  136215. * Tells to `setParticles()` to compute the particle colors or not.
  136216. * Default value : true. The PCS is faster when it's set to false.
  136217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136218. */
  136219. set computeParticleColor(val: boolean);
  136220. set computeParticleTexture(val: boolean);
  136221. /**
  136222. * Gets if `setParticles()` computes the particle colors or not.
  136223. * Default value : false. The PCS is faster when it's set to false.
  136224. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136225. */
  136226. get computeParticleColor(): boolean;
  136227. /**
  136228. * Gets if `setParticles()` computes the particle textures or not.
  136229. * Default value : false. The PCS is faster when it's set to false.
  136230. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136231. */
  136232. get computeParticleTexture(): boolean;
  136233. /**
  136234. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136235. */
  136236. set computeBoundingBox(val: boolean);
  136237. /**
  136238. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136239. */
  136240. get computeBoundingBox(): boolean;
  136241. /**
  136242. * This function does nothing. It may be overwritten to set all the particle first values.
  136243. * The PCS doesn't call this function, you may have to call it by your own.
  136244. * doc :
  136245. */
  136246. initParticles(): void;
  136247. /**
  136248. * This function does nothing. It may be overwritten to recycle a particle
  136249. * The PCS doesn't call this function, you can to call it
  136250. * doc :
  136251. * @param particle The particle to recycle
  136252. * @returns the recycled particle
  136253. */
  136254. recycleParticle(particle: CloudPoint): CloudPoint;
  136255. /**
  136256. * Updates a particle : this function should be overwritten by the user.
  136257. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136258. * doc :
  136259. * @example : just set a particle position or velocity and recycle conditions
  136260. * @param particle The particle to update
  136261. * @returns the updated particle
  136262. */
  136263. updateParticle(particle: CloudPoint): CloudPoint;
  136264. /**
  136265. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136266. * This does nothing and may be overwritten by the user.
  136267. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136268. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136269. * @param update the boolean update value actually passed to setParticles()
  136270. */
  136271. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136272. /**
  136273. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136274. * This will be passed three parameters.
  136275. * This does nothing and may be overwritten by the user.
  136276. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136277. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136278. * @param update the boolean update value actually passed to setParticles()
  136279. */
  136280. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136281. }
  136282. }
  136283. declare module BABYLON {
  136284. /**
  136285. * Represents one particle of a points cloud system.
  136286. */
  136287. export class CloudPoint {
  136288. /**
  136289. * particle global index
  136290. */
  136291. idx: number;
  136292. /**
  136293. * The color of the particle
  136294. */
  136295. color: Nullable<Color4>;
  136296. /**
  136297. * The world space position of the particle.
  136298. */
  136299. position: Vector3;
  136300. /**
  136301. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136302. */
  136303. rotation: Vector3;
  136304. /**
  136305. * The world space rotation quaternion of the particle.
  136306. */
  136307. rotationQuaternion: Nullable<Quaternion>;
  136308. /**
  136309. * The uv of the particle.
  136310. */
  136311. uv: Nullable<Vector2>;
  136312. /**
  136313. * The current speed of the particle.
  136314. */
  136315. velocity: Vector3;
  136316. /**
  136317. * The pivot point in the particle local space.
  136318. */
  136319. pivot: Vector3;
  136320. /**
  136321. * Must the particle be translated from its pivot point in its local space ?
  136322. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136323. * Default : false
  136324. */
  136325. translateFromPivot: boolean;
  136326. /**
  136327. * Index of this particle in the global "positions" array (Internal use)
  136328. * @hidden
  136329. */
  136330. _pos: number;
  136331. /**
  136332. * @hidden Index of this particle in the global "indices" array (Internal use)
  136333. */
  136334. _ind: number;
  136335. /**
  136336. * Group this particle belongs to
  136337. */
  136338. _group: PointsGroup;
  136339. /**
  136340. * Group id of this particle
  136341. */
  136342. groupId: number;
  136343. /**
  136344. * Index of the particle in its group id (Internal use)
  136345. */
  136346. idxInGroup: number;
  136347. /**
  136348. * @hidden Particle BoundingInfo object (Internal use)
  136349. */
  136350. _boundingInfo: BoundingInfo;
  136351. /**
  136352. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136353. */
  136354. _pcs: PointsCloudSystem;
  136355. /**
  136356. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136357. */
  136358. _stillInvisible: boolean;
  136359. /**
  136360. * @hidden Last computed particle rotation matrix
  136361. */
  136362. _rotationMatrix: number[];
  136363. /**
  136364. * Parent particle Id, if any.
  136365. * Default null.
  136366. */
  136367. parentId: Nullable<number>;
  136368. /**
  136369. * @hidden Internal global position in the PCS.
  136370. */
  136371. _globalPosition: Vector3;
  136372. /**
  136373. * Creates a Point Cloud object.
  136374. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136375. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136376. * @param group (PointsGroup) is the group the particle belongs to
  136377. * @param groupId (integer) is the group identifier in the PCS.
  136378. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136379. * @param pcs defines the PCS it is associated to
  136380. */
  136381. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136382. /**
  136383. * get point size
  136384. */
  136385. get size(): Vector3;
  136386. /**
  136387. * Set point size
  136388. */
  136389. set size(scale: Vector3);
  136390. /**
  136391. * Legacy support, changed quaternion to rotationQuaternion
  136392. */
  136393. get quaternion(): Nullable<Quaternion>;
  136394. /**
  136395. * Legacy support, changed quaternion to rotationQuaternion
  136396. */
  136397. set quaternion(q: Nullable<Quaternion>);
  136398. /**
  136399. * Returns a boolean. True if the particle intersects a mesh, else false
  136400. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136401. * @param target is the object (point or mesh) what the intersection is computed against
  136402. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136403. * @returns true if it intersects
  136404. */
  136405. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136406. /**
  136407. * get the rotation matrix of the particle
  136408. * @hidden
  136409. */
  136410. getRotationMatrix(m: Matrix): void;
  136411. }
  136412. /**
  136413. * Represents a group of points in a points cloud system
  136414. * * PCS internal tool, don't use it manually.
  136415. */
  136416. export class PointsGroup {
  136417. /**
  136418. * The group id
  136419. * @hidden
  136420. */
  136421. groupID: number;
  136422. /**
  136423. * image data for group (internal use)
  136424. * @hidden
  136425. */
  136426. _groupImageData: Nullable<ArrayBufferView>;
  136427. /**
  136428. * Image Width (internal use)
  136429. * @hidden
  136430. */
  136431. _groupImgWidth: number;
  136432. /**
  136433. * Image Height (internal use)
  136434. * @hidden
  136435. */
  136436. _groupImgHeight: number;
  136437. /**
  136438. * Custom position function (internal use)
  136439. * @hidden
  136440. */
  136441. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136442. /**
  136443. * density per facet for surface points
  136444. * @hidden
  136445. */
  136446. _groupDensity: number[];
  136447. /**
  136448. * Only when points are colored by texture carries pointer to texture list array
  136449. * @hidden
  136450. */
  136451. _textureNb: number;
  136452. /**
  136453. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136454. * PCS internal tool, don't use it manually.
  136455. * @hidden
  136456. */
  136457. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136458. }
  136459. }
  136460. declare module BABYLON {
  136461. interface Scene {
  136462. /** @hidden (Backing field) */
  136463. _physicsEngine: Nullable<IPhysicsEngine>;
  136464. /** @hidden */
  136465. _physicsTimeAccumulator: number;
  136466. /**
  136467. * Gets the current physics engine
  136468. * @returns a IPhysicsEngine or null if none attached
  136469. */
  136470. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136471. /**
  136472. * Enables physics to the current scene
  136473. * @param gravity defines the scene's gravity for the physics engine
  136474. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136475. * @return a boolean indicating if the physics engine was initialized
  136476. */
  136477. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136478. /**
  136479. * Disables and disposes the physics engine associated with the scene
  136480. */
  136481. disablePhysicsEngine(): void;
  136482. /**
  136483. * Gets a boolean indicating if there is an active physics engine
  136484. * @returns a boolean indicating if there is an active physics engine
  136485. */
  136486. isPhysicsEnabled(): boolean;
  136487. /**
  136488. * Deletes a physics compound impostor
  136489. * @param compound defines the compound to delete
  136490. */
  136491. deleteCompoundImpostor(compound: any): void;
  136492. /**
  136493. * An event triggered when physic simulation is about to be run
  136494. */
  136495. onBeforePhysicsObservable: Observable<Scene>;
  136496. /**
  136497. * An event triggered when physic simulation has been done
  136498. */
  136499. onAfterPhysicsObservable: Observable<Scene>;
  136500. }
  136501. interface AbstractMesh {
  136502. /** @hidden */
  136503. _physicsImpostor: Nullable<PhysicsImpostor>;
  136504. /**
  136505. * Gets or sets impostor used for physic simulation
  136506. * @see http://doc.babylonjs.com/features/physics_engine
  136507. */
  136508. physicsImpostor: Nullable<PhysicsImpostor>;
  136509. /**
  136510. * Gets the current physics impostor
  136511. * @see http://doc.babylonjs.com/features/physics_engine
  136512. * @returns a physics impostor or null
  136513. */
  136514. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136515. /** Apply a physic impulse to the mesh
  136516. * @param force defines the force to apply
  136517. * @param contactPoint defines where to apply the force
  136518. * @returns the current mesh
  136519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136520. */
  136521. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136522. /**
  136523. * Creates a physic joint between two meshes
  136524. * @param otherMesh defines the other mesh to use
  136525. * @param pivot1 defines the pivot to use on this mesh
  136526. * @param pivot2 defines the pivot to use on the other mesh
  136527. * @param options defines additional options (can be plugin dependent)
  136528. * @returns the current mesh
  136529. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136530. */
  136531. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136532. /** @hidden */
  136533. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136534. }
  136535. /**
  136536. * Defines the physics engine scene component responsible to manage a physics engine
  136537. */
  136538. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136539. /**
  136540. * The component name helpful to identify the component in the list of scene components.
  136541. */
  136542. readonly name: string;
  136543. /**
  136544. * The scene the component belongs to.
  136545. */
  136546. scene: Scene;
  136547. /**
  136548. * Creates a new instance of the component for the given scene
  136549. * @param scene Defines the scene to register the component in
  136550. */
  136551. constructor(scene: Scene);
  136552. /**
  136553. * Registers the component in a given scene
  136554. */
  136555. register(): void;
  136556. /**
  136557. * Rebuilds the elements related to this component in case of
  136558. * context lost for instance.
  136559. */
  136560. rebuild(): void;
  136561. /**
  136562. * Disposes the component and the associated ressources
  136563. */
  136564. dispose(): void;
  136565. }
  136566. }
  136567. declare module BABYLON {
  136568. /**
  136569. * A helper for physics simulations
  136570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136571. */
  136572. export class PhysicsHelper {
  136573. private _scene;
  136574. private _physicsEngine;
  136575. /**
  136576. * Initializes the Physics helper
  136577. * @param scene Babylon.js scene
  136578. */
  136579. constructor(scene: Scene);
  136580. /**
  136581. * Applies a radial explosion impulse
  136582. * @param origin the origin of the explosion
  136583. * @param radiusOrEventOptions the radius or the options of radial explosion
  136584. * @param strength the explosion strength
  136585. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136586. * @returns A physics radial explosion event, or null
  136587. */
  136588. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136589. /**
  136590. * Applies a radial explosion force
  136591. * @param origin the origin of the explosion
  136592. * @param radiusOrEventOptions the radius or the options of radial explosion
  136593. * @param strength the explosion strength
  136594. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136595. * @returns A physics radial explosion event, or null
  136596. */
  136597. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136598. /**
  136599. * Creates a gravitational field
  136600. * @param origin the origin of the explosion
  136601. * @param radiusOrEventOptions the radius or the options of radial explosion
  136602. * @param strength the explosion strength
  136603. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136604. * @returns A physics gravitational field event, or null
  136605. */
  136606. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136607. /**
  136608. * Creates a physics updraft event
  136609. * @param origin the origin of the updraft
  136610. * @param radiusOrEventOptions the radius or the options of the updraft
  136611. * @param strength the strength of the updraft
  136612. * @param height the height of the updraft
  136613. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136614. * @returns A physics updraft event, or null
  136615. */
  136616. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136617. /**
  136618. * Creates a physics vortex event
  136619. * @param origin the of the vortex
  136620. * @param radiusOrEventOptions the radius or the options of the vortex
  136621. * @param strength the strength of the vortex
  136622. * @param height the height of the vortex
  136623. * @returns a Physics vortex event, or null
  136624. * A physics vortex event or null
  136625. */
  136626. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136627. }
  136628. /**
  136629. * Represents a physics radial explosion event
  136630. */
  136631. class PhysicsRadialExplosionEvent {
  136632. private _scene;
  136633. private _options;
  136634. private _sphere;
  136635. private _dataFetched;
  136636. /**
  136637. * Initializes a radial explosioin event
  136638. * @param _scene BabylonJS scene
  136639. * @param _options The options for the vortex event
  136640. */
  136641. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136642. /**
  136643. * Returns the data related to the radial explosion event (sphere).
  136644. * @returns The radial explosion event data
  136645. */
  136646. getData(): PhysicsRadialExplosionEventData;
  136647. /**
  136648. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136649. * @param impostor A physics imposter
  136650. * @param origin the origin of the explosion
  136651. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136652. */
  136653. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136654. /**
  136655. * Triggers affecterd impostors callbacks
  136656. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136657. */
  136658. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136659. /**
  136660. * Disposes the sphere.
  136661. * @param force Specifies if the sphere should be disposed by force
  136662. */
  136663. dispose(force?: boolean): void;
  136664. /*** Helpers ***/
  136665. private _prepareSphere;
  136666. private _intersectsWithSphere;
  136667. }
  136668. /**
  136669. * Represents a gravitational field event
  136670. */
  136671. class PhysicsGravitationalFieldEvent {
  136672. private _physicsHelper;
  136673. private _scene;
  136674. private _origin;
  136675. private _options;
  136676. private _tickCallback;
  136677. private _sphere;
  136678. private _dataFetched;
  136679. /**
  136680. * Initializes the physics gravitational field event
  136681. * @param _physicsHelper A physics helper
  136682. * @param _scene BabylonJS scene
  136683. * @param _origin The origin position of the gravitational field event
  136684. * @param _options The options for the vortex event
  136685. */
  136686. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136687. /**
  136688. * Returns the data related to the gravitational field event (sphere).
  136689. * @returns A gravitational field event
  136690. */
  136691. getData(): PhysicsGravitationalFieldEventData;
  136692. /**
  136693. * Enables the gravitational field.
  136694. */
  136695. enable(): void;
  136696. /**
  136697. * Disables the gravitational field.
  136698. */
  136699. disable(): void;
  136700. /**
  136701. * Disposes the sphere.
  136702. * @param force The force to dispose from the gravitational field event
  136703. */
  136704. dispose(force?: boolean): void;
  136705. private _tick;
  136706. }
  136707. /**
  136708. * Represents a physics updraft event
  136709. */
  136710. class PhysicsUpdraftEvent {
  136711. private _scene;
  136712. private _origin;
  136713. private _options;
  136714. private _physicsEngine;
  136715. private _originTop;
  136716. private _originDirection;
  136717. private _tickCallback;
  136718. private _cylinder;
  136719. private _cylinderPosition;
  136720. private _dataFetched;
  136721. /**
  136722. * Initializes the physics updraft event
  136723. * @param _scene BabylonJS scene
  136724. * @param _origin The origin position of the updraft
  136725. * @param _options The options for the updraft event
  136726. */
  136727. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136728. /**
  136729. * Returns the data related to the updraft event (cylinder).
  136730. * @returns A physics updraft event
  136731. */
  136732. getData(): PhysicsUpdraftEventData;
  136733. /**
  136734. * Enables the updraft.
  136735. */
  136736. enable(): void;
  136737. /**
  136738. * Disables the updraft.
  136739. */
  136740. disable(): void;
  136741. /**
  136742. * Disposes the cylinder.
  136743. * @param force Specifies if the updraft should be disposed by force
  136744. */
  136745. dispose(force?: boolean): void;
  136746. private getImpostorHitData;
  136747. private _tick;
  136748. /*** Helpers ***/
  136749. private _prepareCylinder;
  136750. private _intersectsWithCylinder;
  136751. }
  136752. /**
  136753. * Represents a physics vortex event
  136754. */
  136755. class PhysicsVortexEvent {
  136756. private _scene;
  136757. private _origin;
  136758. private _options;
  136759. private _physicsEngine;
  136760. private _originTop;
  136761. private _tickCallback;
  136762. private _cylinder;
  136763. private _cylinderPosition;
  136764. private _dataFetched;
  136765. /**
  136766. * Initializes the physics vortex event
  136767. * @param _scene The BabylonJS scene
  136768. * @param _origin The origin position of the vortex
  136769. * @param _options The options for the vortex event
  136770. */
  136771. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136772. /**
  136773. * Returns the data related to the vortex event (cylinder).
  136774. * @returns The physics vortex event data
  136775. */
  136776. getData(): PhysicsVortexEventData;
  136777. /**
  136778. * Enables the vortex.
  136779. */
  136780. enable(): void;
  136781. /**
  136782. * Disables the cortex.
  136783. */
  136784. disable(): void;
  136785. /**
  136786. * Disposes the sphere.
  136787. * @param force
  136788. */
  136789. dispose(force?: boolean): void;
  136790. private getImpostorHitData;
  136791. private _tick;
  136792. /*** Helpers ***/
  136793. private _prepareCylinder;
  136794. private _intersectsWithCylinder;
  136795. }
  136796. /**
  136797. * Options fot the radial explosion event
  136798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136799. */
  136800. export class PhysicsRadialExplosionEventOptions {
  136801. /**
  136802. * The radius of the sphere for the radial explosion.
  136803. */
  136804. radius: number;
  136805. /**
  136806. * The strenth of the explosion.
  136807. */
  136808. strength: number;
  136809. /**
  136810. * The strenght of the force in correspondence to the distance of the affected object
  136811. */
  136812. falloff: PhysicsRadialImpulseFalloff;
  136813. /**
  136814. * Sphere options for the radial explosion.
  136815. */
  136816. sphere: {
  136817. segments: number;
  136818. diameter: number;
  136819. };
  136820. /**
  136821. * Sphere options for the radial explosion.
  136822. */
  136823. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136824. }
  136825. /**
  136826. * Options fot the updraft event
  136827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136828. */
  136829. export class PhysicsUpdraftEventOptions {
  136830. /**
  136831. * The radius of the cylinder for the vortex
  136832. */
  136833. radius: number;
  136834. /**
  136835. * The strenth of the updraft.
  136836. */
  136837. strength: number;
  136838. /**
  136839. * The height of the cylinder for the updraft.
  136840. */
  136841. height: number;
  136842. /**
  136843. * The mode for the the updraft.
  136844. */
  136845. updraftMode: PhysicsUpdraftMode;
  136846. }
  136847. /**
  136848. * Options fot the vortex event
  136849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136850. */
  136851. export class PhysicsVortexEventOptions {
  136852. /**
  136853. * The radius of the cylinder for the vortex
  136854. */
  136855. radius: number;
  136856. /**
  136857. * The strenth of the vortex.
  136858. */
  136859. strength: number;
  136860. /**
  136861. * The height of the cylinder for the vortex.
  136862. */
  136863. height: number;
  136864. /**
  136865. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136866. */
  136867. centripetalForceThreshold: number;
  136868. /**
  136869. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136870. */
  136871. centripetalForceMultiplier: number;
  136872. /**
  136873. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136874. */
  136875. centrifugalForceMultiplier: number;
  136876. /**
  136877. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136878. */
  136879. updraftForceMultiplier: number;
  136880. }
  136881. /**
  136882. * The strenght of the force in correspondence to the distance of the affected object
  136883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136884. */
  136885. export enum PhysicsRadialImpulseFalloff {
  136886. /** Defines that impulse is constant in strength across it's whole radius */
  136887. Constant = 0,
  136888. /** Defines that impulse gets weaker if it's further from the origin */
  136889. Linear = 1
  136890. }
  136891. /**
  136892. * The strength of the force in correspondence to the distance of the affected object
  136893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136894. */
  136895. export enum PhysicsUpdraftMode {
  136896. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136897. Center = 0,
  136898. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136899. Perpendicular = 1
  136900. }
  136901. /**
  136902. * Interface for a physics hit data
  136903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136904. */
  136905. export interface PhysicsHitData {
  136906. /**
  136907. * The force applied at the contact point
  136908. */
  136909. force: Vector3;
  136910. /**
  136911. * The contact point
  136912. */
  136913. contactPoint: Vector3;
  136914. /**
  136915. * The distance from the origin to the contact point
  136916. */
  136917. distanceFromOrigin: number;
  136918. }
  136919. /**
  136920. * Interface for radial explosion event data
  136921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136922. */
  136923. export interface PhysicsRadialExplosionEventData {
  136924. /**
  136925. * A sphere used for the radial explosion event
  136926. */
  136927. sphere: Mesh;
  136928. }
  136929. /**
  136930. * Interface for gravitational field event data
  136931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136932. */
  136933. export interface PhysicsGravitationalFieldEventData {
  136934. /**
  136935. * A sphere mesh used for the gravitational field event
  136936. */
  136937. sphere: Mesh;
  136938. }
  136939. /**
  136940. * Interface for updraft event data
  136941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136942. */
  136943. export interface PhysicsUpdraftEventData {
  136944. /**
  136945. * A cylinder used for the updraft event
  136946. */
  136947. cylinder: Mesh;
  136948. }
  136949. /**
  136950. * Interface for vortex event data
  136951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136952. */
  136953. export interface PhysicsVortexEventData {
  136954. /**
  136955. * A cylinder used for the vortex event
  136956. */
  136957. cylinder: Mesh;
  136958. }
  136959. /**
  136960. * Interface for an affected physics impostor
  136961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136962. */
  136963. export interface PhysicsAffectedImpostorWithData {
  136964. /**
  136965. * The impostor affected by the effect
  136966. */
  136967. impostor: PhysicsImpostor;
  136968. /**
  136969. * The data about the hit/horce from the explosion
  136970. */
  136971. hitData: PhysicsHitData;
  136972. }
  136973. }
  136974. declare module BABYLON {
  136975. /** @hidden */
  136976. export var blackAndWhitePixelShader: {
  136977. name: string;
  136978. shader: string;
  136979. };
  136980. }
  136981. declare module BABYLON {
  136982. /**
  136983. * Post process used to render in black and white
  136984. */
  136985. export class BlackAndWhitePostProcess extends PostProcess {
  136986. /**
  136987. * Linear about to convert he result to black and white (default: 1)
  136988. */
  136989. degree: number;
  136990. /**
  136991. * Creates a black and white post process
  136992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136993. * @param name The name of the effect.
  136994. * @param options The required width/height ratio to downsize to before computing the render pass.
  136995. * @param camera The camera to apply the render pass to.
  136996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136997. * @param engine The engine which the post process will be applied. (default: current engine)
  136998. * @param reusable If the post process can be reused on the same frame. (default: false)
  136999. */
  137000. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137001. }
  137002. }
  137003. declare module BABYLON {
  137004. /**
  137005. * This represents a set of one or more post processes in Babylon.
  137006. * A post process can be used to apply a shader to a texture after it is rendered.
  137007. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137008. */
  137009. export class PostProcessRenderEffect {
  137010. private _postProcesses;
  137011. private _getPostProcesses;
  137012. private _singleInstance;
  137013. private _cameras;
  137014. private _indicesForCamera;
  137015. /**
  137016. * Name of the effect
  137017. * @hidden
  137018. */
  137019. _name: string;
  137020. /**
  137021. * Instantiates a post process render effect.
  137022. * A post process can be used to apply a shader to a texture after it is rendered.
  137023. * @param engine The engine the effect is tied to
  137024. * @param name The name of the effect
  137025. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137026. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137027. */
  137028. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137029. /**
  137030. * Checks if all the post processes in the effect are supported.
  137031. */
  137032. get isSupported(): boolean;
  137033. /**
  137034. * Updates the current state of the effect
  137035. * @hidden
  137036. */
  137037. _update(): void;
  137038. /**
  137039. * Attaches the effect on cameras
  137040. * @param cameras The camera to attach to.
  137041. * @hidden
  137042. */
  137043. _attachCameras(cameras: Camera): void;
  137044. /**
  137045. * Attaches the effect on cameras
  137046. * @param cameras The camera to attach to.
  137047. * @hidden
  137048. */
  137049. _attachCameras(cameras: Camera[]): void;
  137050. /**
  137051. * Detaches the effect on cameras
  137052. * @param cameras The camera to detatch from.
  137053. * @hidden
  137054. */
  137055. _detachCameras(cameras: Camera): void;
  137056. /**
  137057. * Detatches the effect on cameras
  137058. * @param cameras The camera to detatch from.
  137059. * @hidden
  137060. */
  137061. _detachCameras(cameras: Camera[]): void;
  137062. /**
  137063. * Enables the effect on given cameras
  137064. * @param cameras The camera to enable.
  137065. * @hidden
  137066. */
  137067. _enable(cameras: Camera): void;
  137068. /**
  137069. * Enables the effect on given cameras
  137070. * @param cameras The camera to enable.
  137071. * @hidden
  137072. */
  137073. _enable(cameras: Nullable<Camera[]>): void;
  137074. /**
  137075. * Disables the effect on the given cameras
  137076. * @param cameras The camera to disable.
  137077. * @hidden
  137078. */
  137079. _disable(cameras: Camera): void;
  137080. /**
  137081. * Disables the effect on the given cameras
  137082. * @param cameras The camera to disable.
  137083. * @hidden
  137084. */
  137085. _disable(cameras: Nullable<Camera[]>): void;
  137086. /**
  137087. * Gets a list of the post processes contained in the effect.
  137088. * @param camera The camera to get the post processes on.
  137089. * @returns The list of the post processes in the effect.
  137090. */
  137091. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137092. }
  137093. }
  137094. declare module BABYLON {
  137095. /** @hidden */
  137096. export var extractHighlightsPixelShader: {
  137097. name: string;
  137098. shader: string;
  137099. };
  137100. }
  137101. declare module BABYLON {
  137102. /**
  137103. * 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.
  137104. */
  137105. export class ExtractHighlightsPostProcess extends PostProcess {
  137106. /**
  137107. * The luminance threshold, pixels below this value will be set to black.
  137108. */
  137109. threshold: number;
  137110. /** @hidden */
  137111. _exposure: number;
  137112. /**
  137113. * Post process which has the input texture to be used when performing highlight extraction
  137114. * @hidden
  137115. */
  137116. _inputPostProcess: Nullable<PostProcess>;
  137117. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137118. }
  137119. }
  137120. declare module BABYLON {
  137121. /** @hidden */
  137122. export var bloomMergePixelShader: {
  137123. name: string;
  137124. shader: string;
  137125. };
  137126. }
  137127. declare module BABYLON {
  137128. /**
  137129. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137130. */
  137131. export class BloomMergePostProcess extends PostProcess {
  137132. /** Weight of the bloom to be added to the original input. */
  137133. weight: number;
  137134. /**
  137135. * Creates a new instance of @see BloomMergePostProcess
  137136. * @param name The name of the effect.
  137137. * @param originalFromInput Post process which's input will be used for the merge.
  137138. * @param blurred Blurred highlights post process which's output will be used.
  137139. * @param weight Weight of the bloom to be added to the original input.
  137140. * @param options The required width/height ratio to downsize to before computing the render pass.
  137141. * @param camera The camera to apply the render pass to.
  137142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137143. * @param engine The engine which the post process will be applied. (default: current engine)
  137144. * @param reusable If the post process can be reused on the same frame. (default: false)
  137145. * @param textureType Type of textures used when performing the post process. (default: 0)
  137146. * @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)
  137147. */
  137148. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137149. /** Weight of the bloom to be added to the original input. */
  137150. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137151. }
  137152. }
  137153. declare module BABYLON {
  137154. /**
  137155. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137156. */
  137157. export class BloomEffect extends PostProcessRenderEffect {
  137158. private bloomScale;
  137159. /**
  137160. * @hidden Internal
  137161. */
  137162. _effects: Array<PostProcess>;
  137163. /**
  137164. * @hidden Internal
  137165. */
  137166. _downscale: ExtractHighlightsPostProcess;
  137167. private _blurX;
  137168. private _blurY;
  137169. private _merge;
  137170. /**
  137171. * The luminance threshold to find bright areas of the image to bloom.
  137172. */
  137173. get threshold(): number;
  137174. set threshold(value: number);
  137175. /**
  137176. * The strength of the bloom.
  137177. */
  137178. get weight(): number;
  137179. set weight(value: number);
  137180. /**
  137181. * Specifies the size of the bloom blur kernel, relative to the final output size
  137182. */
  137183. get kernel(): number;
  137184. set kernel(value: number);
  137185. /**
  137186. * Creates a new instance of @see BloomEffect
  137187. * @param scene The scene the effect belongs to.
  137188. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137189. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137190. * @param bloomWeight The the strength of bloom.
  137191. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137192. * @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)
  137193. */
  137194. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137195. /**
  137196. * Disposes each of the internal effects for a given camera.
  137197. * @param camera The camera to dispose the effect on.
  137198. */
  137199. disposeEffects(camera: Camera): void;
  137200. /**
  137201. * @hidden Internal
  137202. */
  137203. _updateEffects(): void;
  137204. /**
  137205. * Internal
  137206. * @returns if all the contained post processes are ready.
  137207. * @hidden
  137208. */
  137209. _isReady(): boolean;
  137210. }
  137211. }
  137212. declare module BABYLON {
  137213. /** @hidden */
  137214. export var chromaticAberrationPixelShader: {
  137215. name: string;
  137216. shader: string;
  137217. };
  137218. }
  137219. declare module BABYLON {
  137220. /**
  137221. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137222. */
  137223. export class ChromaticAberrationPostProcess extends PostProcess {
  137224. /**
  137225. * The amount of seperation of rgb channels (default: 30)
  137226. */
  137227. aberrationAmount: number;
  137228. /**
  137229. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137230. */
  137231. radialIntensity: number;
  137232. /**
  137233. * 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))
  137234. */
  137235. direction: Vector2;
  137236. /**
  137237. * 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))
  137238. */
  137239. centerPosition: Vector2;
  137240. /**
  137241. * Creates a new instance ChromaticAberrationPostProcess
  137242. * @param name The name of the effect.
  137243. * @param screenWidth The width of the screen to apply the effect on.
  137244. * @param screenHeight The height of the screen to apply the effect on.
  137245. * @param options The required width/height ratio to downsize to before computing the render pass.
  137246. * @param camera The camera to apply the render pass to.
  137247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137248. * @param engine The engine which the post process will be applied. (default: current engine)
  137249. * @param reusable If the post process can be reused on the same frame. (default: false)
  137250. * @param textureType Type of textures used when performing the post process. (default: 0)
  137251. * @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)
  137252. */
  137253. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137254. }
  137255. }
  137256. declare module BABYLON {
  137257. /** @hidden */
  137258. export var circleOfConfusionPixelShader: {
  137259. name: string;
  137260. shader: string;
  137261. };
  137262. }
  137263. declare module BABYLON {
  137264. /**
  137265. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137266. */
  137267. export class CircleOfConfusionPostProcess extends PostProcess {
  137268. /**
  137269. * 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.
  137270. */
  137271. lensSize: number;
  137272. /**
  137273. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137274. */
  137275. fStop: number;
  137276. /**
  137277. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137278. */
  137279. focusDistance: number;
  137280. /**
  137281. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137282. */
  137283. focalLength: number;
  137284. private _depthTexture;
  137285. /**
  137286. * Creates a new instance CircleOfConfusionPostProcess
  137287. * @param name The name of the effect.
  137288. * @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.
  137289. * @param options The required width/height ratio to downsize to before computing the render pass.
  137290. * @param camera The camera to apply the render pass to.
  137291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137292. * @param engine The engine which the post process will be applied. (default: current engine)
  137293. * @param reusable If the post process can be reused on the same frame. (default: false)
  137294. * @param textureType Type of textures used when performing the post process. (default: 0)
  137295. * @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)
  137296. */
  137297. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137298. /**
  137299. * 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.
  137300. */
  137301. set depthTexture(value: RenderTargetTexture);
  137302. }
  137303. }
  137304. declare module BABYLON {
  137305. /** @hidden */
  137306. export var colorCorrectionPixelShader: {
  137307. name: string;
  137308. shader: string;
  137309. };
  137310. }
  137311. declare module BABYLON {
  137312. /**
  137313. *
  137314. * This post-process allows the modification of rendered colors by using
  137315. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137316. *
  137317. * The object needs to be provided an url to a texture containing the color
  137318. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137319. * Use an image editing software to tweak the LUT to match your needs.
  137320. *
  137321. * For an example of a color LUT, see here:
  137322. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137323. * For explanations on color grading, see here:
  137324. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137325. *
  137326. */
  137327. export class ColorCorrectionPostProcess extends PostProcess {
  137328. private _colorTableTexture;
  137329. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137330. }
  137331. }
  137332. declare module BABYLON {
  137333. /** @hidden */
  137334. export var convolutionPixelShader: {
  137335. name: string;
  137336. shader: string;
  137337. };
  137338. }
  137339. declare module BABYLON {
  137340. /**
  137341. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137342. * input texture to perform effects such as edge detection or sharpening
  137343. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137344. */
  137345. export class ConvolutionPostProcess extends PostProcess {
  137346. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137347. kernel: number[];
  137348. /**
  137349. * Creates a new instance ConvolutionPostProcess
  137350. * @param name The name of the effect.
  137351. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137352. * @param options The required width/height ratio to downsize to before computing the render pass.
  137353. * @param camera The camera to apply the render pass to.
  137354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137355. * @param engine The engine which the post process will be applied. (default: current engine)
  137356. * @param reusable If the post process can be reused on the same frame. (default: false)
  137357. * @param textureType Type of textures used when performing the post process. (default: 0)
  137358. */
  137359. constructor(name: string,
  137360. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137361. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137362. /**
  137363. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137364. */
  137365. static EdgeDetect0Kernel: number[];
  137366. /**
  137367. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137368. */
  137369. static EdgeDetect1Kernel: number[];
  137370. /**
  137371. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137372. */
  137373. static EdgeDetect2Kernel: number[];
  137374. /**
  137375. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137376. */
  137377. static SharpenKernel: number[];
  137378. /**
  137379. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137380. */
  137381. static EmbossKernel: number[];
  137382. /**
  137383. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137384. */
  137385. static GaussianKernel: number[];
  137386. }
  137387. }
  137388. declare module BABYLON {
  137389. /**
  137390. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137391. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137392. * based on samples that have a large difference in distance than the center pixel.
  137393. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137394. */
  137395. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137396. direction: Vector2;
  137397. /**
  137398. * Creates a new instance CircleOfConfusionPostProcess
  137399. * @param name The name of the effect.
  137400. * @param scene The scene the effect belongs to.
  137401. * @param direction The direction the blur should be applied.
  137402. * @param kernel The size of the kernel used to blur.
  137403. * @param options The required width/height ratio to downsize to before computing the render pass.
  137404. * @param camera The camera to apply the render pass to.
  137405. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137406. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137408. * @param engine The engine which the post process will be applied. (default: current engine)
  137409. * @param reusable If the post process can be reused on the same frame. (default: false)
  137410. * @param textureType Type of textures used when performing the post process. (default: 0)
  137411. * @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)
  137412. */
  137413. 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);
  137414. }
  137415. }
  137416. declare module BABYLON {
  137417. /** @hidden */
  137418. export var depthOfFieldMergePixelShader: {
  137419. name: string;
  137420. shader: string;
  137421. };
  137422. }
  137423. declare module BABYLON {
  137424. /**
  137425. * Options to be set when merging outputs from the default pipeline.
  137426. */
  137427. export class DepthOfFieldMergePostProcessOptions {
  137428. /**
  137429. * The original image to merge on top of
  137430. */
  137431. originalFromInput: PostProcess;
  137432. /**
  137433. * Parameters to perform the merge of the depth of field effect
  137434. */
  137435. depthOfField?: {
  137436. circleOfConfusion: PostProcess;
  137437. blurSteps: Array<PostProcess>;
  137438. };
  137439. /**
  137440. * Parameters to perform the merge of bloom effect
  137441. */
  137442. bloom?: {
  137443. blurred: PostProcess;
  137444. weight: number;
  137445. };
  137446. }
  137447. /**
  137448. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137449. */
  137450. export class DepthOfFieldMergePostProcess extends PostProcess {
  137451. private blurSteps;
  137452. /**
  137453. * Creates a new instance of DepthOfFieldMergePostProcess
  137454. * @param name The name of the effect.
  137455. * @param originalFromInput Post process which's input will be used for the merge.
  137456. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137457. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137458. * @param options The required width/height ratio to downsize to before computing the render pass.
  137459. * @param camera The camera to apply the render pass to.
  137460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137461. * @param engine The engine which the post process will be applied. (default: current engine)
  137462. * @param reusable If the post process can be reused on the same frame. (default: false)
  137463. * @param textureType Type of textures used when performing the post process. (default: 0)
  137464. * @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)
  137465. */
  137466. 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);
  137467. /**
  137468. * Updates the effect with the current post process compile time values and recompiles the shader.
  137469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137472. * @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
  137473. * @param onCompiled Called when the shader has been compiled.
  137474. * @param onError Called if there is an error when compiling a shader.
  137475. */
  137476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137477. }
  137478. }
  137479. declare module BABYLON {
  137480. /**
  137481. * Specifies the level of max blur that should be applied when using the depth of field effect
  137482. */
  137483. export enum DepthOfFieldEffectBlurLevel {
  137484. /**
  137485. * Subtle blur
  137486. */
  137487. Low = 0,
  137488. /**
  137489. * Medium blur
  137490. */
  137491. Medium = 1,
  137492. /**
  137493. * Large blur
  137494. */
  137495. High = 2
  137496. }
  137497. /**
  137498. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137499. */
  137500. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137501. private _circleOfConfusion;
  137502. /**
  137503. * @hidden Internal, blurs from high to low
  137504. */
  137505. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137506. private _depthOfFieldBlurY;
  137507. private _dofMerge;
  137508. /**
  137509. * @hidden Internal post processes in depth of field effect
  137510. */
  137511. _effects: Array<PostProcess>;
  137512. /**
  137513. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137514. */
  137515. set focalLength(value: number);
  137516. get focalLength(): number;
  137517. /**
  137518. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137519. */
  137520. set fStop(value: number);
  137521. get fStop(): number;
  137522. /**
  137523. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137524. */
  137525. set focusDistance(value: number);
  137526. get focusDistance(): number;
  137527. /**
  137528. * 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.
  137529. */
  137530. set lensSize(value: number);
  137531. get lensSize(): number;
  137532. /**
  137533. * Creates a new instance DepthOfFieldEffect
  137534. * @param scene The scene the effect belongs to.
  137535. * @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.
  137536. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137537. * @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)
  137538. */
  137539. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137540. /**
  137541. * Get the current class name of the current effet
  137542. * @returns "DepthOfFieldEffect"
  137543. */
  137544. getClassName(): string;
  137545. /**
  137546. * 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.
  137547. */
  137548. set depthTexture(value: RenderTargetTexture);
  137549. /**
  137550. * Disposes each of the internal effects for a given camera.
  137551. * @param camera The camera to dispose the effect on.
  137552. */
  137553. disposeEffects(camera: Camera): void;
  137554. /**
  137555. * @hidden Internal
  137556. */
  137557. _updateEffects(): void;
  137558. /**
  137559. * Internal
  137560. * @returns if all the contained post processes are ready.
  137561. * @hidden
  137562. */
  137563. _isReady(): boolean;
  137564. }
  137565. }
  137566. declare module BABYLON {
  137567. /** @hidden */
  137568. export var displayPassPixelShader: {
  137569. name: string;
  137570. shader: string;
  137571. };
  137572. }
  137573. declare module BABYLON {
  137574. /**
  137575. * DisplayPassPostProcess which produces an output the same as it's input
  137576. */
  137577. export class DisplayPassPostProcess extends PostProcess {
  137578. /**
  137579. * Creates the DisplayPassPostProcess
  137580. * @param name The name of the effect.
  137581. * @param options The required width/height ratio to downsize to before computing the render pass.
  137582. * @param camera The camera to apply the render pass to.
  137583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137584. * @param engine The engine which the post process will be applied. (default: current engine)
  137585. * @param reusable If the post process can be reused on the same frame. (default: false)
  137586. */
  137587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137588. }
  137589. }
  137590. declare module BABYLON {
  137591. /** @hidden */
  137592. export var filterPixelShader: {
  137593. name: string;
  137594. shader: string;
  137595. };
  137596. }
  137597. declare module BABYLON {
  137598. /**
  137599. * Applies a kernel filter to the image
  137600. */
  137601. export class FilterPostProcess extends PostProcess {
  137602. /** The matrix to be applied to the image */
  137603. kernelMatrix: Matrix;
  137604. /**
  137605. *
  137606. * @param name The name of the effect.
  137607. * @param kernelMatrix The matrix to be applied to the image
  137608. * @param options The required width/height ratio to downsize to before computing the render pass.
  137609. * @param camera The camera to apply the render pass to.
  137610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137611. * @param engine The engine which the post process will be applied. (default: current engine)
  137612. * @param reusable If the post process can be reused on the same frame. (default: false)
  137613. */
  137614. constructor(name: string,
  137615. /** The matrix to be applied to the image */
  137616. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137617. }
  137618. }
  137619. declare module BABYLON {
  137620. /** @hidden */
  137621. export var fxaaPixelShader: {
  137622. name: string;
  137623. shader: string;
  137624. };
  137625. }
  137626. declare module BABYLON {
  137627. /** @hidden */
  137628. export var fxaaVertexShader: {
  137629. name: string;
  137630. shader: string;
  137631. };
  137632. }
  137633. declare module BABYLON {
  137634. /**
  137635. * Fxaa post process
  137636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137637. */
  137638. export class FxaaPostProcess extends PostProcess {
  137639. /** @hidden */
  137640. texelWidth: number;
  137641. /** @hidden */
  137642. texelHeight: number;
  137643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137644. private _getDefines;
  137645. }
  137646. }
  137647. declare module BABYLON {
  137648. /** @hidden */
  137649. export var grainPixelShader: {
  137650. name: string;
  137651. shader: string;
  137652. };
  137653. }
  137654. declare module BABYLON {
  137655. /**
  137656. * The GrainPostProcess adds noise to the image at mid luminance levels
  137657. */
  137658. export class GrainPostProcess extends PostProcess {
  137659. /**
  137660. * The intensity of the grain added (default: 30)
  137661. */
  137662. intensity: number;
  137663. /**
  137664. * If the grain should be randomized on every frame
  137665. */
  137666. animated: boolean;
  137667. /**
  137668. * Creates a new instance of @see GrainPostProcess
  137669. * @param name The name of the effect.
  137670. * @param options The required width/height ratio to downsize to before computing the render pass.
  137671. * @param camera The camera to apply the render pass to.
  137672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137673. * @param engine The engine which the post process will be applied. (default: current engine)
  137674. * @param reusable If the post process can be reused on the same frame. (default: false)
  137675. * @param textureType Type of textures used when performing the post process. (default: 0)
  137676. * @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)
  137677. */
  137678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137679. }
  137680. }
  137681. declare module BABYLON {
  137682. /** @hidden */
  137683. export var highlightsPixelShader: {
  137684. name: string;
  137685. shader: string;
  137686. };
  137687. }
  137688. declare module BABYLON {
  137689. /**
  137690. * Extracts highlights from the image
  137691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137692. */
  137693. export class HighlightsPostProcess extends PostProcess {
  137694. /**
  137695. * Extracts highlights from the image
  137696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137697. * @param name The name of the effect.
  137698. * @param options The required width/height ratio to downsize to before computing the render pass.
  137699. * @param camera The camera to apply the render pass to.
  137700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137701. * @param engine The engine which the post process will be applied. (default: current engine)
  137702. * @param reusable If the post process can be reused on the same frame. (default: false)
  137703. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137704. */
  137705. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137706. }
  137707. }
  137708. declare module BABYLON {
  137709. /** @hidden */
  137710. export var mrtFragmentDeclaration: {
  137711. name: string;
  137712. shader: string;
  137713. };
  137714. }
  137715. declare module BABYLON {
  137716. /** @hidden */
  137717. export var geometryPixelShader: {
  137718. name: string;
  137719. shader: string;
  137720. };
  137721. }
  137722. declare module BABYLON {
  137723. /** @hidden */
  137724. export var geometryVertexShader: {
  137725. name: string;
  137726. shader: string;
  137727. };
  137728. }
  137729. declare module BABYLON {
  137730. /** @hidden */
  137731. interface ISavedTransformationMatrix {
  137732. world: Matrix;
  137733. viewProjection: Matrix;
  137734. }
  137735. /**
  137736. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137737. */
  137738. export class GeometryBufferRenderer {
  137739. /**
  137740. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137741. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137742. */
  137743. static readonly POSITION_TEXTURE_TYPE: number;
  137744. /**
  137745. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137746. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137747. */
  137748. static readonly VELOCITY_TEXTURE_TYPE: number;
  137749. /**
  137750. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137751. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137752. */
  137753. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137754. /**
  137755. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137756. * in order to compute objects velocities when enableVelocity is set to "true"
  137757. * @hidden
  137758. */
  137759. _previousTransformationMatrices: {
  137760. [index: number]: ISavedTransformationMatrix;
  137761. };
  137762. /**
  137763. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137764. * in order to compute objects velocities when enableVelocity is set to "true"
  137765. * @hidden
  137766. */
  137767. _previousBonesTransformationMatrices: {
  137768. [index: number]: Float32Array;
  137769. };
  137770. /**
  137771. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137772. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137773. */
  137774. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137775. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137776. renderTransparentMeshes: boolean;
  137777. private _scene;
  137778. private _multiRenderTarget;
  137779. private _ratio;
  137780. private _enablePosition;
  137781. private _enableVelocity;
  137782. private _enableReflectivity;
  137783. private _positionIndex;
  137784. private _velocityIndex;
  137785. private _reflectivityIndex;
  137786. protected _effect: Effect;
  137787. protected _cachedDefines: string;
  137788. /**
  137789. * Set the render list (meshes to be rendered) used in the G buffer.
  137790. */
  137791. set renderList(meshes: Mesh[]);
  137792. /**
  137793. * Gets wether or not G buffer are supported by the running hardware.
  137794. * This requires draw buffer supports
  137795. */
  137796. get isSupported(): boolean;
  137797. /**
  137798. * Returns the index of the given texture type in the G-Buffer textures array
  137799. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137800. * @returns the index of the given texture type in the G-Buffer textures array
  137801. */
  137802. getTextureIndex(textureType: number): number;
  137803. /**
  137804. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137805. */
  137806. get enablePosition(): boolean;
  137807. /**
  137808. * Sets whether or not objects positions are enabled for the G buffer.
  137809. */
  137810. set enablePosition(enable: boolean);
  137811. /**
  137812. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137813. */
  137814. get enableVelocity(): boolean;
  137815. /**
  137816. * Sets wether or not objects velocities are enabled for the G buffer.
  137817. */
  137818. set enableVelocity(enable: boolean);
  137819. /**
  137820. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137821. */
  137822. get enableReflectivity(): boolean;
  137823. /**
  137824. * Sets wether or not objects roughness are enabled for the G buffer.
  137825. */
  137826. set enableReflectivity(enable: boolean);
  137827. /**
  137828. * Gets the scene associated with the buffer.
  137829. */
  137830. get scene(): Scene;
  137831. /**
  137832. * Gets the ratio used by the buffer during its creation.
  137833. * How big is the buffer related to the main canvas.
  137834. */
  137835. get ratio(): number;
  137836. /** @hidden */
  137837. static _SceneComponentInitialization: (scene: Scene) => void;
  137838. /**
  137839. * Creates a new G Buffer for the scene
  137840. * @param scene The scene the buffer belongs to
  137841. * @param ratio How big is the buffer related to the main canvas.
  137842. */
  137843. constructor(scene: Scene, ratio?: number);
  137844. /**
  137845. * Checks wether everything is ready to render a submesh to the G buffer.
  137846. * @param subMesh the submesh to check readiness for
  137847. * @param useInstances is the mesh drawn using instance or not
  137848. * @returns true if ready otherwise false
  137849. */
  137850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137851. /**
  137852. * Gets the current underlying G Buffer.
  137853. * @returns the buffer
  137854. */
  137855. getGBuffer(): MultiRenderTarget;
  137856. /**
  137857. * Gets the number of samples used to render the buffer (anti aliasing).
  137858. */
  137859. get samples(): number;
  137860. /**
  137861. * Sets the number of samples used to render the buffer (anti aliasing).
  137862. */
  137863. set samples(value: number);
  137864. /**
  137865. * Disposes the renderer and frees up associated resources.
  137866. */
  137867. dispose(): void;
  137868. protected _createRenderTargets(): void;
  137869. private _copyBonesTransformationMatrices;
  137870. }
  137871. }
  137872. declare module BABYLON {
  137873. interface Scene {
  137874. /** @hidden (Backing field) */
  137875. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137876. /**
  137877. * Gets or Sets the current geometry buffer associated to the scene.
  137878. */
  137879. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137880. /**
  137881. * Enables a GeometryBufferRender and associates it with the scene
  137882. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137883. * @returns the GeometryBufferRenderer
  137884. */
  137885. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137886. /**
  137887. * Disables the GeometryBufferRender associated with the scene
  137888. */
  137889. disableGeometryBufferRenderer(): void;
  137890. }
  137891. /**
  137892. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137893. * in several rendering techniques.
  137894. */
  137895. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137896. /**
  137897. * The component name helpful to identify the component in the list of scene components.
  137898. */
  137899. readonly name: string;
  137900. /**
  137901. * The scene the component belongs to.
  137902. */
  137903. scene: Scene;
  137904. /**
  137905. * Creates a new instance of the component for the given scene
  137906. * @param scene Defines the scene to register the component in
  137907. */
  137908. constructor(scene: Scene);
  137909. /**
  137910. * Registers the component in a given scene
  137911. */
  137912. register(): void;
  137913. /**
  137914. * Rebuilds the elements related to this component in case of
  137915. * context lost for instance.
  137916. */
  137917. rebuild(): void;
  137918. /**
  137919. * Disposes the component and the associated ressources
  137920. */
  137921. dispose(): void;
  137922. private _gatherRenderTargets;
  137923. }
  137924. }
  137925. declare module BABYLON {
  137926. /** @hidden */
  137927. export var motionBlurPixelShader: {
  137928. name: string;
  137929. shader: string;
  137930. };
  137931. }
  137932. declare module BABYLON {
  137933. /**
  137934. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137935. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137936. * As an example, all you have to do is to create the post-process:
  137937. * var mb = new BABYLON.MotionBlurPostProcess(
  137938. * 'mb', // The name of the effect.
  137939. * scene, // The scene containing the objects to blur according to their velocity.
  137940. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137941. * camera // The camera to apply the render pass to.
  137942. * );
  137943. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137944. */
  137945. export class MotionBlurPostProcess extends PostProcess {
  137946. /**
  137947. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137948. */
  137949. motionStrength: number;
  137950. /**
  137951. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137952. */
  137953. get motionBlurSamples(): number;
  137954. /**
  137955. * Sets the number of iterations to be used for motion blur quality
  137956. */
  137957. set motionBlurSamples(samples: number);
  137958. private _motionBlurSamples;
  137959. private _geometryBufferRenderer;
  137960. /**
  137961. * Creates a new instance MotionBlurPostProcess
  137962. * @param name The name of the effect.
  137963. * @param scene The scene containing the objects to blur according to their velocity.
  137964. * @param options The required width/height ratio to downsize to before computing the render pass.
  137965. * @param camera The camera to apply the render pass to.
  137966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137967. * @param engine The engine which the post process will be applied. (default: current engine)
  137968. * @param reusable If the post process can be reused on the same frame. (default: false)
  137969. * @param textureType Type of textures used when performing the post process. (default: 0)
  137970. * @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)
  137971. */
  137972. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137973. /**
  137974. * Excludes the given skinned mesh from computing bones velocities.
  137975. * 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.
  137976. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137977. */
  137978. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137979. /**
  137980. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137981. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137982. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137983. */
  137984. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137985. /**
  137986. * Disposes the post process.
  137987. * @param camera The camera to dispose the post process on.
  137988. */
  137989. dispose(camera?: Camera): void;
  137990. }
  137991. }
  137992. declare module BABYLON {
  137993. /** @hidden */
  137994. export var refractionPixelShader: {
  137995. name: string;
  137996. shader: string;
  137997. };
  137998. }
  137999. declare module BABYLON {
  138000. /**
  138001. * Post process which applies a refractin texture
  138002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138003. */
  138004. export class RefractionPostProcess extends PostProcess {
  138005. /** the base color of the refraction (used to taint the rendering) */
  138006. color: Color3;
  138007. /** simulated refraction depth */
  138008. depth: number;
  138009. /** the coefficient of the base color (0 to remove base color tainting) */
  138010. colorLevel: number;
  138011. private _refTexture;
  138012. private _ownRefractionTexture;
  138013. /**
  138014. * Gets or sets the refraction texture
  138015. * Please note that you are responsible for disposing the texture if you set it manually
  138016. */
  138017. get refractionTexture(): Texture;
  138018. set refractionTexture(value: Texture);
  138019. /**
  138020. * Initializes the RefractionPostProcess
  138021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138022. * @param name The name of the effect.
  138023. * @param refractionTextureUrl Url of the refraction texture to use
  138024. * @param color the base color of the refraction (used to taint the rendering)
  138025. * @param depth simulated refraction depth
  138026. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138027. * @param camera The camera to apply the render pass to.
  138028. * @param options The required width/height ratio to downsize to before computing the render pass.
  138029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138030. * @param engine The engine which the post process will be applied. (default: current engine)
  138031. * @param reusable If the post process can be reused on the same frame. (default: false)
  138032. */
  138033. constructor(name: string, refractionTextureUrl: string,
  138034. /** the base color of the refraction (used to taint the rendering) */
  138035. color: Color3,
  138036. /** simulated refraction depth */
  138037. depth: number,
  138038. /** the coefficient of the base color (0 to remove base color tainting) */
  138039. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138040. /**
  138041. * Disposes of the post process
  138042. * @param camera Camera to dispose post process on
  138043. */
  138044. dispose(camera: Camera): void;
  138045. }
  138046. }
  138047. declare module BABYLON {
  138048. /** @hidden */
  138049. export var sharpenPixelShader: {
  138050. name: string;
  138051. shader: string;
  138052. };
  138053. }
  138054. declare module BABYLON {
  138055. /**
  138056. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138057. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138058. */
  138059. export class SharpenPostProcess extends PostProcess {
  138060. /**
  138061. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138062. */
  138063. colorAmount: number;
  138064. /**
  138065. * How much sharpness should be applied (default: 0.3)
  138066. */
  138067. edgeAmount: number;
  138068. /**
  138069. * Creates a new instance ConvolutionPostProcess
  138070. * @param name The name of the effect.
  138071. * @param options The required width/height ratio to downsize to before computing the render pass.
  138072. * @param camera The camera to apply the render pass to.
  138073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138074. * @param engine The engine which the post process will be applied. (default: current engine)
  138075. * @param reusable If the post process can be reused on the same frame. (default: false)
  138076. * @param textureType Type of textures used when performing the post process. (default: 0)
  138077. * @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)
  138078. */
  138079. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138080. }
  138081. }
  138082. declare module BABYLON {
  138083. /**
  138084. * PostProcessRenderPipeline
  138085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138086. */
  138087. export class PostProcessRenderPipeline {
  138088. private engine;
  138089. private _renderEffects;
  138090. private _renderEffectsForIsolatedPass;
  138091. /**
  138092. * List of inspectable custom properties (used by the Inspector)
  138093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138094. */
  138095. inspectableCustomProperties: IInspectable[];
  138096. /**
  138097. * @hidden
  138098. */
  138099. protected _cameras: Camera[];
  138100. /** @hidden */
  138101. _name: string;
  138102. /**
  138103. * Gets pipeline name
  138104. */
  138105. get name(): string;
  138106. /** Gets the list of attached cameras */
  138107. get cameras(): Camera[];
  138108. /**
  138109. * Initializes a PostProcessRenderPipeline
  138110. * @param engine engine to add the pipeline to
  138111. * @param name name of the pipeline
  138112. */
  138113. constructor(engine: Engine, name: string);
  138114. /**
  138115. * Gets the class name
  138116. * @returns "PostProcessRenderPipeline"
  138117. */
  138118. getClassName(): string;
  138119. /**
  138120. * If all the render effects in the pipeline are supported
  138121. */
  138122. get isSupported(): boolean;
  138123. /**
  138124. * Adds an effect to the pipeline
  138125. * @param renderEffect the effect to add
  138126. */
  138127. addEffect(renderEffect: PostProcessRenderEffect): void;
  138128. /** @hidden */
  138129. _rebuild(): void;
  138130. /** @hidden */
  138131. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138132. /** @hidden */
  138133. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138134. /** @hidden */
  138135. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138136. /** @hidden */
  138137. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138138. /** @hidden */
  138139. _attachCameras(cameras: Camera, unique: boolean): void;
  138140. /** @hidden */
  138141. _attachCameras(cameras: Camera[], unique: boolean): void;
  138142. /** @hidden */
  138143. _detachCameras(cameras: Camera): void;
  138144. /** @hidden */
  138145. _detachCameras(cameras: Nullable<Camera[]>): void;
  138146. /** @hidden */
  138147. _update(): void;
  138148. /** @hidden */
  138149. _reset(): void;
  138150. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138151. /**
  138152. * Disposes of the pipeline
  138153. */
  138154. dispose(): void;
  138155. }
  138156. }
  138157. declare module BABYLON {
  138158. /**
  138159. * PostProcessRenderPipelineManager class
  138160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138161. */
  138162. export class PostProcessRenderPipelineManager {
  138163. private _renderPipelines;
  138164. /**
  138165. * Initializes a PostProcessRenderPipelineManager
  138166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138167. */
  138168. constructor();
  138169. /**
  138170. * Gets the list of supported render pipelines
  138171. */
  138172. get supportedPipelines(): PostProcessRenderPipeline[];
  138173. /**
  138174. * Adds a pipeline to the manager
  138175. * @param renderPipeline The pipeline to add
  138176. */
  138177. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138178. /**
  138179. * Attaches a camera to the pipeline
  138180. * @param renderPipelineName The name of the pipeline to attach to
  138181. * @param cameras the camera to attach
  138182. * @param unique if the camera can be attached multiple times to the pipeline
  138183. */
  138184. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138185. /**
  138186. * Detaches a camera from the pipeline
  138187. * @param renderPipelineName The name of the pipeline to detach from
  138188. * @param cameras the camera to detach
  138189. */
  138190. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138191. /**
  138192. * Enables an effect by name on a pipeline
  138193. * @param renderPipelineName the name of the pipeline to enable the effect in
  138194. * @param renderEffectName the name of the effect to enable
  138195. * @param cameras the cameras that the effect should be enabled on
  138196. */
  138197. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138198. /**
  138199. * Disables an effect by name on a pipeline
  138200. * @param renderPipelineName the name of the pipeline to disable the effect in
  138201. * @param renderEffectName the name of the effect to disable
  138202. * @param cameras the cameras that the effect should be disabled on
  138203. */
  138204. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138205. /**
  138206. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138207. */
  138208. update(): void;
  138209. /** @hidden */
  138210. _rebuild(): void;
  138211. /**
  138212. * Disposes of the manager and pipelines
  138213. */
  138214. dispose(): void;
  138215. }
  138216. }
  138217. declare module BABYLON {
  138218. interface Scene {
  138219. /** @hidden (Backing field) */
  138220. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138221. /**
  138222. * Gets the postprocess render pipeline manager
  138223. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138224. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138225. */
  138226. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138227. }
  138228. /**
  138229. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138230. */
  138231. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138232. /**
  138233. * The component name helpfull to identify the component in the list of scene components.
  138234. */
  138235. readonly name: string;
  138236. /**
  138237. * The scene the component belongs to.
  138238. */
  138239. scene: Scene;
  138240. /**
  138241. * Creates a new instance of the component for the given scene
  138242. * @param scene Defines the scene to register the component in
  138243. */
  138244. constructor(scene: Scene);
  138245. /**
  138246. * Registers the component in a given scene
  138247. */
  138248. register(): void;
  138249. /**
  138250. * Rebuilds the elements related to this component in case of
  138251. * context lost for instance.
  138252. */
  138253. rebuild(): void;
  138254. /**
  138255. * Disposes the component and the associated ressources
  138256. */
  138257. dispose(): void;
  138258. private _gatherRenderTargets;
  138259. }
  138260. }
  138261. declare module BABYLON {
  138262. /**
  138263. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138264. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138265. */
  138266. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138267. private _scene;
  138268. private _camerasToBeAttached;
  138269. /**
  138270. * ID of the sharpen post process,
  138271. */
  138272. private readonly SharpenPostProcessId;
  138273. /**
  138274. * @ignore
  138275. * ID of the image processing post process;
  138276. */
  138277. readonly ImageProcessingPostProcessId: string;
  138278. /**
  138279. * @ignore
  138280. * ID of the Fast Approximate Anti-Aliasing post process;
  138281. */
  138282. readonly FxaaPostProcessId: string;
  138283. /**
  138284. * ID of the chromatic aberration post process,
  138285. */
  138286. private readonly ChromaticAberrationPostProcessId;
  138287. /**
  138288. * ID of the grain post process
  138289. */
  138290. private readonly GrainPostProcessId;
  138291. /**
  138292. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138293. */
  138294. sharpen: SharpenPostProcess;
  138295. private _sharpenEffect;
  138296. private bloom;
  138297. /**
  138298. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138299. */
  138300. depthOfField: DepthOfFieldEffect;
  138301. /**
  138302. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138303. */
  138304. fxaa: FxaaPostProcess;
  138305. /**
  138306. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138307. */
  138308. imageProcessing: ImageProcessingPostProcess;
  138309. /**
  138310. * Chromatic aberration post process which will shift rgb colors in the image
  138311. */
  138312. chromaticAberration: ChromaticAberrationPostProcess;
  138313. private _chromaticAberrationEffect;
  138314. /**
  138315. * Grain post process which add noise to the image
  138316. */
  138317. grain: GrainPostProcess;
  138318. private _grainEffect;
  138319. /**
  138320. * Glow post process which adds a glow to emissive areas of the image
  138321. */
  138322. private _glowLayer;
  138323. /**
  138324. * Animations which can be used to tweak settings over a period of time
  138325. */
  138326. animations: Animation[];
  138327. private _imageProcessingConfigurationObserver;
  138328. private _sharpenEnabled;
  138329. private _bloomEnabled;
  138330. private _depthOfFieldEnabled;
  138331. private _depthOfFieldBlurLevel;
  138332. private _fxaaEnabled;
  138333. private _imageProcessingEnabled;
  138334. private _defaultPipelineTextureType;
  138335. private _bloomScale;
  138336. private _chromaticAberrationEnabled;
  138337. private _grainEnabled;
  138338. private _buildAllowed;
  138339. /**
  138340. * Gets active scene
  138341. */
  138342. get scene(): Scene;
  138343. /**
  138344. * Enable or disable the sharpen process from the pipeline
  138345. */
  138346. set sharpenEnabled(enabled: boolean);
  138347. get sharpenEnabled(): boolean;
  138348. private _resizeObserver;
  138349. private _hardwareScaleLevel;
  138350. private _bloomKernel;
  138351. /**
  138352. * Specifies the size of the bloom blur kernel, relative to the final output size
  138353. */
  138354. get bloomKernel(): number;
  138355. set bloomKernel(value: number);
  138356. /**
  138357. * Specifies the weight of the bloom in the final rendering
  138358. */
  138359. private _bloomWeight;
  138360. /**
  138361. * Specifies the luma threshold for the area that will be blurred by the bloom
  138362. */
  138363. private _bloomThreshold;
  138364. private _hdr;
  138365. /**
  138366. * The strength of the bloom.
  138367. */
  138368. set bloomWeight(value: number);
  138369. get bloomWeight(): number;
  138370. /**
  138371. * The strength of the bloom.
  138372. */
  138373. set bloomThreshold(value: number);
  138374. get bloomThreshold(): number;
  138375. /**
  138376. * The scale of the bloom, lower value will provide better performance.
  138377. */
  138378. set bloomScale(value: number);
  138379. get bloomScale(): number;
  138380. /**
  138381. * Enable or disable the bloom from the pipeline
  138382. */
  138383. set bloomEnabled(enabled: boolean);
  138384. get bloomEnabled(): boolean;
  138385. private _rebuildBloom;
  138386. /**
  138387. * If the depth of field is enabled.
  138388. */
  138389. get depthOfFieldEnabled(): boolean;
  138390. set depthOfFieldEnabled(enabled: boolean);
  138391. /**
  138392. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138393. */
  138394. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138395. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138396. /**
  138397. * If the anti aliasing is enabled.
  138398. */
  138399. set fxaaEnabled(enabled: boolean);
  138400. get fxaaEnabled(): boolean;
  138401. private _samples;
  138402. /**
  138403. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138404. */
  138405. set samples(sampleCount: number);
  138406. get samples(): number;
  138407. /**
  138408. * If image processing is enabled.
  138409. */
  138410. set imageProcessingEnabled(enabled: boolean);
  138411. get imageProcessingEnabled(): boolean;
  138412. /**
  138413. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138414. */
  138415. set glowLayerEnabled(enabled: boolean);
  138416. get glowLayerEnabled(): boolean;
  138417. /**
  138418. * Gets the glow layer (or null if not defined)
  138419. */
  138420. get glowLayer(): Nullable<GlowLayer>;
  138421. /**
  138422. * Enable or disable the chromaticAberration process from the pipeline
  138423. */
  138424. set chromaticAberrationEnabled(enabled: boolean);
  138425. get chromaticAberrationEnabled(): boolean;
  138426. /**
  138427. * Enable or disable the grain process from the pipeline
  138428. */
  138429. set grainEnabled(enabled: boolean);
  138430. get grainEnabled(): boolean;
  138431. /**
  138432. * @constructor
  138433. * @param name - The rendering pipeline name (default: "")
  138434. * @param hdr - If high dynamic range textures should be used (default: true)
  138435. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138436. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138437. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138438. */
  138439. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138440. /**
  138441. * Get the class name
  138442. * @returns "DefaultRenderingPipeline"
  138443. */
  138444. getClassName(): string;
  138445. /**
  138446. * Force the compilation of the entire pipeline.
  138447. */
  138448. prepare(): void;
  138449. private _hasCleared;
  138450. private _prevPostProcess;
  138451. private _prevPrevPostProcess;
  138452. private _setAutoClearAndTextureSharing;
  138453. private _depthOfFieldSceneObserver;
  138454. private _buildPipeline;
  138455. private _disposePostProcesses;
  138456. /**
  138457. * Adds a camera to the pipeline
  138458. * @param camera the camera to be added
  138459. */
  138460. addCamera(camera: Camera): void;
  138461. /**
  138462. * Removes a camera from the pipeline
  138463. * @param camera the camera to remove
  138464. */
  138465. removeCamera(camera: Camera): void;
  138466. /**
  138467. * Dispose of the pipeline and stop all post processes
  138468. */
  138469. dispose(): void;
  138470. /**
  138471. * Serialize the rendering pipeline (Used when exporting)
  138472. * @returns the serialized object
  138473. */
  138474. serialize(): any;
  138475. /**
  138476. * Parse the serialized pipeline
  138477. * @param source Source pipeline.
  138478. * @param scene The scene to load the pipeline to.
  138479. * @param rootUrl The URL of the serialized pipeline.
  138480. * @returns An instantiated pipeline from the serialized object.
  138481. */
  138482. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138483. }
  138484. }
  138485. declare module BABYLON {
  138486. /** @hidden */
  138487. export var lensHighlightsPixelShader: {
  138488. name: string;
  138489. shader: string;
  138490. };
  138491. }
  138492. declare module BABYLON {
  138493. /** @hidden */
  138494. export var depthOfFieldPixelShader: {
  138495. name: string;
  138496. shader: string;
  138497. };
  138498. }
  138499. declare module BABYLON {
  138500. /**
  138501. * BABYLON.JS Chromatic Aberration GLSL Shader
  138502. * Author: Olivier Guyot
  138503. * Separates very slightly R, G and B colors on the edges of the screen
  138504. * Inspired by Francois Tarlier & Martins Upitis
  138505. */
  138506. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138507. /**
  138508. * @ignore
  138509. * The chromatic aberration PostProcess id in the pipeline
  138510. */
  138511. LensChromaticAberrationEffect: string;
  138512. /**
  138513. * @ignore
  138514. * The highlights enhancing PostProcess id in the pipeline
  138515. */
  138516. HighlightsEnhancingEffect: string;
  138517. /**
  138518. * @ignore
  138519. * The depth-of-field PostProcess id in the pipeline
  138520. */
  138521. LensDepthOfFieldEffect: string;
  138522. private _scene;
  138523. private _depthTexture;
  138524. private _grainTexture;
  138525. private _chromaticAberrationPostProcess;
  138526. private _highlightsPostProcess;
  138527. private _depthOfFieldPostProcess;
  138528. private _edgeBlur;
  138529. private _grainAmount;
  138530. private _chromaticAberration;
  138531. private _distortion;
  138532. private _highlightsGain;
  138533. private _highlightsThreshold;
  138534. private _dofDistance;
  138535. private _dofAperture;
  138536. private _dofDarken;
  138537. private _dofPentagon;
  138538. private _blurNoise;
  138539. /**
  138540. * @constructor
  138541. *
  138542. * Effect parameters are as follow:
  138543. * {
  138544. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138545. * edge_blur: number; // from 0 to x (1 for realism)
  138546. * distortion: number; // from 0 to x (1 for realism)
  138547. * grain_amount: number; // from 0 to 1
  138548. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138549. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138550. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138551. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138552. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138553. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138554. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138555. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138556. * }
  138557. * Note: if an effect parameter is unset, effect is disabled
  138558. *
  138559. * @param name The rendering pipeline name
  138560. * @param parameters - An object containing all parameters (see above)
  138561. * @param scene The scene linked to this pipeline
  138562. * @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)
  138563. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138564. */
  138565. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138566. /**
  138567. * Get the class name
  138568. * @returns "LensRenderingPipeline"
  138569. */
  138570. getClassName(): string;
  138571. /**
  138572. * Gets associated scene
  138573. */
  138574. get scene(): Scene;
  138575. /**
  138576. * Gets or sets the edge blur
  138577. */
  138578. get edgeBlur(): number;
  138579. set edgeBlur(value: number);
  138580. /**
  138581. * Gets or sets the grain amount
  138582. */
  138583. get grainAmount(): number;
  138584. set grainAmount(value: number);
  138585. /**
  138586. * Gets or sets the chromatic aberration amount
  138587. */
  138588. get chromaticAberration(): number;
  138589. set chromaticAberration(value: number);
  138590. /**
  138591. * Gets or sets the depth of field aperture
  138592. */
  138593. get dofAperture(): number;
  138594. set dofAperture(value: number);
  138595. /**
  138596. * Gets or sets the edge distortion
  138597. */
  138598. get edgeDistortion(): number;
  138599. set edgeDistortion(value: number);
  138600. /**
  138601. * Gets or sets the depth of field distortion
  138602. */
  138603. get dofDistortion(): number;
  138604. set dofDistortion(value: number);
  138605. /**
  138606. * Gets or sets the darken out of focus amount
  138607. */
  138608. get darkenOutOfFocus(): number;
  138609. set darkenOutOfFocus(value: number);
  138610. /**
  138611. * Gets or sets a boolean indicating if blur noise is enabled
  138612. */
  138613. get blurNoise(): boolean;
  138614. set blurNoise(value: boolean);
  138615. /**
  138616. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138617. */
  138618. get pentagonBokeh(): boolean;
  138619. set pentagonBokeh(value: boolean);
  138620. /**
  138621. * Gets or sets the highlight grain amount
  138622. */
  138623. get highlightsGain(): number;
  138624. set highlightsGain(value: number);
  138625. /**
  138626. * Gets or sets the highlight threshold
  138627. */
  138628. get highlightsThreshold(): number;
  138629. set highlightsThreshold(value: number);
  138630. /**
  138631. * Sets the amount of blur at the edges
  138632. * @param amount blur amount
  138633. */
  138634. setEdgeBlur(amount: number): void;
  138635. /**
  138636. * Sets edge blur to 0
  138637. */
  138638. disableEdgeBlur(): void;
  138639. /**
  138640. * Sets the amout of grain
  138641. * @param amount Amount of grain
  138642. */
  138643. setGrainAmount(amount: number): void;
  138644. /**
  138645. * Set grain amount to 0
  138646. */
  138647. disableGrain(): void;
  138648. /**
  138649. * Sets the chromatic aberration amount
  138650. * @param amount amount of chromatic aberration
  138651. */
  138652. setChromaticAberration(amount: number): void;
  138653. /**
  138654. * Sets chromatic aberration amount to 0
  138655. */
  138656. disableChromaticAberration(): void;
  138657. /**
  138658. * Sets the EdgeDistortion amount
  138659. * @param amount amount of EdgeDistortion
  138660. */
  138661. setEdgeDistortion(amount: number): void;
  138662. /**
  138663. * Sets edge distortion to 0
  138664. */
  138665. disableEdgeDistortion(): void;
  138666. /**
  138667. * Sets the FocusDistance amount
  138668. * @param amount amount of FocusDistance
  138669. */
  138670. setFocusDistance(amount: number): void;
  138671. /**
  138672. * Disables depth of field
  138673. */
  138674. disableDepthOfField(): void;
  138675. /**
  138676. * Sets the Aperture amount
  138677. * @param amount amount of Aperture
  138678. */
  138679. setAperture(amount: number): void;
  138680. /**
  138681. * Sets the DarkenOutOfFocus amount
  138682. * @param amount amount of DarkenOutOfFocus
  138683. */
  138684. setDarkenOutOfFocus(amount: number): void;
  138685. private _pentagonBokehIsEnabled;
  138686. /**
  138687. * Creates a pentagon bokeh effect
  138688. */
  138689. enablePentagonBokeh(): void;
  138690. /**
  138691. * Disables the pentagon bokeh effect
  138692. */
  138693. disablePentagonBokeh(): void;
  138694. /**
  138695. * Enables noise blur
  138696. */
  138697. enableNoiseBlur(): void;
  138698. /**
  138699. * Disables noise blur
  138700. */
  138701. disableNoiseBlur(): void;
  138702. /**
  138703. * Sets the HighlightsGain amount
  138704. * @param amount amount of HighlightsGain
  138705. */
  138706. setHighlightsGain(amount: number): void;
  138707. /**
  138708. * Sets the HighlightsThreshold amount
  138709. * @param amount amount of HighlightsThreshold
  138710. */
  138711. setHighlightsThreshold(amount: number): void;
  138712. /**
  138713. * Disables highlights
  138714. */
  138715. disableHighlights(): void;
  138716. /**
  138717. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138718. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138719. */
  138720. dispose(disableDepthRender?: boolean): void;
  138721. private _createChromaticAberrationPostProcess;
  138722. private _createHighlightsPostProcess;
  138723. private _createDepthOfFieldPostProcess;
  138724. private _createGrainTexture;
  138725. }
  138726. }
  138727. declare module BABYLON {
  138728. /** @hidden */
  138729. export var ssao2PixelShader: {
  138730. name: string;
  138731. shader: string;
  138732. };
  138733. }
  138734. declare module BABYLON {
  138735. /** @hidden */
  138736. export var ssaoCombinePixelShader: {
  138737. name: string;
  138738. shader: string;
  138739. };
  138740. }
  138741. declare module BABYLON {
  138742. /**
  138743. * Render pipeline to produce ssao effect
  138744. */
  138745. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138746. /**
  138747. * @ignore
  138748. * The PassPostProcess id in the pipeline that contains the original scene color
  138749. */
  138750. SSAOOriginalSceneColorEffect: string;
  138751. /**
  138752. * @ignore
  138753. * The SSAO PostProcess id in the pipeline
  138754. */
  138755. SSAORenderEffect: string;
  138756. /**
  138757. * @ignore
  138758. * The horizontal blur PostProcess id in the pipeline
  138759. */
  138760. SSAOBlurHRenderEffect: string;
  138761. /**
  138762. * @ignore
  138763. * The vertical blur PostProcess id in the pipeline
  138764. */
  138765. SSAOBlurVRenderEffect: string;
  138766. /**
  138767. * @ignore
  138768. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138769. */
  138770. SSAOCombineRenderEffect: string;
  138771. /**
  138772. * The output strength of the SSAO post-process. Default value is 1.0.
  138773. */
  138774. totalStrength: number;
  138775. /**
  138776. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138777. */
  138778. maxZ: number;
  138779. /**
  138780. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138781. */
  138782. minZAspect: number;
  138783. private _samples;
  138784. /**
  138785. * Number of samples used for the SSAO calculations. Default value is 8
  138786. */
  138787. set samples(n: number);
  138788. get samples(): number;
  138789. private _textureSamples;
  138790. /**
  138791. * Number of samples to use for antialiasing
  138792. */
  138793. set textureSamples(n: number);
  138794. get textureSamples(): number;
  138795. /**
  138796. * Ratio object used for SSAO ratio and blur ratio
  138797. */
  138798. private _ratio;
  138799. /**
  138800. * Dynamically generated sphere sampler.
  138801. */
  138802. private _sampleSphere;
  138803. /**
  138804. * Blur filter offsets
  138805. */
  138806. private _samplerOffsets;
  138807. private _expensiveBlur;
  138808. /**
  138809. * If bilateral blur should be used
  138810. */
  138811. set expensiveBlur(b: boolean);
  138812. get expensiveBlur(): boolean;
  138813. /**
  138814. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138815. */
  138816. radius: number;
  138817. /**
  138818. * The base color of the SSAO post-process
  138819. * The final result is "base + ssao" between [0, 1]
  138820. */
  138821. base: number;
  138822. /**
  138823. * Support test.
  138824. */
  138825. static get IsSupported(): boolean;
  138826. private _scene;
  138827. private _depthTexture;
  138828. private _normalTexture;
  138829. private _randomTexture;
  138830. private _originalColorPostProcess;
  138831. private _ssaoPostProcess;
  138832. private _blurHPostProcess;
  138833. private _blurVPostProcess;
  138834. private _ssaoCombinePostProcess;
  138835. /**
  138836. * Gets active scene
  138837. */
  138838. get scene(): Scene;
  138839. /**
  138840. * @constructor
  138841. * @param name The rendering pipeline name
  138842. * @param scene The scene linked to this pipeline
  138843. * @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 }
  138844. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138845. */
  138846. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138847. /**
  138848. * Get the class name
  138849. * @returns "SSAO2RenderingPipeline"
  138850. */
  138851. getClassName(): string;
  138852. /**
  138853. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138854. */
  138855. dispose(disableGeometryBufferRenderer?: boolean): void;
  138856. private _createBlurPostProcess;
  138857. /** @hidden */
  138858. _rebuild(): void;
  138859. private _bits;
  138860. private _radicalInverse_VdC;
  138861. private _hammersley;
  138862. private _hemisphereSample_uniform;
  138863. private _generateHemisphere;
  138864. private _createSSAOPostProcess;
  138865. private _createSSAOCombinePostProcess;
  138866. private _createRandomTexture;
  138867. /**
  138868. * Serialize the rendering pipeline (Used when exporting)
  138869. * @returns the serialized object
  138870. */
  138871. serialize(): any;
  138872. /**
  138873. * Parse the serialized pipeline
  138874. * @param source Source pipeline.
  138875. * @param scene The scene to load the pipeline to.
  138876. * @param rootUrl The URL of the serialized pipeline.
  138877. * @returns An instantiated pipeline from the serialized object.
  138878. */
  138879. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138880. }
  138881. }
  138882. declare module BABYLON {
  138883. /** @hidden */
  138884. export var ssaoPixelShader: {
  138885. name: string;
  138886. shader: string;
  138887. };
  138888. }
  138889. declare module BABYLON {
  138890. /**
  138891. * Render pipeline to produce ssao effect
  138892. */
  138893. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138894. /**
  138895. * @ignore
  138896. * The PassPostProcess id in the pipeline that contains the original scene color
  138897. */
  138898. SSAOOriginalSceneColorEffect: string;
  138899. /**
  138900. * @ignore
  138901. * The SSAO PostProcess id in the pipeline
  138902. */
  138903. SSAORenderEffect: string;
  138904. /**
  138905. * @ignore
  138906. * The horizontal blur PostProcess id in the pipeline
  138907. */
  138908. SSAOBlurHRenderEffect: string;
  138909. /**
  138910. * @ignore
  138911. * The vertical blur PostProcess id in the pipeline
  138912. */
  138913. SSAOBlurVRenderEffect: string;
  138914. /**
  138915. * @ignore
  138916. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138917. */
  138918. SSAOCombineRenderEffect: string;
  138919. /**
  138920. * The output strength of the SSAO post-process. Default value is 1.0.
  138921. */
  138922. totalStrength: number;
  138923. /**
  138924. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138925. */
  138926. radius: number;
  138927. /**
  138928. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138929. * Must not be equal to fallOff and superior to fallOff.
  138930. * Default value is 0.0075
  138931. */
  138932. area: number;
  138933. /**
  138934. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138935. * Must not be equal to area and inferior to area.
  138936. * Default value is 0.000001
  138937. */
  138938. fallOff: number;
  138939. /**
  138940. * The base color of the SSAO post-process
  138941. * The final result is "base + ssao" between [0, 1]
  138942. */
  138943. base: number;
  138944. private _scene;
  138945. private _depthTexture;
  138946. private _randomTexture;
  138947. private _originalColorPostProcess;
  138948. private _ssaoPostProcess;
  138949. private _blurHPostProcess;
  138950. private _blurVPostProcess;
  138951. private _ssaoCombinePostProcess;
  138952. private _firstUpdate;
  138953. /**
  138954. * Gets active scene
  138955. */
  138956. get scene(): Scene;
  138957. /**
  138958. * @constructor
  138959. * @param name - The rendering pipeline name
  138960. * @param scene - The scene linked to this pipeline
  138961. * @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 }
  138962. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138963. */
  138964. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138965. /**
  138966. * Get the class name
  138967. * @returns "SSAORenderingPipeline"
  138968. */
  138969. getClassName(): string;
  138970. /**
  138971. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138972. */
  138973. dispose(disableDepthRender?: boolean): void;
  138974. private _createBlurPostProcess;
  138975. /** @hidden */
  138976. _rebuild(): void;
  138977. private _createSSAOPostProcess;
  138978. private _createSSAOCombinePostProcess;
  138979. private _createRandomTexture;
  138980. }
  138981. }
  138982. declare module BABYLON {
  138983. /** @hidden */
  138984. export var screenSpaceReflectionPixelShader: {
  138985. name: string;
  138986. shader: string;
  138987. };
  138988. }
  138989. declare module BABYLON {
  138990. /**
  138991. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138992. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138993. */
  138994. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138995. /**
  138996. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138997. */
  138998. threshold: number;
  138999. /**
  139000. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139001. */
  139002. strength: number;
  139003. /**
  139004. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139005. */
  139006. reflectionSpecularFalloffExponent: number;
  139007. /**
  139008. * 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]
  139009. */
  139010. step: number;
  139011. /**
  139012. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139013. */
  139014. roughnessFactor: number;
  139015. private _geometryBufferRenderer;
  139016. private _enableSmoothReflections;
  139017. private _reflectionSamples;
  139018. private _smoothSteps;
  139019. /**
  139020. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139021. * @param name The name of the effect.
  139022. * @param scene The scene containing the objects to calculate reflections.
  139023. * @param options The required width/height ratio to downsize to before computing the render pass.
  139024. * @param camera The camera to apply the render pass to.
  139025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139026. * @param engine The engine which the post process will be applied. (default: current engine)
  139027. * @param reusable If the post process can be reused on the same frame. (default: false)
  139028. * @param textureType Type of textures used when performing the post process. (default: 0)
  139029. * @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)
  139030. */
  139031. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139032. /**
  139033. * Gets wether or not smoothing reflections is enabled.
  139034. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139035. */
  139036. get enableSmoothReflections(): boolean;
  139037. /**
  139038. * Sets wether or not smoothing reflections is enabled.
  139039. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139040. */
  139041. set enableSmoothReflections(enabled: boolean);
  139042. /**
  139043. * Gets the number of samples taken while computing reflections. More samples count is high,
  139044. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139045. */
  139046. get reflectionSamples(): number;
  139047. /**
  139048. * Sets the number of samples taken while computing reflections. More samples count is high,
  139049. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139050. */
  139051. set reflectionSamples(samples: number);
  139052. /**
  139053. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139054. * more the post-process will require GPU power and can generate a drop in FPS.
  139055. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139056. */
  139057. get smoothSteps(): number;
  139058. set smoothSteps(steps: number);
  139059. private _updateEffectDefines;
  139060. }
  139061. }
  139062. declare module BABYLON {
  139063. /** @hidden */
  139064. export var standardPixelShader: {
  139065. name: string;
  139066. shader: string;
  139067. };
  139068. }
  139069. declare module BABYLON {
  139070. /**
  139071. * Standard rendering pipeline
  139072. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139073. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139074. */
  139075. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139076. /**
  139077. * Public members
  139078. */
  139079. /**
  139080. * Post-process which contains the original scene color before the pipeline applies all the effects
  139081. */
  139082. originalPostProcess: Nullable<PostProcess>;
  139083. /**
  139084. * Post-process used to down scale an image x4
  139085. */
  139086. downSampleX4PostProcess: Nullable<PostProcess>;
  139087. /**
  139088. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139089. */
  139090. brightPassPostProcess: Nullable<PostProcess>;
  139091. /**
  139092. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139093. */
  139094. blurHPostProcesses: PostProcess[];
  139095. /**
  139096. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139097. */
  139098. blurVPostProcesses: PostProcess[];
  139099. /**
  139100. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139101. */
  139102. textureAdderPostProcess: Nullable<PostProcess>;
  139103. /**
  139104. * Post-process used to create volumetric lighting effect
  139105. */
  139106. volumetricLightPostProcess: Nullable<PostProcess>;
  139107. /**
  139108. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139109. */
  139110. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139111. /**
  139112. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139113. */
  139114. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139115. /**
  139116. * Post-process used to merge the volumetric light effect and the real scene color
  139117. */
  139118. volumetricLightMergePostProces: Nullable<PostProcess>;
  139119. /**
  139120. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139121. */
  139122. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139123. /**
  139124. * Base post-process used to calculate the average luminance of the final image for HDR
  139125. */
  139126. luminancePostProcess: Nullable<PostProcess>;
  139127. /**
  139128. * Post-processes used to create down sample post-processes in order to get
  139129. * the average luminance of the final image for HDR
  139130. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139131. */
  139132. luminanceDownSamplePostProcesses: PostProcess[];
  139133. /**
  139134. * Post-process used to create a HDR effect (light adaptation)
  139135. */
  139136. hdrPostProcess: Nullable<PostProcess>;
  139137. /**
  139138. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139139. */
  139140. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139141. /**
  139142. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139143. */
  139144. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139145. /**
  139146. * Post-process used to merge the final HDR post-process and the real scene color
  139147. */
  139148. hdrFinalPostProcess: Nullable<PostProcess>;
  139149. /**
  139150. * Post-process used to create a lens flare effect
  139151. */
  139152. lensFlarePostProcess: Nullable<PostProcess>;
  139153. /**
  139154. * Post-process that merges the result of the lens flare post-process and the real scene color
  139155. */
  139156. lensFlareComposePostProcess: Nullable<PostProcess>;
  139157. /**
  139158. * Post-process used to create a motion blur effect
  139159. */
  139160. motionBlurPostProcess: Nullable<PostProcess>;
  139161. /**
  139162. * Post-process used to create a depth of field effect
  139163. */
  139164. depthOfFieldPostProcess: Nullable<PostProcess>;
  139165. /**
  139166. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139167. */
  139168. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139169. /**
  139170. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139171. */
  139172. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139173. /**
  139174. * Represents the brightness threshold in order to configure the illuminated surfaces
  139175. */
  139176. brightThreshold: number;
  139177. /**
  139178. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139179. */
  139180. blurWidth: number;
  139181. /**
  139182. * Sets if the blur for highlighted surfaces must be only horizontal
  139183. */
  139184. horizontalBlur: boolean;
  139185. /**
  139186. * Gets the overall exposure used by the pipeline
  139187. */
  139188. get exposure(): number;
  139189. /**
  139190. * Sets the overall exposure used by the pipeline
  139191. */
  139192. set exposure(value: number);
  139193. /**
  139194. * Texture used typically to simulate "dirty" on camera lens
  139195. */
  139196. lensTexture: Nullable<Texture>;
  139197. /**
  139198. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139199. */
  139200. volumetricLightCoefficient: number;
  139201. /**
  139202. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139203. */
  139204. volumetricLightPower: number;
  139205. /**
  139206. * Used the set the blur intensity to smooth the volumetric lights
  139207. */
  139208. volumetricLightBlurScale: number;
  139209. /**
  139210. * Light (spot or directional) used to generate the volumetric lights rays
  139211. * The source light must have a shadow generate so the pipeline can get its
  139212. * depth map
  139213. */
  139214. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139215. /**
  139216. * For eye adaptation, represents the minimum luminance the eye can see
  139217. */
  139218. hdrMinimumLuminance: number;
  139219. /**
  139220. * For eye adaptation, represents the decrease luminance speed
  139221. */
  139222. hdrDecreaseRate: number;
  139223. /**
  139224. * For eye adaptation, represents the increase luminance speed
  139225. */
  139226. hdrIncreaseRate: number;
  139227. /**
  139228. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139229. */
  139230. get hdrAutoExposure(): boolean;
  139231. /**
  139232. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139233. */
  139234. set hdrAutoExposure(value: boolean);
  139235. /**
  139236. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139237. */
  139238. lensColorTexture: Nullable<Texture>;
  139239. /**
  139240. * The overall strengh for the lens flare effect
  139241. */
  139242. lensFlareStrength: number;
  139243. /**
  139244. * Dispersion coefficient for lens flare ghosts
  139245. */
  139246. lensFlareGhostDispersal: number;
  139247. /**
  139248. * Main lens flare halo width
  139249. */
  139250. lensFlareHaloWidth: number;
  139251. /**
  139252. * Based on the lens distortion effect, defines how much the lens flare result
  139253. * is distorted
  139254. */
  139255. lensFlareDistortionStrength: number;
  139256. /**
  139257. * Configures the blur intensity used for for lens flare (halo)
  139258. */
  139259. lensFlareBlurWidth: number;
  139260. /**
  139261. * Lens star texture must be used to simulate rays on the flares and is available
  139262. * in the documentation
  139263. */
  139264. lensStarTexture: Nullable<Texture>;
  139265. /**
  139266. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139267. * flare effect by taking account of the dirt texture
  139268. */
  139269. lensFlareDirtTexture: Nullable<Texture>;
  139270. /**
  139271. * Represents the focal length for the depth of field effect
  139272. */
  139273. depthOfFieldDistance: number;
  139274. /**
  139275. * Represents the blur intensity for the blurred part of the depth of field effect
  139276. */
  139277. depthOfFieldBlurWidth: number;
  139278. /**
  139279. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139280. */
  139281. get motionStrength(): number;
  139282. /**
  139283. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139284. */
  139285. set motionStrength(strength: number);
  139286. /**
  139287. * Gets wether or not the motion blur post-process is object based or screen based.
  139288. */
  139289. get objectBasedMotionBlur(): boolean;
  139290. /**
  139291. * Sets wether or not the motion blur post-process should be object based or screen based
  139292. */
  139293. set objectBasedMotionBlur(value: boolean);
  139294. /**
  139295. * List of animations for the pipeline (IAnimatable implementation)
  139296. */
  139297. animations: Animation[];
  139298. /**
  139299. * Private members
  139300. */
  139301. private _scene;
  139302. private _currentDepthOfFieldSource;
  139303. private _basePostProcess;
  139304. private _fixedExposure;
  139305. private _currentExposure;
  139306. private _hdrAutoExposure;
  139307. private _hdrCurrentLuminance;
  139308. private _motionStrength;
  139309. private _isObjectBasedMotionBlur;
  139310. private _floatTextureType;
  139311. private _camerasToBeAttached;
  139312. private _ratio;
  139313. private _bloomEnabled;
  139314. private _depthOfFieldEnabled;
  139315. private _vlsEnabled;
  139316. private _lensFlareEnabled;
  139317. private _hdrEnabled;
  139318. private _motionBlurEnabled;
  139319. private _fxaaEnabled;
  139320. private _screenSpaceReflectionsEnabled;
  139321. private _motionBlurSamples;
  139322. private _volumetricLightStepsCount;
  139323. private _samples;
  139324. /**
  139325. * @ignore
  139326. * Specifies if the bloom pipeline is enabled
  139327. */
  139328. get BloomEnabled(): boolean;
  139329. set BloomEnabled(enabled: boolean);
  139330. /**
  139331. * @ignore
  139332. * Specifies if the depth of field pipeline is enabed
  139333. */
  139334. get DepthOfFieldEnabled(): boolean;
  139335. set DepthOfFieldEnabled(enabled: boolean);
  139336. /**
  139337. * @ignore
  139338. * Specifies if the lens flare pipeline is enabed
  139339. */
  139340. get LensFlareEnabled(): boolean;
  139341. set LensFlareEnabled(enabled: boolean);
  139342. /**
  139343. * @ignore
  139344. * Specifies if the HDR pipeline is enabled
  139345. */
  139346. get HDREnabled(): boolean;
  139347. set HDREnabled(enabled: boolean);
  139348. /**
  139349. * @ignore
  139350. * Specifies if the volumetric lights scattering effect is enabled
  139351. */
  139352. get VLSEnabled(): boolean;
  139353. set VLSEnabled(enabled: boolean);
  139354. /**
  139355. * @ignore
  139356. * Specifies if the motion blur effect is enabled
  139357. */
  139358. get MotionBlurEnabled(): boolean;
  139359. set MotionBlurEnabled(enabled: boolean);
  139360. /**
  139361. * Specifies if anti-aliasing is enabled
  139362. */
  139363. get fxaaEnabled(): boolean;
  139364. set fxaaEnabled(enabled: boolean);
  139365. /**
  139366. * Specifies if screen space reflections are enabled.
  139367. */
  139368. get screenSpaceReflectionsEnabled(): boolean;
  139369. set screenSpaceReflectionsEnabled(enabled: boolean);
  139370. /**
  139371. * Specifies the number of steps used to calculate the volumetric lights
  139372. * Typically in interval [50, 200]
  139373. */
  139374. get volumetricLightStepsCount(): number;
  139375. set volumetricLightStepsCount(count: number);
  139376. /**
  139377. * Specifies the number of samples used for the motion blur effect
  139378. * Typically in interval [16, 64]
  139379. */
  139380. get motionBlurSamples(): number;
  139381. set motionBlurSamples(samples: number);
  139382. /**
  139383. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139384. */
  139385. get samples(): number;
  139386. set samples(sampleCount: number);
  139387. /**
  139388. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139389. * @constructor
  139390. * @param name The rendering pipeline name
  139391. * @param scene The scene linked to this pipeline
  139392. * @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)
  139393. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139394. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139395. */
  139396. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139397. private _buildPipeline;
  139398. private _createDownSampleX4PostProcess;
  139399. private _createBrightPassPostProcess;
  139400. private _createBlurPostProcesses;
  139401. private _createTextureAdderPostProcess;
  139402. private _createVolumetricLightPostProcess;
  139403. private _createLuminancePostProcesses;
  139404. private _createHdrPostProcess;
  139405. private _createLensFlarePostProcess;
  139406. private _createDepthOfFieldPostProcess;
  139407. private _createMotionBlurPostProcess;
  139408. private _getDepthTexture;
  139409. private _disposePostProcesses;
  139410. /**
  139411. * Dispose of the pipeline and stop all post processes
  139412. */
  139413. dispose(): void;
  139414. /**
  139415. * Serialize the rendering pipeline (Used when exporting)
  139416. * @returns the serialized object
  139417. */
  139418. serialize(): any;
  139419. /**
  139420. * Parse the serialized pipeline
  139421. * @param source Source pipeline.
  139422. * @param scene The scene to load the pipeline to.
  139423. * @param rootUrl The URL of the serialized pipeline.
  139424. * @returns An instantiated pipeline from the serialized object.
  139425. */
  139426. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139427. /**
  139428. * Luminance steps
  139429. */
  139430. static LuminanceSteps: number;
  139431. }
  139432. }
  139433. declare module BABYLON {
  139434. /** @hidden */
  139435. export var tonemapPixelShader: {
  139436. name: string;
  139437. shader: string;
  139438. };
  139439. }
  139440. declare module BABYLON {
  139441. /** Defines operator used for tonemapping */
  139442. export enum TonemappingOperator {
  139443. /** Hable */
  139444. Hable = 0,
  139445. /** Reinhard */
  139446. Reinhard = 1,
  139447. /** HejiDawson */
  139448. HejiDawson = 2,
  139449. /** Photographic */
  139450. Photographic = 3
  139451. }
  139452. /**
  139453. * Defines a post process to apply tone mapping
  139454. */
  139455. export class TonemapPostProcess extends PostProcess {
  139456. private _operator;
  139457. /** Defines the required exposure adjustement */
  139458. exposureAdjustment: number;
  139459. /**
  139460. * Creates a new TonemapPostProcess
  139461. * @param name defines the name of the postprocess
  139462. * @param _operator defines the operator to use
  139463. * @param exposureAdjustment defines the required exposure adjustement
  139464. * @param camera defines the camera to use (can be null)
  139465. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139466. * @param engine defines the hosting engine (can be ignore if camera is set)
  139467. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139468. */
  139469. constructor(name: string, _operator: TonemappingOperator,
  139470. /** Defines the required exposure adjustement */
  139471. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139472. }
  139473. }
  139474. declare module BABYLON {
  139475. /** @hidden */
  139476. export var volumetricLightScatteringPixelShader: {
  139477. name: string;
  139478. shader: string;
  139479. };
  139480. }
  139481. declare module BABYLON {
  139482. /** @hidden */
  139483. export var volumetricLightScatteringPassVertexShader: {
  139484. name: string;
  139485. shader: string;
  139486. };
  139487. }
  139488. declare module BABYLON {
  139489. /** @hidden */
  139490. export var volumetricLightScatteringPassPixelShader: {
  139491. name: string;
  139492. shader: string;
  139493. };
  139494. }
  139495. declare module BABYLON {
  139496. /**
  139497. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139498. */
  139499. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139500. private _volumetricLightScatteringPass;
  139501. private _volumetricLightScatteringRTT;
  139502. private _viewPort;
  139503. private _screenCoordinates;
  139504. private _cachedDefines;
  139505. /**
  139506. * If not undefined, the mesh position is computed from the attached node position
  139507. */
  139508. attachedNode: {
  139509. position: Vector3;
  139510. };
  139511. /**
  139512. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139513. */
  139514. customMeshPosition: Vector3;
  139515. /**
  139516. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139517. */
  139518. useCustomMeshPosition: boolean;
  139519. /**
  139520. * If the post-process should inverse the light scattering direction
  139521. */
  139522. invert: boolean;
  139523. /**
  139524. * The internal mesh used by the post-process
  139525. */
  139526. mesh: Mesh;
  139527. /**
  139528. * @hidden
  139529. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139530. */
  139531. get useDiffuseColor(): boolean;
  139532. set useDiffuseColor(useDiffuseColor: boolean);
  139533. /**
  139534. * Array containing the excluded meshes not rendered in the internal pass
  139535. */
  139536. excludedMeshes: AbstractMesh[];
  139537. /**
  139538. * Controls the overall intensity of the post-process
  139539. */
  139540. exposure: number;
  139541. /**
  139542. * Dissipates each sample's contribution in range [0, 1]
  139543. */
  139544. decay: number;
  139545. /**
  139546. * Controls the overall intensity of each sample
  139547. */
  139548. weight: number;
  139549. /**
  139550. * Controls the density of each sample
  139551. */
  139552. density: number;
  139553. /**
  139554. * @constructor
  139555. * @param name The post-process name
  139556. * @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)
  139557. * @param camera The camera that the post-process will be attached to
  139558. * @param mesh The mesh used to create the light scattering
  139559. * @param samples The post-process quality, default 100
  139560. * @param samplingModeThe post-process filtering mode
  139561. * @param engine The babylon engine
  139562. * @param reusable If the post-process is reusable
  139563. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139564. */
  139565. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139566. /**
  139567. * Returns the string "VolumetricLightScatteringPostProcess"
  139568. * @returns "VolumetricLightScatteringPostProcess"
  139569. */
  139570. getClassName(): string;
  139571. private _isReady;
  139572. /**
  139573. * Sets the new light position for light scattering effect
  139574. * @param position The new custom light position
  139575. */
  139576. setCustomMeshPosition(position: Vector3): void;
  139577. /**
  139578. * Returns the light position for light scattering effect
  139579. * @return Vector3 The custom light position
  139580. */
  139581. getCustomMeshPosition(): Vector3;
  139582. /**
  139583. * Disposes the internal assets and detaches the post-process from the camera
  139584. */
  139585. dispose(camera: Camera): void;
  139586. /**
  139587. * Returns the render target texture used by the post-process
  139588. * @return the render target texture used by the post-process
  139589. */
  139590. getPass(): RenderTargetTexture;
  139591. private _meshExcluded;
  139592. private _createPass;
  139593. private _updateMeshScreenCoordinates;
  139594. /**
  139595. * Creates a default mesh for the Volumeric Light Scattering post-process
  139596. * @param name The mesh name
  139597. * @param scene The scene where to create the mesh
  139598. * @return the default mesh
  139599. */
  139600. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139601. }
  139602. }
  139603. declare module BABYLON {
  139604. interface Scene {
  139605. /** @hidden (Backing field) */
  139606. _boundingBoxRenderer: BoundingBoxRenderer;
  139607. /** @hidden (Backing field) */
  139608. _forceShowBoundingBoxes: boolean;
  139609. /**
  139610. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139611. */
  139612. forceShowBoundingBoxes: boolean;
  139613. /**
  139614. * Gets the bounding box renderer associated with the scene
  139615. * @returns a BoundingBoxRenderer
  139616. */
  139617. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139618. }
  139619. interface AbstractMesh {
  139620. /** @hidden (Backing field) */
  139621. _showBoundingBox: boolean;
  139622. /**
  139623. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139624. */
  139625. showBoundingBox: boolean;
  139626. }
  139627. /**
  139628. * Component responsible of rendering the bounding box of the meshes in a scene.
  139629. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139630. */
  139631. export class BoundingBoxRenderer implements ISceneComponent {
  139632. /**
  139633. * The component name helpfull to identify the component in the list of scene components.
  139634. */
  139635. readonly name: string;
  139636. /**
  139637. * The scene the component belongs to.
  139638. */
  139639. scene: Scene;
  139640. /**
  139641. * Color of the bounding box lines placed in front of an object
  139642. */
  139643. frontColor: Color3;
  139644. /**
  139645. * Color of the bounding box lines placed behind an object
  139646. */
  139647. backColor: Color3;
  139648. /**
  139649. * Defines if the renderer should show the back lines or not
  139650. */
  139651. showBackLines: boolean;
  139652. /**
  139653. * @hidden
  139654. */
  139655. renderList: SmartArray<BoundingBox>;
  139656. private _colorShader;
  139657. private _vertexBuffers;
  139658. private _indexBuffer;
  139659. private _fillIndexBuffer;
  139660. private _fillIndexData;
  139661. /**
  139662. * Instantiates a new bounding box renderer in a scene.
  139663. * @param scene the scene the renderer renders in
  139664. */
  139665. constructor(scene: Scene);
  139666. /**
  139667. * Registers the component in a given scene
  139668. */
  139669. register(): void;
  139670. private _evaluateSubMesh;
  139671. private _activeMesh;
  139672. private _prepareRessources;
  139673. private _createIndexBuffer;
  139674. /**
  139675. * Rebuilds the elements related to this component in case of
  139676. * context lost for instance.
  139677. */
  139678. rebuild(): void;
  139679. /**
  139680. * @hidden
  139681. */
  139682. reset(): void;
  139683. /**
  139684. * Render the bounding boxes of a specific rendering group
  139685. * @param renderingGroupId defines the rendering group to render
  139686. */
  139687. render(renderingGroupId: number): void;
  139688. /**
  139689. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139690. * @param mesh Define the mesh to render the occlusion bounding box for
  139691. */
  139692. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139693. /**
  139694. * Dispose and release the resources attached to this renderer.
  139695. */
  139696. dispose(): void;
  139697. }
  139698. }
  139699. declare module BABYLON {
  139700. interface Scene {
  139701. /** @hidden (Backing field) */
  139702. _depthRenderer: {
  139703. [id: string]: DepthRenderer;
  139704. };
  139705. /**
  139706. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139707. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139708. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139709. * @returns the created depth renderer
  139710. */
  139711. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139712. /**
  139713. * Disables a depth renderer for a given camera
  139714. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139715. */
  139716. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139717. }
  139718. /**
  139719. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139720. * in several rendering techniques.
  139721. */
  139722. export class DepthRendererSceneComponent implements ISceneComponent {
  139723. /**
  139724. * The component name helpfull to identify the component in the list of scene components.
  139725. */
  139726. readonly name: string;
  139727. /**
  139728. * The scene the component belongs to.
  139729. */
  139730. scene: Scene;
  139731. /**
  139732. * Creates a new instance of the component for the given scene
  139733. * @param scene Defines the scene to register the component in
  139734. */
  139735. constructor(scene: Scene);
  139736. /**
  139737. * Registers the component in a given scene
  139738. */
  139739. register(): void;
  139740. /**
  139741. * Rebuilds the elements related to this component in case of
  139742. * context lost for instance.
  139743. */
  139744. rebuild(): void;
  139745. /**
  139746. * Disposes the component and the associated ressources
  139747. */
  139748. dispose(): void;
  139749. private _gatherRenderTargets;
  139750. private _gatherActiveCameraRenderTargets;
  139751. }
  139752. }
  139753. declare module BABYLON {
  139754. /** @hidden */
  139755. export var outlinePixelShader: {
  139756. name: string;
  139757. shader: string;
  139758. };
  139759. }
  139760. declare module BABYLON {
  139761. /** @hidden */
  139762. export var outlineVertexShader: {
  139763. name: string;
  139764. shader: string;
  139765. };
  139766. }
  139767. declare module BABYLON {
  139768. interface Scene {
  139769. /** @hidden */
  139770. _outlineRenderer: OutlineRenderer;
  139771. /**
  139772. * Gets the outline renderer associated with the scene
  139773. * @returns a OutlineRenderer
  139774. */
  139775. getOutlineRenderer(): OutlineRenderer;
  139776. }
  139777. interface AbstractMesh {
  139778. /** @hidden (Backing field) */
  139779. _renderOutline: boolean;
  139780. /**
  139781. * Gets or sets a boolean indicating if the outline must be rendered as well
  139782. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139783. */
  139784. renderOutline: boolean;
  139785. /** @hidden (Backing field) */
  139786. _renderOverlay: boolean;
  139787. /**
  139788. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139789. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139790. */
  139791. renderOverlay: boolean;
  139792. }
  139793. /**
  139794. * This class is responsible to draw bothe outline/overlay of meshes.
  139795. * It should not be used directly but through the available method on mesh.
  139796. */
  139797. export class OutlineRenderer implements ISceneComponent {
  139798. /**
  139799. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139800. */
  139801. private static _StencilReference;
  139802. /**
  139803. * The name of the component. Each component must have a unique name.
  139804. */
  139805. name: string;
  139806. /**
  139807. * The scene the component belongs to.
  139808. */
  139809. scene: Scene;
  139810. /**
  139811. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139812. */
  139813. zOffset: number;
  139814. private _engine;
  139815. private _effect;
  139816. private _cachedDefines;
  139817. private _savedDepthWrite;
  139818. /**
  139819. * Instantiates a new outline renderer. (There could be only one per scene).
  139820. * @param scene Defines the scene it belongs to
  139821. */
  139822. constructor(scene: Scene);
  139823. /**
  139824. * Register the component to one instance of a scene.
  139825. */
  139826. register(): void;
  139827. /**
  139828. * Rebuilds the elements related to this component in case of
  139829. * context lost for instance.
  139830. */
  139831. rebuild(): void;
  139832. /**
  139833. * Disposes the component and the associated ressources.
  139834. */
  139835. dispose(): void;
  139836. /**
  139837. * Renders the outline in the canvas.
  139838. * @param subMesh Defines the sumesh to render
  139839. * @param batch Defines the batch of meshes in case of instances
  139840. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139841. */
  139842. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139843. /**
  139844. * Returns whether or not the outline renderer is ready for a given submesh.
  139845. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139846. * @param subMesh Defines the submesh to check readyness for
  139847. * @param useInstances Defines wheter wee are trying to render instances or not
  139848. * @returns true if ready otherwise false
  139849. */
  139850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139851. private _beforeRenderingMesh;
  139852. private _afterRenderingMesh;
  139853. }
  139854. }
  139855. declare module BABYLON {
  139856. /**
  139857. * Defines the basic options interface of a Sprite Frame Source Size.
  139858. */
  139859. export interface ISpriteJSONSpriteSourceSize {
  139860. /**
  139861. * number of the original width of the Frame
  139862. */
  139863. w: number;
  139864. /**
  139865. * number of the original height of the Frame
  139866. */
  139867. h: number;
  139868. }
  139869. /**
  139870. * Defines the basic options interface of a Sprite Frame Data.
  139871. */
  139872. export interface ISpriteJSONSpriteFrameData {
  139873. /**
  139874. * number of the x offset of the Frame
  139875. */
  139876. x: number;
  139877. /**
  139878. * number of the y offset of the Frame
  139879. */
  139880. y: number;
  139881. /**
  139882. * number of the width of the Frame
  139883. */
  139884. w: number;
  139885. /**
  139886. * number of the height of the Frame
  139887. */
  139888. h: number;
  139889. }
  139890. /**
  139891. * Defines the basic options interface of a JSON Sprite.
  139892. */
  139893. export interface ISpriteJSONSprite {
  139894. /**
  139895. * string name of the Frame
  139896. */
  139897. filename: string;
  139898. /**
  139899. * ISpriteJSONSpriteFrame basic object of the frame data
  139900. */
  139901. frame: ISpriteJSONSpriteFrameData;
  139902. /**
  139903. * boolean to flag is the frame was rotated.
  139904. */
  139905. rotated: boolean;
  139906. /**
  139907. * boolean to flag is the frame was trimmed.
  139908. */
  139909. trimmed: boolean;
  139910. /**
  139911. * ISpriteJSONSpriteFrame basic object of the source data
  139912. */
  139913. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139914. /**
  139915. * ISpriteJSONSpriteFrame basic object of the source data
  139916. */
  139917. sourceSize: ISpriteJSONSpriteSourceSize;
  139918. }
  139919. /**
  139920. * Defines the basic options interface of a JSON atlas.
  139921. */
  139922. export interface ISpriteJSONAtlas {
  139923. /**
  139924. * Array of objects that contain the frame data.
  139925. */
  139926. frames: Array<ISpriteJSONSprite>;
  139927. /**
  139928. * object basic object containing the sprite meta data.
  139929. */
  139930. meta?: object;
  139931. }
  139932. }
  139933. declare module BABYLON {
  139934. /** @hidden */
  139935. export var spriteMapPixelShader: {
  139936. name: string;
  139937. shader: string;
  139938. };
  139939. }
  139940. declare module BABYLON {
  139941. /** @hidden */
  139942. export var spriteMapVertexShader: {
  139943. name: string;
  139944. shader: string;
  139945. };
  139946. }
  139947. declare module BABYLON {
  139948. /**
  139949. * Defines the basic options interface of a SpriteMap
  139950. */
  139951. export interface ISpriteMapOptions {
  139952. /**
  139953. * Vector2 of the number of cells in the grid.
  139954. */
  139955. stageSize?: Vector2;
  139956. /**
  139957. * Vector2 of the size of the output plane in World Units.
  139958. */
  139959. outputSize?: Vector2;
  139960. /**
  139961. * Vector3 of the position of the output plane in World Units.
  139962. */
  139963. outputPosition?: Vector3;
  139964. /**
  139965. * Vector3 of the rotation of the output plane.
  139966. */
  139967. outputRotation?: Vector3;
  139968. /**
  139969. * number of layers that the system will reserve in resources.
  139970. */
  139971. layerCount?: number;
  139972. /**
  139973. * number of max animation frames a single cell will reserve in resources.
  139974. */
  139975. maxAnimationFrames?: number;
  139976. /**
  139977. * number cell index of the base tile when the system compiles.
  139978. */
  139979. baseTile?: number;
  139980. /**
  139981. * boolean flip the sprite after its been repositioned by the framing data.
  139982. */
  139983. flipU?: boolean;
  139984. /**
  139985. * Vector3 scalar of the global RGB values of the SpriteMap.
  139986. */
  139987. colorMultiply?: Vector3;
  139988. }
  139989. /**
  139990. * Defines the IDisposable interface in order to be cleanable from resources.
  139991. */
  139992. export interface ISpriteMap extends IDisposable {
  139993. /**
  139994. * String name of the SpriteMap.
  139995. */
  139996. name: string;
  139997. /**
  139998. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139999. */
  140000. atlasJSON: ISpriteJSONAtlas;
  140001. /**
  140002. * Texture of the SpriteMap.
  140003. */
  140004. spriteSheet: Texture;
  140005. /**
  140006. * The parameters to initialize the SpriteMap with.
  140007. */
  140008. options: ISpriteMapOptions;
  140009. }
  140010. /**
  140011. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140012. */
  140013. export class SpriteMap implements ISpriteMap {
  140014. /** The Name of the spriteMap */
  140015. name: string;
  140016. /** The JSON file with the frame and meta data */
  140017. atlasJSON: ISpriteJSONAtlas;
  140018. /** The systems Sprite Sheet Texture */
  140019. spriteSheet: Texture;
  140020. /** Arguments passed with the Constructor */
  140021. options: ISpriteMapOptions;
  140022. /** Public Sprite Storage array, parsed from atlasJSON */
  140023. sprites: Array<ISpriteJSONSprite>;
  140024. /** Returns the Number of Sprites in the System */
  140025. get spriteCount(): number;
  140026. /** Returns the Position of Output Plane*/
  140027. get position(): Vector3;
  140028. /** Returns the Position of Output Plane*/
  140029. set position(v: Vector3);
  140030. /** Returns the Rotation of Output Plane*/
  140031. get rotation(): Vector3;
  140032. /** Returns the Rotation of Output Plane*/
  140033. set rotation(v: Vector3);
  140034. /** Sets the AnimationMap*/
  140035. get animationMap(): RawTexture;
  140036. /** Sets the AnimationMap*/
  140037. set animationMap(v: RawTexture);
  140038. /** Scene that the SpriteMap was created in */
  140039. private _scene;
  140040. /** Texture Buffer of Float32 that holds tile frame data*/
  140041. private _frameMap;
  140042. /** Texture Buffers of Float32 that holds tileMap data*/
  140043. private _tileMaps;
  140044. /** Texture Buffer of Float32 that holds Animation Data*/
  140045. private _animationMap;
  140046. /** Custom ShaderMaterial Central to the System*/
  140047. private _material;
  140048. /** Custom ShaderMaterial Central to the System*/
  140049. private _output;
  140050. /** Systems Time Ticker*/
  140051. private _time;
  140052. /**
  140053. * Creates a new SpriteMap
  140054. * @param name defines the SpriteMaps Name
  140055. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140056. * @param spriteSheet is the Texture that the Sprites are on.
  140057. * @param options a basic deployment configuration
  140058. * @param scene The Scene that the map is deployed on
  140059. */
  140060. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140061. /**
  140062. * Returns tileID location
  140063. * @returns Vector2 the cell position ID
  140064. */
  140065. getTileID(): Vector2;
  140066. /**
  140067. * Gets the UV location of the mouse over the SpriteMap.
  140068. * @returns Vector2 the UV position of the mouse interaction
  140069. */
  140070. getMousePosition(): Vector2;
  140071. /**
  140072. * Creates the "frame" texture Buffer
  140073. * -------------------------------------
  140074. * Structure of frames
  140075. * "filename": "Falling-Water-2.png",
  140076. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140077. * "rotated": true,
  140078. * "trimmed": true,
  140079. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140080. * "sourceSize": {"w":32,"h":32}
  140081. * @returns RawTexture of the frameMap
  140082. */
  140083. private _createFrameBuffer;
  140084. /**
  140085. * Creates the tileMap texture Buffer
  140086. * @param buffer normally and array of numbers, or a false to generate from scratch
  140087. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140088. * @returns RawTexture of the tileMap
  140089. */
  140090. private _createTileBuffer;
  140091. /**
  140092. * Modifies the data of the tileMaps
  140093. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140094. * @param pos is the iVector2 Coordinates of the Tile
  140095. * @param tile The SpriteIndex of the new Tile
  140096. */
  140097. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140098. /**
  140099. * Creates the animationMap texture Buffer
  140100. * @param buffer normally and array of numbers, or a false to generate from scratch
  140101. * @returns RawTexture of the animationMap
  140102. */
  140103. private _createTileAnimationBuffer;
  140104. /**
  140105. * Modifies the data of the animationMap
  140106. * @param cellID is the Index of the Sprite
  140107. * @param _frame is the target Animation frame
  140108. * @param toCell is the Target Index of the next frame of the animation
  140109. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140110. * @param speed is a global scalar of the time variable on the map.
  140111. */
  140112. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140113. /**
  140114. * Exports the .tilemaps file
  140115. */
  140116. saveTileMaps(): void;
  140117. /**
  140118. * Imports the .tilemaps file
  140119. * @param url of the .tilemaps file
  140120. */
  140121. loadTileMaps(url: string): void;
  140122. /**
  140123. * Release associated resources
  140124. */
  140125. dispose(): void;
  140126. }
  140127. }
  140128. declare module BABYLON {
  140129. /**
  140130. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140131. * @see http://doc.babylonjs.com/babylon101/sprites
  140132. */
  140133. export class SpritePackedManager extends SpriteManager {
  140134. /** defines the packed manager's name */
  140135. name: string;
  140136. /**
  140137. * Creates a new sprite manager from a packed sprite sheet
  140138. * @param name defines the manager's name
  140139. * @param imgUrl defines the sprite sheet url
  140140. * @param capacity defines the maximum allowed number of sprites
  140141. * @param scene defines the hosting scene
  140142. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140143. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140144. * @param samplingMode defines the smapling mode to use with spritesheet
  140145. * @param fromPacked set to true; do not alter
  140146. */
  140147. constructor(
  140148. /** defines the packed manager's name */
  140149. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140150. }
  140151. }
  140152. declare module BABYLON {
  140153. /**
  140154. * Defines the list of states available for a task inside a AssetsManager
  140155. */
  140156. export enum AssetTaskState {
  140157. /**
  140158. * Initialization
  140159. */
  140160. INIT = 0,
  140161. /**
  140162. * Running
  140163. */
  140164. RUNNING = 1,
  140165. /**
  140166. * Done
  140167. */
  140168. DONE = 2,
  140169. /**
  140170. * Error
  140171. */
  140172. ERROR = 3
  140173. }
  140174. /**
  140175. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140176. */
  140177. export abstract class AbstractAssetTask {
  140178. /**
  140179. * Task name
  140180. */ name: string;
  140181. /**
  140182. * Callback called when the task is successful
  140183. */
  140184. onSuccess: (task: any) => void;
  140185. /**
  140186. * Callback called when the task is not successful
  140187. */
  140188. onError: (task: any, message?: string, exception?: any) => void;
  140189. /**
  140190. * Creates a new AssetsManager
  140191. * @param name defines the name of the task
  140192. */
  140193. constructor(
  140194. /**
  140195. * Task name
  140196. */ name: string);
  140197. private _isCompleted;
  140198. private _taskState;
  140199. private _errorObject;
  140200. /**
  140201. * Get if the task is completed
  140202. */
  140203. get isCompleted(): boolean;
  140204. /**
  140205. * Gets the current state of the task
  140206. */
  140207. get taskState(): AssetTaskState;
  140208. /**
  140209. * Gets the current error object (if task is in error)
  140210. */
  140211. get errorObject(): {
  140212. message?: string;
  140213. exception?: any;
  140214. };
  140215. /**
  140216. * Internal only
  140217. * @hidden
  140218. */
  140219. _setErrorObject(message?: string, exception?: any): void;
  140220. /**
  140221. * Execute the current task
  140222. * @param scene defines the scene where you want your assets to be loaded
  140223. * @param onSuccess is a callback called when the task is successfully executed
  140224. * @param onError is a callback called if an error occurs
  140225. */
  140226. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140227. /**
  140228. * Execute the current task
  140229. * @param scene defines the scene where you want your assets to be loaded
  140230. * @param onSuccess is a callback called when the task is successfully executed
  140231. * @param onError is a callback called if an error occurs
  140232. */
  140233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140234. /**
  140235. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140236. * This can be used with failed tasks that have the reason for failure fixed.
  140237. */
  140238. reset(): void;
  140239. private onErrorCallback;
  140240. private onDoneCallback;
  140241. }
  140242. /**
  140243. * Define the interface used by progress events raised during assets loading
  140244. */
  140245. export interface IAssetsProgressEvent {
  140246. /**
  140247. * Defines the number of remaining tasks to process
  140248. */
  140249. remainingCount: number;
  140250. /**
  140251. * Defines the total number of tasks
  140252. */
  140253. totalCount: number;
  140254. /**
  140255. * Defines the task that was just processed
  140256. */
  140257. task: AbstractAssetTask;
  140258. }
  140259. /**
  140260. * Class used to share progress information about assets loading
  140261. */
  140262. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140263. /**
  140264. * Defines the number of remaining tasks to process
  140265. */
  140266. remainingCount: number;
  140267. /**
  140268. * Defines the total number of tasks
  140269. */
  140270. totalCount: number;
  140271. /**
  140272. * Defines the task that was just processed
  140273. */
  140274. task: AbstractAssetTask;
  140275. /**
  140276. * Creates a AssetsProgressEvent
  140277. * @param remainingCount defines the number of remaining tasks to process
  140278. * @param totalCount defines the total number of tasks
  140279. * @param task defines the task that was just processed
  140280. */
  140281. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140282. }
  140283. /**
  140284. * Define a task used by AssetsManager to load meshes
  140285. */
  140286. export class MeshAssetTask extends AbstractAssetTask {
  140287. /**
  140288. * Defines the name of the task
  140289. */
  140290. name: string;
  140291. /**
  140292. * Defines the list of mesh's names you want to load
  140293. */
  140294. meshesNames: any;
  140295. /**
  140296. * Defines the root url to use as a base to load your meshes and associated resources
  140297. */
  140298. rootUrl: string;
  140299. /**
  140300. * Defines the filename of the scene to load from
  140301. */
  140302. sceneFilename: string;
  140303. /**
  140304. * Gets the list of loaded meshes
  140305. */
  140306. loadedMeshes: Array<AbstractMesh>;
  140307. /**
  140308. * Gets the list of loaded particle systems
  140309. */
  140310. loadedParticleSystems: Array<IParticleSystem>;
  140311. /**
  140312. * Gets the list of loaded skeletons
  140313. */
  140314. loadedSkeletons: Array<Skeleton>;
  140315. /**
  140316. * Gets the list of loaded animation groups
  140317. */
  140318. loadedAnimationGroups: Array<AnimationGroup>;
  140319. /**
  140320. * Callback called when the task is successful
  140321. */
  140322. onSuccess: (task: MeshAssetTask) => void;
  140323. /**
  140324. * Callback called when the task is successful
  140325. */
  140326. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140327. /**
  140328. * Creates a new MeshAssetTask
  140329. * @param name defines the name of the task
  140330. * @param meshesNames defines the list of mesh's names you want to load
  140331. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140332. * @param sceneFilename defines the filename of the scene to load from
  140333. */
  140334. constructor(
  140335. /**
  140336. * Defines the name of the task
  140337. */
  140338. name: string,
  140339. /**
  140340. * Defines the list of mesh's names you want to load
  140341. */
  140342. meshesNames: any,
  140343. /**
  140344. * Defines the root url to use as a base to load your meshes and associated resources
  140345. */
  140346. rootUrl: string,
  140347. /**
  140348. * Defines the filename of the scene to load from
  140349. */
  140350. sceneFilename: string);
  140351. /**
  140352. * Execute the current task
  140353. * @param scene defines the scene where you want your assets to be loaded
  140354. * @param onSuccess is a callback called when the task is successfully executed
  140355. * @param onError is a callback called if an error occurs
  140356. */
  140357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140358. }
  140359. /**
  140360. * Define a task used by AssetsManager to load text content
  140361. */
  140362. export class TextFileAssetTask extends AbstractAssetTask {
  140363. /**
  140364. * Defines the name of the task
  140365. */
  140366. name: string;
  140367. /**
  140368. * Defines the location of the file to load
  140369. */
  140370. url: string;
  140371. /**
  140372. * Gets the loaded text string
  140373. */
  140374. text: string;
  140375. /**
  140376. * Callback called when the task is successful
  140377. */
  140378. onSuccess: (task: TextFileAssetTask) => void;
  140379. /**
  140380. * Callback called when the task is successful
  140381. */
  140382. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140383. /**
  140384. * Creates a new TextFileAssetTask object
  140385. * @param name defines the name of the task
  140386. * @param url defines the location of the file to load
  140387. */
  140388. constructor(
  140389. /**
  140390. * Defines the name of the task
  140391. */
  140392. name: string,
  140393. /**
  140394. * Defines the location of the file to load
  140395. */
  140396. url: string);
  140397. /**
  140398. * Execute the current task
  140399. * @param scene defines the scene where you want your assets to be loaded
  140400. * @param onSuccess is a callback called when the task is successfully executed
  140401. * @param onError is a callback called if an error occurs
  140402. */
  140403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140404. }
  140405. /**
  140406. * Define a task used by AssetsManager to load binary data
  140407. */
  140408. export class BinaryFileAssetTask extends AbstractAssetTask {
  140409. /**
  140410. * Defines the name of the task
  140411. */
  140412. name: string;
  140413. /**
  140414. * Defines the location of the file to load
  140415. */
  140416. url: string;
  140417. /**
  140418. * Gets the lodaded data (as an array buffer)
  140419. */
  140420. data: ArrayBuffer;
  140421. /**
  140422. * Callback called when the task is successful
  140423. */
  140424. onSuccess: (task: BinaryFileAssetTask) => void;
  140425. /**
  140426. * Callback called when the task is successful
  140427. */
  140428. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140429. /**
  140430. * Creates a new BinaryFileAssetTask object
  140431. * @param name defines the name of the new task
  140432. * @param url defines the location of the file to load
  140433. */
  140434. constructor(
  140435. /**
  140436. * Defines the name of the task
  140437. */
  140438. name: string,
  140439. /**
  140440. * Defines the location of the file to load
  140441. */
  140442. url: string);
  140443. /**
  140444. * Execute the current task
  140445. * @param scene defines the scene where you want your assets to be loaded
  140446. * @param onSuccess is a callback called when the task is successfully executed
  140447. * @param onError is a callback called if an error occurs
  140448. */
  140449. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140450. }
  140451. /**
  140452. * Define a task used by AssetsManager to load images
  140453. */
  140454. export class ImageAssetTask extends AbstractAssetTask {
  140455. /**
  140456. * Defines the name of the task
  140457. */
  140458. name: string;
  140459. /**
  140460. * Defines the location of the image to load
  140461. */
  140462. url: string;
  140463. /**
  140464. * Gets the loaded images
  140465. */
  140466. image: HTMLImageElement;
  140467. /**
  140468. * Callback called when the task is successful
  140469. */
  140470. onSuccess: (task: ImageAssetTask) => void;
  140471. /**
  140472. * Callback called when the task is successful
  140473. */
  140474. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140475. /**
  140476. * Creates a new ImageAssetTask
  140477. * @param name defines the name of the task
  140478. * @param url defines the location of the image to load
  140479. */
  140480. constructor(
  140481. /**
  140482. * Defines the name of the task
  140483. */
  140484. name: string,
  140485. /**
  140486. * Defines the location of the image to load
  140487. */
  140488. url: string);
  140489. /**
  140490. * Execute the current task
  140491. * @param scene defines the scene where you want your assets to be loaded
  140492. * @param onSuccess is a callback called when the task is successfully executed
  140493. * @param onError is a callback called if an error occurs
  140494. */
  140495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140496. }
  140497. /**
  140498. * Defines the interface used by texture loading tasks
  140499. */
  140500. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140501. /**
  140502. * Gets the loaded texture
  140503. */
  140504. texture: TEX;
  140505. }
  140506. /**
  140507. * Define a task used by AssetsManager to load 2D textures
  140508. */
  140509. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140510. /**
  140511. * Defines the name of the task
  140512. */
  140513. name: string;
  140514. /**
  140515. * Defines the location of the file to load
  140516. */
  140517. url: string;
  140518. /**
  140519. * Defines if mipmap should not be generated (default is false)
  140520. */
  140521. noMipmap?: boolean | undefined;
  140522. /**
  140523. * Defines if texture must be inverted on Y axis (default is false)
  140524. */
  140525. invertY?: boolean | undefined;
  140526. /**
  140527. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140528. */
  140529. samplingMode: number;
  140530. /**
  140531. * Gets the loaded texture
  140532. */
  140533. texture: Texture;
  140534. /**
  140535. * Callback called when the task is successful
  140536. */
  140537. onSuccess: (task: TextureAssetTask) => void;
  140538. /**
  140539. * Callback called when the task is successful
  140540. */
  140541. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140542. /**
  140543. * Creates a new TextureAssetTask object
  140544. * @param name defines the name of the task
  140545. * @param url defines the location of the file to load
  140546. * @param noMipmap defines if mipmap should not be generated (default is false)
  140547. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140548. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140549. */
  140550. constructor(
  140551. /**
  140552. * Defines the name of the task
  140553. */
  140554. name: string,
  140555. /**
  140556. * Defines the location of the file to load
  140557. */
  140558. url: string,
  140559. /**
  140560. * Defines if mipmap should not be generated (default is false)
  140561. */
  140562. noMipmap?: boolean | undefined,
  140563. /**
  140564. * Defines if texture must be inverted on Y axis (default is false)
  140565. */
  140566. invertY?: boolean | undefined,
  140567. /**
  140568. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140569. */
  140570. samplingMode?: number);
  140571. /**
  140572. * Execute the current task
  140573. * @param scene defines the scene where you want your assets to be loaded
  140574. * @param onSuccess is a callback called when the task is successfully executed
  140575. * @param onError is a callback called if an error occurs
  140576. */
  140577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140578. }
  140579. /**
  140580. * Define a task used by AssetsManager to load cube textures
  140581. */
  140582. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140583. /**
  140584. * Defines the name of the task
  140585. */
  140586. name: string;
  140587. /**
  140588. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140589. */
  140590. url: string;
  140591. /**
  140592. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140593. */
  140594. extensions?: string[] | undefined;
  140595. /**
  140596. * Defines if mipmaps should not be generated (default is false)
  140597. */
  140598. noMipmap?: boolean | undefined;
  140599. /**
  140600. * Defines the explicit list of files (undefined by default)
  140601. */
  140602. files?: string[] | undefined;
  140603. /**
  140604. * Gets the loaded texture
  140605. */
  140606. texture: CubeTexture;
  140607. /**
  140608. * Callback called when the task is successful
  140609. */
  140610. onSuccess: (task: CubeTextureAssetTask) => void;
  140611. /**
  140612. * Callback called when the task is successful
  140613. */
  140614. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140615. /**
  140616. * Creates a new CubeTextureAssetTask
  140617. * @param name defines the name of the task
  140618. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140619. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140620. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140621. * @param files defines the explicit list of files (undefined by default)
  140622. */
  140623. constructor(
  140624. /**
  140625. * Defines the name of the task
  140626. */
  140627. name: string,
  140628. /**
  140629. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140630. */
  140631. url: string,
  140632. /**
  140633. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140634. */
  140635. extensions?: string[] | undefined,
  140636. /**
  140637. * Defines if mipmaps should not be generated (default is false)
  140638. */
  140639. noMipmap?: boolean | undefined,
  140640. /**
  140641. * Defines the explicit list of files (undefined by default)
  140642. */
  140643. files?: string[] | undefined);
  140644. /**
  140645. * Execute the current task
  140646. * @param scene defines the scene where you want your assets to be loaded
  140647. * @param onSuccess is a callback called when the task is successfully executed
  140648. * @param onError is a callback called if an error occurs
  140649. */
  140650. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140651. }
  140652. /**
  140653. * Define a task used by AssetsManager to load HDR cube textures
  140654. */
  140655. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140656. /**
  140657. * Defines the name of the task
  140658. */
  140659. name: string;
  140660. /**
  140661. * Defines the location of the file to load
  140662. */
  140663. url: string;
  140664. /**
  140665. * Defines the desired size (the more it increases the longer the generation will be)
  140666. */
  140667. size: number;
  140668. /**
  140669. * Defines if mipmaps should not be generated (default is false)
  140670. */
  140671. noMipmap: boolean;
  140672. /**
  140673. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140674. */
  140675. generateHarmonics: boolean;
  140676. /**
  140677. * 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)
  140678. */
  140679. gammaSpace: boolean;
  140680. /**
  140681. * Internal Use Only
  140682. */
  140683. reserved: boolean;
  140684. /**
  140685. * Gets the loaded texture
  140686. */
  140687. texture: HDRCubeTexture;
  140688. /**
  140689. * Callback called when the task is successful
  140690. */
  140691. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140692. /**
  140693. * Callback called when the task is successful
  140694. */
  140695. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140696. /**
  140697. * Creates a new HDRCubeTextureAssetTask object
  140698. * @param name defines the name of the task
  140699. * @param url defines the location of the file to load
  140700. * @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.
  140701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140702. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140703. * @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)
  140704. * @param reserved Internal use only
  140705. */
  140706. constructor(
  140707. /**
  140708. * Defines the name of the task
  140709. */
  140710. name: string,
  140711. /**
  140712. * Defines the location of the file to load
  140713. */
  140714. url: string,
  140715. /**
  140716. * Defines the desired size (the more it increases the longer the generation will be)
  140717. */
  140718. size: number,
  140719. /**
  140720. * Defines if mipmaps should not be generated (default is false)
  140721. */
  140722. noMipmap?: boolean,
  140723. /**
  140724. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140725. */
  140726. generateHarmonics?: boolean,
  140727. /**
  140728. * 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)
  140729. */
  140730. gammaSpace?: boolean,
  140731. /**
  140732. * Internal Use Only
  140733. */
  140734. reserved?: boolean);
  140735. /**
  140736. * Execute the current task
  140737. * @param scene defines the scene where you want your assets to be loaded
  140738. * @param onSuccess is a callback called when the task is successfully executed
  140739. * @param onError is a callback called if an error occurs
  140740. */
  140741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140742. }
  140743. /**
  140744. * Define a task used by AssetsManager to load Equirectangular cube textures
  140745. */
  140746. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140747. /**
  140748. * Defines the name of the task
  140749. */
  140750. name: string;
  140751. /**
  140752. * Defines the location of the file to load
  140753. */
  140754. url: string;
  140755. /**
  140756. * Defines the desired size (the more it increases the longer the generation will be)
  140757. */
  140758. size: number;
  140759. /**
  140760. * Defines if mipmaps should not be generated (default is false)
  140761. */
  140762. noMipmap: boolean;
  140763. /**
  140764. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140765. * but the standard material would require them in Gamma space) (default is true)
  140766. */
  140767. gammaSpace: boolean;
  140768. /**
  140769. * Gets the loaded texture
  140770. */
  140771. texture: EquiRectangularCubeTexture;
  140772. /**
  140773. * Callback called when the task is successful
  140774. */
  140775. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140776. /**
  140777. * Callback called when the task is successful
  140778. */
  140779. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140780. /**
  140781. * Creates a new EquiRectangularCubeTextureAssetTask object
  140782. * @param name defines the name of the task
  140783. * @param url defines the location of the file to load
  140784. * @param size defines the desired size (the more it increases the longer the generation will be)
  140785. * If the size is omitted this implies you are using a preprocessed cubemap.
  140786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140787. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140788. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140789. * (default is true)
  140790. */
  140791. constructor(
  140792. /**
  140793. * Defines the name of the task
  140794. */
  140795. name: string,
  140796. /**
  140797. * Defines the location of the file to load
  140798. */
  140799. url: string,
  140800. /**
  140801. * Defines the desired size (the more it increases the longer the generation will be)
  140802. */
  140803. size: number,
  140804. /**
  140805. * Defines if mipmaps should not be generated (default is false)
  140806. */
  140807. noMipmap?: boolean,
  140808. /**
  140809. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140810. * but the standard material would require them in Gamma space) (default is true)
  140811. */
  140812. gammaSpace?: boolean);
  140813. /**
  140814. * Execute the current task
  140815. * @param scene defines the scene where you want your assets to be loaded
  140816. * @param onSuccess is a callback called when the task is successfully executed
  140817. * @param onError is a callback called if an error occurs
  140818. */
  140819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140820. }
  140821. /**
  140822. * This class can be used to easily import assets into a scene
  140823. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140824. */
  140825. export class AssetsManager {
  140826. private _scene;
  140827. private _isLoading;
  140828. protected _tasks: AbstractAssetTask[];
  140829. protected _waitingTasksCount: number;
  140830. protected _totalTasksCount: number;
  140831. /**
  140832. * Callback called when all tasks are processed
  140833. */
  140834. onFinish: (tasks: AbstractAssetTask[]) => void;
  140835. /**
  140836. * Callback called when a task is successful
  140837. */
  140838. onTaskSuccess: (task: AbstractAssetTask) => void;
  140839. /**
  140840. * Callback called when a task had an error
  140841. */
  140842. onTaskError: (task: AbstractAssetTask) => void;
  140843. /**
  140844. * Callback called when a task is done (whatever the result is)
  140845. */
  140846. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140847. /**
  140848. * Observable called when all tasks are processed
  140849. */
  140850. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140851. /**
  140852. * Observable called when a task had an error
  140853. */
  140854. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140855. /**
  140856. * Observable called when all tasks were executed
  140857. */
  140858. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140859. /**
  140860. * Observable called when a task is done (whatever the result is)
  140861. */
  140862. onProgressObservable: Observable<IAssetsProgressEvent>;
  140863. /**
  140864. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140866. */
  140867. useDefaultLoadingScreen: boolean;
  140868. /**
  140869. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140870. * when all assets have been downloaded.
  140871. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140872. */
  140873. autoHideLoadingUI: boolean;
  140874. /**
  140875. * Creates a new AssetsManager
  140876. * @param scene defines the scene to work on
  140877. */
  140878. constructor(scene: Scene);
  140879. /**
  140880. * Add a MeshAssetTask to the list of active tasks
  140881. * @param taskName defines the name of the new task
  140882. * @param meshesNames defines the name of meshes to load
  140883. * @param rootUrl defines the root url to use to locate files
  140884. * @param sceneFilename defines the filename of the scene file
  140885. * @returns a new MeshAssetTask object
  140886. */
  140887. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140888. /**
  140889. * Add a TextFileAssetTask to the list of active tasks
  140890. * @param taskName defines the name of the new task
  140891. * @param url defines the url of the file to load
  140892. * @returns a new TextFileAssetTask object
  140893. */
  140894. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140895. /**
  140896. * Add a BinaryFileAssetTask to the list of active tasks
  140897. * @param taskName defines the name of the new task
  140898. * @param url defines the url of the file to load
  140899. * @returns a new BinaryFileAssetTask object
  140900. */
  140901. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140902. /**
  140903. * Add a ImageAssetTask to the list of active tasks
  140904. * @param taskName defines the name of the new task
  140905. * @param url defines the url of the file to load
  140906. * @returns a new ImageAssetTask object
  140907. */
  140908. addImageTask(taskName: string, url: string): ImageAssetTask;
  140909. /**
  140910. * Add a TextureAssetTask to the list of active tasks
  140911. * @param taskName defines the name of the new task
  140912. * @param url defines the url of the file to load
  140913. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140914. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140915. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140916. * @returns a new TextureAssetTask object
  140917. */
  140918. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140919. /**
  140920. * Add a CubeTextureAssetTask to the list of active tasks
  140921. * @param taskName defines the name of the new task
  140922. * @param url defines the url of the file to load
  140923. * @param extensions defines the extension to use to load the cube map (can be null)
  140924. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140925. * @param files defines the list of files to load (can be null)
  140926. * @returns a new CubeTextureAssetTask object
  140927. */
  140928. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140929. /**
  140930. *
  140931. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140932. * @param taskName defines the name of the new task
  140933. * @param url defines the url of the file to load
  140934. * @param size defines the size you want for the cubemap (can be null)
  140935. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140936. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140937. * @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)
  140938. * @param reserved Internal use only
  140939. * @returns a new HDRCubeTextureAssetTask object
  140940. */
  140941. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140942. /**
  140943. *
  140944. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140945. * @param taskName defines the name of the new task
  140946. * @param url defines the url of the file to load
  140947. * @param size defines the size you want for the cubemap (can be null)
  140948. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140949. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140950. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140951. * @returns a new EquiRectangularCubeTextureAssetTask object
  140952. */
  140953. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140954. /**
  140955. * Remove a task from the assets manager.
  140956. * @param task the task to remove
  140957. */
  140958. removeTask(task: AbstractAssetTask): void;
  140959. private _decreaseWaitingTasksCount;
  140960. private _runTask;
  140961. /**
  140962. * Reset the AssetsManager and remove all tasks
  140963. * @return the current instance of the AssetsManager
  140964. */
  140965. reset(): AssetsManager;
  140966. /**
  140967. * Start the loading process
  140968. * @return the current instance of the AssetsManager
  140969. */
  140970. load(): AssetsManager;
  140971. /**
  140972. * Start the loading process as an async operation
  140973. * @return a promise returning the list of failed tasks
  140974. */
  140975. loadAsync(): Promise<void>;
  140976. }
  140977. }
  140978. declare module BABYLON {
  140979. /**
  140980. * Wrapper class for promise with external resolve and reject.
  140981. */
  140982. export class Deferred<T> {
  140983. /**
  140984. * The promise associated with this deferred object.
  140985. */
  140986. readonly promise: Promise<T>;
  140987. private _resolve;
  140988. private _reject;
  140989. /**
  140990. * The resolve method of the promise associated with this deferred object.
  140991. */
  140992. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140993. /**
  140994. * The reject method of the promise associated with this deferred object.
  140995. */
  140996. get reject(): (reason?: any) => void;
  140997. /**
  140998. * Constructor for this deferred object.
  140999. */
  141000. constructor();
  141001. }
  141002. }
  141003. declare module BABYLON {
  141004. /**
  141005. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141006. */
  141007. export class MeshExploder {
  141008. private _centerMesh;
  141009. private _meshes;
  141010. private _meshesOrigins;
  141011. private _toCenterVectors;
  141012. private _scaledDirection;
  141013. private _newPosition;
  141014. private _centerPosition;
  141015. /**
  141016. * Explodes meshes from a center mesh.
  141017. * @param meshes The meshes to explode.
  141018. * @param centerMesh The mesh to be center of explosion.
  141019. */
  141020. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141021. private _setCenterMesh;
  141022. /**
  141023. * Get class name
  141024. * @returns "MeshExploder"
  141025. */
  141026. getClassName(): string;
  141027. /**
  141028. * "Exploded meshes"
  141029. * @returns Array of meshes with the centerMesh at index 0.
  141030. */
  141031. getMeshes(): Array<Mesh>;
  141032. /**
  141033. * Explodes meshes giving a specific direction
  141034. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141035. */
  141036. explode(direction?: number): void;
  141037. }
  141038. }
  141039. declare module BABYLON {
  141040. /**
  141041. * Class used to help managing file picking and drag'n'drop
  141042. */
  141043. export class FilesInput {
  141044. /**
  141045. * List of files ready to be loaded
  141046. */
  141047. static get FilesToLoad(): {
  141048. [key: string]: File;
  141049. };
  141050. /**
  141051. * Callback called when a file is processed
  141052. */
  141053. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141054. private _engine;
  141055. private _currentScene;
  141056. private _sceneLoadedCallback;
  141057. private _progressCallback;
  141058. private _additionalRenderLoopLogicCallback;
  141059. private _textureLoadingCallback;
  141060. private _startingProcessingFilesCallback;
  141061. private _onReloadCallback;
  141062. private _errorCallback;
  141063. private _elementToMonitor;
  141064. private _sceneFileToLoad;
  141065. private _filesToLoad;
  141066. /**
  141067. * Creates a new FilesInput
  141068. * @param engine defines the rendering engine
  141069. * @param scene defines the hosting scene
  141070. * @param sceneLoadedCallback callback called when scene is loaded
  141071. * @param progressCallback callback called to track progress
  141072. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141073. * @param textureLoadingCallback callback called when a texture is loading
  141074. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141075. * @param onReloadCallback callback called when a reload is requested
  141076. * @param errorCallback callback call if an error occurs
  141077. */
  141078. 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);
  141079. private _dragEnterHandler;
  141080. private _dragOverHandler;
  141081. private _dropHandler;
  141082. /**
  141083. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141084. * @param elementToMonitor defines the DOM element to track
  141085. */
  141086. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141087. /**
  141088. * Release all associated resources
  141089. */
  141090. dispose(): void;
  141091. private renderFunction;
  141092. private drag;
  141093. private drop;
  141094. private _traverseFolder;
  141095. private _processFiles;
  141096. /**
  141097. * Load files from a drop event
  141098. * @param event defines the drop event to use as source
  141099. */
  141100. loadFiles(event: any): void;
  141101. private _processReload;
  141102. /**
  141103. * Reload the current scene from the loaded files
  141104. */
  141105. reload(): void;
  141106. }
  141107. }
  141108. declare module BABYLON {
  141109. /**
  141110. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141112. */
  141113. export class SceneOptimization {
  141114. /**
  141115. * Defines the priority of this optimization (0 by default which means first in the list)
  141116. */
  141117. priority: number;
  141118. /**
  141119. * Gets a string describing the action executed by the current optimization
  141120. * @returns description string
  141121. */
  141122. getDescription(): string;
  141123. /**
  141124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141125. * @param scene defines the current scene where to apply this optimization
  141126. * @param optimizer defines the current optimizer
  141127. * @returns true if everything that can be done was applied
  141128. */
  141129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141130. /**
  141131. * Creates the SceneOptimization object
  141132. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141133. * @param desc defines the description associated with the optimization
  141134. */
  141135. constructor(
  141136. /**
  141137. * Defines the priority of this optimization (0 by default which means first in the list)
  141138. */
  141139. priority?: number);
  141140. }
  141141. /**
  141142. * Defines an optimization used to reduce the size of render target textures
  141143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141144. */
  141145. export class TextureOptimization extends SceneOptimization {
  141146. /**
  141147. * Defines the priority of this optimization (0 by default which means first in the list)
  141148. */
  141149. priority: number;
  141150. /**
  141151. * 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
  141152. */
  141153. maximumSize: number;
  141154. /**
  141155. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141156. */
  141157. step: number;
  141158. /**
  141159. * Gets a string describing the action executed by the current optimization
  141160. * @returns description string
  141161. */
  141162. getDescription(): string;
  141163. /**
  141164. * Creates the TextureOptimization object
  141165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141166. * @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
  141167. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141168. */
  141169. constructor(
  141170. /**
  141171. * Defines the priority of this optimization (0 by default which means first in the list)
  141172. */
  141173. priority?: number,
  141174. /**
  141175. * 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
  141176. */
  141177. maximumSize?: number,
  141178. /**
  141179. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141180. */
  141181. step?: number);
  141182. /**
  141183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141184. * @param scene defines the current scene where to apply this optimization
  141185. * @param optimizer defines the current optimizer
  141186. * @returns true if everything that can be done was applied
  141187. */
  141188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141189. }
  141190. /**
  141191. * Defines an optimization used to increase or decrease the rendering resolution
  141192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141193. */
  141194. export class HardwareScalingOptimization extends SceneOptimization {
  141195. /**
  141196. * Defines the priority of this optimization (0 by default which means first in the list)
  141197. */
  141198. priority: number;
  141199. /**
  141200. * Defines the maximum scale to use (2 by default)
  141201. */
  141202. maximumScale: number;
  141203. /**
  141204. * Defines the step to use between two passes (0.5 by default)
  141205. */
  141206. step: number;
  141207. private _currentScale;
  141208. private _directionOffset;
  141209. /**
  141210. * Gets a string describing the action executed by the current optimization
  141211. * @return description string
  141212. */
  141213. getDescription(): string;
  141214. /**
  141215. * Creates the HardwareScalingOptimization object
  141216. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141217. * @param maximumScale defines the maximum scale to use (2 by default)
  141218. * @param step defines the step to use between two passes (0.5 by default)
  141219. */
  141220. constructor(
  141221. /**
  141222. * Defines the priority of this optimization (0 by default which means first in the list)
  141223. */
  141224. priority?: number,
  141225. /**
  141226. * Defines the maximum scale to use (2 by default)
  141227. */
  141228. maximumScale?: number,
  141229. /**
  141230. * Defines the step to use between two passes (0.5 by default)
  141231. */
  141232. step?: number);
  141233. /**
  141234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141235. * @param scene defines the current scene where to apply this optimization
  141236. * @param optimizer defines the current optimizer
  141237. * @returns true if everything that can be done was applied
  141238. */
  141239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141240. }
  141241. /**
  141242. * Defines an optimization used to remove shadows
  141243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141244. */
  141245. export class ShadowsOptimization extends SceneOptimization {
  141246. /**
  141247. * Gets a string describing the action executed by the current optimization
  141248. * @return description string
  141249. */
  141250. getDescription(): string;
  141251. /**
  141252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141253. * @param scene defines the current scene where to apply this optimization
  141254. * @param optimizer defines the current optimizer
  141255. * @returns true if everything that can be done was applied
  141256. */
  141257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141258. }
  141259. /**
  141260. * Defines an optimization used to turn post-processes off
  141261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141262. */
  141263. export class PostProcessesOptimization extends SceneOptimization {
  141264. /**
  141265. * Gets a string describing the action executed by the current optimization
  141266. * @return description string
  141267. */
  141268. getDescription(): string;
  141269. /**
  141270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141271. * @param scene defines the current scene where to apply this optimization
  141272. * @param optimizer defines the current optimizer
  141273. * @returns true if everything that can be done was applied
  141274. */
  141275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141276. }
  141277. /**
  141278. * Defines an optimization used to turn lens flares off
  141279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141280. */
  141281. export class LensFlaresOptimization extends SceneOptimization {
  141282. /**
  141283. * Gets a string describing the action executed by the current optimization
  141284. * @return description string
  141285. */
  141286. getDescription(): string;
  141287. /**
  141288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141289. * @param scene defines the current scene where to apply this optimization
  141290. * @param optimizer defines the current optimizer
  141291. * @returns true if everything that can be done was applied
  141292. */
  141293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141294. }
  141295. /**
  141296. * Defines an optimization based on user defined callback.
  141297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141298. */
  141299. export class CustomOptimization extends SceneOptimization {
  141300. /**
  141301. * Callback called to apply the custom optimization.
  141302. */
  141303. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141304. /**
  141305. * Callback called to get custom description
  141306. */
  141307. onGetDescription: () => string;
  141308. /**
  141309. * Gets a string describing the action executed by the current optimization
  141310. * @returns description string
  141311. */
  141312. getDescription(): string;
  141313. /**
  141314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141315. * @param scene defines the current scene where to apply this optimization
  141316. * @param optimizer defines the current optimizer
  141317. * @returns true if everything that can be done was applied
  141318. */
  141319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141320. }
  141321. /**
  141322. * Defines an optimization used to turn particles off
  141323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141324. */
  141325. export class ParticlesOptimization extends SceneOptimization {
  141326. /**
  141327. * Gets a string describing the action executed by the current optimization
  141328. * @return description string
  141329. */
  141330. getDescription(): string;
  141331. /**
  141332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141333. * @param scene defines the current scene where to apply this optimization
  141334. * @param optimizer defines the current optimizer
  141335. * @returns true if everything that can be done was applied
  141336. */
  141337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141338. }
  141339. /**
  141340. * Defines an optimization used to turn render targets off
  141341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141342. */
  141343. export class RenderTargetsOptimization extends SceneOptimization {
  141344. /**
  141345. * Gets a string describing the action executed by the current optimization
  141346. * @return description string
  141347. */
  141348. getDescription(): string;
  141349. /**
  141350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141351. * @param scene defines the current scene where to apply this optimization
  141352. * @param optimizer defines the current optimizer
  141353. * @returns true if everything that can be done was applied
  141354. */
  141355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141356. }
  141357. /**
  141358. * Defines an optimization used to merge meshes with compatible materials
  141359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141360. */
  141361. export class MergeMeshesOptimization extends SceneOptimization {
  141362. private static _UpdateSelectionTree;
  141363. /**
  141364. * Gets or sets a boolean which defines if optimization octree has to be updated
  141365. */
  141366. static get UpdateSelectionTree(): boolean;
  141367. /**
  141368. * Gets or sets a boolean which defines if optimization octree has to be updated
  141369. */
  141370. static set UpdateSelectionTree(value: boolean);
  141371. /**
  141372. * Gets a string describing the action executed by the current optimization
  141373. * @return description string
  141374. */
  141375. getDescription(): string;
  141376. private _canBeMerged;
  141377. /**
  141378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141379. * @param scene defines the current scene where to apply this optimization
  141380. * @param optimizer defines the current optimizer
  141381. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141382. * @returns true if everything that can be done was applied
  141383. */
  141384. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141385. }
  141386. /**
  141387. * Defines a list of options used by SceneOptimizer
  141388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141389. */
  141390. export class SceneOptimizerOptions {
  141391. /**
  141392. * Defines the target frame rate to reach (60 by default)
  141393. */
  141394. targetFrameRate: number;
  141395. /**
  141396. * Defines the interval between two checkes (2000ms by default)
  141397. */
  141398. trackerDuration: number;
  141399. /**
  141400. * Gets the list of optimizations to apply
  141401. */
  141402. optimizations: SceneOptimization[];
  141403. /**
  141404. * Creates a new list of options used by SceneOptimizer
  141405. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141406. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141407. */
  141408. constructor(
  141409. /**
  141410. * Defines the target frame rate to reach (60 by default)
  141411. */
  141412. targetFrameRate?: number,
  141413. /**
  141414. * Defines the interval between two checkes (2000ms by default)
  141415. */
  141416. trackerDuration?: number);
  141417. /**
  141418. * Add a new optimization
  141419. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141420. * @returns the current SceneOptimizerOptions
  141421. */
  141422. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141423. /**
  141424. * Add a new custom optimization
  141425. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141426. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141427. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141428. * @returns the current SceneOptimizerOptions
  141429. */
  141430. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141431. /**
  141432. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141433. * @param targetFrameRate defines the target frame rate (60 by default)
  141434. * @returns a SceneOptimizerOptions object
  141435. */
  141436. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141437. /**
  141438. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141439. * @param targetFrameRate defines the target frame rate (60 by default)
  141440. * @returns a SceneOptimizerOptions object
  141441. */
  141442. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141443. /**
  141444. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141445. * @param targetFrameRate defines the target frame rate (60 by default)
  141446. * @returns a SceneOptimizerOptions object
  141447. */
  141448. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141449. }
  141450. /**
  141451. * Class used to run optimizations in order to reach a target frame rate
  141452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141453. */
  141454. export class SceneOptimizer implements IDisposable {
  141455. private _isRunning;
  141456. private _options;
  141457. private _scene;
  141458. private _currentPriorityLevel;
  141459. private _targetFrameRate;
  141460. private _trackerDuration;
  141461. private _currentFrameRate;
  141462. private _sceneDisposeObserver;
  141463. private _improvementMode;
  141464. /**
  141465. * Defines an observable called when the optimizer reaches the target frame rate
  141466. */
  141467. onSuccessObservable: Observable<SceneOptimizer>;
  141468. /**
  141469. * Defines an observable called when the optimizer enables an optimization
  141470. */
  141471. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141472. /**
  141473. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141474. */
  141475. onFailureObservable: Observable<SceneOptimizer>;
  141476. /**
  141477. * Gets a boolean indicating if the optimizer is in improvement mode
  141478. */
  141479. get isInImprovementMode(): boolean;
  141480. /**
  141481. * Gets the current priority level (0 at start)
  141482. */
  141483. get currentPriorityLevel(): number;
  141484. /**
  141485. * Gets the current frame rate checked by the SceneOptimizer
  141486. */
  141487. get currentFrameRate(): number;
  141488. /**
  141489. * Gets or sets the current target frame rate (60 by default)
  141490. */
  141491. get targetFrameRate(): number;
  141492. /**
  141493. * Gets or sets the current target frame rate (60 by default)
  141494. */
  141495. set targetFrameRate(value: number);
  141496. /**
  141497. * Gets or sets the current interval between two checks (every 2000ms by default)
  141498. */
  141499. get trackerDuration(): number;
  141500. /**
  141501. * Gets or sets the current interval between two checks (every 2000ms by default)
  141502. */
  141503. set trackerDuration(value: number);
  141504. /**
  141505. * Gets the list of active optimizations
  141506. */
  141507. get optimizations(): SceneOptimization[];
  141508. /**
  141509. * Creates a new SceneOptimizer
  141510. * @param scene defines the scene to work on
  141511. * @param options defines the options to use with the SceneOptimizer
  141512. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141513. * @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)
  141514. */
  141515. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141516. /**
  141517. * Stops the current optimizer
  141518. */
  141519. stop(): void;
  141520. /**
  141521. * Reset the optimizer to initial step (current priority level = 0)
  141522. */
  141523. reset(): void;
  141524. /**
  141525. * Start the optimizer. By default it will try to reach a specific framerate
  141526. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141527. */
  141528. start(): void;
  141529. private _checkCurrentState;
  141530. /**
  141531. * Release all resources
  141532. */
  141533. dispose(): void;
  141534. /**
  141535. * Helper function to create a SceneOptimizer with one single line of code
  141536. * @param scene defines the scene to work on
  141537. * @param options defines the options to use with the SceneOptimizer
  141538. * @param onSuccess defines a callback to call on success
  141539. * @param onFailure defines a callback to call on failure
  141540. * @returns the new SceneOptimizer object
  141541. */
  141542. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141543. }
  141544. }
  141545. declare module BABYLON {
  141546. /**
  141547. * Class used to serialize a scene into a string
  141548. */
  141549. export class SceneSerializer {
  141550. /**
  141551. * Clear cache used by a previous serialization
  141552. */
  141553. static ClearCache(): void;
  141554. /**
  141555. * Serialize a scene into a JSON compatible object
  141556. * @param scene defines the scene to serialize
  141557. * @returns a JSON compatible object
  141558. */
  141559. static Serialize(scene: Scene): any;
  141560. /**
  141561. * Serialize a mesh into a JSON compatible object
  141562. * @param toSerialize defines the mesh to serialize
  141563. * @param withParents defines if parents must be serialized as well
  141564. * @param withChildren defines if children must be serialized as well
  141565. * @returns a JSON compatible object
  141566. */
  141567. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141568. }
  141569. }
  141570. declare module BABYLON {
  141571. /**
  141572. * Class used to host texture specific utilities
  141573. */
  141574. export class TextureTools {
  141575. /**
  141576. * Uses the GPU to create a copy texture rescaled at a given size
  141577. * @param texture Texture to copy from
  141578. * @param width defines the desired width
  141579. * @param height defines the desired height
  141580. * @param useBilinearMode defines if bilinear mode has to be used
  141581. * @return the generated texture
  141582. */
  141583. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141584. }
  141585. }
  141586. declare module BABYLON {
  141587. /**
  141588. * This represents the different options available for the video capture.
  141589. */
  141590. export interface VideoRecorderOptions {
  141591. /** Defines the mime type of the video. */
  141592. mimeType: string;
  141593. /** Defines the FPS the video should be recorded at. */
  141594. fps: number;
  141595. /** Defines the chunk size for the recording data. */
  141596. recordChunckSize: number;
  141597. /** The audio tracks to attach to the recording. */
  141598. audioTracks?: MediaStreamTrack[];
  141599. }
  141600. /**
  141601. * This can help with recording videos from BabylonJS.
  141602. * This is based on the available WebRTC functionalities of the browser.
  141603. *
  141604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141605. */
  141606. export class VideoRecorder {
  141607. private static readonly _defaultOptions;
  141608. /**
  141609. * Returns whether or not the VideoRecorder is available in your browser.
  141610. * @param engine Defines the Babylon Engine.
  141611. * @returns true if supported otherwise false.
  141612. */
  141613. static IsSupported(engine: Engine): boolean;
  141614. private readonly _options;
  141615. private _canvas;
  141616. private _mediaRecorder;
  141617. private _recordedChunks;
  141618. private _fileName;
  141619. private _resolve;
  141620. private _reject;
  141621. /**
  141622. * True when a recording is already in progress.
  141623. */
  141624. get isRecording(): boolean;
  141625. /**
  141626. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141627. * @param engine Defines the BabylonJS Engine you wish to record.
  141628. * @param options Defines options that can be used to customize the capture.
  141629. */
  141630. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141631. /**
  141632. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141633. */
  141634. stopRecording(): void;
  141635. /**
  141636. * Starts recording the canvas for a max duration specified in parameters.
  141637. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141638. * If null no automatic download will start and you can rely on the promise to get the data back.
  141639. * @param maxDuration Defines the maximum recording time in seconds.
  141640. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141641. * @return A promise callback at the end of the recording with the video data in Blob.
  141642. */
  141643. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141644. /**
  141645. * Releases internal resources used during the recording.
  141646. */
  141647. dispose(): void;
  141648. private _handleDataAvailable;
  141649. private _handleError;
  141650. private _handleStop;
  141651. }
  141652. }
  141653. declare module BABYLON {
  141654. /**
  141655. * Class containing a set of static utilities functions for screenshots
  141656. */
  141657. export class ScreenshotTools {
  141658. /**
  141659. * Captures a screenshot of the current rendering
  141660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141661. * @param engine defines the rendering engine
  141662. * @param camera defines the source camera
  141663. * @param size This parameter can be set to a single number or to an object with the
  141664. * following (optional) properties: precision, width, height. If a single number is passed,
  141665. * it will be used for both width and height. If an object is passed, the screenshot size
  141666. * will be derived from the parameters. The precision property is a multiplier allowing
  141667. * rendering at a higher or lower resolution
  141668. * @param successCallback defines the callback receives a single parameter which contains the
  141669. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141670. * src parameter of an <img> to display it
  141671. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141672. * Check your browser for supported MIME types
  141673. */
  141674. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141675. /**
  141676. * Captures a screenshot of the current rendering
  141677. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141678. * @param engine defines the rendering engine
  141679. * @param camera defines the source camera
  141680. * @param size This parameter can be set to a single number or to an object with the
  141681. * following (optional) properties: precision, width, height. If a single number is passed,
  141682. * it will be used for both width and height. If an object is passed, the screenshot size
  141683. * will be derived from the parameters. The precision property is a multiplier allowing
  141684. * rendering at a higher or lower resolution
  141685. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141686. * Check your browser for supported MIME types
  141687. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141688. * to the src parameter of an <img> to display it
  141689. */
  141690. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141691. /**
  141692. * Generates an image screenshot from the specified camera.
  141693. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141694. * @param engine The engine to use for rendering
  141695. * @param camera The camera to use for rendering
  141696. * @param size This parameter can be set to a single number or to an object with the
  141697. * following (optional) properties: precision, width, height. If a single number is passed,
  141698. * it will be used for both width and height. If an object is passed, the screenshot size
  141699. * will be derived from the parameters. The precision property is a multiplier allowing
  141700. * rendering at a higher or lower resolution
  141701. * @param successCallback The callback receives a single parameter which contains the
  141702. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141703. * src parameter of an <img> to display it
  141704. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141705. * Check your browser for supported MIME types
  141706. * @param samples Texture samples (default: 1)
  141707. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141708. * @param fileName A name for for the downloaded file.
  141709. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141710. */
  141711. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141712. /**
  141713. * Generates an image screenshot from the specified camera.
  141714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141715. * @param engine The engine to use for rendering
  141716. * @param camera The camera to use for rendering
  141717. * @param size This parameter can be set to a single number or to an object with the
  141718. * following (optional) properties: precision, width, height. If a single number is passed,
  141719. * it will be used for both width and height. If an object is passed, the screenshot size
  141720. * will be derived from the parameters. The precision property is a multiplier allowing
  141721. * rendering at a higher or lower resolution
  141722. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141723. * Check your browser for supported MIME types
  141724. * @param samples Texture samples (default: 1)
  141725. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141726. * @param fileName A name for for the downloaded file.
  141727. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141728. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141729. * to the src parameter of an <img> to display it
  141730. */
  141731. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141732. /**
  141733. * Gets height and width for screenshot size
  141734. * @private
  141735. */
  141736. private static _getScreenshotSize;
  141737. }
  141738. }
  141739. declare module BABYLON {
  141740. /**
  141741. * Interface for a data buffer
  141742. */
  141743. export interface IDataBuffer {
  141744. /**
  141745. * Reads bytes from the data buffer.
  141746. * @param byteOffset The byte offset to read
  141747. * @param byteLength The byte length to read
  141748. * @returns A promise that resolves when the bytes are read
  141749. */
  141750. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141751. /**
  141752. * The byte length of the buffer.
  141753. */
  141754. readonly byteLength: number;
  141755. }
  141756. /**
  141757. * Utility class for reading from a data buffer
  141758. */
  141759. export class DataReader {
  141760. /**
  141761. * The data buffer associated with this data reader.
  141762. */
  141763. readonly buffer: IDataBuffer;
  141764. /**
  141765. * The current byte offset from the beginning of the data buffer.
  141766. */
  141767. byteOffset: number;
  141768. private _dataView;
  141769. private _dataByteOffset;
  141770. /**
  141771. * Constructor
  141772. * @param buffer The buffer to read
  141773. */
  141774. constructor(buffer: IDataBuffer);
  141775. /**
  141776. * Loads the given byte length.
  141777. * @param byteLength The byte length to load
  141778. * @returns A promise that resolves when the load is complete
  141779. */
  141780. loadAsync(byteLength: number): Promise<void>;
  141781. /**
  141782. * Read a unsigned 32-bit integer from the currently loaded data range.
  141783. * @returns The 32-bit integer read
  141784. */
  141785. readUint32(): number;
  141786. /**
  141787. * Read a byte array from the currently loaded data range.
  141788. * @param byteLength The byte length to read
  141789. * @returns The byte array read
  141790. */
  141791. readUint8Array(byteLength: number): Uint8Array;
  141792. /**
  141793. * Read a string from the currently loaded data range.
  141794. * @param byteLength The byte length to read
  141795. * @returns The string read
  141796. */
  141797. readString(byteLength: number): string;
  141798. /**
  141799. * Skips the given byte length the currently loaded data range.
  141800. * @param byteLength The byte length to skip
  141801. */
  141802. skipBytes(byteLength: number): void;
  141803. }
  141804. }
  141805. declare module BABYLON {
  141806. /**
  141807. * Options used for hit testing
  141808. */
  141809. export interface IWebXRHitTestOptions {
  141810. /**
  141811. * Only test when user interacted with the scene. Default - hit test every frame
  141812. */
  141813. testOnPointerDownOnly?: boolean;
  141814. /**
  141815. * The node to use to transform the local results to world coordinates
  141816. */
  141817. worldParentNode?: TransformNode;
  141818. }
  141819. /**
  141820. * Interface defining the babylon result of raycasting/hit-test
  141821. */
  141822. export interface IWebXRHitResult {
  141823. /**
  141824. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141825. */
  141826. transformationMatrix: Matrix;
  141827. /**
  141828. * The native hit test result
  141829. */
  141830. xrHitResult: XRHitResult;
  141831. }
  141832. /**
  141833. * The currently-working hit-test module.
  141834. * Hit test (or Ray-casting) is used to interact with the real world.
  141835. * For further information read here - https://github.com/immersive-web/hit-test
  141836. */
  141837. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141838. /**
  141839. * options to use when constructing this feature
  141840. */
  141841. readonly options: IWebXRHitTestOptions;
  141842. private _direction;
  141843. private _mat;
  141844. private _onSelectEnabled;
  141845. private _origin;
  141846. /**
  141847. * The module's name
  141848. */
  141849. static readonly Name: string;
  141850. /**
  141851. * The (Babylon) version of this module.
  141852. * This is an integer representing the implementation version.
  141853. * This number does not correspond to the WebXR specs version
  141854. */
  141855. static readonly Version: number;
  141856. /**
  141857. * Populated with the last native XR Hit Results
  141858. */
  141859. lastNativeXRHitResults: XRHitResult[];
  141860. /**
  141861. * Triggered when new babylon (transformed) hit test results are available
  141862. */
  141863. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141864. /**
  141865. * Creates a new instance of the (legacy version) hit test feature
  141866. * @param _xrSessionManager an instance of WebXRSessionManager
  141867. * @param options options to use when constructing this feature
  141868. */
  141869. constructor(_xrSessionManager: WebXRSessionManager,
  141870. /**
  141871. * options to use when constructing this feature
  141872. */
  141873. options?: IWebXRHitTestOptions);
  141874. /**
  141875. * execute a hit test with an XR Ray
  141876. *
  141877. * @param xrSession a native xrSession that will execute this hit test
  141878. * @param xrRay the ray (position and direction) to use for ray-casting
  141879. * @param referenceSpace native XR reference space to use for the hit-test
  141880. * @param filter filter function that will filter the results
  141881. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141882. */
  141883. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141884. /**
  141885. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141886. * @param event the (select) event to use to select with
  141887. * @param referenceSpace the reference space to use for this hit test
  141888. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141889. */
  141890. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141891. /**
  141892. * attach this feature
  141893. * Will usually be called by the features manager
  141894. *
  141895. * @returns true if successful.
  141896. */
  141897. attach(): boolean;
  141898. /**
  141899. * detach this feature.
  141900. * Will usually be called by the features manager
  141901. *
  141902. * @returns true if successful.
  141903. */
  141904. detach(): boolean;
  141905. /**
  141906. * Dispose this feature and all of the resources attached
  141907. */
  141908. dispose(): void;
  141909. protected _onXRFrame(frame: XRFrame): void;
  141910. private _onHitTestResults;
  141911. private _onSelect;
  141912. }
  141913. }
  141914. declare module BABYLON {
  141915. /**
  141916. * Options used in the plane detector module
  141917. */
  141918. export interface IWebXRPlaneDetectorOptions {
  141919. /**
  141920. * The node to use to transform the local results to world coordinates
  141921. */
  141922. worldParentNode?: TransformNode;
  141923. }
  141924. /**
  141925. * A babylon interface for a WebXR plane.
  141926. * A Plane is actually a polygon, built from N points in space
  141927. *
  141928. * Supported in chrome 79, not supported in canary 81 ATM
  141929. */
  141930. export interface IWebXRPlane {
  141931. /**
  141932. * a babylon-assigned ID for this polygon
  141933. */
  141934. id: number;
  141935. /**
  141936. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141937. */
  141938. polygonDefinition: Array<Vector3>;
  141939. /**
  141940. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141941. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141942. */
  141943. transformationMatrix: Matrix;
  141944. /**
  141945. * the native xr-plane object
  141946. */
  141947. xrPlane: XRPlane;
  141948. }
  141949. /**
  141950. * The plane detector is used to detect planes in the real world when in AR
  141951. * For more information see https://github.com/immersive-web/real-world-geometry/
  141952. */
  141953. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  141954. private _options;
  141955. private _detectedPlanes;
  141956. private _enabled;
  141957. private _lastFrameDetected;
  141958. /**
  141959. * The module's name
  141960. */
  141961. static readonly Name: string;
  141962. /**
  141963. * The (Babylon) version of this module.
  141964. * This is an integer representing the implementation version.
  141965. * This number does not correspond to the WebXR specs version
  141966. */
  141967. static readonly Version: number;
  141968. /**
  141969. * Observers registered here will be executed when a new plane was added to the session
  141970. */
  141971. onPlaneAddedObservable: Observable<IWebXRPlane>;
  141972. /**
  141973. * Observers registered here will be executed when a plane is no longer detected in the session
  141974. */
  141975. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  141976. /**
  141977. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  141978. * This can execute N times every frame
  141979. */
  141980. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  141981. /**
  141982. * construct a new Plane Detector
  141983. * @param _xrSessionManager an instance of xr Session manager
  141984. * @param _options configuration to use when constructing this feature
  141985. */
  141986. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  141987. /**
  141988. * Dispose this feature and all of the resources attached
  141989. */
  141990. dispose(): void;
  141991. protected _onXRFrame(frame: XRFrame): void;
  141992. private _init;
  141993. private _updatePlaneWithXRPlane;
  141994. /**
  141995. * avoiding using Array.find for global support.
  141996. * @param xrPlane the plane to find in the array
  141997. */
  141998. private findIndexInPlaneArray;
  141999. }
  142000. }
  142001. declare module BABYLON {
  142002. /**
  142003. * Configuration options of the anchor system
  142004. */
  142005. export interface IWebXRAnchorSystemOptions {
  142006. /**
  142007. * Should a new anchor be added every time a select event is triggered
  142008. */
  142009. addAnchorOnSelect?: boolean;
  142010. /**
  142011. * should the anchor system use plane detection.
  142012. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142013. */
  142014. usePlaneDetection?: boolean;
  142015. /**
  142016. * a node that will be used to convert local to world coordinates
  142017. */
  142018. worldParentNode?: TransformNode;
  142019. }
  142020. /**
  142021. * A babylon container for an XR Anchor
  142022. */
  142023. export interface IWebXRAnchor {
  142024. /**
  142025. * A babylon-assigned ID for this anchor
  142026. */
  142027. id: number;
  142028. /**
  142029. * Transformation matrix to apply to an object attached to this anchor
  142030. */
  142031. transformationMatrix: Matrix;
  142032. /**
  142033. * The native anchor object
  142034. */
  142035. xrAnchor: XRAnchor;
  142036. }
  142037. /**
  142038. * An implementation of the anchor system of WebXR.
  142039. * Note that the current documented implementation is not available in any browser. Future implementations
  142040. * will use the frame to create an anchor and not the session or a detected plane
  142041. * For further information see https://github.com/immersive-web/anchors/
  142042. */
  142043. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142044. private _options;
  142045. private _enabled;
  142046. private _hitTestModule;
  142047. private _lastFrameDetected;
  142048. private _onSelect;
  142049. private _planeDetector;
  142050. private _trackedAnchors;
  142051. /**
  142052. * The module's name
  142053. */
  142054. static readonly Name: string;
  142055. /**
  142056. * The (Babylon) version of this module.
  142057. * This is an integer representing the implementation version.
  142058. * This number does not correspond to the WebXR specs version
  142059. */
  142060. static readonly Version: number;
  142061. /**
  142062. * Observers registered here will be executed when a new anchor was added to the session
  142063. */
  142064. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142065. /**
  142066. * Observers registered here will be executed when an anchor was removed from the session
  142067. */
  142068. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142069. /**
  142070. * Observers registered here will be executed when an existing anchor updates
  142071. * This can execute N times every frame
  142072. */
  142073. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142074. /**
  142075. * constructs a new anchor system
  142076. * @param _xrSessionManager an instance of WebXRSessionManager
  142077. * @param _options configuration object for this feature
  142078. */
  142079. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142080. /**
  142081. * Add anchor at a specific XR point.
  142082. *
  142083. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142084. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142085. * @returns a promise the fulfills when the anchor was created
  142086. */
  142087. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142088. /**
  142089. * attach this feature
  142090. * Will usually be called by the features manager
  142091. *
  142092. * @returns true if successful.
  142093. */
  142094. attach(): boolean;
  142095. /**
  142096. * detach this feature.
  142097. * Will usually be called by the features manager
  142098. *
  142099. * @returns true if successful.
  142100. */
  142101. detach(): boolean;
  142102. /**
  142103. * Dispose this feature and all of the resources attached
  142104. */
  142105. dispose(): void;
  142106. /**
  142107. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142108. * @param hitTestModule the hit-test module to use.
  142109. */
  142110. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142111. /**
  142112. * set the plane detector to use in order to create anchors from frames
  142113. * @param planeDetector the plane-detector module to use
  142114. * @param enable enable plane-anchors. default is true
  142115. */
  142116. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142117. protected _onXRFrame(frame: XRFrame): void;
  142118. /**
  142119. * avoiding using Array.find for global support.
  142120. * @param xrAnchor the plane to find in the array
  142121. */
  142122. private _findIndexInAnchorArray;
  142123. private _updateAnchorWithXRFrame;
  142124. }
  142125. }
  142126. declare module BABYLON {
  142127. /**
  142128. * Options interface for the background remover plugin
  142129. */
  142130. export interface IWebXRBackgroundRemoverOptions {
  142131. /**
  142132. * Further background meshes to disable when entering AR
  142133. */
  142134. backgroundMeshes?: AbstractMesh[];
  142135. /**
  142136. * flags to configure the removal of the environment helper.
  142137. * If not set, the entire background will be removed. If set, flags should be set as well.
  142138. */
  142139. environmentHelperRemovalFlags?: {
  142140. /**
  142141. * Should the skybox be removed (default false)
  142142. */
  142143. skyBox?: boolean;
  142144. /**
  142145. * Should the ground be removed (default false)
  142146. */
  142147. ground?: boolean;
  142148. };
  142149. /**
  142150. * don't disable the environment helper
  142151. */
  142152. ignoreEnvironmentHelper?: boolean;
  142153. }
  142154. /**
  142155. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142156. */
  142157. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142158. /**
  142159. * read-only options to be used in this module
  142160. */
  142161. readonly options: IWebXRBackgroundRemoverOptions;
  142162. /**
  142163. * The module's name
  142164. */
  142165. static readonly Name: string;
  142166. /**
  142167. * The (Babylon) version of this module.
  142168. * This is an integer representing the implementation version.
  142169. * This number does not correspond to the WebXR specs version
  142170. */
  142171. static readonly Version: number;
  142172. /**
  142173. * registered observers will be triggered when the background state changes
  142174. */
  142175. onBackgroundStateChangedObservable: Observable<boolean>;
  142176. /**
  142177. * constructs a new background remover module
  142178. * @param _xrSessionManager the session manager for this module
  142179. * @param options read-only options to be used in this module
  142180. */
  142181. constructor(_xrSessionManager: WebXRSessionManager,
  142182. /**
  142183. * read-only options to be used in this module
  142184. */
  142185. options?: IWebXRBackgroundRemoverOptions);
  142186. /**
  142187. * attach this feature
  142188. * Will usually be called by the features manager
  142189. *
  142190. * @returns true if successful.
  142191. */
  142192. attach(): boolean;
  142193. /**
  142194. * detach this feature.
  142195. * Will usually be called by the features manager
  142196. *
  142197. * @returns true if successful.
  142198. */
  142199. detach(): boolean;
  142200. /**
  142201. * Dispose this feature and all of the resources attached
  142202. */
  142203. dispose(): void;
  142204. protected _onXRFrame(_xrFrame: XRFrame): void;
  142205. private _setBackgroundState;
  142206. }
  142207. }
  142208. declare module BABYLON {
  142209. /**
  142210. * Options for the controller physics feature
  142211. */
  142212. export class IWebXRControllerPhysicsOptions {
  142213. /**
  142214. * Should the headset get its own impostor
  142215. */
  142216. enableHeadsetImpostor?: boolean;
  142217. /**
  142218. * Optional parameters for the headset impostor
  142219. */
  142220. headsetImpostorParams?: {
  142221. /**
  142222. * The type of impostor to create. Default is sphere
  142223. */
  142224. impostorType: number;
  142225. /**
  142226. * the size of the impostor. Defaults to 10cm
  142227. */
  142228. impostorSize?: number | {
  142229. width: number;
  142230. height: number;
  142231. depth: number;
  142232. };
  142233. /**
  142234. * Friction definitions
  142235. */
  142236. friction?: number;
  142237. /**
  142238. * Restitution
  142239. */
  142240. restitution?: number;
  142241. };
  142242. /**
  142243. * The physics properties of the future impostors
  142244. */
  142245. physicsProperties?: {
  142246. /**
  142247. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142248. * Note that this requires a physics engine that supports mesh impostors!
  142249. */
  142250. useControllerMesh?: boolean;
  142251. /**
  142252. * The type of impostor to create. Default is sphere
  142253. */
  142254. impostorType?: number;
  142255. /**
  142256. * the size of the impostor. Defaults to 10cm
  142257. */
  142258. impostorSize?: number | {
  142259. width: number;
  142260. height: number;
  142261. depth: number;
  142262. };
  142263. /**
  142264. * Friction definitions
  142265. */
  142266. friction?: number;
  142267. /**
  142268. * Restitution
  142269. */
  142270. restitution?: number;
  142271. };
  142272. /**
  142273. * the xr input to use with this pointer selection
  142274. */
  142275. xrInput: WebXRInput;
  142276. }
  142277. /**
  142278. * Add physics impostor to your webxr controllers,
  142279. * including naive calculation of their linear and angular velocity
  142280. */
  142281. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142282. private readonly _options;
  142283. private _attachController;
  142284. private _controllers;
  142285. private _debugMode;
  142286. private _delta;
  142287. private _headsetImpostor?;
  142288. private _headsetMesh?;
  142289. private _lastTimestamp;
  142290. private _tmpQuaternion;
  142291. private _tmpVector;
  142292. /**
  142293. * The module's name
  142294. */
  142295. static readonly Name: string;
  142296. /**
  142297. * The (Babylon) version of this module.
  142298. * This is an integer representing the implementation version.
  142299. * This number does not correspond to the webxr specs version
  142300. */
  142301. static readonly Version: number;
  142302. /**
  142303. * Construct a new Controller Physics Feature
  142304. * @param _xrSessionManager the corresponding xr session manager
  142305. * @param _options options to create this feature with
  142306. */
  142307. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142308. /**
  142309. * @hidden
  142310. * enable debugging - will show console outputs and the impostor mesh
  142311. */
  142312. _enablePhysicsDebug(): void;
  142313. /**
  142314. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142315. * @param xrController the controller to add
  142316. */
  142317. addController(xrController: WebXRInputSource): void;
  142318. /**
  142319. * attach this feature
  142320. * Will usually be called by the features manager
  142321. *
  142322. * @returns true if successful.
  142323. */
  142324. attach(): boolean;
  142325. /**
  142326. * detach this feature.
  142327. * Will usually be called by the features manager
  142328. *
  142329. * @returns true if successful.
  142330. */
  142331. detach(): boolean;
  142332. /**
  142333. * Get the headset impostor, if enabled
  142334. * @returns the impostor
  142335. */
  142336. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142337. /**
  142338. * Get the physics impostor of a specific controller.
  142339. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142340. * @param controller the controller or the controller id of which to get the impostor
  142341. * @returns the impostor or null
  142342. */
  142343. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142344. /**
  142345. * Update the physics properties provided in the constructor
  142346. * @param newProperties the new properties object
  142347. */
  142348. setPhysicsProperties(newProperties: {
  142349. impostorType?: number;
  142350. impostorSize?: number | {
  142351. width: number;
  142352. height: number;
  142353. depth: number;
  142354. };
  142355. friction?: number;
  142356. restitution?: number;
  142357. }): void;
  142358. protected _onXRFrame(_xrFrame: any): void;
  142359. private _detachController;
  142360. }
  142361. }
  142362. declare module BABYLON {
  142363. /**
  142364. * The motion controller class for all microsoft mixed reality controllers
  142365. */
  142366. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142367. protected readonly _mapping: {
  142368. defaultButton: {
  142369. "valueNodeName": string;
  142370. "unpressedNodeName": string;
  142371. "pressedNodeName": string;
  142372. };
  142373. defaultAxis: {
  142374. "valueNodeName": string;
  142375. "minNodeName": string;
  142376. "maxNodeName": string;
  142377. };
  142378. buttons: {
  142379. "xr-standard-trigger": {
  142380. "rootNodeName": string;
  142381. "componentProperty": string;
  142382. "states": string[];
  142383. };
  142384. "xr-standard-squeeze": {
  142385. "rootNodeName": string;
  142386. "componentProperty": string;
  142387. "states": string[];
  142388. };
  142389. "xr-standard-touchpad": {
  142390. "rootNodeName": string;
  142391. "labelAnchorNodeName": string;
  142392. "touchPointNodeName": string;
  142393. };
  142394. "xr-standard-thumbstick": {
  142395. "rootNodeName": string;
  142396. "componentProperty": string;
  142397. "states": string[];
  142398. };
  142399. };
  142400. axes: {
  142401. "xr-standard-touchpad": {
  142402. "x-axis": {
  142403. "rootNodeName": string;
  142404. };
  142405. "y-axis": {
  142406. "rootNodeName": string;
  142407. };
  142408. };
  142409. "xr-standard-thumbstick": {
  142410. "x-axis": {
  142411. "rootNodeName": string;
  142412. };
  142413. "y-axis": {
  142414. "rootNodeName": string;
  142415. };
  142416. };
  142417. };
  142418. };
  142419. /**
  142420. * The base url used to load the left and right controller models
  142421. */
  142422. static MODEL_BASE_URL: string;
  142423. /**
  142424. * The name of the left controller model file
  142425. */
  142426. static MODEL_LEFT_FILENAME: string;
  142427. /**
  142428. * The name of the right controller model file
  142429. */
  142430. static MODEL_RIGHT_FILENAME: string;
  142431. profileId: string;
  142432. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142433. protected _getFilenameAndPath(): {
  142434. filename: string;
  142435. path: string;
  142436. };
  142437. protected _getModelLoadingConstraints(): boolean;
  142438. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142439. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142440. protected _updateModel(): void;
  142441. }
  142442. }
  142443. declare module BABYLON {
  142444. /**
  142445. * The motion controller class for oculus touch (quest, rift).
  142446. * This class supports legacy mapping as well the standard xr mapping
  142447. */
  142448. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142449. private _forceLegacyControllers;
  142450. private _modelRootNode;
  142451. /**
  142452. * The base url used to load the left and right controller models
  142453. */
  142454. static MODEL_BASE_URL: string;
  142455. /**
  142456. * The name of the left controller model file
  142457. */
  142458. static MODEL_LEFT_FILENAME: string;
  142459. /**
  142460. * The name of the right controller model file
  142461. */
  142462. static MODEL_RIGHT_FILENAME: string;
  142463. /**
  142464. * Base Url for the Quest controller model.
  142465. */
  142466. static QUEST_MODEL_BASE_URL: string;
  142467. profileId: string;
  142468. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142469. protected _getFilenameAndPath(): {
  142470. filename: string;
  142471. path: string;
  142472. };
  142473. protected _getModelLoadingConstraints(): boolean;
  142474. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142475. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142476. protected _updateModel(): void;
  142477. /**
  142478. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142479. * between the touch and touch 2.
  142480. */
  142481. private _isQuest;
  142482. }
  142483. }
  142484. declare module BABYLON {
  142485. /**
  142486. * The motion controller class for the standard HTC-Vive controllers
  142487. */
  142488. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142489. private _modelRootNode;
  142490. /**
  142491. * The base url used to load the left and right controller models
  142492. */
  142493. static MODEL_BASE_URL: string;
  142494. /**
  142495. * File name for the controller model.
  142496. */
  142497. static MODEL_FILENAME: string;
  142498. profileId: string;
  142499. /**
  142500. * Create a new Vive motion controller object
  142501. * @param scene the scene to use to create this controller
  142502. * @param gamepadObject the corresponding gamepad object
  142503. * @param handness the handness of the controller
  142504. */
  142505. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142506. protected _getFilenameAndPath(): {
  142507. filename: string;
  142508. path: string;
  142509. };
  142510. protected _getModelLoadingConstraints(): boolean;
  142511. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142512. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142513. protected _updateModel(): void;
  142514. }
  142515. }
  142516. declare module BABYLON {
  142517. /**
  142518. * A cursor which tracks a point on a path
  142519. */
  142520. export class PathCursor {
  142521. private path;
  142522. /**
  142523. * Stores path cursor callbacks for when an onchange event is triggered
  142524. */
  142525. private _onchange;
  142526. /**
  142527. * The value of the path cursor
  142528. */
  142529. value: number;
  142530. /**
  142531. * The animation array of the path cursor
  142532. */
  142533. animations: Animation[];
  142534. /**
  142535. * Initializes the path cursor
  142536. * @param path The path to track
  142537. */
  142538. constructor(path: Path2);
  142539. /**
  142540. * Gets the cursor point on the path
  142541. * @returns A point on the path cursor at the cursor location
  142542. */
  142543. getPoint(): Vector3;
  142544. /**
  142545. * Moves the cursor ahead by the step amount
  142546. * @param step The amount to move the cursor forward
  142547. * @returns This path cursor
  142548. */
  142549. moveAhead(step?: number): PathCursor;
  142550. /**
  142551. * Moves the cursor behind by the step amount
  142552. * @param step The amount to move the cursor back
  142553. * @returns This path cursor
  142554. */
  142555. moveBack(step?: number): PathCursor;
  142556. /**
  142557. * Moves the cursor by the step amount
  142558. * If the step amount is greater than one, an exception is thrown
  142559. * @param step The amount to move the cursor
  142560. * @returns This path cursor
  142561. */
  142562. move(step: number): PathCursor;
  142563. /**
  142564. * Ensures that the value is limited between zero and one
  142565. * @returns This path cursor
  142566. */
  142567. private ensureLimits;
  142568. /**
  142569. * Runs onchange callbacks on change (used by the animation engine)
  142570. * @returns This path cursor
  142571. */
  142572. private raiseOnChange;
  142573. /**
  142574. * Executes a function on change
  142575. * @param f A path cursor onchange callback
  142576. * @returns This path cursor
  142577. */
  142578. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142579. }
  142580. }
  142581. declare module BABYLON {
  142582. /** @hidden */
  142583. export var blurPixelShader: {
  142584. name: string;
  142585. shader: string;
  142586. };
  142587. }
  142588. declare module BABYLON {
  142589. /** @hidden */
  142590. export var pointCloudVertexDeclaration: {
  142591. name: string;
  142592. shader: string;
  142593. };
  142594. }
  142595. // Mixins
  142596. interface Window {
  142597. mozIndexedDB: IDBFactory;
  142598. webkitIndexedDB: IDBFactory;
  142599. msIndexedDB: IDBFactory;
  142600. webkitURL: typeof URL;
  142601. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142602. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142603. WebGLRenderingContext: WebGLRenderingContext;
  142604. MSGesture: MSGesture;
  142605. CANNON: any;
  142606. AudioContext: AudioContext;
  142607. webkitAudioContext: AudioContext;
  142608. PointerEvent: any;
  142609. Math: Math;
  142610. Uint8Array: Uint8ArrayConstructor;
  142611. Float32Array: Float32ArrayConstructor;
  142612. mozURL: typeof URL;
  142613. msURL: typeof URL;
  142614. VRFrameData: any; // WebVR, from specs 1.1
  142615. DracoDecoderModule: any;
  142616. setImmediate(handler: (...args: any[]) => void): number;
  142617. }
  142618. interface HTMLCanvasElement {
  142619. requestPointerLock(): void;
  142620. msRequestPointerLock?(): void;
  142621. mozRequestPointerLock?(): void;
  142622. webkitRequestPointerLock?(): void;
  142623. /** Track wether a record is in progress */
  142624. isRecording: boolean;
  142625. /** Capture Stream method defined by some browsers */
  142626. captureStream(fps?: number): MediaStream;
  142627. }
  142628. interface CanvasRenderingContext2D {
  142629. msImageSmoothingEnabled: boolean;
  142630. }
  142631. interface MouseEvent {
  142632. mozMovementX: number;
  142633. mozMovementY: number;
  142634. webkitMovementX: number;
  142635. webkitMovementY: number;
  142636. msMovementX: number;
  142637. msMovementY: number;
  142638. }
  142639. interface Navigator {
  142640. mozGetVRDevices: (any: any) => any;
  142641. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142642. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142643. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142644. webkitGetGamepads(): Gamepad[];
  142645. msGetGamepads(): Gamepad[];
  142646. webkitGamepads(): Gamepad[];
  142647. }
  142648. interface HTMLVideoElement {
  142649. mozSrcObject: any;
  142650. }
  142651. interface Math {
  142652. fround(x: number): number;
  142653. imul(a: number, b: number): number;
  142654. }
  142655. interface WebGLRenderingContext {
  142656. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142657. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142658. vertexAttribDivisor(index: number, divisor: number): void;
  142659. createVertexArray(): any;
  142660. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142661. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142662. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142663. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142664. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142665. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142666. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142667. // Queries
  142668. createQuery(): WebGLQuery;
  142669. deleteQuery(query: WebGLQuery): void;
  142670. beginQuery(target: number, query: WebGLQuery): void;
  142671. endQuery(target: number): void;
  142672. getQueryParameter(query: WebGLQuery, pname: number): any;
  142673. getQuery(target: number, pname: number): any;
  142674. MAX_SAMPLES: number;
  142675. RGBA8: number;
  142676. READ_FRAMEBUFFER: number;
  142677. DRAW_FRAMEBUFFER: number;
  142678. UNIFORM_BUFFER: number;
  142679. HALF_FLOAT_OES: number;
  142680. RGBA16F: number;
  142681. RGBA32F: number;
  142682. R32F: number;
  142683. RG32F: number;
  142684. RGB32F: number;
  142685. R16F: number;
  142686. RG16F: number;
  142687. RGB16F: number;
  142688. RED: number;
  142689. RG: number;
  142690. R8: number;
  142691. RG8: number;
  142692. UNSIGNED_INT_24_8: number;
  142693. DEPTH24_STENCIL8: number;
  142694. MIN: number;
  142695. MAX: number;
  142696. /* Multiple Render Targets */
  142697. drawBuffers(buffers: number[]): void;
  142698. readBuffer(src: number): void;
  142699. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142700. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142701. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142702. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142703. // Occlusion Query
  142704. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142705. ANY_SAMPLES_PASSED: number;
  142706. QUERY_RESULT_AVAILABLE: number;
  142707. QUERY_RESULT: number;
  142708. }
  142709. interface WebGLProgram {
  142710. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142711. }
  142712. interface EXT_disjoint_timer_query {
  142713. QUERY_COUNTER_BITS_EXT: number;
  142714. TIME_ELAPSED_EXT: number;
  142715. TIMESTAMP_EXT: number;
  142716. GPU_DISJOINT_EXT: number;
  142717. QUERY_RESULT_EXT: number;
  142718. QUERY_RESULT_AVAILABLE_EXT: number;
  142719. queryCounterEXT(query: WebGLQuery, target: number): void;
  142720. createQueryEXT(): WebGLQuery;
  142721. beginQueryEXT(target: number, query: WebGLQuery): void;
  142722. endQueryEXT(target: number): void;
  142723. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142724. deleteQueryEXT(query: WebGLQuery): void;
  142725. }
  142726. interface WebGLUniformLocation {
  142727. _currentState: any;
  142728. }
  142729. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142730. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142731. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142732. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142733. interface WebGLRenderingContext {
  142734. readonly RASTERIZER_DISCARD: number;
  142735. readonly DEPTH_COMPONENT24: number;
  142736. readonly TEXTURE_3D: number;
  142737. readonly TEXTURE_2D_ARRAY: number;
  142738. readonly TEXTURE_COMPARE_FUNC: number;
  142739. readonly TEXTURE_COMPARE_MODE: number;
  142740. readonly COMPARE_REF_TO_TEXTURE: number;
  142741. readonly TEXTURE_WRAP_R: number;
  142742. readonly HALF_FLOAT: number;
  142743. readonly RGB8: number;
  142744. readonly RED_INTEGER: number;
  142745. readonly RG_INTEGER: number;
  142746. readonly RGB_INTEGER: number;
  142747. readonly RGBA_INTEGER: number;
  142748. readonly R8_SNORM: number;
  142749. readonly RG8_SNORM: number;
  142750. readonly RGB8_SNORM: number;
  142751. readonly RGBA8_SNORM: number;
  142752. readonly R8I: number;
  142753. readonly RG8I: number;
  142754. readonly RGB8I: number;
  142755. readonly RGBA8I: number;
  142756. readonly R8UI: number;
  142757. readonly RG8UI: number;
  142758. readonly RGB8UI: number;
  142759. readonly RGBA8UI: number;
  142760. readonly R16I: number;
  142761. readonly RG16I: number;
  142762. readonly RGB16I: number;
  142763. readonly RGBA16I: number;
  142764. readonly R16UI: number;
  142765. readonly RG16UI: number;
  142766. readonly RGB16UI: number;
  142767. readonly RGBA16UI: number;
  142768. readonly R32I: number;
  142769. readonly RG32I: number;
  142770. readonly RGB32I: number;
  142771. readonly RGBA32I: number;
  142772. readonly R32UI: number;
  142773. readonly RG32UI: number;
  142774. readonly RGB32UI: number;
  142775. readonly RGBA32UI: number;
  142776. readonly RGB10_A2UI: number;
  142777. readonly R11F_G11F_B10F: number;
  142778. readonly RGB9_E5: number;
  142779. readonly RGB10_A2: number;
  142780. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142781. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142782. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142783. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142784. readonly DEPTH_COMPONENT32F: number;
  142785. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142786. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142787. 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;
  142788. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142789. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142790. readonly TRANSFORM_FEEDBACK: number;
  142791. readonly INTERLEAVED_ATTRIBS: number;
  142792. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142793. createTransformFeedback(): WebGLTransformFeedback;
  142794. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142795. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142796. beginTransformFeedback(primitiveMode: number): void;
  142797. endTransformFeedback(): void;
  142798. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142799. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142800. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142801. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142802. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142803. }
  142804. interface ImageBitmap {
  142805. readonly width: number;
  142806. readonly height: number;
  142807. close(): void;
  142808. }
  142809. interface WebGLQuery extends WebGLObject {
  142810. }
  142811. declare var WebGLQuery: {
  142812. prototype: WebGLQuery;
  142813. new(): WebGLQuery;
  142814. };
  142815. interface WebGLSampler extends WebGLObject {
  142816. }
  142817. declare var WebGLSampler: {
  142818. prototype: WebGLSampler;
  142819. new(): WebGLSampler;
  142820. };
  142821. interface WebGLSync extends WebGLObject {
  142822. }
  142823. declare var WebGLSync: {
  142824. prototype: WebGLSync;
  142825. new(): WebGLSync;
  142826. };
  142827. interface WebGLTransformFeedback extends WebGLObject {
  142828. }
  142829. declare var WebGLTransformFeedback: {
  142830. prototype: WebGLTransformFeedback;
  142831. new(): WebGLTransformFeedback;
  142832. };
  142833. interface WebGLVertexArrayObject extends WebGLObject {
  142834. }
  142835. declare var WebGLVertexArrayObject: {
  142836. prototype: WebGLVertexArrayObject;
  142837. new(): WebGLVertexArrayObject;
  142838. };
  142839. // Type definitions for WebVR API
  142840. // Project: https://w3c.github.io/webvr/
  142841. // Definitions by: six a <https://github.com/lostfictions>
  142842. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142843. interface VRDisplay extends EventTarget {
  142844. /**
  142845. * Dictionary of capabilities describing the VRDisplay.
  142846. */
  142847. readonly capabilities: VRDisplayCapabilities;
  142848. /**
  142849. * z-depth defining the far plane of the eye view frustum
  142850. * enables mapping of values in the render target depth
  142851. * attachment to scene coordinates. Initially set to 10000.0.
  142852. */
  142853. depthFar: number;
  142854. /**
  142855. * z-depth defining the near plane of the eye view frustum
  142856. * enables mapping of values in the render target depth
  142857. * attachment to scene coordinates. Initially set to 0.01.
  142858. */
  142859. depthNear: number;
  142860. /**
  142861. * An identifier for this distinct VRDisplay. Used as an
  142862. * association point in the Gamepad API.
  142863. */
  142864. readonly displayId: number;
  142865. /**
  142866. * A display name, a user-readable name identifying it.
  142867. */
  142868. readonly displayName: string;
  142869. readonly isConnected: boolean;
  142870. readonly isPresenting: boolean;
  142871. /**
  142872. * If this VRDisplay supports room-scale experiences, the optional
  142873. * stage attribute contains details on the room-scale parameters.
  142874. */
  142875. readonly stageParameters: VRStageParameters | null;
  142876. /**
  142877. * Passing the value returned by `requestAnimationFrame` to
  142878. * `cancelAnimationFrame` will unregister the callback.
  142879. * @param handle Define the hanle of the request to cancel
  142880. */
  142881. cancelAnimationFrame(handle: number): void;
  142882. /**
  142883. * Stops presenting to the VRDisplay.
  142884. * @returns a promise to know when it stopped
  142885. */
  142886. exitPresent(): Promise<void>;
  142887. /**
  142888. * Return the current VREyeParameters for the given eye.
  142889. * @param whichEye Define the eye we want the parameter for
  142890. * @returns the eye parameters
  142891. */
  142892. getEyeParameters(whichEye: string): VREyeParameters;
  142893. /**
  142894. * Populates the passed VRFrameData with the information required to render
  142895. * the current frame.
  142896. * @param frameData Define the data structure to populate
  142897. * @returns true if ok otherwise false
  142898. */
  142899. getFrameData(frameData: VRFrameData): boolean;
  142900. /**
  142901. * Get the layers currently being presented.
  142902. * @returns the list of VR layers
  142903. */
  142904. getLayers(): VRLayer[];
  142905. /**
  142906. * Return a VRPose containing the future predicted pose of the VRDisplay
  142907. * when the current frame will be presented. The value returned will not
  142908. * change until JavaScript has returned control to the browser.
  142909. *
  142910. * The VRPose will contain the position, orientation, velocity,
  142911. * and acceleration of each of these properties.
  142912. * @returns the pose object
  142913. */
  142914. getPose(): VRPose;
  142915. /**
  142916. * Return the current instantaneous pose of the VRDisplay, with no
  142917. * prediction applied.
  142918. * @returns the current instantaneous pose
  142919. */
  142920. getImmediatePose(): VRPose;
  142921. /**
  142922. * The callback passed to `requestAnimationFrame` will be called
  142923. * any time a new frame should be rendered. When the VRDisplay is
  142924. * presenting the callback will be called at the native refresh
  142925. * rate of the HMD. When not presenting this function acts
  142926. * identically to how window.requestAnimationFrame acts. Content should
  142927. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142928. * asynchronously from other displays and at differing refresh rates.
  142929. * @param callback Define the eaction to run next frame
  142930. * @returns the request handle it
  142931. */
  142932. requestAnimationFrame(callback: FrameRequestCallback): number;
  142933. /**
  142934. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142935. * Repeat calls while already presenting will update the VRLayers being displayed.
  142936. * @param layers Define the list of layer to present
  142937. * @returns a promise to know when the request has been fulfilled
  142938. */
  142939. requestPresent(layers: VRLayer[]): Promise<void>;
  142940. /**
  142941. * Reset the pose for this display, treating its current position and
  142942. * orientation as the "origin/zero" values. VRPose.position,
  142943. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142944. * updated when calling resetPose(). This should be called in only
  142945. * sitting-space experiences.
  142946. */
  142947. resetPose(): void;
  142948. /**
  142949. * The VRLayer provided to the VRDisplay will be captured and presented
  142950. * in the HMD. Calling this function has the same effect on the source
  142951. * canvas as any other operation that uses its source image, and canvases
  142952. * created without preserveDrawingBuffer set to true will be cleared.
  142953. * @param pose Define the pose to submit
  142954. */
  142955. submitFrame(pose?: VRPose): void;
  142956. }
  142957. declare var VRDisplay: {
  142958. prototype: VRDisplay;
  142959. new(): VRDisplay;
  142960. };
  142961. interface VRLayer {
  142962. leftBounds?: number[] | Float32Array | null;
  142963. rightBounds?: number[] | Float32Array | null;
  142964. source?: HTMLCanvasElement | null;
  142965. }
  142966. interface VRDisplayCapabilities {
  142967. readonly canPresent: boolean;
  142968. readonly hasExternalDisplay: boolean;
  142969. readonly hasOrientation: boolean;
  142970. readonly hasPosition: boolean;
  142971. readonly maxLayers: number;
  142972. }
  142973. interface VREyeParameters {
  142974. /** @deprecated */
  142975. readonly fieldOfView: VRFieldOfView;
  142976. readonly offset: Float32Array;
  142977. readonly renderHeight: number;
  142978. readonly renderWidth: number;
  142979. }
  142980. interface VRFieldOfView {
  142981. readonly downDegrees: number;
  142982. readonly leftDegrees: number;
  142983. readonly rightDegrees: number;
  142984. readonly upDegrees: number;
  142985. }
  142986. interface VRFrameData {
  142987. readonly leftProjectionMatrix: Float32Array;
  142988. readonly leftViewMatrix: Float32Array;
  142989. readonly pose: VRPose;
  142990. readonly rightProjectionMatrix: Float32Array;
  142991. readonly rightViewMatrix: Float32Array;
  142992. readonly timestamp: number;
  142993. }
  142994. interface VRPose {
  142995. readonly angularAcceleration: Float32Array | null;
  142996. readonly angularVelocity: Float32Array | null;
  142997. readonly linearAcceleration: Float32Array | null;
  142998. readonly linearVelocity: Float32Array | null;
  142999. readonly orientation: Float32Array | null;
  143000. readonly position: Float32Array | null;
  143001. readonly timestamp: number;
  143002. }
  143003. interface VRStageParameters {
  143004. sittingToStandingTransform?: Float32Array;
  143005. sizeX?: number;
  143006. sizeY?: number;
  143007. }
  143008. interface Navigator {
  143009. getVRDisplays(): Promise<VRDisplay[]>;
  143010. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143011. }
  143012. interface Window {
  143013. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143014. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143015. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143016. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143017. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143018. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143019. }
  143020. interface Gamepad {
  143021. readonly displayId: number;
  143022. }
  143023. type XRSessionMode =
  143024. | "inline"
  143025. | "immersive-vr"
  143026. | "immersive-ar";
  143027. type XRReferenceSpaceType =
  143028. | "viewer"
  143029. | "local"
  143030. | "local-floor"
  143031. | "bounded-floor"
  143032. | "unbounded";
  143033. type XREnvironmentBlendMode =
  143034. | "opaque"
  143035. | "additive"
  143036. | "alpha-blend";
  143037. type XRVisibilityState =
  143038. | "visible"
  143039. | "visible-blurred"
  143040. | "hidden";
  143041. type XRHandedness =
  143042. | "none"
  143043. | "left"
  143044. | "right";
  143045. type XRTargetRayMode =
  143046. | "gaze"
  143047. | "tracked-pointer"
  143048. | "screen";
  143049. type XREye =
  143050. | "none"
  143051. | "left"
  143052. | "right";
  143053. interface XRSpace extends EventTarget {
  143054. }
  143055. interface XRRenderState {
  143056. depthNear?: number;
  143057. depthFar?: number;
  143058. inlineVerticalFieldOfView?: number;
  143059. baseLayer?: XRWebGLLayer;
  143060. }
  143061. interface XRInputSource {
  143062. handedness: XRHandedness;
  143063. targetRayMode: XRTargetRayMode;
  143064. targetRaySpace: XRSpace;
  143065. gripSpace: XRSpace | undefined;
  143066. gamepad: Gamepad | undefined;
  143067. profiles: Array<string>;
  143068. }
  143069. interface XRSessionInit {
  143070. optionalFeatures?: XRReferenceSpaceType[];
  143071. requiredFeatures?: XRReferenceSpaceType[];
  143072. }
  143073. interface XRSession extends XRAnchorCreator {
  143074. addEventListener: Function;
  143075. removeEventListener: Function;
  143076. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143077. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143078. requestAnimationFrame: Function;
  143079. end(): Promise<void>;
  143080. renderState: XRRenderState;
  143081. inputSources: Array<XRInputSource>;
  143082. // AR hit test
  143083. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143084. updateWorldTrackingState(options: {
  143085. planeDetectionState?: { enabled: boolean; }
  143086. }): void;
  143087. }
  143088. interface XRReferenceSpace extends XRSpace {
  143089. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143090. onreset: any;
  143091. }
  143092. type XRPlaneSet = Set<XRPlane>;
  143093. type XRAnchorSet = Set<XRAnchor>;
  143094. interface XRFrame {
  143095. session: XRSession;
  143096. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143097. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143098. // Anchors
  143099. trackedAnchors?: XRAnchorSet;
  143100. // Planes
  143101. worldInformation: {
  143102. detectedPlanes?: XRPlaneSet;
  143103. };
  143104. }
  143105. interface XRViewerPose extends XRPose {
  143106. views: Array<XRView>;
  143107. }
  143108. interface XRPose {
  143109. transform: XRRigidTransform;
  143110. emulatedPosition: boolean;
  143111. }
  143112. interface XRWebGLLayerOptions {
  143113. antialias?: boolean;
  143114. depth?: boolean;
  143115. stencil?: boolean;
  143116. alpha?: boolean;
  143117. multiview?: boolean;
  143118. framebufferScaleFactor?: number;
  143119. }
  143120. declare var XRWebGLLayer: {
  143121. prototype: XRWebGLLayer;
  143122. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143123. };
  143124. interface XRWebGLLayer {
  143125. framebuffer: WebGLFramebuffer;
  143126. framebufferWidth: number;
  143127. framebufferHeight: number;
  143128. getViewport: Function;
  143129. }
  143130. declare class XRRigidTransform {
  143131. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143132. position: DOMPointReadOnly;
  143133. orientation: DOMPointReadOnly;
  143134. matrix: Float32Array;
  143135. inverse: XRRigidTransform;
  143136. }
  143137. interface XRView {
  143138. eye: XREye;
  143139. projectionMatrix: Float32Array;
  143140. transform: XRRigidTransform;
  143141. }
  143142. interface XRInputSourceChangeEvent {
  143143. session: XRSession;
  143144. removed: Array<XRInputSource>;
  143145. added: Array<XRInputSource>;
  143146. }
  143147. interface XRInputSourceEvent extends Event {
  143148. readonly frame: XRFrame;
  143149. readonly inputSource: XRInputSource;
  143150. }
  143151. // Experimental(er) features
  143152. declare class XRRay {
  143153. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143154. origin: DOMPointReadOnly;
  143155. direction: DOMPointReadOnly;
  143156. matrix: Float32Array;
  143157. }
  143158. interface XRHitResult {
  143159. hitMatrix: Float32Array;
  143160. }
  143161. interface XRAnchor {
  143162. // remove?
  143163. id?: string;
  143164. anchorSpace: XRSpace;
  143165. lastChangedTime: number;
  143166. detach(): void;
  143167. }
  143168. interface XRPlane extends XRAnchorCreator {
  143169. orientation: "Horizontal" | "Vertical";
  143170. planeSpace: XRSpace;
  143171. polygon: Array<DOMPointReadOnly>;
  143172. lastChangedTime: number;
  143173. }
  143174. interface XRAnchorCreator {
  143175. // AR Anchors
  143176. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143177. }